From 3c4f83049809ee40d539e170dab2538e97c832c6 Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Sun, 10 Aug 2025 12:48:41 -0400 Subject: [PATCH] Core/Guilds: Guild bank tabs are now purchased only using money deposited in the bank (since 11.1.0) Port From (https://github.com/TrinityCore/TrinityCore/commit/8f07dce5c128951d80ad86838013e5bba276f3c3) --- Source/Framework/Constants/GuildConst.cs | 4 ++-- Source/Game/Guilds/Guild.cs | 30 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/Framework/Constants/GuildConst.cs b/Source/Framework/Constants/GuildConst.cs index 6bcd94e28..c30b07bda 100644 --- a/Source/Framework/Constants/GuildConst.cs +++ b/Source/Framework/Constants/GuildConst.cs @@ -171,8 +171,8 @@ namespace Framework.Constants WithdrawMoney = 5, RepairMoney = 6, MoveItem2 = 7, - Unk1 = 8, - BuySlot = 9, + WithdrawToBuyTab = 8, + BuyTab = 9, CashFlowDeposit = 10 } diff --git a/Source/Game/Guilds/Guild.cs b/Source/Game/Guilds/Guild.cs index 792fb379b..ff72eb452 100644 --- a/Source/Game/Guilds/Guild.cs +++ b/Source/Game/Guilds/Guild.cs @@ -505,6 +505,9 @@ namespace Game.Guilds if (member == null) return; + if (GetLeaderGUID() != player.GetGUID()) + return; + if (_GetPurchasedTabsSize() >= GuildConst.MaxBankTabs) return; @@ -514,18 +517,19 @@ namespace Game.Guilds if (tabId >= GuildConst.MaxBankTabs) 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 < GuildConst.MaxBankTabs - 2) // 7th tab is actually the 6th - { - long tabCost = (long)(GetGuildBankTabPrice(tabId) * MoneyConstants.Gold); - if (!player.HasEnoughMoney(tabCost)) // Should not happen, this is checked by client - return; + SQLTransaction trans = new SQLTransaction(); - player.ModifyMoney(-tabCost); - } + // Remove money from bank + ulong tabCost = GetGuildBankTabPrice(tabId) * MoneyConstants.Gold; + if (tabCost != 0 && !_ModifyBankMoney(trans, tabCost, false)) // Should not happen, this is checked by client + return; - _CreateNewBankTab(); + // Log guild bank event + _LogBankEvent(trans, GuildBankEventLogTypes.BuyTab, tabId, player.GetGUID().GetCounter(), (uint)tabCost); + + _CreateNewBankTab(trans); + + DB.Characters.CommitTransaction(trans); BroadcastPacket(new GuildEventTabAdded()); @@ -1813,13 +1817,11 @@ namespace Game.Guilds } // Private methods - void _CreateNewBankTab() + void _CreateNewBankTab(SQLTransaction trans) { byte tabId = _GetPurchasedTabsSize(); // Next free id m_bankTabs.Add(new BankTab(m_id, tabId)); - SQLTransaction trans = new(); - PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_GUILD_BANK_TAB); stmt.AddValue(0, m_id); stmt.AddValue(1, tabId); @@ -1833,8 +1835,6 @@ namespace Game.Guilds ++tabId; foreach (var rank in m_ranks) rank.CreateMissingTabsIfNeeded(tabId, trans, false); - - DB.Characters.CommitTransaction(trans); } void _CreateDefaultGuildRanks(SQLTransaction trans, Locale loc = Locale.enUS)