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)
This commit is contained in:
@@ -171,8 +171,8 @@ namespace Framework.Constants
|
|||||||
WithdrawMoney = 5,
|
WithdrawMoney = 5,
|
||||||
RepairMoney = 6,
|
RepairMoney = 6,
|
||||||
MoveItem2 = 7,
|
MoveItem2 = 7,
|
||||||
Unk1 = 8,
|
WithdrawToBuyTab = 8,
|
||||||
BuySlot = 9,
|
BuyTab = 9,
|
||||||
CashFlowDeposit = 10
|
CashFlowDeposit = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -505,6 +505,9 @@ namespace Game.Guilds
|
|||||||
if (member == null)
|
if (member == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (GetLeaderGUID() != player.GetGUID())
|
||||||
|
return;
|
||||||
|
|
||||||
if (_GetPurchasedTabsSize() >= GuildConst.MaxBankTabs)
|
if (_GetPurchasedTabsSize() >= GuildConst.MaxBankTabs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -514,18 +517,19 @@ namespace Game.Guilds
|
|||||||
if (tabId >= GuildConst.MaxBankTabs)
|
if (tabId >= GuildConst.MaxBankTabs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Do not get money for bank tabs that the GM bought, we had to buy them already.
|
SQLTransaction trans = new SQLTransaction();
|
||||||
// This is just a speedup check, GetGuildBankTabPrice will return 0.
|
|
||||||
if (tabId < GuildConst.MaxBankTabs - 2) // 7th tab is actually the 6th
|
// Remove money from bank
|
||||||
{
|
ulong tabCost = GetGuildBankTabPrice(tabId) * MoneyConstants.Gold;
|
||||||
long tabCost = (long)(GetGuildBankTabPrice(tabId) * MoneyConstants.Gold);
|
if (tabCost != 0 && !_ModifyBankMoney(trans, tabCost, false)) // Should not happen, this is checked by client
|
||||||
if (!player.HasEnoughMoney(tabCost)) // Should not happen, this is checked by client
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player.ModifyMoney(-tabCost);
|
// Log guild bank event
|
||||||
}
|
_LogBankEvent(trans, GuildBankEventLogTypes.BuyTab, tabId, player.GetGUID().GetCounter(), (uint)tabCost);
|
||||||
|
|
||||||
_CreateNewBankTab();
|
_CreateNewBankTab(trans);
|
||||||
|
|
||||||
|
DB.Characters.CommitTransaction(trans);
|
||||||
|
|
||||||
BroadcastPacket(new GuildEventTabAdded());
|
BroadcastPacket(new GuildEventTabAdded());
|
||||||
|
|
||||||
@@ -1813,13 +1817,11 @@ namespace Game.Guilds
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
void _CreateNewBankTab()
|
void _CreateNewBankTab(SQLTransaction trans)
|
||||||
{
|
{
|
||||||
byte tabId = _GetPurchasedTabsSize(); // Next free id
|
byte tabId = _GetPurchasedTabsSize(); // Next free id
|
||||||
m_bankTabs.Add(new BankTab(m_id, tabId));
|
m_bankTabs.Add(new BankTab(m_id, tabId));
|
||||||
|
|
||||||
SQLTransaction trans = new();
|
|
||||||
|
|
||||||
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_GUILD_BANK_TAB);
|
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.DEL_GUILD_BANK_TAB);
|
||||||
stmt.AddValue(0, m_id);
|
stmt.AddValue(0, m_id);
|
||||||
stmt.AddValue(1, tabId);
|
stmt.AddValue(1, tabId);
|
||||||
@@ -1833,8 +1835,6 @@ namespace Game.Guilds
|
|||||||
++tabId;
|
++tabId;
|
||||||
foreach (var rank in m_ranks)
|
foreach (var rank in m_ranks)
|
||||||
rank.CreateMissingTabsIfNeeded(tabId, trans, false);
|
rank.CreateMissingTabsIfNeeded(tabId, trans, false);
|
||||||
|
|
||||||
DB.Characters.CommitTransaction(trans);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _CreateDefaultGuildRanks(SQLTransaction trans, Locale loc = Locale.enUS)
|
void _CreateDefaultGuildRanks(SQLTransaction trans, Locale loc = Locale.enUS)
|
||||||
|
|||||||
Reference in New Issue
Block a user