mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Guilds: Guild bank tabs are now purchased only using money deposited in the bank (since 11.1.0)
This commit is contained in:
@@ -1644,6 +1644,9 @@ void Guild::HandleBuyBankTab(WorldSession* session, uint8 tabId)
|
||||
if (!member)
|
||||
return;
|
||||
|
||||
if (GetLeaderGUID() != player->GetGUID())
|
||||
return;
|
||||
|
||||
if (_GetPurchasedTabsSize() >= GUILD_BANK_MAX_TABS)
|
||||
return;
|
||||
|
||||
@@ -1653,18 +1656,19 @@ void Guild::HandleBuyBankTab(WorldSession* session, uint8 tabId)
|
||||
if (tabId >= GUILD_BANK_MAX_TABS)
|
||||
return;
|
||||
|
||||
// Do not get money for bank tabs that the GM bought, we had to buy them already.
|
||||
// This is just a speedup check, GetGuildBankTabPrice will return 0.
|
||||
if (tabId < GUILD_BANK_MAX_TABS - 2) // 7th tab is actually the 6th
|
||||
{
|
||||
int64 tabCost = GetGuildBankTabPrice(tabId) * GOLD;
|
||||
if (!player->HasEnoughMoney(tabCost)) // Should not happen, this is checked by client
|
||||
return;
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
player->ModifyMoney(-tabCost);
|
||||
}
|
||||
// Remove money from bank
|
||||
uint64 tabCost = GetGuildBankTabPrice(tabId) * GOLD;
|
||||
if (tabCost && !_ModifyBankMoney(trans, tabCost, false)) // Should not happen, this is checked by client
|
||||
return;
|
||||
|
||||
_CreateNewBankTab();
|
||||
// Log guild bank event
|
||||
_LogBankEvent(trans, GUILD_BANK_LOG_BUY_TAB, tabId, player->GetGUID().GetCounter(), tabCost);
|
||||
|
||||
_CreateNewBankTab(trans);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
WorldPackets::Guild::GuildEventTabAdded packet;
|
||||
BroadcastPacket(packet.Write());
|
||||
@@ -3145,13 +3149,11 @@ void Guild::_DeleteMemberFromDB(CharacterDatabaseTransaction trans, ObjectGuid::
|
||||
}
|
||||
|
||||
// Private methods
|
||||
void Guild::_CreateNewBankTab()
|
||||
void Guild::_CreateNewBankTab(CharacterDatabaseTransaction trans)
|
||||
{
|
||||
uint8 tabId = _GetPurchasedTabsSize(); // Next free id
|
||||
m_bankTabs.emplace_back(m_id, tabId);
|
||||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_TAB);
|
||||
stmt->setUInt64(0, m_id);
|
||||
stmt->setUInt8 (1, tabId);
|
||||
@@ -3163,10 +3165,8 @@ void Guild::_CreateNewBankTab()
|
||||
trans->Append(stmt);
|
||||
|
||||
++tabId;
|
||||
for (auto itr = m_ranks.begin(); itr != m_ranks.end(); ++itr)
|
||||
(*itr).CreateMissingTabsIfNeeded(tabId, trans, false);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
for (RankInfo& rank : m_ranks)
|
||||
rank.CreateMissingTabsIfNeeded(tabId, trans, false);
|
||||
}
|
||||
|
||||
void Guild::_CreateDefaultGuildRanks(CharacterDatabaseTransaction trans, LocaleConstant loc)
|
||||
|
||||
Reference in New Issue
Block a user