73 lines
3.8 KiB
C++
73 lines
3.8 KiB
C++
#pragma once
|
|
#include "gateway/protocol.hpp"
|
|
#include <map>
|
|
#include <optional>
|
|
namespace gateway {
|
|
// Source GuildBank.cpp: five tabs,98 one-based slots. bank_id is a bank-local
|
|
// database identity, never a player item GUID, template ID or modern slot.
|
|
struct GuildBankItem {
|
|
uint32_t tab=0,slot=0,bank_id=0,item=0,count=0,enchant=0;
|
|
int32_t random_property=0;
|
|
std::string random_name;
|
|
bool operator==(const GuildBankItem&) const = default;
|
|
};
|
|
struct GuildBankTab {
|
|
std::string name,icon;
|
|
uint32_t weekly_limit=0,min_rank=0;
|
|
std::optional<int32_t> withdrawals_left;
|
|
std::map<uint32_t,GuildBankItem> items;
|
|
bool loaded=false;
|
|
};
|
|
// #91 bank log: one Turtle TabLog/MoneyLog row (GuildBank::SendTabLog / SendMoneyLog), actions 0..9 as Turtle.
|
|
struct GuildBankLogRow {
|
|
uint32_t stamp=0,action=0,item=0,count=0;
|
|
uint64_t money=0;
|
|
std::string player;
|
|
bool operator==(const GuildBankLogRow&) const = default;
|
|
};
|
|
inline constexpr uint32_t GuildBankMoneyLog=6; // log key of MoneyLog; item tabs are 1..5
|
|
struct GuildBankChange {
|
|
bool metadata=false,money=false,resync_info=false;
|
|
std::optional<uint32_t> completed_tab,resync_tab,completed_log;
|
|
// #91 Turtle "<Request>:Error:<Reason>" reply as native GuildCommandResult {Result, Command} (TC Guild.h values).
|
|
std::optional<std::pair<uint8_t,uint8_t>> error;
|
|
};
|
|
struct GuildBankState {
|
|
uint32_t unlocked=0;
|
|
std::optional<uint64_t> money;
|
|
bool metadata_ready=false;
|
|
bool no_bank=false; // #91 BankInfo:NoGuildBank: guild has not bought its bank (native window with zero tabs)
|
|
std::array<GuildBankTab,5> tabs;
|
|
std::map<uint32_t,std::vector<GuildBankLogRow>> logs; // completed, by log key
|
|
void begin_log(uint32_t key){if(!key || key>GuildBankMoneyLog)throw Error("bank log key bound");log_pending[key].clear();}
|
|
bool log_requested(uint32_t key) const {return log_pending.contains(key);}
|
|
std::optional<uint32_t> tab_query(std::string_view) const;
|
|
bool tab_pending(uint32_t tab) const {return pending.contains(tab);}
|
|
void begin_tab(uint32_t);
|
|
void abandon_tab(uint32_t);
|
|
GuildBankChange consume(std::string_view,bool direct_reply);
|
|
private:
|
|
struct Snapshot {std::map<uint32_t,GuildBankItem> items;bool conflicted=false;};
|
|
std::map<uint32_t,Snapshot> pending;
|
|
std::map<uint32_t,std::vector<GuildBankLogRow>> log_pending;
|
|
};
|
|
// Native GuildBankLogQueryResults (70334 SMSG 0x530026): Tab, entries {PlayerGUID, TimeOffset, EntryType, optional
|
|
// Money/ItemID/Count/OtherTab}, no weekly bonus. Rows whose Turtle action has no native log type are left out.
|
|
// `players` maps a Turtle player name to its native GUID; an unknown name keeps an empty GUID.
|
|
Bytes forever_guild_bank_log(int32_t native_tab,uint32_t key,const std::vector<GuildBankLogRow>&,uint32_t now,
|
|
const std::map<std::string,Guid128>& players);
|
|
// Original70334 GuildBankQueryResults/GuildPermissionsQueryResults layouts.
|
|
// Random properties require an explicit converted bonus-list mapping; never
|
|
// silently present an affixed item as its unmodified base template.
|
|
// #90: Turtle numbers the 98 slots row by row (14 columns x 7 rows, Turtle_GuildBankUI CreateFrames); the native
|
|
// window numbers them down 2-wide column groups of 7 rows (Blizzard_GuildBankUI Button1..7 then Button8..14).
|
|
uint32_t native_guild_bank_slot(uint32_t turtle_slot); // Turtle 1..98 -> native 0..97
|
|
uint32_t turtle_guild_bank_slot(uint32_t native_slot); // native 0..97 -> Turtle 1..98
|
|
Bytes forever_guild_bank_tab(const GuildBankState&,uint32_t source_tab,
|
|
const std::map<int32_t,uint32_t>& random_bonus={});
|
|
std::vector<uint32_t> turtle_guild_rank_rights(std::span<const uint8_t>);
|
|
uint32_t forever_guild_rank_flags(uint32_t source_rank,uint32_t source_rights);
|
|
Bytes forever_guild_bank_permissions(const GuildBankState&,uint32_t source_rank,uint32_t source_rights);
|
|
bool turtle_guild_bank_npc(uint32_t entry);
|
|
}
|