nugu100
Members-
Posts
1 -
Joined
-
Last visited
Never -
Donations
0.00 GBP
nugu100's Achievements
Newbie (1/3)
0
Reputation
-
In present, Bag(contains items) and bag(in inventory) cannot be swaped. So, I made codes which bag swap. void Player::SwapItem( uint16 src, uint16 dst ) { uint8 srcbag = src >> 8; uint8 srcslot = src & 255; uint8 dstbag = dst >> 8; uint8 dstslot = dst & 255; Item *pSrcItem = GetItemByPos( srcbag, srcslot ); Item *pDstItem = GetItemByPos( dstbag, dstslot ); if( !pSrcItem ) return; sLog.outDebug( "STORAGE: SwapItem bag = %u, slot = %u, item = %u", dstbag, dstslot, pSrcItem->GetEntry()); if(!isAlive() ) { SendEquipError( EQUIP_ERR_YOU_ARE_DEAD, pSrcItem, pDstItem ); return; } if(pSrcItem->m_lootGenerated) // prevent swap looting item { //best error message found for attempting to swap while looting SendEquipError( EQUIP_ERR_CANT_DO_RIGHT_NOW, pSrcItem, NULL ); return; } // ******************** ADDED CODE ********************** bool bagswapfailed = false; if (pDstItem) { const ItemPrototype *srcProto = pSrcItem->GetProto(), *dstProto = pDstItem->GetProto(); if ( !IsBagPos(src) && IsBagPos(dst) && pSrcItem->IsBag() && pDstItem->IsBag() && ((Bag *)pSrcItem)->IsEmpty() && srcProto && dstProto ) { Bag *sBag = (Bag *)pSrcItem; Bag *dBag = (Bag *)pDstItem; uint32 dstbagsize, count = 0; dstbagsize = dBag->GetBagSize(); for(int i=0; i<dstbagsize; ++i) { Item *dstbagitem = dBag->GetItemByPos(i); if (!dstbagitem) continue; const ItemPrototype *dstitemproto = dstbagitem->GetProto(); if (!dstitemproto) { bagswapfailed = true; break; } if ( !ItemCanGoIntoBag(dstitemproto, srcProto) ) { bagswapfailed = true; break; } ++count; } if (count > sBag->GetBagSize()) bagswapfailed = true; if (!bagswapfailed) { // Items swap count = 0; for(int i=0; i<dstbagsize; ++i) { Item *dstbagitem = dBag->GetItemByPos(i); if (!dstbagitem) continue; dBag->RemoveItem(i, true); sBag->StoreItem(count, dstbagitem, true); dstbagitem->SetState(ITEM_CHANGED, this); ++count; } // Bag swap // now do moves, remove... RemoveItem(dstbag, dstslot, false); RemoveItem(srcbag, srcslot, false); // add to dest _StoreItem(dst, pSrcItem, pSrcItem->GetCount(), false, true); _StoreItem(src, pDstItem, pDstItem->GetCount(), false, true); pSrcItem->SetState(ITEM_CHANGED, this); pDstItem->SetState(ITEM_CHANGED, this); return; } } } // ****************************** ADD END ****************************** // check unequip potability for equipped items and bank bags if(IsEquipmentPos ( src ) || IsBagPos ( src )) Please verify my code.
Contact Us
To contact us
click here
You can also email us at [email protected]
Privacy Policy | Terms & Conditions
You can also email us at [email protected]
Privacy Policy | Terms & Conditions
Copyright © getMaNGOS. All rights Reserved.
This website is in no way associated with or endorsed by Blizzard Entertainment®
This website is in no way associated with or endorsed by Blizzard Entertainment®