Jump to content

nugu100

Members
  • Posts

    1
  • Joined

  • Last visited

    Never
  • Donations

    0.00 GBP 

Everything posted by nugu100

  1. 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.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use