mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[8407] Extract from guild bank handler functions for 3 cases and move code to Guild class.
This mostly just move code and caller updates to use it from new place. More code chnages possible later.
This commit is contained in:
parent
f3930cb06f
commit
5ceb0919e7
5 changed files with 429 additions and 411 deletions
|
|
@ -1973,6 +1973,418 @@ void Guild::SendGuildBankTabText(WorldSession *session, uint8 TabId)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTabDst, uint8 BankTabSlotDst, uint32 SplitedAmount )
|
||||||
|
{
|
||||||
|
// empty operation
|
||||||
|
if(BankTab==BankTabDst && BankTabSlot==BankTabSlotDst)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Item *pItemSrc = GetItem(BankTab, BankTabSlot);
|
||||||
|
if (!pItemSrc) // may prevent crash
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(SplitedAmount > pItemSrc->GetCount())
|
||||||
|
return; // cheating?
|
||||||
|
else if(SplitedAmount == pItemSrc->GetCount())
|
||||||
|
SplitedAmount = 0; // no split
|
||||||
|
|
||||||
|
Item *pItemDst = GetItem(BankTabDst, BankTabSlotDst);
|
||||||
|
|
||||||
|
if(BankTab!=BankTabDst)
|
||||||
|
{
|
||||||
|
// check dest pos rights (if different tabs)
|
||||||
|
if(!IsMemberHaveRights(pl->GetGUIDLow(), BankTabDst, GUILD_BANK_RIGHT_DEPOSIT_ITEM))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// check source pos rights (if different tabs)
|
||||||
|
uint32 remRight = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
||||||
|
if(remRight <= 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SplitedAmount)
|
||||||
|
{ // Bank -> Bank item split (in empty or non empty slot
|
||||||
|
GuildItemPosCountVec dest;
|
||||||
|
uint8 msg = CanStoreItem(BankTabDst,BankTabSlotDst,dest,SplitedAmount,pItemSrc,false);
|
||||||
|
if( msg != EQUIP_ERR_OK )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( msg, pItemSrc, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *pNewItem = pItemSrc->CloneItem( SplitedAmount );
|
||||||
|
if( !pNewItem )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pItemSrc, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_MOVE_ITEM, BankTab, pl->GetGUIDLow(), pItemSrc->GetEntry(), SplitedAmount, BankTabDst);
|
||||||
|
|
||||||
|
pl->ItemRemovedQuestCheck( pItemSrc->GetEntry(), SplitedAmount );
|
||||||
|
pItemSrc->SetCount( pItemSrc->GetCount() - SplitedAmount );
|
||||||
|
pItemSrc->FSetState(ITEM_CHANGED);
|
||||||
|
pItemSrc->SaveToDB(); // not in inventory and can be save standalone
|
||||||
|
StoreItem(BankTabDst,dest,pNewItem);
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
|
}
|
||||||
|
else // non split
|
||||||
|
{
|
||||||
|
GuildItemPosCountVec gDest;
|
||||||
|
uint8 msg = CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,false);
|
||||||
|
if( msg == EQUIP_ERR_OK ) // merge to
|
||||||
|
{
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_MOVE_ITEM, BankTab, pl->GetGUIDLow(), pItemSrc->GetEntry(), pItemSrc->GetCount(), BankTabDst);
|
||||||
|
|
||||||
|
RemoveItem(BankTab, BankTabSlot);
|
||||||
|
StoreItem(BankTabDst, gDest, pItemSrc);
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
|
}
|
||||||
|
else // swap
|
||||||
|
{
|
||||||
|
gDest.clear();
|
||||||
|
msg = CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,true);
|
||||||
|
if( msg != EQUIP_ERR_OK )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( msg, pItemSrc, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuildItemPosCountVec gSrc;
|
||||||
|
msg = CanStoreItem(BankTab,BankTabSlot,gSrc,pItemDst->GetCount(),pItemDst,true);
|
||||||
|
if( msg != EQUIP_ERR_OK )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( msg, pItemDst, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(BankTab!=BankTabDst)
|
||||||
|
{
|
||||||
|
// check source pos rights (item swapped to src)
|
||||||
|
if(!IsMemberHaveRights(pl->GetGUIDLow(), BankTab, GUILD_BANK_RIGHT_DEPOSIT_ITEM))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// check dest pos rights (item swapped to src)
|
||||||
|
uint32 remRightDst = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTabDst);
|
||||||
|
if(remRightDst <= 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_MOVE_ITEM, BankTab, pl->GetGUIDLow(), pItemSrc->GetEntry(), pItemSrc->GetCount(), BankTabDst);
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_MOVE_ITEM, BankTabDst, pl->GetGUIDLow(), pItemDst->GetEntry(), pItemDst->GetCount(), BankTab);
|
||||||
|
|
||||||
|
RemoveItem(BankTab, BankTabSlot);
|
||||||
|
RemoveItem(BankTabDst, BankTabSlotDst);
|
||||||
|
StoreItem(BankTab, gSrc, pItemDst);
|
||||||
|
StoreItem(BankTabDst, gDest, pItemSrc);
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DisplayGuildBankContentUpdate(BankTab,BankTabSlot,BankTab==BankTabDst ? BankTabSlotDst : -1);
|
||||||
|
if(BankTab!=BankTabDst)
|
||||||
|
DisplayGuildBankContentUpdate(BankTabDst,BankTabSlotDst);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Guild::MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 PlayerBag, uint8 PlayerSlot, uint32 SplitedAmount)
|
||||||
|
{
|
||||||
|
Item *pItemBank = GetItem(BankTab, BankTabSlot);
|
||||||
|
Item *pItemChar = pl->GetItemByPos(PlayerBag, PlayerSlot);
|
||||||
|
|
||||||
|
if (!pItemBank) // Problem to get bank item
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(SplitedAmount > pItemBank->GetCount())
|
||||||
|
return; // cheating?
|
||||||
|
else if(SplitedAmount == pItemBank->GetCount())
|
||||||
|
SplitedAmount = 0; // no split
|
||||||
|
|
||||||
|
if (SplitedAmount)
|
||||||
|
{ // Bank -> Char split to slot (patly move)
|
||||||
|
Item *pNewItem = pItemBank->CloneItem( SplitedAmount );
|
||||||
|
if( !pNewItem )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pItemBank, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemPosCountVec dest;
|
||||||
|
uint8 msg = pl->CanStoreItem(PlayerBag, PlayerSlot, dest, pNewItem, false);
|
||||||
|
if( msg != EQUIP_ERR_OK )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( msg, pNewItem, NULL );
|
||||||
|
delete pNewItem;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check source pos rights (item moved to inventory)
|
||||||
|
uint32 remRight = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
||||||
|
if(remRight <= 0)
|
||||||
|
{
|
||||||
|
delete pNewItem;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), SplitedAmount);
|
||||||
|
|
||||||
|
pItemBank->SetCount(pItemBank->GetCount()-SplitedAmount);
|
||||||
|
pItemBank->FSetState(ITEM_CHANGED);
|
||||||
|
pItemBank->SaveToDB(); // not in inventory and can be save standalone
|
||||||
|
pl->MoveItemToInventory(dest,pNewItem,true);
|
||||||
|
pl->SaveInventoryAndGoldToDB();
|
||||||
|
|
||||||
|
MemberItemWithdraw(BankTab, pl->GetGUIDLow());
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
|
}
|
||||||
|
else // Bank -> Char swap with slot (move)
|
||||||
|
{
|
||||||
|
ItemPosCountVec dest;
|
||||||
|
uint8 msg = pl->CanStoreItem(PlayerBag, PlayerSlot, dest, pItemBank, false);
|
||||||
|
if( msg == EQUIP_ERR_OK ) // merge case
|
||||||
|
{
|
||||||
|
// check source pos rights (item moved to inventory)
|
||||||
|
uint32 remRight = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
||||||
|
if(remRight <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), pItemBank->GetCount());
|
||||||
|
|
||||||
|
RemoveItem(BankTab, BankTabSlot);
|
||||||
|
pl->MoveItemToInventory(dest,pItemBank,true);
|
||||||
|
pl->SaveInventoryAndGoldToDB();
|
||||||
|
|
||||||
|
MemberItemWithdraw(BankTab, pl->GetGUIDLow());
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
|
}
|
||||||
|
else // Bank <-> Char swap items
|
||||||
|
{
|
||||||
|
// check source pos rights (item swapped to bank)
|
||||||
|
if(!IsMemberHaveRights(pl->GetGUIDLow(), BankTab, GUILD_BANK_RIGHT_DEPOSIT_ITEM))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(pItemChar)
|
||||||
|
{
|
||||||
|
if(!pItemChar->CanBeTraded())
|
||||||
|
{
|
||||||
|
pl->SendEquipError( EQUIP_ERR_ITEMS_CANT_BE_SWAPPED, pItemChar, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemPosCountVec iDest;
|
||||||
|
msg = pl->CanStoreItem(PlayerBag, PlayerSlot, iDest, pItemBank, true);
|
||||||
|
if( msg != EQUIP_ERR_OK )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( msg, pItemBank, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuildItemPosCountVec gDest;
|
||||||
|
if(pItemChar)
|
||||||
|
{
|
||||||
|
msg = CanStoreItem(BankTab,BankTabSlot,gDest,pItemChar->GetCount(),pItemChar,true);
|
||||||
|
if( msg != EQUIP_ERR_OK )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( msg, pItemChar, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check source pos rights (item moved to inventory)
|
||||||
|
uint32 remRight = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
||||||
|
if(remRight <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(pItemChar)
|
||||||
|
{
|
||||||
|
// logging item move to bank
|
||||||
|
if(pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||||
|
{
|
||||||
|
sLog.outCommand(pl->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||||
|
pl->GetName(),pl->GetSession()->GetAccountId(),
|
||||||
|
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(),
|
||||||
|
m_Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), pItemBank->GetCount());
|
||||||
|
if(pItemChar)
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_DEPOSIT_ITEM, BankTab, pl->GetGUIDLow(), pItemChar->GetEntry(), pItemChar->GetCount());
|
||||||
|
|
||||||
|
RemoveItem(BankTab, BankTabSlot);
|
||||||
|
if(pItemChar)
|
||||||
|
{
|
||||||
|
pl->MoveItemFromInventory(PlayerBag, PlayerSlot, true);
|
||||||
|
pItemChar->DeleteFromInventoryDB();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pItemChar)
|
||||||
|
StoreItem(BankTab, gDest, pItemChar);
|
||||||
|
pl->MoveItemToInventory(iDest,pItemBank,true);
|
||||||
|
pl->SaveInventoryAndGoldToDB();
|
||||||
|
|
||||||
|
MemberItemWithdraw(BankTab, pl->GetGUIDLow());
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DisplayGuildBankContentUpdate(BankTab,BankTabSlot);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot, uint8 BankTab, uint8 BankTabSlot, uint32 SplitedAmount )
|
||||||
|
{
|
||||||
|
Item *pItemBank = GetItem(BankTab, BankTabSlot);
|
||||||
|
Item *pItemChar = pl->GetItemByPos(PlayerBag, PlayerSlot);
|
||||||
|
|
||||||
|
if (!pItemChar) // Problem to get item from player
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!pItemChar->CanBeTraded())
|
||||||
|
{
|
||||||
|
pl->SendEquipError( EQUIP_ERR_ITEMS_CANT_BE_SWAPPED, pItemChar, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check source pos rights (item moved to bank)
|
||||||
|
if(!IsMemberHaveRights(pl->GetGUIDLow(), BankTab, GUILD_BANK_RIGHT_DEPOSIT_ITEM))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(SplitedAmount > pItemChar->GetCount())
|
||||||
|
return; // cheating?
|
||||||
|
else if(SplitedAmount == pItemChar->GetCount())
|
||||||
|
SplitedAmount = 0; // no split
|
||||||
|
|
||||||
|
if (SplitedAmount)
|
||||||
|
{ // Char -> Bank split to empty or non-empty slot (partly move)
|
||||||
|
GuildItemPosCountVec dest;
|
||||||
|
uint8 msg = CanStoreItem(BankTab,BankTabSlot,dest,SplitedAmount,pItemChar,false);
|
||||||
|
if( msg != EQUIP_ERR_OK )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( msg, pItemChar, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Item *pNewItem = pItemChar->CloneItem( SplitedAmount );
|
||||||
|
if( !pNewItem )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pItemChar, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// logging item move to bank (before items merge
|
||||||
|
if(pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||||
|
{
|
||||||
|
sLog.outCommand(pl->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||||
|
pl->GetName(),pl->GetSession()->GetAccountId(),
|
||||||
|
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),SplitedAmount,m_Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_DEPOSIT_ITEM, BankTab, pl->GetGUIDLow(), pItemChar->GetEntry(), SplitedAmount);
|
||||||
|
|
||||||
|
pl->ItemRemovedQuestCheck( pItemChar->GetEntry(), SplitedAmount );
|
||||||
|
pItemChar->SetCount(pItemChar->GetCount()-SplitedAmount);
|
||||||
|
pItemChar->SetState(ITEM_CHANGED);
|
||||||
|
pl->SaveInventoryAndGoldToDB();
|
||||||
|
StoreItem(BankTab, dest, pNewItem);
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
|
|
||||||
|
DisplayGuildBankContentUpdate(BankTab,dest);
|
||||||
|
}
|
||||||
|
else // Char -> Bank swap with empty or non-empty (move)
|
||||||
|
{
|
||||||
|
GuildItemPosCountVec dest;
|
||||||
|
uint8 msg = CanStoreItem(BankTab,BankTabSlot,dest,pItemChar->GetCount(),pItemChar,false);
|
||||||
|
if( msg == EQUIP_ERR_OK ) // merge
|
||||||
|
{
|
||||||
|
// logging item move to bank
|
||||||
|
if(pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||||
|
{
|
||||||
|
sLog.outCommand(pl->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||||
|
pl->GetName(),pl->GetSession()->GetAccountId(),
|
||||||
|
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(),
|
||||||
|
m_Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_DEPOSIT_ITEM, BankTab, pl->GetGUIDLow(), pItemChar->GetEntry(), pItemChar->GetCount());
|
||||||
|
|
||||||
|
pl->MoveItemFromInventory(PlayerBag, PlayerSlot, true);
|
||||||
|
pItemChar->DeleteFromInventoryDB();
|
||||||
|
|
||||||
|
StoreItem(BankTab,dest,pItemChar);
|
||||||
|
pl->SaveInventoryAndGoldToDB();
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
|
|
||||||
|
DisplayGuildBankContentUpdate(BankTab,dest);
|
||||||
|
}
|
||||||
|
else // Char <-> Bank swap items (posible NULL bank item)
|
||||||
|
{
|
||||||
|
ItemPosCountVec iDest;
|
||||||
|
if(pItemBank)
|
||||||
|
{
|
||||||
|
msg = pl->CanStoreItem(PlayerBag, PlayerSlot, iDest, pItemBank, true);
|
||||||
|
if( msg != EQUIP_ERR_OK )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( msg, pItemBank, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GuildItemPosCountVec gDest;
|
||||||
|
msg = CanStoreItem(BankTab,BankTabSlot,gDest,pItemChar->GetCount(),pItemChar,true);
|
||||||
|
if( msg != EQUIP_ERR_OK )
|
||||||
|
{
|
||||||
|
pl->SendEquipError( msg, pItemChar, NULL );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pItemBank)
|
||||||
|
{
|
||||||
|
// check bank pos rights (item swapped with inventory)
|
||||||
|
uint32 remRight = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
||||||
|
if(remRight <= 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// logging item move to bank
|
||||||
|
if(pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||||
|
{
|
||||||
|
sLog.outCommand(pl->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
||||||
|
pl->GetName(),pl->GetSession()->GetAccountId(),
|
||||||
|
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(),
|
||||||
|
m_Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
if(pItemBank)
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), pItemBank->GetCount());
|
||||||
|
LogBankEvent(GUILD_BANK_LOG_DEPOSIT_ITEM, BankTab, pl->GetGUIDLow(), pItemChar->GetEntry(), pItemChar->GetCount());
|
||||||
|
|
||||||
|
pl->MoveItemFromInventory(PlayerBag, PlayerSlot, true);
|
||||||
|
pItemChar->DeleteFromInventoryDB();
|
||||||
|
if(pItemBank)
|
||||||
|
RemoveItem(BankTab, BankTabSlot);
|
||||||
|
|
||||||
|
StoreItem(BankTab,gDest,pItemChar);
|
||||||
|
if(pItemBank)
|
||||||
|
pl->MoveItemToInventory(iDest,pItemBank,true);
|
||||||
|
pl->SaveInventoryAndGoldToDB();
|
||||||
|
if(pItemBank)
|
||||||
|
MemberItemWithdraw(BankTab, pl->GetGUIDLow());
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
|
|
||||||
|
DisplayGuildBankContentUpdate(BankTab,gDest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GuildItemPosCount::isContainedIn(GuildItemPosCountVec const &vec) const
|
bool GuildItemPosCount::isContainedIn(GuildItemPosCountVec const &vec) const
|
||||||
{
|
{
|
||||||
for(GuildItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr)
|
for(GuildItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr)
|
||||||
|
|
|
||||||
|
|
@ -380,14 +380,11 @@ class Guild
|
||||||
// ** Guild bank **
|
// ** Guild bank **
|
||||||
// Content & item deposit/withdraw
|
// Content & item deposit/withdraw
|
||||||
void DisplayGuildBankContent(WorldSession *session, uint8 TabId);
|
void DisplayGuildBankContent(WorldSession *session, uint8 TabId);
|
||||||
void DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2 = -1);
|
|
||||||
void DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec const& slots);
|
|
||||||
void DisplayGuildBankMoneyUpdate();
|
void DisplayGuildBankMoneyUpdate();
|
||||||
|
|
||||||
Item* GetItem(uint8 TabId, uint8 SlotId);
|
void SwapItems( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTabDst, uint8 BankTabSlotDst, uint32 SplitedAmount);
|
||||||
uint8 CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const;
|
void MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 PlayerBag, uint8 PlayerSlot, uint32 SplitedAmount);
|
||||||
Item* StoreItem( uint8 tab, GuildItemPosCountVec const& pos, Item *pItem );
|
void MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot, uint8 BankTab, uint8 BankTabSlot, uint32 SplitedAmount);
|
||||||
void RemoveItem(uint8 tab, uint8 slot );
|
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
void DisplayGuildBankTabsInfo(WorldSession *session);
|
void DisplayGuildBankTabsInfo(WorldSession *session);
|
||||||
|
|
@ -470,6 +467,14 @@ class Guild
|
||||||
uint8 m_PurchasedTabs;
|
uint8 m_PurchasedTabs;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// used only from high level Swap/Move functions
|
||||||
|
Item* GetItem(uint8 TabId, uint8 SlotId);
|
||||||
|
uint8 CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const;
|
||||||
|
Item* StoreItem( uint8 tab, GuildItemPosCountVec const& pos, Item *pItem );
|
||||||
|
void RemoveItem(uint8 tab, uint8 slot );
|
||||||
|
void DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2 = -1);
|
||||||
|
void DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec const& slots);
|
||||||
|
|
||||||
// internal common parts for CanStore/StoreItem functions
|
// internal common parts for CanStore/StoreItem functions
|
||||||
void AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *tab, int32 slot );
|
void AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *tab, int32 slot );
|
||||||
uint8 _CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item *pSrcItem ) const;
|
uint8 _CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item *pSrcItem ) const;
|
||||||
|
|
|
||||||
|
|
@ -1098,117 +1098,7 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data )
|
||||||
// Bank <-> Bank
|
// Bank <-> Bank
|
||||||
if (BankToBank)
|
if (BankToBank)
|
||||||
{
|
{
|
||||||
// empty operation
|
pGuild->SwapItems(pl, BankTab, BankTabSlot, BankTabDst, BankTabSlotDst, SplitedAmount);
|
||||||
if(BankTab==BankTabDst && BankTabSlot==BankTabSlotDst)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Item *pItemSrc = pGuild->GetItem(BankTab, BankTabSlot);
|
|
||||||
if (!pItemSrc) // may prevent crash
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(SplitedAmount > pItemSrc->GetCount())
|
|
||||||
return; // cheating?
|
|
||||||
else if(SplitedAmount == pItemSrc->GetCount())
|
|
||||||
SplitedAmount = 0; // no split
|
|
||||||
|
|
||||||
Item *pItemDst = pGuild->GetItem(BankTabDst, BankTabSlotDst);
|
|
||||||
|
|
||||||
if(BankTab!=BankTabDst)
|
|
||||||
{
|
|
||||||
// check dest pos rights (if different tabs)
|
|
||||||
if(!pGuild->IsMemberHaveRights(pl->GetGUIDLow(), BankTabDst, GUILD_BANK_RIGHT_DEPOSIT_ITEM))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// check source pos rights (if different tabs)
|
|
||||||
uint32 remRight = pGuild->GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
|
||||||
if(remRight <= 0)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SplitedAmount)
|
|
||||||
{ // Bank -> Bank item split (in empty or non empty slot
|
|
||||||
GuildItemPosCountVec dest;
|
|
||||||
uint8 msg = pGuild->CanStoreItem(BankTabDst,BankTabSlotDst,dest,SplitedAmount,pItemSrc,false);
|
|
||||||
if( msg != EQUIP_ERR_OK )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( msg, pItemSrc, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Item *pNewItem = pItemSrc->CloneItem( SplitedAmount );
|
|
||||||
if( !pNewItem )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pItemSrc, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_MOVE_ITEM, BankTab, pl->GetGUIDLow(), pItemSrc->GetEntry(), SplitedAmount, BankTabDst);
|
|
||||||
|
|
||||||
pl->ItemRemovedQuestCheck( pItemSrc->GetEntry(), SplitedAmount );
|
|
||||||
pItemSrc->SetCount( pItemSrc->GetCount() - SplitedAmount );
|
|
||||||
pItemSrc->FSetState(ITEM_CHANGED);
|
|
||||||
pItemSrc->SaveToDB(); // not in inventory and can be save standalone
|
|
||||||
pGuild->StoreItem(BankTabDst,dest,pNewItem);
|
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
}
|
|
||||||
else // non split
|
|
||||||
{
|
|
||||||
GuildItemPosCountVec gDest;
|
|
||||||
uint8 msg = pGuild->CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,false);
|
|
||||||
if( msg == EQUIP_ERR_OK ) // merge to
|
|
||||||
{
|
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_MOVE_ITEM, BankTab, pl->GetGUIDLow(), pItemSrc->GetEntry(), pItemSrc->GetCount(), BankTabDst);
|
|
||||||
|
|
||||||
pGuild->RemoveItem(BankTab, BankTabSlot);
|
|
||||||
pGuild->StoreItem(BankTabDst, gDest, pItemSrc);
|
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
}
|
|
||||||
else // swap
|
|
||||||
{
|
|
||||||
gDest.clear();
|
|
||||||
msg = pGuild->CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,true);
|
|
||||||
if( msg != EQUIP_ERR_OK )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( msg, pItemSrc, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuildItemPosCountVec gSrc;
|
|
||||||
msg = pGuild->CanStoreItem(BankTab,BankTabSlot,gSrc,pItemDst->GetCount(),pItemDst,true);
|
|
||||||
if( msg != EQUIP_ERR_OK )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( msg, pItemDst, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(BankTab!=BankTabDst)
|
|
||||||
{
|
|
||||||
// check source pos rights (item swapped to src)
|
|
||||||
if(!pGuild->IsMemberHaveRights(pl->GetGUIDLow(), BankTab, GUILD_BANK_RIGHT_DEPOSIT_ITEM))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// check dest pos rights (item swapped to src)
|
|
||||||
uint32 remRightDst = pGuild->GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTabDst);
|
|
||||||
if(remRightDst <= 0)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_MOVE_ITEM, BankTab, pl->GetGUIDLow(), pItemSrc->GetEntry(), pItemSrc->GetCount(), BankTabDst);
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_MOVE_ITEM, BankTabDst, pl->GetGUIDLow(), pItemDst->GetEntry(), pItemDst->GetCount(), BankTab);
|
|
||||||
|
|
||||||
pGuild->RemoveItem(BankTab, BankTabSlot);
|
|
||||||
pGuild->RemoveItem(BankTabDst, BankTabSlotDst);
|
|
||||||
pGuild->StoreItem(BankTab, gSrc, pItemDst);
|
|
||||||
pGuild->StoreItem(BankTabDst, gDest, pItemSrc);
|
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pGuild->DisplayGuildBankContentUpdate(BankTab,BankTabSlot,BankTab==BankTabDst ? BankTabSlotDst : -1);
|
|
||||||
if(BankTab!=BankTabDst)
|
|
||||||
pGuild->DisplayGuildBankContentUpdate(BankTabDst,BankTabSlotDst);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1221,301 +1111,11 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item *pItemBank = pGuild->GetItem(BankTab, BankTabSlot);
|
|
||||||
Item *pItemChar = GetPlayer()->GetItemByPos(PlayerBag, PlayerSlot);
|
|
||||||
if (!pItemChar && !pItemBank) // Nothing to do
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!pItemChar && !ToChar) // Problem to get item from player
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!pItemBank && ToChar) // Problem to get bank item
|
|
||||||
return;
|
|
||||||
|
|
||||||
// BankToChar swap or char to bank remaining
|
// BankToChar swap or char to bank remaining
|
||||||
|
|
||||||
if (ToChar) // Bank -> Char cases
|
if (ToChar) // Bank -> Char cases
|
||||||
{
|
pGuild->MoveFromBankToChar(pl, BankTab, BankTabSlot, PlayerBag, PlayerSlot, SplitedAmount);
|
||||||
if(SplitedAmount > pItemBank->GetCount())
|
else // Char -> Bank cases
|
||||||
return; // cheating?
|
pGuild->MoveFromCharToBank(pl, PlayerBag, PlayerSlot, BankTab, BankTabSlot, SplitedAmount);
|
||||||
else if(SplitedAmount == pItemBank->GetCount())
|
|
||||||
SplitedAmount = 0; // no split
|
|
||||||
|
|
||||||
if (SplitedAmount)
|
|
||||||
{ // Bank -> Char split to slot (patly move)
|
|
||||||
Item *pNewItem = pItemBank->CloneItem( SplitedAmount );
|
|
||||||
if( !pNewItem )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pItemBank, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemPosCountVec dest;
|
|
||||||
uint8 msg = pl->CanStoreItem(PlayerBag, PlayerSlot, dest, pNewItem, false);
|
|
||||||
if( msg != EQUIP_ERR_OK )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( msg, pNewItem, NULL );
|
|
||||||
delete pNewItem;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check source pos rights (item moved to inventory)
|
|
||||||
uint32 remRight = pGuild->GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
|
||||||
if(remRight <= 0)
|
|
||||||
{
|
|
||||||
delete pNewItem;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), SplitedAmount);
|
|
||||||
|
|
||||||
pItemBank->SetCount(pItemBank->GetCount()-SplitedAmount);
|
|
||||||
pItemBank->FSetState(ITEM_CHANGED);
|
|
||||||
pItemBank->SaveToDB(); // not in inventory and can be save standalone
|
|
||||||
pl->MoveItemToInventory(dest,pNewItem,true);
|
|
||||||
pl->SaveInventoryAndGoldToDB();
|
|
||||||
|
|
||||||
pGuild->MemberItemWithdraw(BankTab, pl->GetGUIDLow());
|
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
}
|
|
||||||
else // Bank -> Char swap with slot (move)
|
|
||||||
{
|
|
||||||
ItemPosCountVec dest;
|
|
||||||
uint8 msg = pl->CanStoreItem(PlayerBag, PlayerSlot, dest, pItemBank, false);
|
|
||||||
if( msg == EQUIP_ERR_OK ) // merge case
|
|
||||||
{
|
|
||||||
// check source pos rights (item moved to inventory)
|
|
||||||
uint32 remRight = pGuild->GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
|
||||||
if(remRight <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), pItemBank->GetCount());
|
|
||||||
|
|
||||||
pGuild->RemoveItem(BankTab, BankTabSlot);
|
|
||||||
pl->MoveItemToInventory(dest,pItemBank,true);
|
|
||||||
pl->SaveInventoryAndGoldToDB();
|
|
||||||
|
|
||||||
pGuild->MemberItemWithdraw(BankTab, pl->GetGUIDLow());
|
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
}
|
|
||||||
else // Bank <-> Char swap items
|
|
||||||
{
|
|
||||||
// check source pos rights (item swapped to bank)
|
|
||||||
if(!pGuild->IsMemberHaveRights(pl->GetGUIDLow(), BankTab, GUILD_BANK_RIGHT_DEPOSIT_ITEM))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(pItemChar)
|
|
||||||
{
|
|
||||||
if(!pItemChar->CanBeTraded())
|
|
||||||
{
|
|
||||||
_player->SendEquipError( EQUIP_ERR_ITEMS_CANT_BE_SWAPPED, pItemChar, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemPosCountVec iDest;
|
|
||||||
msg = pl->CanStoreItem(PlayerBag, PlayerSlot, iDest, pItemBank, true);
|
|
||||||
if( msg != EQUIP_ERR_OK )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( msg, pItemBank, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuildItemPosCountVec gDest;
|
|
||||||
if(pItemChar)
|
|
||||||
{
|
|
||||||
msg = pGuild->CanStoreItem(BankTab,BankTabSlot,gDest,pItemChar->GetCount(),pItemChar,true);
|
|
||||||
if( msg != EQUIP_ERR_OK )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( msg, pItemChar, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check source pos rights (item moved to inventory)
|
|
||||||
uint32 remRight = pGuild->GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
|
||||||
if(remRight <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(pItemChar)
|
|
||||||
{
|
|
||||||
// logging item move to bank
|
|
||||||
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
|
||||||
{
|
|
||||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
|
||||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
|
||||||
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(),
|
|
||||||
GuildId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), pItemBank->GetCount());
|
|
||||||
if(pItemChar)
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_DEPOSIT_ITEM, BankTab, pl->GetGUIDLow(), pItemChar->GetEntry(), pItemChar->GetCount());
|
|
||||||
|
|
||||||
pGuild->RemoveItem(BankTab, BankTabSlot);
|
|
||||||
if(pItemChar)
|
|
||||||
{
|
|
||||||
pl->MoveItemFromInventory(PlayerBag, PlayerSlot, true);
|
|
||||||
pItemChar->DeleteFromInventoryDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pItemChar)
|
|
||||||
pGuild->StoreItem(BankTab, gDest, pItemChar);
|
|
||||||
pl->MoveItemToInventory(iDest,pItemBank,true);
|
|
||||||
pl->SaveInventoryAndGoldToDB();
|
|
||||||
|
|
||||||
pGuild->MemberItemWithdraw(BankTab, pl->GetGUIDLow());
|
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pGuild->DisplayGuildBankContentUpdate(BankTab,BankTabSlot);
|
|
||||||
return;
|
|
||||||
} // End "To char" part
|
|
||||||
|
|
||||||
// Char -> Bank cases
|
|
||||||
|
|
||||||
if(!pItemChar->CanBeTraded())
|
|
||||||
{
|
|
||||||
_player->SendEquipError( EQUIP_ERR_ITEMS_CANT_BE_SWAPPED, pItemChar, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check source pos rights (item moved to bank)
|
|
||||||
if(!pGuild->IsMemberHaveRights(pl->GetGUIDLow(), BankTab, GUILD_BANK_RIGHT_DEPOSIT_ITEM))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(SplitedAmount > pItemChar->GetCount())
|
|
||||||
return; // cheating?
|
|
||||||
else if(SplitedAmount == pItemChar->GetCount())
|
|
||||||
SplitedAmount = 0; // no split
|
|
||||||
|
|
||||||
if (SplitedAmount)
|
|
||||||
{ // Char -> Bank split to empty or non-empty slot (partly move)
|
|
||||||
GuildItemPosCountVec dest;
|
|
||||||
uint8 msg = pGuild->CanStoreItem(BankTab,BankTabSlot,dest,SplitedAmount,pItemChar,false);
|
|
||||||
if( msg != EQUIP_ERR_OK )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( msg, pItemChar, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Item *pNewItem = pItemChar->CloneItem( SplitedAmount );
|
|
||||||
if( !pNewItem )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pItemChar, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// logging item move to bank (before items merge
|
|
||||||
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
|
||||||
{
|
|
||||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
|
||||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
|
||||||
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),SplitedAmount,GuildId);
|
|
||||||
}
|
|
||||||
|
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_DEPOSIT_ITEM, BankTab, pl->GetGUIDLow(), pItemChar->GetEntry(), SplitedAmount);
|
|
||||||
|
|
||||||
pl->ItemRemovedQuestCheck( pItemChar->GetEntry(), SplitedAmount );
|
|
||||||
pItemChar->SetCount(pItemChar->GetCount()-SplitedAmount);
|
|
||||||
pItemChar->SetState(ITEM_CHANGED);
|
|
||||||
pl->SaveInventoryAndGoldToDB();
|
|
||||||
pGuild->StoreItem(BankTab, dest, pNewItem);
|
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
|
|
||||||
pGuild->DisplayGuildBankContentUpdate(BankTab,dest);
|
|
||||||
}
|
|
||||||
else // Char -> Bank swap with empty or non-empty (move)
|
|
||||||
{
|
|
||||||
GuildItemPosCountVec dest;
|
|
||||||
uint8 msg = pGuild->CanStoreItem(BankTab,BankTabSlot,dest,pItemChar->GetCount(),pItemChar,false);
|
|
||||||
if( msg == EQUIP_ERR_OK ) // merge
|
|
||||||
{
|
|
||||||
// logging item move to bank
|
|
||||||
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
|
||||||
{
|
|
||||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
|
||||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
|
||||||
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(),
|
|
||||||
GuildId);
|
|
||||||
}
|
|
||||||
|
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_DEPOSIT_ITEM, BankTab, pl->GetGUIDLow(), pItemChar->GetEntry(), pItemChar->GetCount());
|
|
||||||
|
|
||||||
pl->MoveItemFromInventory(PlayerBag, PlayerSlot, true);
|
|
||||||
pItemChar->DeleteFromInventoryDB();
|
|
||||||
|
|
||||||
pGuild->StoreItem(BankTab,dest,pItemChar);
|
|
||||||
pl->SaveInventoryAndGoldToDB();
|
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
|
|
||||||
pGuild->DisplayGuildBankContentUpdate(BankTab,dest);
|
|
||||||
}
|
|
||||||
else // Char <-> Bank swap items (posible NULL bank item)
|
|
||||||
{
|
|
||||||
ItemPosCountVec iDest;
|
|
||||||
if(pItemBank)
|
|
||||||
{
|
|
||||||
msg = pl->CanStoreItem(PlayerBag, PlayerSlot, iDest, pItemBank, true);
|
|
||||||
if( msg != EQUIP_ERR_OK )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( msg, pItemBank, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GuildItemPosCountVec gDest;
|
|
||||||
msg = pGuild->CanStoreItem(BankTab,BankTabSlot,gDest,pItemChar->GetCount(),pItemChar,true);
|
|
||||||
if( msg != EQUIP_ERR_OK )
|
|
||||||
{
|
|
||||||
pl->SendEquipError( msg, pItemChar, NULL );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pItemBank)
|
|
||||||
{
|
|
||||||
// check bank pos rights (item swapped with inventory)
|
|
||||||
uint32 remRight = pGuild->GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab);
|
|
||||||
if(remRight <= 0)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// logging item move to bank
|
|
||||||
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
|
||||||
{
|
|
||||||
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )",
|
|
||||||
_player->GetName(),_player->GetSession()->GetAccountId(),
|
|
||||||
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(),
|
|
||||||
GuildId);
|
|
||||||
}
|
|
||||||
|
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
if(pItemBank)
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), pItemBank->GetCount());
|
|
||||||
pGuild->LogBankEvent(GUILD_BANK_LOG_DEPOSIT_ITEM, BankTab, pl->GetGUIDLow(), pItemChar->GetEntry(), pItemChar->GetCount());
|
|
||||||
|
|
||||||
pl->MoveItemFromInventory(PlayerBag, PlayerSlot, true);
|
|
||||||
pItemChar->DeleteFromInventoryDB();
|
|
||||||
if(pItemBank)
|
|
||||||
pGuild->RemoveItem(BankTab, BankTabSlot);
|
|
||||||
|
|
||||||
pGuild->StoreItem(BankTab,gDest,pItemChar);
|
|
||||||
if(pItemBank)
|
|
||||||
pl->MoveItemToInventory(iDest,pItemBank,true);
|
|
||||||
pl->SaveInventoryAndGoldToDB();
|
|
||||||
if(pItemBank)
|
|
||||||
pGuild->MemberItemWithdraw(BankTab, pl->GetGUIDLow());
|
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
|
|
||||||
pGuild->DisplayGuildBankContentUpdate(BankTab,gDest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleGuildBankBuyTab( WorldPacket & recv_data )
|
void WorldSession::HandleGuildBankBuyTab( WorldPacket & recv_data )
|
||||||
|
|
|
||||||
|
|
@ -679,6 +679,7 @@ class MANGOS_DLL_SPEC WorldSession
|
||||||
void HandleGuildBankDepositMoney(WorldPacket& recv_data);
|
void HandleGuildBankDepositMoney(WorldPacket& recv_data);
|
||||||
void HandleGuildBankWithdrawMoney(WorldPacket& recv_data);
|
void HandleGuildBankWithdrawMoney(WorldPacket& recv_data);
|
||||||
void HandleGuildBankSwapItems(WorldPacket& recv_data);
|
void HandleGuildBankSwapItems(WorldPacket& recv_data);
|
||||||
|
|
||||||
void HandleGuildBankUpdateTab(WorldPacket& recv_data);
|
void HandleGuildBankUpdateTab(WorldPacket& recv_data);
|
||||||
void HandleGuildBankBuyTab(WorldPacket& recv_data);
|
void HandleGuildBankBuyTab(WorldPacket& recv_data);
|
||||||
void HandleQueryGuildBankTabText(WorldPacket& recv_data);
|
void HandleQueryGuildBankTabText(WorldPacket& recv_data);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8406"
|
#define REVISION_NR "8407"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue