Skip to content

Commit f6d0b38

Browse files
mostlikely4rinsunaa
andcommitted
Bank: Fix guild bank item access to be less hacky
Co-Authored-By: insuna <insuna@no.capfr.fr>
1 parent b56cea1 commit f6d0b38

3 files changed

Lines changed: 8 additions & 50 deletions

File tree

playerbot/strategy/actions/GuildBankAction.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,9 @@ bool GuildBankAction::AutoWithdraw(GameObject* bank)
167167

168168
for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
169169
{
170-
#ifdef MANGOSBOT_TWO
171-
GuildAccess* guildAccess = reinterpret_cast<GuildAccess*>(guild);
172-
Item* item = guildAccess->GetItem(tabId, slotId);
173-
#else
174-
Item* item = guild->GetItem(tabId, slotId);
175-
#endif
170+
GuildAccess* guildAccess = static_cast<GuildAccess*>(guild);
171+
Item* item = guildAccess->GetGuildItem(tabId, slotId);
172+
176173
if (!item)
177174
continue;
178175

playerbot/strategy/values/GuildValues.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
using namespace ai;
1212

13-
#ifdef MANGOSBOT_TWO
14-
Item* GuildAccess::GetItem(uint8 TabId, uint8 SlotId)
13+
#ifndef MANGOSBOT_ZERO
14+
Item* GuildAccess::GetGuildItem(uint8 TabId, uint8 SlotId)
1515
{
1616
if (TabId >= GetPurchasedTabs() || SlotId >= GUILD_BANK_MAX_SLOTS)
1717
return nullptr;

playerbot/strategy/values/GuildValues.h

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,11 @@
44

55
namespace ai
66
{
7-
#ifdef MANGOSBOT_TWO
8-
// Accessor class to reach private Guild methods (mirrors LootAccess pattern)
9-
class GuildAccess
7+
#ifndef MANGOSBOT_ZERO
8+
class GuildAccess : public Guild
109
{
1110
public:
12-
uint8 GetPurchasedTabs() const { return m_TabList.size(); }
13-
Item* GetItem(uint8 TabId, uint8 SlotId);
14-
private:
15-
typedef std::unordered_map<uint32, MemberSlot> MemberList;
16-
typedef std::vector<RankInfo> RankList;
17-
uint32 m_Id;
18-
std::string m_Name;
19-
ObjectGuid m_LeaderGuid;
20-
std::string MOTD;
21-
std::string GINFO;
22-
time_t m_CreatedDate;
23-
24-
uint32 m_EmblemStyle;
25-
uint32 m_EmblemColor;
26-
uint32 m_BorderStyle;
27-
uint32 m_BorderColor;
28-
uint32 m_BackgroundColor;
29-
uint32 m_accountsNumber; // 0 used as marker for need lazy calculation at request
30-
31-
RankList m_Ranks;
32-
33-
MemberList members;
34-
35-
std::vector<GuildBankTab> m_TabList;
36-
37-
/** These are actually ordered lists. The first element is the oldest entry.*/
38-
typedef std::list<GuildEventLogEntry> GuildEventLog;
39-
typedef std::list<GuildBankEventLogEntry> GuildBankEventLog;
40-
GuildEventLog m_GuildEventLog;
41-
GuildBankEventLog m_GuildBankEventLog_Money;
42-
GuildBankEventLog m_GuildBankEventLog_Item[GUILD_BANK_MAX_TABS];
43-
44-
uint32 m_GuildEventLogNextGuid;
45-
uint32 m_GuildBankEventLogNextGuid_Money;
46-
uint32 m_GuildBankEventLogNextGuid_Item[GUILD_BANK_MAX_TABS];
47-
48-
uint64 m_GuildBankMoney;
49-
50-
MaNGOS::unique_weak_ptr<Guild> m_weakRef;
11+
Item* GetGuildItem(uint8 TabId, uint8 SlotId);
5112
};
5213
#endif
5314

0 commit comments

Comments
 (0)