mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)
This commit is contained in:
@@ -274,7 +274,7 @@ public: // pussywizard: public class Member
|
||||
class Member
|
||||
{
|
||||
public:
|
||||
Member(uint32 guildId, uint64 guid, uint8 rankId):
|
||||
Member(uint32 guildId, ObjectGuid guid, uint8 rankId):
|
||||
m_guildId(guildId),
|
||||
m_guid(guid),
|
||||
m_zoneId(0),
|
||||
@@ -305,7 +305,7 @@ public: // pussywizard: public class Member
|
||||
void SaveToDB(SQLTransaction& trans) const;
|
||||
void WritePacket(WorldPacket& data, bool sendOfficerNote) const;
|
||||
|
||||
uint64 GetGUID() const { return m_guid; }
|
||||
ObjectGuid GetGUID() const { return m_guid; }
|
||||
std::string const& GetName() const { return m_name; }
|
||||
uint32 GetAccountId() const { return m_accountId; }
|
||||
uint8 GetRankId() const { return m_rankId; }
|
||||
@@ -324,18 +324,18 @@ public: // pussywizard: public class Member
|
||||
inline void UpdateLogoutTime() { m_logoutTime = ::time(nullptr); }
|
||||
inline bool IsRank(uint8 rankId) const { return m_rankId == rankId; }
|
||||
inline bool IsRankNotLower(uint8 rankId) const { return m_rankId <= rankId; }
|
||||
inline bool IsSamePlayer(uint64 guid) const { return m_guid == guid; }
|
||||
inline bool IsSamePlayer(ObjectGuid guid) const { return m_guid == guid; }
|
||||
|
||||
void UpdateBankWithdrawValue(SQLTransaction& trans, uint8 tabId, uint32 amount);
|
||||
int32 GetBankWithdrawValue(uint8 tabId) const;
|
||||
void ResetValues();
|
||||
|
||||
inline Player* FindPlayer() const { return ObjectAccessor::GetObjectInOrOutOfWorld(m_guid, (Player*)nullptr); }
|
||||
inline Player* FindPlayer() const { return ObjectAccessor::FindConnectedPlayer(m_guid); }
|
||||
|
||||
private:
|
||||
uint32 m_guildId;
|
||||
// Fields from characters table
|
||||
uint64 m_guid;
|
||||
ObjectGuid m_guid;
|
||||
std::string m_name;
|
||||
uint32 m_zoneId;
|
||||
uint8 m_level;
|
||||
@@ -353,14 +353,14 @@ public: // pussywizard: public class Member
|
||||
};
|
||||
|
||||
// pussywizard: public GetMember
|
||||
inline const Member* GetMember(uint64 guid) const
|
||||
inline const Member* GetMember(ObjectGuid guid) const
|
||||
{
|
||||
Members::const_iterator itr = m_members.find(GUID_LOPART(guid));
|
||||
Members::const_iterator itr = m_members.find(guid);
|
||||
return itr != m_members.end() ? itr->second : nullptr;
|
||||
}
|
||||
inline Member* GetMember(uint64 guid)
|
||||
inline Member* GetMember(ObjectGuid guid)
|
||||
{
|
||||
Members::iterator itr = m_members.find(GUID_LOPART(guid));
|
||||
Members::iterator itr = m_members.find(guid);
|
||||
return itr != m_members.end() ? itr->second : nullptr;
|
||||
}
|
||||
inline Member* GetMember(std::string const& name)
|
||||
@@ -377,11 +377,11 @@ private:
|
||||
class LogEntry
|
||||
{
|
||||
public:
|
||||
LogEntry(uint32 guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(nullptr)) { }
|
||||
LogEntry(uint32 guildId, uint32 guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { }
|
||||
LogEntry(uint32 guildId, ObjectGuid::LowType guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(nullptr)) { }
|
||||
LogEntry(uint32 guildId, ObjectGuid::LowType guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { }
|
||||
virtual ~LogEntry() { }
|
||||
|
||||
uint32 GetGUID() const { return m_guid; }
|
||||
ObjectGuid::LowType GetGUID() const { return m_guid; }
|
||||
uint64 GetTimestamp() const { return m_timestamp; }
|
||||
|
||||
virtual void SaveToDB(SQLTransaction& trans) const = 0;
|
||||
@@ -389,7 +389,7 @@ private:
|
||||
|
||||
protected:
|
||||
uint32 m_guildId;
|
||||
uint32 m_guid;
|
||||
ObjectGuid::LowType m_guid;
|
||||
uint64 m_timestamp;
|
||||
};
|
||||
|
||||
@@ -397,10 +397,10 @@ private:
|
||||
class EventLogEntry : public LogEntry
|
||||
{
|
||||
public:
|
||||
EventLogEntry(uint32 guildId, uint32 guid, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) :
|
||||
EventLogEntry(uint32 guildId, ObjectGuid::LowType guid, GuildEventLogTypes eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2, uint8 newRank) :
|
||||
LogEntry(guildId, guid), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { }
|
||||
|
||||
EventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank) :
|
||||
EventLogEntry(uint32 guildId, ObjectGuid::LowType guid, time_t timestamp, GuildEventLogTypes eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2, uint8 newRank) :
|
||||
LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_playerGuid1(playerGuid1), m_playerGuid2(playerGuid2), m_newRank(newRank) { }
|
||||
|
||||
~EventLogEntry() override { }
|
||||
@@ -410,8 +410,8 @@ private:
|
||||
|
||||
private:
|
||||
GuildEventLogTypes m_eventType;
|
||||
uint32 m_playerGuid1;
|
||||
uint32 m_playerGuid2;
|
||||
ObjectGuid m_playerGuid1;
|
||||
ObjectGuid m_playerGuid2;
|
||||
uint8 m_newRank;
|
||||
};
|
||||
|
||||
@@ -427,11 +427,11 @@ private:
|
||||
eventType == GUILD_BANK_LOG_REPAIR_MONEY;
|
||||
}
|
||||
|
||||
BankEventLogEntry(uint32 guildId, uint32 guid, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
|
||||
BankEventLogEntry(uint32 guildId, ObjectGuid::LowType guid, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
|
||||
LogEntry(guildId, guid), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
|
||||
m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { }
|
||||
|
||||
BankEventLogEntry(uint32 guildId, uint32 guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
|
||||
BankEventLogEntry(uint32 guildId, ObjectGuid::LowType guid, time_t timestamp, uint8 tabId, GuildBankEventLogTypes eventType, ObjectGuid playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) :
|
||||
LogEntry(guildId, guid, timestamp), m_eventType(eventType), m_bankTabId(tabId), m_playerGuid(playerGuid),
|
||||
m_itemOrMoney(itemOrMoney), m_itemStackCount(itemStackCount), m_destTabId(destTabId) { }
|
||||
|
||||
@@ -443,7 +443,7 @@ private:
|
||||
private:
|
||||
GuildBankEventLogTypes m_eventType;
|
||||
uint8 m_bankTabId;
|
||||
uint32 m_playerGuid;
|
||||
ObjectGuid m_playerGuid;
|
||||
uint32 m_itemOrMoney;
|
||||
uint16 m_itemStackCount;
|
||||
uint8 m_destTabId;
|
||||
@@ -650,7 +650,7 @@ private:
|
||||
void CanStoreItemInTab(Item* pItem, uint8 skipSlotId, bool merge, uint32& count);
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32, Member*> Members;
|
||||
typedef std::unordered_map<ObjectGuid, Member*> Members;
|
||||
typedef std::vector<RankInfo> Ranks;
|
||||
typedef std::vector<BankTab*> BankTabs;
|
||||
|
||||
@@ -666,7 +666,7 @@ public:
|
||||
|
||||
// Getters
|
||||
uint32 GetId() const { return m_id; }
|
||||
uint64 GetLeaderGUID() const { return m_leaderGuid; }
|
||||
ObjectGuid GetLeaderGUID() const { return m_leaderGuid; }
|
||||
std::string const& GetName() const { return m_name; }
|
||||
std::string const& GetMOTD() const { return m_motd; }
|
||||
std::string const& GetInfo() const { return m_info; }
|
||||
@@ -738,9 +738,9 @@ public:
|
||||
|
||||
// Members
|
||||
// Adds member to guild. If rankId == GUILD_RANK_NONE, lowest rank is assigned.
|
||||
bool AddMember(uint64 guid, uint8 rankId = GUILD_RANK_NONE);
|
||||
void DeleteMember(uint64 guid, bool isDisbanding = false, bool isKicked = false, bool canDeleteGuild = false);
|
||||
bool ChangeMemberRank(uint64 guid, uint8 newRank);
|
||||
bool AddMember(ObjectGuid guid, uint8 rankId = GUILD_RANK_NONE);
|
||||
void DeleteMember(ObjectGuid guid, bool isDisbanding = false, bool isKicked = false, bool canDeleteGuild = false);
|
||||
bool ChangeMemberRank(ObjectGuid guid, uint8 newRank);
|
||||
|
||||
// Bank
|
||||
void SwapItems(Player* player, uint8 tabId, uint8 slotId, uint8 destTabId, uint8 destSlotId, uint32 splitedAmount);
|
||||
@@ -762,7 +762,7 @@ public:
|
||||
protected:
|
||||
uint32 m_id;
|
||||
std::string m_name;
|
||||
uint64 m_leaderGuid;
|
||||
ObjectGuid m_leaderGuid;
|
||||
std::string m_motd;
|
||||
std::string m_info;
|
||||
time_t m_createdDate;
|
||||
@@ -797,7 +797,7 @@ private:
|
||||
inline BankTab* GetBankTab(uint8 tabId) { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : nullptr; }
|
||||
inline const BankTab* GetBankTab(uint8 tabId) const { return tabId < m_bankTabs.size() ? m_bankTabs[tabId] : nullptr; }
|
||||
|
||||
inline void _DeleteMemberFromDB(uint32 lowguid) const
|
||||
inline void _DeleteMemberFromDB(ObjectGuid::LowType lowguid) const
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBER);
|
||||
stmt->setUInt32(0, lowguid);
|
||||
@@ -829,11 +829,11 @@ private:
|
||||
|
||||
int32 _GetMemberRemainingSlots(Member const* member, uint8 tabId) const;
|
||||
int32 _GetMemberRemainingMoney(Member const* member) const;
|
||||
void _UpdateMemberWithdrawSlots(SQLTransaction& trans, uint64 guid, uint8 tabId);
|
||||
bool _MemberHasTabRights(uint64 guid, uint8 tabId, uint32 rights) const;
|
||||
void _UpdateMemberWithdrawSlots(SQLTransaction& trans, ObjectGuid guid, uint8 tabId);
|
||||
bool _MemberHasTabRights(ObjectGuid guid, uint8 tabId, uint32 rights) const;
|
||||
|
||||
void _LogEvent(GuildEventLogTypes eventType, uint32 playerGuid1, uint32 playerGuid2 = 0, uint8 newRank = 0);
|
||||
void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0);
|
||||
void _LogEvent(GuildEventLogTypes eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2 = ObjectGuid::Empty, uint8 newRank = 0);
|
||||
void _LogBankEvent(SQLTransaction& trans, GuildBankEventLogTypes eventType, uint8 tabId, ObjectGuid playerGuid, uint32 itemOrMoney, uint16 itemStackCount = 0, uint8 destTabId = 0);
|
||||
|
||||
Item* _GetItem(uint8 tabId, uint8 slotId) const;
|
||||
void _RemoveItem(SQLTransaction& trans, uint8 tabId, uint8 slotId);
|
||||
@@ -846,6 +846,6 @@ private:
|
||||
void _SendBankContentUpdate(uint8 tabId, SlotIds slots) const;
|
||||
void _SendBankList(WorldSession* session = nullptr, uint8 tabId = 0, bool sendFullSlots = false, SlotIds* slots = nullptr) const;
|
||||
|
||||
void _BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* param1 = nullptr, const char* param2 = nullptr, const char* param3 = nullptr) const;
|
||||
void _BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid = ObjectGuid::Empty, const char* param1 = nullptr, const char* param2 = nullptr, const char* param3 = nullptr) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user