Fix some problem with Guild Bank after switch to client version 3.3.2, also cleanup code. Thx TOM_RUS.

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2010-02-15 14:30:12 +01:00
parent a5585ceb3c
commit 490f4bf7ec
4 changed files with 113 additions and 186 deletions
+87 -153
View File
@@ -48,15 +48,12 @@ Guild::Guild()
m_CreatedMonth = 0; m_CreatedMonth = 0;
m_CreatedDay = 0; m_CreatedDay = 0;
m_EventLogLoaded = false;
m_GuildBankLoaded = false;
m_OnlineMembers = 0;
m_GuildBankMoney = 0; m_GuildBankMoney = 0;
m_PurchasedTabs = 0; m_PurchasedTabs = 0;
m_GuildEventLogNextGuid = 0; m_GuildEventLogNextGuid = 0;
m_GuildBankEventLogNextGuid_Money = 0; m_GuildBankEventLogNextGuid_Money = 0;
for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; i++) for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
m_GuildBankEventLogNextGuid_Item[i] = 0; m_GuildBankEventLogNextGuid_Item[i] = 0;
} }
@@ -573,12 +570,12 @@ void Guild::BroadcastToGuild(WorldSession *session, const std::string& msg, uint
void Guild::BroadcastToOfficers(WorldSession *session, const std::string& msg, uint32 language) void Guild::BroadcastToOfficers(WorldSession *session, const std::string& msg, uint32 language)
{ {
if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_OFFCHATSPEAK)) if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(), GR_RIGHT_OFFCHATSPEAK))
{ {
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr) for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
{ {
WorldPacket data; WorldPacket data;
ChatHandler::FillMessageData(&data, session, CHAT_MSG_OFFICER, language, NULL, 0, msg.c_str(),NULL); ChatHandler::FillMessageData(&data, session, CHAT_MSG_OFFICER, language, NULL, 0, msg.c_str(), NULL);
Player *pl = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); Player *pl = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));
@@ -786,7 +783,7 @@ void Guild::Query(WorldSession *session)
data << m_Id; data << m_Id;
data << m_Name; data << m_Name;
for (size_t i = 0 ; i < 10; ++i) // show always 10 ranks for (size_t i = 0 ; i < GUILD_RANKS_MAX_COUNT; ++i) // show always 10 ranks
{ {
if (i < m_Ranks.size()) if (i < m_Ranks.size())
data << m_Ranks[i].Name; data << m_Ranks[i].Name;
@@ -823,14 +820,6 @@ void Guild::UpdateLogoutTime(uint64 guid)
return; return;
itr->second.LogoutTime = time(NULL); itr->second.LogoutTime = time(NULL);
if (m_OnlineMembers > 0)
--m_OnlineMembers;
else
{
UnloadGuildBank();
UnloadGuildEventLog();
}
} }
// ************************************************* // *************************************************
@@ -839,10 +828,6 @@ void Guild::UpdateLogoutTime(uint64 guid)
// Display guild eventlog // Display guild eventlog
void Guild::DisplayGuildEventLog(WorldSession *session) void Guild::DisplayGuildEventLog(WorldSession *session)
{ {
// Load guild eventlog, if not already done
if (!m_EventLogLoaded)
LoadGuildEventLogFromDB();
// Sending result // Sending result
WorldPacket data(MSG_GUILD_EVENT_LOG_QUERY, 0); WorldPacket data(MSG_GUILD_EVENT_LOG_QUERY, 0);
// count, max count == 100 // count, max count == 100
@@ -869,10 +854,6 @@ void Guild::DisplayGuildEventLog(WorldSession *session)
// Load guild eventlog from DB // Load guild eventlog from DB
void Guild::LoadGuildEventLogFromDB() void Guild::LoadGuildEventLogFromDB()
{ {
// Return if already loaded
if (m_EventLogLoaded)
return;
// 0 1 2 3 4 5 // 0 1 2 3 4 5
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog WHERE guildid=%u ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, GUILD_EVENTLOG_MAX_RECORDS); QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog WHERE guildid=%u ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, GUILD_EVENTLOG_MAX_RECORDS);
if (!result) if (!result)
@@ -904,18 +885,6 @@ void Guild::LoadGuildEventLogFromDB()
m_GuildEventLog.push_front(NewEvent); m_GuildEventLog.push_front(NewEvent);
} while (result->NextRow()); } while (result->NextRow());
m_EventLogLoaded = true;
}
// Unload guild eventlog
void Guild::UnloadGuildEventLog()
{
if (!m_EventLogLoaded)
return;
m_GuildEventLog.clear();
m_EventLogLoaded = false;
} }
// Add entry to guild eventlog // Add entry to guild eventlog
@@ -949,19 +918,19 @@ void Guild::DisplayGuildBankContent(WorldSession *session, uint8 TabId)
{ {
GuildBankTab const* tab = m_TabListMap[TabId]; GuildBankTab const* tab = m_TabListMap[TabId];
if (!IsMemberHaveRights(session->GetPlayer()->GetGUIDLow(),TabId,GUILD_BANK_RIGHT_VIEW_TAB)) if (!IsMemberHaveRights(session->GetPlayer()->GetGUIDLow(), TabId, GUILD_BANK_RIGHT_VIEW_TAB))
return; return;
WorldPacket data(SMSG_GUILD_BANK_LIST,1200); WorldPacket data(SMSG_GUILD_BANK_LIST, 1200);
data << uint64(GetGuildBankMoney()); data << uint64(GetGuildBankMoney());
data << uint8(TabId); data << uint8(TabId);
data << uint32(GetMemberSlotWithdrawRem(session->GetPlayer()->GetGUIDLow(), TabId)); // remaining slots for today data << uint32(GetMemberSlotWithdrawRem(session->GetPlayer()->GetGUIDLow(), TabId)); // remaining slots for today
data << uint8(0); // Tell client this is a tab content packet data << uint8(0); // Tell client that there's no tab info in this packet
data << uint8(GUILD_BANK_MAX_SLOTS); data << uint8(GUILD_BANK_MAX_SLOTS);
for (uint8 i=0; i<GUILD_BANK_MAX_SLOTS; ++i) for (uint8 i=0; i < GUILD_BANK_MAX_SLOTS; ++i)
AppendDisplayGuildBankSlot(data, tab, i); AppendDisplayGuildBankSlot(data, tab, i);
session->SendPacket(&data); session->SendPacket(&data);
@@ -973,25 +942,24 @@ void Guild::DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2)
{ {
GuildBankTab const* tab = m_TabListMap[TabId]; GuildBankTab const* tab = m_TabListMap[TabId];
WorldPacket data(SMSG_GUILD_BANK_LIST,1200); WorldPacket data(SMSG_GUILD_BANK_LIST, 1200);
data << uint64(GetGuildBankMoney()); data << uint64(GetGuildBankMoney());
data << uint8(TabId); data << uint8(TabId);
// remaining slots for today
size_t rempos = data.wpos(); size_t rempos = data.wpos();
data << uint32(0); // will be filled later data << uint32(0); // item withdraw amount, will be filled later
data << uint8(0); // Tell client this is a tab content packet data << uint8(0); // Tell client that there's no tab info in this packet
if (slot2 == -1) // single item in slot1 if (slot2 == -1) // single item in slot1
{ {
data << uint8(1); data << uint8(1); // item count
AppendDisplayGuildBankSlot(data, tab, slot1); AppendDisplayGuildBankSlot(data, tab, slot1);
} }
else // 2 items (in slot1 and slot2) else // 2 items (in slot1 and slot2)
{ {
data << uint8(2); data << uint8(2); // item count
if (slot1 > slot2) if (slot1 > slot2)
std::swap(slot1,slot2); std::swap(slot1,slot2);
@@ -1021,15 +989,14 @@ void Guild::DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec cons
{ {
GuildBankTab const* tab = m_TabListMap[TabId]; GuildBankTab const* tab = m_TabListMap[TabId];
WorldPacket data(SMSG_GUILD_BANK_LIST,1200); WorldPacket data(SMSG_GUILD_BANK_LIST, 1200);
data << uint64(GetGuildBankMoney()); data << uint64(GetGuildBankMoney());
data << uint8(TabId); data << uint8(TabId);
// remaining slots for today
size_t rempos = data.wpos(); size_t rempos = data.wpos();
data << uint32(0); // will be filled later data << uint32(0); // item withdraw amount, will be filled later
data << uint8(0); // Tell client this is a tab content packet data << uint8(0); // Tell client that there's no tab info in this packet
data << uint8(slots.size()); // updates count data << uint8(slots.size()); // updates count
@@ -1065,17 +1032,12 @@ Item* Guild::GetItem(uint8 TabId, uint8 SlotId)
void Guild::DisplayGuildBankTabsInfo(WorldSession *session) void Guild::DisplayGuildBankTabsInfo(WorldSession *session)
{ {
// Time to load bank if not already done
if (!m_GuildBankLoaded)
LoadGuildBankFromDB();
WorldPacket data(SMSG_GUILD_BANK_LIST, 500); WorldPacket data(SMSG_GUILD_BANK_LIST, 500);
data << uint64(GetGuildBankMoney()); data << uint64(GetGuildBankMoney());
data << uint8(0); // TabInfo packet must be for TabId 0 data << uint8(0); // TabInfo packet must be for TabId 0
//data << uint32(0xFFFFFFFF); // bit 9 must be set for this packet to work data << uint32(GetMemberSlotWithdrawRem(session->GetPlayer()->GetGUIDLow(), 0));
data << uint32(0); data << uint8(1); // Tell client that this packet includes tab info
data << uint8(1); // Tell Client this is a TabInfo packet
data << uint8(m_PurchasedTabs); // here is the number of tabs data << uint8(m_PurchasedTabs); // here is the number of tabs
for (uint8 i = 0; i < m_PurchasedTabs; ++i) for (uint8 i = 0; i < m_PurchasedTabs; ++i)
@@ -1089,14 +1051,14 @@ void Guild::DisplayGuildBankTabsInfo(WorldSession *session)
sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)");
} }
void Guild::DisplayGuildBankMoneyUpdate() void Guild::DisplayGuildBankMoneyUpdate(WorldSession *session)
{ {
WorldPacket data(SMSG_GUILD_BANK_LIST, 8+1+4+1+1); WorldPacket data(SMSG_GUILD_BANK_LIST, 8+1+4+1+1);
data << uint64(GetGuildBankMoney()); data << uint64(GetGuildBankMoney());
data << uint8(0); // TabId, default 0 data << uint8(0); // TabId, default 0
data << uint32(0); // slot withdrow, default 0 data << uint32(GetMemberSlotWithdrawRem(session->GetPlayer()->GetGUIDLow(), 0));
data << uint8(0); // Tell client this is a tab content packet data << uint8(0); // Tell that there's no tab info in this packet
data << uint8(0); // not send items data << uint8(0); // not send items
BroadcastPacket(&data); BroadcastPacket(&data);
@@ -1143,17 +1105,11 @@ uint32 Guild::GetBankRights(uint32 rankId, uint8 TabId) const
} }
// ************************************************* // *************************************************
// Guild bank loading/unloading related // Guild bank loading related
// This load should be called when the bank is first accessed by a guild member // This load should be called on startup only
void Guild::LoadGuildBankFromDB() void Guild::LoadGuildBankFromDB()
{ {
if (m_GuildBankLoaded)
return;
m_GuildBankLoaded = true;
LoadGuildBankEventLogFromDB();
// 0 1 2 3 // 0 1 2 3
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT TabId, TabName, TabIcon, TabText FROM guild_bank_tab WHERE guildid='%u' ORDER BY TabId", m_Id); QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT TabId, TabName, TabIcon, TabText FROM guild_bank_tab WHERE guildid='%u' ORDER BY TabId", m_Id);
if (!result) if (!result)
@@ -1176,7 +1132,7 @@ void Guild::LoadGuildBankFromDB()
NewTab->Text = fields[3].GetCppString(); NewTab->Text = fields[3].GetCppString();
m_TabListMap[TabId] = NewTab; m_TabListMap[TabId] = NewTab;
}while (result->NextRow()); } while (result->NextRow());
// data needs to be at first place for Item::LoadFromDB // data needs to be at first place for Item::LoadFromDB
// 0 1 2 3 4 // 0 1 2 3 4
@@ -1226,29 +1182,6 @@ void Guild::LoadGuildBankFromDB()
}while (result->NextRow()); }while (result->NextRow());
} }
// This unload should be called when the last member of the guild gets offline
void Guild::UnloadGuildBank()
{
if (!m_GuildBankLoaded)
return;
for (uint8 i = 0; i < m_PurchasedTabs ; ++i)
{
for (uint8 j = 0; j < GUILD_BANK_MAX_SLOTS ; ++j)
{
if (m_TabListMap[i]->Slots[j])
{
m_TabListMap[i]->Slots[j]->RemoveFromWorld();
delete m_TabListMap[i]->Slots[j];
}
}
delete m_TabListMap[i];
}
m_TabListMap.clear();
UnloadGuildBankEventLog();
m_GuildBankLoaded = false;
}
// ************************************************* // *************************************************
// Money deposit/withdraw related // Money deposit/withdraw related
@@ -1341,7 +1274,7 @@ uint32 Guild::GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId)
{ {
itr->second.BankResetTimeTab[TabId] = curTime; itr->second.BankResetTimeTab[TabId] = curTime;
itr->second.BankRemSlotsTab[TabId] = GetBankSlotPerDay(itr->second.RankId, TabId); itr->second.BankRemSlotsTab[TabId] = GetBankSlotPerDay(itr->second.RankId, TabId);
CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeTab%u='%u',BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'", CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeTab%u='%u', BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'",
uint32(TabId), itr->second.BankResetTimeTab[TabId], uint32(TabId), itr->second.BankRemSlotsTab[TabId], m_Id, LowGuid); uint32(TabId), itr->second.BankResetTimeTab[TabId], uint32(TabId), itr->second.BankRemSlotsTab[TabId], m_Id, LowGuid);
} }
return itr->second.BankRemSlotsTab[TabId]; return itr->second.BankRemSlotsTab[TabId];
@@ -1362,7 +1295,7 @@ uint32 Guild::GetMemberMoneyWithdrawRem(uint32 LowGuid)
{ {
itr->second.BankResetTimeMoney = curTime; itr->second.BankResetTimeMoney = curTime;
itr->second.BankRemMoney = GetBankMoneyPerDay(itr->second.RankId); itr->second.BankRemMoney = GetBankMoneyPerDay(itr->second.RankId);
CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='%u',BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'", CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='%u', BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'",
itr->second.BankResetTimeMoney, itr->second.BankRemMoney, m_Id, LowGuid); itr->second.BankResetTimeMoney, itr->second.BankRemMoney, m_Id, LowGuid);
} }
return itr->second.BankRemMoney; return itr->second.BankRemMoney;
@@ -1471,7 +1404,7 @@ void Guild::LoadGuildBankEventLogFromDB()
//uint32 configCount = sWorld.getConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT); //uint32 configCount = sWorld.getConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT);
//cycle through all purchased guild bank item tabs //cycle through all purchased guild bank item tabs
for (uint32 tabId = 0; tabId < m_PurchasedTabs; tabId++) for (uint32 tabId = 0; tabId < m_PurchasedTabs; ++tabId)
{ {
// 0 1 2 3 4 5 6 // 0 1 2 3 4 5 6
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog WHERE guildid='%u' AND TabId='%u' ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, tabId, GUILD_BANK_MAX_LOGS); QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog WHERE guildid='%u' AND TabId='%u' ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, tabId, GUILD_BANK_MAX_LOGS);
@@ -1549,14 +1482,6 @@ void Guild::LoadGuildBankEventLogFromDB()
} while (result->NextRow()); } while (result->NextRow());
} }
void Guild::UnloadGuildBankEventLog()
{
m_GuildBankEventLog_Money.clear();
for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
m_GuildBankEventLog_Item[i].clear();
}
void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId) void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId)
{ {
if (TabId >= GUILD_BANK_MAX_TABS) // tabs starts in 0 if (TabId >= GUILD_BANK_MAX_TABS) // tabs starts in 0
@@ -1682,21 +1607,30 @@ void Guild::AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *t
data << uint32(entry); data << uint32(entry);
if (entry) if (entry)
{ {
data << (int32) pItem->GetItemRandomPropertyId(); // random item property id +8 data << uint32(0); // 3.3.0 (0x8000, 0x8020)
if (pItem->GetItemRandomPropertyId()) data << uint32(pItem->GetItemRandomPropertyId()); // random item property id + 8
data << (uint32) pItem->GetItemSuffixFactor(); // SuffixFactor +4
data << uint32(pItem->GetCount()); // +12 // ITEM_FIELD_STACK_COUNT if (pItem->GetItemRandomPropertyId())
data << uint32(0); // +16 // Unknown value data << uint32(pItem->GetItemSuffixFactor()); // SuffixFactor + 4
data << uint32(pItem->GetCount()); // +12 ITEM_FIELD_STACK_COUNT
data << uint32(0); // +16 Unknown value
data << uint8(abs(pItem->GetSpellCharges())); // spell charges data << uint8(abs(pItem->GetSpellCharges())); // spell charges
if (uint32 Enchant0 = pItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT))
uint8 enchCount = 0;
size_t enchCountPos = data.wpos();
data << uint8(enchCount); // number of enchantments
for(uint32 i = PERM_ENCHANTMENT_SLOT; i < MAX_ENCHANTMENT_SLOT; ++i)
{ {
data << uint8(1); // number of enchantments (max 3) why max 3? if(uint32 enchId = pItem->GetEnchantmentId(EnchantmentSlot(i)))
data << uint8(PERM_ENCHANTMENT_SLOT); // enchantment slot (range: 0:2) {
data << uint32(Enchant0); // enchantment id data << uint8(i);
data << uint32(enchId);
++enchCount;
}
} }
else data.put<uint8>(enchCountPos, enchCount);
data << uint8(0); // no enchantments (0)
} }
} }
@@ -1716,11 +1650,11 @@ Item* Guild::StoreItem(uint8 tabId, GuildItemPosCountVec const& dest, Item* pIte
if (itr == dest.end()) if (itr == dest.end())
{ {
lastItem = _StoreItem(tabId,slot,pItem,count,false); lastItem = _StoreItem(tabId, slot, pItem, count, false);
break; break;
} }
lastItem = _StoreItem(tabId,slot,pItem,count,true); lastItem = _StoreItem(tabId, slot, pItem, count, true);
} }
return lastItem; return lastItem;
@@ -1752,7 +1686,7 @@ Item* Guild::_StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool
pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0); pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0);
AddGBankItemToDB(GetId(), tab, slot, pItem->GetGUIDLow(), pItem->GetEntry()); AddGBankItemToDB(GetId(), tab, slot, pItem->GetGUIDLow(), pItem->GetEntry());
pItem->FSetState(ITEM_NEW); pItem->FSetState(ITEM_NEW);
pItem->SaveToDB(); // not in onventory and can be save standalone pItem->SaveToDB(); // not in inventory and can be save standalone
return pItem; return pItem;
} }
@@ -1760,7 +1694,7 @@ Item* Guild::_StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool
{ {
pItem2->SetCount( pItem2->GetCount() + count ); pItem2->SetCount( pItem2->GetCount() + count );
pItem2->FSetState(ITEM_CHANGED); pItem2->FSetState(ITEM_CHANGED);
pItem2->SaveToDB(); // not in onventory and can be save standalone pItem2->SaveToDB(); // not in inventory and can be save standalone
if (!clone) if (!clone)
{ {
@@ -1826,7 +1760,7 @@ uint8 Guild::_CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCo
uint8 Guild::_CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec &dest, uint32& count, bool merge, Item* pSrcItem, uint8 skip_slot ) const uint8 Guild::_CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec &dest, uint32& count, bool merge, Item* pSrcItem, uint8 skip_slot ) const
{ {
assert(pSrcItem); assert(pSrcItem);
for (uint32 j = 0; j < GUILD_BANK_MAX_SLOTS; j++) for (uint32 j = 0; j < GUILD_BANK_MAX_SLOTS; ++j)
{ {
// skip specific slot already processed in first called _CanStoreItem_InSpecificSlot // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot
if (j == skip_slot) if (j == skip_slot)
@@ -1850,7 +1784,7 @@ uint8 Guild::_CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec &dest, uint32&
if (need_space > count) if (need_space > count)
need_space = count; need_space = count;
GuildItemPosCount newPosition = GuildItemPosCount(j,need_space); GuildItemPosCount newPosition = GuildItemPosCount(j, need_space);
if (!newPosition.isContainedIn(dest)) if (!newPosition.isContainedIn(dest))
{ {
dest.push_back(newPosition); dest.push_back(newPosition);
@@ -1867,7 +1801,7 @@ uint8 Guild::_CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec &dest, uint32&
if (need_space > count) if (need_space > count)
need_space = count; need_space = count;
GuildItemPosCount newPosition = GuildItemPosCount(j,need_space); GuildItemPosCount newPosition = GuildItemPosCount(j, need_space);
if (!newPosition.isContainedIn(dest)) if (!newPosition.isContainedIn(dest))
{ {
dest.push_back(newPosition); dest.push_back(newPosition);
@@ -1906,12 +1840,12 @@ uint8 Guild::CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, ui
return EQUIP_ERR_OK; return EQUIP_ERR_OK;
} }
// not specific slot or have spece for partly store only in specific slot // not specific slot or have space for partly store only in specific slot
// search stack in tab for merge to // search stack in tab for merge to
if (pItem->GetMaxStackCount() > 1) if (pItem->GetMaxStackCount() > 1)
{ {
uint8 res = _CanStoreItem_InTab(tab,dest,count,true,pItem,slot); uint8 res = _CanStoreItem_InTab(tab, dest, count, true, pItem, slot);
if (res != EQUIP_ERR_OK) if (res != EQUIP_ERR_OK)
return res; return res;
@@ -1920,7 +1854,7 @@ uint8 Guild::CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, ui
} }
// search free slot in bag for place to // search free slot in bag for place to
uint8 res = _CanStoreItem_InTab(tab,dest,count,false,pItem,slot); uint8 res = _CanStoreItem_InTab(tab, dest, count, false, pItem, slot);
if (res != EQUIP_ERR_OK) if (res != EQUIP_ERR_OK)
return res; return res;
@@ -1942,7 +1876,7 @@ void Guild::SetGuildBankTabText(uint8 TabId, std::string text)
if (m_TabListMap[TabId]->Text == text) if (m_TabListMap[TabId]->Text == text)
return; return;
utf8truncate(text,500); // DB and client size limitation utf8truncate(text, 500); // DB and client size limitation
m_TabListMap[TabId]->Text = text; m_TabListMap[TabId]->Text = text;
@@ -2004,7 +1938,7 @@ void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankT
if (SplitedAmount) if (SplitedAmount)
{ // Bank -> Bank item split (in empty or non empty slot { // Bank -> Bank item split (in empty or non empty slot
GuildItemPosCountVec dest; GuildItemPosCountVec dest;
uint8 msg = CanStoreItem(BankTabDst,BankTabSlotDst,dest,SplitedAmount,pItemSrc,false); uint8 msg = CanStoreItem(BankTabDst, BankTabSlotDst, dest, SplitedAmount, pItemSrc, false);
if (msg != EQUIP_ERR_OK) if (msg != EQUIP_ERR_OK)
{ {
pl->SendEquipError(msg, pItemSrc, NULL); pl->SendEquipError(msg, pItemSrc, NULL);
@@ -2025,13 +1959,13 @@ void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankT
pItemSrc->SetCount(pItemSrc->GetCount() - SplitedAmount); pItemSrc->SetCount(pItemSrc->GetCount() - SplitedAmount);
pItemSrc->FSetState(ITEM_CHANGED); pItemSrc->FSetState(ITEM_CHANGED);
pItemSrc->SaveToDB(); // not in inventory and can be save standalone pItemSrc->SaveToDB(); // not in inventory and can be save standalone
StoreItem(BankTabDst,dest,pNewItem); StoreItem(BankTabDst, dest, pNewItem);
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
} }
else // non split else // non split
{ {
GuildItemPosCountVec gDest; GuildItemPosCountVec gDest;
uint8 msg = CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,false); uint8 msg = CanStoreItem(BankTabDst, BankTabSlotDst, gDest, pItemSrc->GetCount(), pItemSrc, false);
if (msg == EQUIP_ERR_OK) // merge to if (msg == EQUIP_ERR_OK) // merge to
{ {
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
@@ -2044,7 +1978,7 @@ void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankT
else // swap else // swap
{ {
gDest.clear(); gDest.clear();
msg = CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,true); msg = CanStoreItem(BankTabDst, BankTabSlotDst, gDest, pItemSrc->GetCount(), pItemSrc, true);
if (msg != EQUIP_ERR_OK) if (msg != EQUIP_ERR_OK)
{ {
pl->SendEquipError(msg, pItemSrc, NULL); pl->SendEquipError(msg, pItemSrc, NULL);
@@ -2052,7 +1986,7 @@ void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankT
} }
GuildItemPosCountVec gSrc; GuildItemPosCountVec gSrc;
msg = CanStoreItem(BankTab,BankTabSlot,gSrc,pItemDst->GetCount(),pItemDst,true); msg = CanStoreItem(BankTab, BankTabSlot, gSrc, pItemDst->GetCount(), pItemDst, true);
if (msg != EQUIP_ERR_OK) if (msg != EQUIP_ERR_OK)
{ {
pl->SendEquipError(msg, pItemDst, NULL); pl->SendEquipError(msg, pItemDst, NULL);
@@ -2132,7 +2066,7 @@ void Guild::MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, u
pItemBank->SetCount(pItemBank->GetCount()-SplitedAmount); pItemBank->SetCount(pItemBank->GetCount()-SplitedAmount);
pItemBank->FSetState(ITEM_CHANGED); pItemBank->FSetState(ITEM_CHANGED);
pItemBank->SaveToDB(); // not in inventory and can be save standalone pItemBank->SaveToDB(); // not in inventory and can be save standalone
pl->MoveItemToInventory(dest,pNewItem,true); pl->MoveItemToInventory(dest, pNewItem, true);
pl->SaveInventoryAndGoldToDB(); pl->SaveInventoryAndGoldToDB();
MemberItemWithdraw(BankTab, pl->GetGUIDLow()); MemberItemWithdraw(BankTab, pl->GetGUIDLow());
@@ -2153,7 +2087,7 @@ void Guild::MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, u
LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), pItemBank->GetCount()); LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), pItemBank->GetCount());
RemoveItem(BankTab, BankTabSlot); RemoveItem(BankTab, BankTabSlot);
pl->MoveItemToInventory(dest,pItemBank,true); pl->MoveItemToInventory(dest, pItemBank, true);
pl->SaveInventoryAndGoldToDB(); pl->SaveInventoryAndGoldToDB();
MemberItemWithdraw(BankTab, pl->GetGUIDLow()); MemberItemWithdraw(BankTab, pl->GetGUIDLow());
@@ -2185,7 +2119,7 @@ void Guild::MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, u
GuildItemPosCountVec gDest; GuildItemPosCountVec gDest;
if (pItemChar) if (pItemChar)
{ {
msg = CanStoreItem(BankTab,BankTabSlot,gDest,pItemChar->GetCount(),pItemChar,true); msg = CanStoreItem(BankTab, BankTabSlot, gDest, pItemChar->GetCount(), pItemChar, true);
if (msg != EQUIP_ERR_OK) if (msg != EQUIP_ERR_OK)
{ {
pl->SendEquipError(msg, pItemChar, NULL); pl->SendEquipError(msg, pItemChar, NULL);
@@ -2203,9 +2137,9 @@ void Guild::MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, u
// logging item move to bank // logging item move to bank
if (pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) 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 )", 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(), pl->GetName(), pl->GetSession()->GetAccountId(),
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(), pItemChar->GetProto()->Name1, pItemChar->GetEntry(), pItemChar->GetCount(),
m_Id); m_Id);
} }
} }
@@ -2224,7 +2158,7 @@ void Guild::MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, u
if (pItemChar) if (pItemChar)
StoreItem(BankTab, gDest, pItemChar); StoreItem(BankTab, gDest, pItemChar);
pl->MoveItemToInventory(iDest,pItemBank,true); pl->MoveItemToInventory(iDest, pItemBank, true);
pl->SaveInventoryAndGoldToDB(); pl->SaveInventoryAndGoldToDB();
MemberItemWithdraw(BankTab, pl->GetGUIDLow()); MemberItemWithdraw(BankTab, pl->GetGUIDLow());
@@ -2260,7 +2194,7 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
if (SplitedAmount) if (SplitedAmount)
{ // Char -> Bank split to empty or non-empty slot (partly move) { // Char -> Bank split to empty or non-empty slot (partly move)
GuildItemPosCountVec dest; GuildItemPosCountVec dest;
uint8 msg = CanStoreItem(BankTab,BankTabSlot,dest,SplitedAmount,pItemChar,false); uint8 msg = CanStoreItem(BankTab, BankTabSlot, dest, SplitedAmount, pItemChar, false);
if (msg != EQUIP_ERR_OK) if (msg != EQUIP_ERR_OK)
{ {
pl->SendEquipError(msg, pItemChar, NULL); pl->SendEquipError(msg, pItemChar, NULL);
@@ -2277,9 +2211,9 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
// logging item move to bank (before items merge // logging item move to bank (before items merge
if (pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) 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 )", 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(), pl->GetName(), pl->GetSession()->GetAccountId(),
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),SplitedAmount,m_Id); pItemChar->GetProto()->Name1, pItemChar->GetEntry(), SplitedAmount,m_Id);
} }
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
@@ -2292,20 +2226,20 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
StoreItem(BankTab, dest, pNewItem); StoreItem(BankTab, dest, pNewItem);
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
DisplayGuildBankContentUpdate(BankTab,dest); DisplayGuildBankContentUpdate(BankTab, dest);
} }
else // Char -> Bank swap with empty or non-empty (move) else // Char -> Bank swap with empty or non-empty (move)
{ {
GuildItemPosCountVec dest; GuildItemPosCountVec dest;
uint8 msg = CanStoreItem(BankTab,BankTabSlot,dest,pItemChar->GetCount(),pItemChar,false); uint8 msg = CanStoreItem(BankTab, BankTabSlot, dest, pItemChar->GetCount(), pItemChar, false);
if (msg == EQUIP_ERR_OK) // merge if (msg == EQUIP_ERR_OK) // merge
{ {
// logging item move to bank // logging item move to bank
if (pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) 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 )", 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(), pl->GetName(), pl->GetSession()->GetAccountId(),
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(), pItemChar->GetProto()->Name1, pItemChar->GetEntry(), pItemChar->GetCount(),
m_Id); m_Id);
} }
@@ -2315,11 +2249,11 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
pl->MoveItemFromInventory(PlayerBag, PlayerSlot, true); pl->MoveItemFromInventory(PlayerBag, PlayerSlot, true);
pItemChar->DeleteFromInventoryDB(); pItemChar->DeleteFromInventoryDB();
StoreItem(BankTab,dest,pItemChar); StoreItem(BankTab, dest, pItemChar);
pl->SaveInventoryAndGoldToDB(); pl->SaveInventoryAndGoldToDB();
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
DisplayGuildBankContentUpdate(BankTab,dest); DisplayGuildBankContentUpdate(BankTab, dest);
} }
else // Char <-> Bank swap items (posible NULL bank item) else // Char <-> Bank swap items (posible NULL bank item)
{ {
@@ -2335,7 +2269,7 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
} }
GuildItemPosCountVec gDest; GuildItemPosCountVec gDest;
msg = CanStoreItem(BankTab,BankTabSlot,gDest,pItemChar->GetCount(),pItemChar,true); msg = CanStoreItem(BankTab, BankTabSlot, gDest, pItemChar->GetCount(), pItemChar, true);
if (msg != EQUIP_ERR_OK) if (msg != EQUIP_ERR_OK)
{ {
pl->SendEquipError(msg, pItemChar, NULL); pl->SendEquipError(msg, pItemChar, NULL);
@@ -2353,9 +2287,9 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
// logging item move to bank // logging item move to bank
if (pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE)) 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 )", 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(), pl->GetName(), pl->GetSession()->GetAccountId(),
pItemChar->GetProto()->Name1,pItemChar->GetEntry(),pItemChar->GetCount(), pItemChar->GetProto()->Name1, pItemChar->GetEntry(), pItemChar->GetCount(),
m_Id); m_Id);
} }
@@ -2371,13 +2305,13 @@ void Guild::MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot,
StoreItem(BankTab,gDest,pItemChar); StoreItem(BankTab,gDest,pItemChar);
if (pItemBank) if (pItemBank)
pl->MoveItemToInventory(iDest,pItemBank,true); pl->MoveItemToInventory(iDest, pItemBank, true);
pl->SaveInventoryAndGoldToDB(); pl->SaveInventoryAndGoldToDB();
if (pItemBank) if (pItemBank)
MemberItemWithdraw(BankTab, pl->GetGUIDLow()); MemberItemWithdraw(BankTab, pl->GetGUIDLow());
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
DisplayGuildBankContentUpdate(BankTab,gDest); DisplayGuildBankContentUpdate(BankTab, gDest);
} }
} }
} }
+12 -19
View File
@@ -117,15 +117,16 @@ enum GuildEvents
GE_LEADER_CHANGED = 0x07, GE_LEADER_CHANGED = 0x07,
GE_DISBANDED = 0x08, GE_DISBANDED = 0x08,
GE_TABARDCHANGE = 0x09, GE_TABARDCHANGE = 0x09,
GE_UNK1 = 0x0A, // string, string GE_UNK1 = 0x0A, // string, string EVENT_GUILD_ROSTER_UPDATE
GE_UNK2 = 0x0B, GE_UNK2 = 0x0B, // EVENT_GUILD_ROSTER_UPDATE
GE_SIGNED_ON = 0x0C, GE_SIGNED_ON = 0x0C, // ERR_FRIEND_ONLINE_SS
GE_SIGNED_OFF = 0x0D, GE_SIGNED_OFF = 0x0D, // ERR_FRIEND_OFFLINE_S
GE_UNK3 = 0x0E, GE_UNK3 = 0x0E, // EVENT_GUILDBANKBAGSLOTS_CHANGED
GE_BANKTAB_PURCHASED= 0x0F, GE_BANKTAB_PURCHASED= 0x0F, // EVENT_GUILDBANK_UPDATE_TABS
GE_UNK5 = 0x10, GE_UNK5 = 0x10, // EVENT_GUILDBANK_UPDATE_TABS
GE_UNK6 = 0x11, // string 0000000000002710 is 1 gold GE_UNK6 = 0x11, // EVENT_GUILDBANK_UPDATE_MONEY, string 0000000000002710 is 1 gold
GE_UNK7 = 0x12 GE_UNK7 = 0x12, // MSG_GUILD_BANK_MONEY_WITHDRAWN
GE_UNK8 = 0x13 // EVENT_GUILDBANK_TEXT_CHANGED
}; };
enum PetitionTurns enum PetitionTurns
@@ -382,14 +383,13 @@ class Guild
void UpdateLogoutTime(uint64 guid); void UpdateLogoutTime(uint64 guid);
// Guild EventLog // Guild EventLog
void LoadGuildEventLogFromDB(); void LoadGuildEventLogFromDB();
void UnloadGuildEventLog();
void DisplayGuildEventLog(WorldSession *session); void DisplayGuildEventLog(WorldSession *session);
void LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid2, uint8 NewRank); void LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid2, uint8 NewRank);
// ** 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 DisplayGuildBankMoneyUpdate(); void DisplayGuildBankMoneyUpdate(WorldSession *session);
void SwapItems( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTabDst, uint8 BankTabSlotDst, uint32 SplitedAmount); void SwapItems( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTabDst, uint8 BankTabSlotDst, uint32 SplitedAmount);
void MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 PlayerBag, uint8 PlayerSlot, uint32 SplitedAmount); void MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 PlayerBag, uint8 PlayerSlot, uint32 SplitedAmount);
@@ -405,11 +405,8 @@ class Guild
uint32 GetBankRights(uint32 rankId, uint8 TabId) const; uint32 GetBankRights(uint32 rankId, uint8 TabId) const;
bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId,uint32 rights) const; bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId,uint32 rights) const;
bool CanMemberViewTab(uint32 LowGuid, uint8 TabId) const; bool CanMemberViewTab(uint32 LowGuid, uint8 TabId) const;
// Load/unload // Load
void LoadGuildBankFromDB(); void LoadGuildBankFromDB();
void UnloadGuildBank();
bool IsGuildBankLoaded() const { return m_GuildBankLoaded; }
void IncOnlineMemberCount() { ++m_OnlineMembers; }
// Money deposit/withdraw // Money deposit/withdraw
void SendMoneyInfo(WorldSession *session, uint32 LowGuid); void SendMoneyInfo(WorldSession *session, uint32 LowGuid);
bool MemberMoneyWithdraw(uint32 amount, uint32 LowGuid); bool MemberMoneyWithdraw(uint32 amount, uint32 LowGuid);
@@ -427,7 +424,6 @@ class Guild
void LoadBankRightsFromDB(uint32 GuildId); void LoadBankRightsFromDB(uint32 GuildId);
// Guild Bank Event Logs // Guild Bank Event Logs
void LoadGuildBankEventLogFromDB(); void LoadGuildBankEventLogFromDB();
void UnloadGuildBankEventLog();
void DisplayGuildBankLogs(WorldSession *session, uint8 TabId); void DisplayGuildBankLogs(WorldSession *session, uint8 TabId);
void LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0); void LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0);
bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry ); bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry );
@@ -468,9 +464,6 @@ class Guild
uint32 m_GuildBankEventLogNextGuid_Money; uint32 m_GuildBankEventLogNextGuid_Money;
uint32 m_GuildBankEventLogNextGuid_Item[GUILD_BANK_MAX_TABS]; uint32 m_GuildBankEventLogNextGuid_Item[GUILD_BANK_MAX_TABS];
bool m_GuildBankLoaded;
bool m_EventLogLoaded;
uint32 m_OnlineMembers;
uint64 m_GuildBankMoney; uint64 m_GuildBankMoney;
uint8 m_PurchasedTabs; uint8 m_PurchasedTabs;
+10 -13
View File
@@ -891,7 +891,7 @@ void WorldSession::HandleGuildBankQueryTab( WorldPacket & recv_data )
if (!pGuild) if (!pGuild)
return; return;
if (!pGuild->IsGuildBankLoaded() || TabId >= pGuild->GetPurchasedTabs()) if (TabId >= pGuild->GetPurchasedTabs())
return; return;
// Let's update the amount of gold the player can withdraw before displaying the content // Let's update the amount of gold the player can withdraw before displaying the content
@@ -925,7 +925,7 @@ void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data )
if (!pGuild) if (!pGuild)
return; return;
if (!pGuild->IsGuildBankLoaded() || !pGuild->GetPurchasedTabs()) if (!pGuild->GetPurchasedTabs())
return; return;
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
@@ -948,7 +948,7 @@ void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data )
pGuild->DisplayGuildBankTabsInfo(this); pGuild->DisplayGuildBankTabsInfo(this);
pGuild->DisplayGuildBankContent(this, 0); pGuild->DisplayGuildBankContent(this, 0);
pGuild->DisplayGuildBankMoneyUpdate(); pGuild->DisplayGuildBankMoneyUpdate(this);
} }
void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data ) void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data )
@@ -973,7 +973,7 @@ void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data )
if(!pGuild) if(!pGuild)
return; return;
if (!pGuild->IsGuildBankLoaded() || !pGuild->GetPurchasedTabs()) if (!pGuild->GetPurchasedTabs())
return; return;
if (pGuild->GetGuildBankMoney()<money) // not enough money in bank if (pGuild->GetGuildBankMoney()<money) // not enough money in bank
@@ -1001,7 +1001,7 @@ void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data )
pGuild->SendMoneyInfo(this, GetPlayer()->GetGUIDLow()); pGuild->SendMoneyInfo(this, GetPlayer()->GetGUIDLow());
pGuild->DisplayGuildBankTabsInfo(this); pGuild->DisplayGuildBankTabsInfo(this);
pGuild->DisplayGuildBankContent(this,0); pGuild->DisplayGuildBankContent(this,0);
pGuild->DisplayGuildBankMoneyUpdate(); pGuild->DisplayGuildBankMoneyUpdate(this);
} }
void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data ) void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data )
@@ -1030,7 +1030,7 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data )
} }
Guild *pGuild = objmgr.GetGuildById(GuildId); Guild *pGuild = objmgr.GetGuildById(GuildId);
if (!pGuild || !pGuild->IsGuildBankLoaded()) if (!pGuild)
{ {
recv_data.rpos(recv_data.wpos()); // prevent additional spam at rejected packet recv_data.rpos(recv_data.wpos()); // prevent additional spam at rejected packet
return; return;
@@ -1135,7 +1135,7 @@ void WorldSession::HandleGuildBankBuyTab( WorldPacket & recv_data )
return; return;
// m_PurchasedTabs = 0 when buying Tab 0, that is why this check can be made // m_PurchasedTabs = 0 when buying Tab 0, that is why this check can be made
if (!pGuild->IsGuildBankLoaded() || TabId != pGuild->GetPurchasedTabs()) if (TabId != pGuild->GetPurchasedTabs())
return; return;
uint32 TabCost = GetGuildBankTabPrice(TabId) * GOLD; uint32 TabCost = GetGuildBankTabPrice(TabId) * GOLD;
@@ -1185,7 +1185,7 @@ void WorldSession::HandleGuildBankUpdateTab( WorldPacket & recv_data )
if (!pGuild) if (!pGuild)
return; return;
if (!pGuild->IsGuildBankLoaded() || TabId >= pGuild->GetPurchasedTabs()) if (TabId >= pGuild->GetPurchasedTabs())
return; return;
pGuild->SetGuildBankTabInfo(TabId, Name, IconIndex); pGuild->SetGuildBankTabInfo(TabId, Name, IconIndex);
@@ -1208,9 +1208,6 @@ void WorldSession::HandleGuildBankLogQuery( WorldPacket & recv_data )
if (!pGuild) if (!pGuild)
return; return;
if (!pGuild->IsGuildBankLoaded())
return;
// GUILD_BANK_MAX_TABS send by client for money log // GUILD_BANK_MAX_TABS send by client for money log
if (TabId >= pGuild->GetPurchasedTabs() && TabId != GUILD_BANK_MAX_TABS) if (TabId >= pGuild->GetPurchasedTabs() && TabId != GUILD_BANK_MAX_TABS)
return; return;
@@ -1233,7 +1230,7 @@ void WorldSession::HandleQueryGuildBankTabText(WorldPacket &recv_data)
if (!pGuild) if (!pGuild)
return; return;
if (!pGuild->IsGuildBankLoaded() || TabId >= pGuild->GetPurchasedTabs()) if (TabId >= pGuild->GetPurchasedTabs())
return; return;
pGuild->SendGuildBankTabText(this, TabId); pGuild->SendGuildBankTabText(this, TabId);
@@ -1256,7 +1253,7 @@ void WorldSession::HandleSetGuildBankTabText(WorldPacket &recv_data)
if (!pGuild) if (!pGuild)
return; return;
if (!pGuild->IsGuildBankLoaded() || TabId >= pGuild->GetPurchasedTabs()) if (TabId >= pGuild->GetPurchasedTabs())
return; return;
pGuild->SetGuildBankTabText(TabId, Text); pGuild->SetGuildBankTabText(TabId, Text);
+4 -1
View File
@@ -3250,9 +3250,12 @@ void ObjectMgr::LoadGuilds()
delete newguild; delete newguild;
continue; continue;
} }
newguild->LoadGuildEventLogFromDB();
newguild->LoadGuildBankEventLogFromDB();
newguild->LoadGuildBankFromDB();
AddGuild(newguild); AddGuild(newguild);
}while (result->NextRow()); } while (result->NextRow());
//delete unused LogGuid records in guild_eventlog and guild_bank_eventlog table //delete unused LogGuid records in guild_eventlog and guild_bank_eventlog table
//you can comment these lines if you don't plan to change CONFIG_GUILD_EVENT_LOG_COUNT and CONFIG_GUILD_BANK_EVENT_LOG_COUNT //you can comment these lines if you don't plan to change CONFIG_GUILD_EVENT_LOG_COUNT and CONFIG_GUILD_BANK_EVENT_LOG_COUNT