Skip to content

Commit 207dcaf

Browse files
committed
Bank: Fix guild bank access in wotlk.
1 parent 5aed541 commit 207dcaf

4 files changed

Lines changed: 70 additions & 1 deletion

File tree

playerbot/strategy/actions/GuildBankAction.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "playerbot/strategy/values/ItemUsageValue.h"
77
#include "Guilds/Guild.h"
88
#include "Guilds/GuildMgr.h"
9+
#include "playerbot/strategy/values/GuildValues.h"
910

1011
using namespace ai;
1112

@@ -166,7 +167,12 @@ bool GuildBankAction::AutoWithdraw(GameObject* bank)
166167

167168
for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
168169
{
170+
#ifdef MANGOSBOT_TWO
171+
GuildAccess* guildAccess = reinterpret_cast<GuildAccess*>(guild);
172+
Item* item = guildAccess->GetItem(tabId, slotId);
173+
#else
169174
Item* item = guild->GetItem(tabId, slotId);
175+
#endif
170176
if (!item)
171177
continue;
172178

playerbot/strategy/values/BankValues.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "ItemCountValue.h"
55
#include "Guilds/Guild.h"
66
#include "Guilds/GuildMgr.h"
7+
#include "playerbot/strategy/values/GuildValues.h"
78

89
using namespace ai;
910

@@ -196,7 +197,12 @@ bool ShouldGuildBankWithdrawValue::Calculate()
196197

197198
for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
198199
{
200+
#ifdef MANGOSBOT_TWO
201+
GuildAccess* guildAccess = reinterpret_cast<GuildAccess*>(guild);
202+
Item* item = guildAccess->GetItem(tabId, slotId);
203+
#else
199204
Item* item = guild->GetItem(tabId, slotId);
205+
#endif
200206
if (!item)
201207
continue;
202208

playerbot/strategy/values/GuildValues.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010

1111
using namespace ai;
1212

13+
#ifdef MANGOSBOT_TWO
14+
Item* GuildAccess::GetItem(uint8 TabId, uint8 SlotId)
15+
{
16+
if (TabId >= GetPurchasedTabs() || SlotId >= GUILD_BANK_MAX_SLOTS)
17+
return nullptr;
18+
return m_TabList[TabId].Slots[SlotId];
19+
}
20+
#endif
21+
1322
std::string GuildOrderValue::TrimWhitespace(const std::string& str)
1423
{
1524
std::string result = str;

playerbot/strategy/values/GuildValues.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,56 @@
11
#pragma once
22
#include "playerbot/strategy/Value.h"
3+
#include "Guilds/Guild.h"
34

45
namespace ai
56
{
7+
#ifdef MANGOSBOT_TWO
8+
// Accessor class to reach private Guild methods (mirrors LootAccess pattern)
9+
class GuildAccess
10+
{
11+
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;
51+
};
52+
#endif
53+
654
enum class GuildOrderType : uint8
755
{
856
None = 0,
@@ -126,7 +174,7 @@ namespace ai
126174
}
127175

128176
QuestStatus status = bot->GetQuestStatus(order.questId);
129-
// Quest already in log (incomplete or complete) no need to accept.
177+
// Quest already in log (incomplete or complete) no need to accept.
130178
if (status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_COMPLETE)
131179
return false;
132180

0 commit comments

Comments
 (0)