feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)

This commit is contained in:
UltraNix
2021-04-25 22:18:03 +02:00
committed by GitHub
parent 91081f4ad8
commit f4c226423d
568 changed files with 10655 additions and 11019 deletions
+77 -78
View File
@@ -137,13 +137,13 @@ namespace lfg
struct RBInternalInfo
{
uint64 guid;
ObjectGuid guid;
std::string comment;
bool isGroupLeader;
uint64 groupGuid;
ObjectGuid groupGuid;
uint8 roles;
uint32 encounterMask;
uint64 instanceGuid;
ObjectGuid instanceGuid;
// additional character info parameters:
uint8 _online;
@@ -179,7 +179,7 @@ namespace lfg
uint32 _expertiseRating;
RBInternalInfo() {}
RBInternalInfo(uint64 guid, std::string const& comment, bool isGroupLeader, uint64 groupGuid, uint8 roles, uint32 encounterMask, uint64 instanceGuid,
RBInternalInfo(ObjectGuid guid, std::string const& comment, bool isGroupLeader, ObjectGuid groupGuid, uint8 roles, uint32 encounterMask, ObjectGuid instanceGuid,
uint8 _online, uint8 _level, uint8 _class, uint8 _race, float _avgItemLevel,
uint8 (&_talents)[3], uint32 _area, uint32 _armor, uint32 _spellDamage, uint32 _spellHeal,
uint32 _critRatingMelee, uint32 _critRatingRanged, uint32 _critRatingSpell, float _mp5, float _mp5combat,
@@ -242,13 +242,13 @@ namespace lfg
typedef std::multimap<uint32, LfgReward const*> LfgRewardContainer;
typedef std::pair<LfgRewardContainer::const_iterator, LfgRewardContainer::const_iterator> LfgRewardContainerBounds;
typedef std::map<uint8, LfgDungeonSet> LfgCachedDungeonContainer;
typedef std::map<uint64, LfgAnswer> LfgAnswerContainer;
typedef std::map<uint64, LfgRoleCheck> LfgRoleCheckContainer;
typedef std::map<ObjectGuid, LfgAnswer> LfgAnswerContainer;
typedef std::map<ObjectGuid, LfgRoleCheck> LfgRoleCheckContainer;
typedef std::map<uint32, LfgProposal> LfgProposalContainer;
typedef std::map<uint64, LfgProposalPlayer> LfgProposalPlayerContainer;
typedef std::map<uint64, LfgPlayerBoot> LfgPlayerBootContainer;
typedef std::map<uint64, LfgGroupData> LfgGroupDataContainer;
typedef std::map<uint64, LfgPlayerData> LfgPlayerDataContainer;
typedef std::map<ObjectGuid, LfgProposalPlayer> LfgProposalPlayerContainer;
typedef std::map<ObjectGuid, LfgPlayerBoot> LfgPlayerBootContainer;
typedef std::map<ObjectGuid, LfgGroupData> LfgGroupDataContainer;
typedef std::map<ObjectGuid, LfgPlayerData> LfgPlayerDataContainer;
typedef std::unordered_map<uint32, LFGDungeonData> LFGDungeonContainer;
// Data needed by SMSG_LFG_JOIN_RESULT
@@ -320,24 +320,23 @@ namespace lfg
/// Stores player data related to proposal to join
struct LfgProposalPlayer
{
LfgProposalPlayer(): role(0), accept(LFG_ANSWER_PENDING), group(0) { }
LfgProposalPlayer(): role(0), accept(LFG_ANSWER_PENDING) { }
uint8 role; ///< Proposed role
LfgAnswer accept; ///< Accept status (-1 not answer | 0 Not agree | 1 agree)
uint64 group; ///< Original group guid. 0 if no original group
ObjectGuid group; ///< Original group guid. 0 if no original group
};
/// Stores group data related to proposal to join
struct LfgProposal
{
LfgProposal(uint32 dungeon = 0): id(0), dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING),
group(0), leader(0), cancelTime(0), encounters(0), isNew(true)
LfgProposal(uint32 dungeon = 0): id(0), dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING), cancelTime(0), encounters(0), isNew(true)
{ }
uint32 id; ///< Proposal Id
uint32 dungeonId; ///< Dungeon to join
LfgProposalState state; ///< State of the proposal
uint64 group; ///< Proposal group (0 if new)
uint64 leader; ///< Leader guid.
ObjectGuid group; ///< Proposal group (0 if new)
ObjectGuid leader; ///< Leader guid.
time_t cancelTime; ///< Time when we will cancel this proposal
uint32 encounters; ///< Dungeon Encounters
bool isNew; ///< Determines if it's new group or not
@@ -354,7 +353,7 @@ namespace lfg
LfgRoleCheckState state; ///< State of the rolecheck
LfgDungeonSet dungeons; ///< Dungeons group is applying for (expanded random dungeons)
uint32 rDungeonId; ///< Random Dungeon Id.
uint64 leader; ///< Leader of the group
ObjectGuid leader; ///< Leader of the group
};
/// Stores information of a current vote to kick someone from a group
@@ -363,7 +362,7 @@ namespace lfg
time_t cancelTime; ///< Time left to vote
bool inProgress; ///< Vote in progress
LfgAnswerContainer votes; ///< Player votes (-1 not answer | 0 Not agree | 1 agree)
uint64 victim; ///< Player guid to be kicked (can't vote)
ObjectGuid victim; ///< Player guid to be kicked (can't vote)
std::string reason; ///< kick reason
};
@@ -401,14 +400,14 @@ namespace lfg
~LFGMgr();
// pussywizard: RAIDBROWSER
typedef std::unordered_map<uint32 /*playerGuidLow*/, RBEntryInfo> RBEntryInfoMap;
typedef std::unordered_map<ObjectGuid /*playerGuid*/, RBEntryInfo> RBEntryInfoMap;
typedef std::unordered_map<uint32 /*dungeonId*/, RBEntryInfoMap> RBStoreMap;
RBStoreMap RaidBrowserStore[2]; // for 2 factions
typedef std::unordered_map<uint32 /*playerGuidLow*/, uint32 /*dungeonId*/> RBSearchersMap;
typedef std::unordered_map<ObjectGuid /*playerGuid*/, uint32 /*dungeonId*/> RBSearchersMap;
RBSearchersMap RBSearchersStore[2]; // for 2 factions
typedef std::unordered_map<uint32 /*dungeonId*/, WorldPacket> RBCacheMap;
RBCacheMap RBCacheStore[2]; // for 2 factions
typedef std::unordered_map<uint32 /*guidLow*/, RBInternalInfo> RBInternalInfoMap;
typedef std::unordered_map<ObjectGuid /*guid*/, RBInternalInfo> RBInternalInfoMap;
typedef std::unordered_map<uint32 /*dungeonId*/, RBInternalInfoMap> RBInternalInfoMapMap;
RBInternalInfoMapMap RBInternalInfoStorePrev[2]; // for 2 factions
RBInternalInfoMapMap RBInternalInfoStoreCurr[2]; // for 2 factions
@@ -423,7 +422,7 @@ namespace lfg
// World.cpp
/// Finish the dungeon for the given group. All check are performed using internal lfg data
void FinishDungeon(uint64 gguid, uint32 dungeonId, const Map* currMap);
void FinishDungeon(ObjectGuid gguid, uint32 dungeonId, const Map* currMap);
/// Loads rewards for random dungeons
void LoadRewards();
/// Loads dungeons from dbc and adds teleport coords
@@ -431,31 +430,31 @@ namespace lfg
// Multiple files
/// Check if given guid applied for random dungeon
bool selectedRandomLfgDungeon(uint64 guid);
bool selectedRandomLfgDungeon(ObjectGuid guid);
/// Check if given guid applied for given map and difficulty. Used to know
bool inLfgDungeonMap(uint64 guid, uint32 map, Difficulty difficulty);
bool inLfgDungeonMap(ObjectGuid guid, uint32 map, Difficulty difficulty);
/// Get selected dungeons
LfgDungeonSet const& GetSelectedDungeons(uint64 guid);
LfgDungeonSet const& GetSelectedDungeons(ObjectGuid guid);
/// Get current lfg state
LfgState GetState(uint64 guid);
LfgState GetState(ObjectGuid guid);
/// Get current dungeon
uint32 GetDungeon(uint64 guid, bool asId = true);
uint32 GetDungeon(ObjectGuid guid, bool asId = true);
/// Get the map id of the current dungeon
uint32 GetDungeonMapId(uint64 guid);
uint32 GetDungeonMapId(ObjectGuid guid);
/// Get kicks left in current group
uint8 GetKicksLeft(uint64 gguid);
uint8 GetKicksLeft(ObjectGuid gguid);
/// Load Lfg group info from DB
void _LoadFromDB(Field* fields, uint64 guid);
void _LoadFromDB(Field* fields, ObjectGuid guid);
/// Initializes player data after loading group data from DB
void SetupGroupMember(uint64 guid, uint64 gguid);
void SetupGroupMember(ObjectGuid guid, ObjectGuid gguid);
/// Return Lfg dungeon entry for given dungeon id
uint32 GetLFGDungeonEntry(uint32 id);
// cs_lfg
/// Get current player roles
uint8 GetRoles(uint64 guid);
uint8 GetRoles(ObjectGuid guid);
/// Get current player comment (used for LFR)
std::string const& GetComment(uint64 gguid);
std::string const& GetComment(ObjectGuid gguid);
/// Gets current lfg options
uint32 GetOptions();
/// Sets new lfg options
@@ -467,33 +466,33 @@ namespace lfg
// LFGScripts
/// Get leader of the group (using internal data)
uint64 GetLeader(uint64 guid);
ObjectGuid GetLeader(ObjectGuid guid);
/// Initializes locked dungeons for given player (called at login or level change)
void InitializeLockedDungeons(Player* player, uint8 level = 0);
/// Sets player team
void SetTeam(uint64 guid, TeamId teamId);
void SetTeam(ObjectGuid guid, TeamId teamId);
/// Sets player group
void SetGroup(uint64 guid, uint64 group);
void SetGroup(ObjectGuid guid, ObjectGuid group);
/// Gets player group
uint64 GetGroup(uint64 guid);
ObjectGuid GetGroup(ObjectGuid guid);
/// Sets the leader of the group
void SetLeader(uint64 gguid, uint64 leader);
void SetLeader(ObjectGuid gguid, ObjectGuid leader);
/// Removes saved group data
void RemoveGroupData(uint64 guid);
void RemoveGroupData(ObjectGuid guid);
/// Removes a player from a group
uint8 RemovePlayerFromGroup(uint64 gguid, uint64 guid);
uint8 RemovePlayerFromGroup(ObjectGuid gguid, ObjectGuid guid);
/// Adds player to group
void AddPlayerToGroup(uint64 gguid, uint64 guid);
void AddPlayerToGroup(ObjectGuid gguid, ObjectGuid guid);
/// Xinef: Set Random Players Count
void SetRandomPlayersCount(uint64 guid, uint8 count);
void SetRandomPlayersCount(ObjectGuid guid, uint8 count);
/// Xinef: Get Random Players Count
uint8 GetRandomPlayersCount(uint64 guid);
uint8 GetRandomPlayersCount(ObjectGuid guid);
// LFGHandler
/// Get locked dungeons
LfgLockMap const& GetLockedDungeons(uint64 guid);
LfgLockMap const& GetLockedDungeons(ObjectGuid guid);
/// Returns current lfg status
LfgUpdateData GetLfgStatus(uint64 guid);
LfgUpdateData GetLfgStatus(ObjectGuid guid);
/// Checks if Seasonal dungeon is active
bool IsSeasonActive(uint32 dungeonId);
/// Gets the random dungeon reward corresponding to given dungeon and player level
@@ -503,26 +502,26 @@ namespace lfg
/// Teleport a player to/from selected dungeon
void TeleportPlayer(Player* player, bool out, bool fromOpcode = false);
/// Inits new proposal to boot a player
void InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string const& reason);
void InitBoot(ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, std::string const& reason);
/// Updates player boot proposal with new player answer
void UpdateBoot(uint64 guid, bool accept);
void UpdateBoot(ObjectGuid guid, bool accept);
/// Updates proposal to join dungeon with player answer
void UpdateProposal(uint32 proposalId, uint64 guid, bool accept);
void UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept);
/// Updates the role check with player answer
void UpdateRoleCheck(uint64 gguid, uint64 guid = 0, uint8 roles = PLAYER_ROLE_NONE);
void UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid = ObjectGuid::Empty, uint8 roles = PLAYER_ROLE_NONE);
/// Sets player lfg roles
void SetRoles(uint64 guid, uint8 roles);
void SetRoles(ObjectGuid guid, uint8 roles);
/// Sets player lfr comment
void SetComment(uint64 guid, std::string const& comment);
void SetComment(ObjectGuid guid, std::string const& comment);
/// Join Lfg with selected roles, dungeons and comment
void JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, std::string const& comment);
/// Leaves lfg
void LeaveLfg(uint64 guid);
void LeaveLfg(ObjectGuid guid);
/// pussywizard: cleans all queues' data
void LeaveAllLfgQueues(uint64 guid, bool allowgroup, uint64 groupguid = 0);
void LeaveAllLfgQueues(ObjectGuid guid, bool allowgroup, ObjectGuid groupguid = ObjectGuid::Empty);
/// pussywizard: Raid Browser
void JoinRaidBrowser(Player* player, uint8 roles, LfgDungeonSet& dungeons, std::string comment);
void LeaveRaidBrowser(uint64 guid);
void LeaveRaidBrowser(ObjectGuid guid);
void LfrSearchAdd(Player* p, uint32 dungeonId);
void LfrSearchRemove(Player* p);
void SendRaidBrowserCachedList(Player* player, uint32 dungeonId);
@@ -536,11 +535,11 @@ namespace lfg
// LfgQueue
/// Get last lfg state (NONE, DUNGEON or FINISHED_DUNGEON)
LfgState GetOldState(uint64 guid);
LfgState GetOldState(ObjectGuid guid);
/// Check if given group guid is lfg
bool IsLfgGroup(uint64 guid);
bool IsLfgGroup(ObjectGuid guid);
/// Gets the player count of given group
uint8 GetPlayerCount(uint64 guid);
uint8 GetPlayerCount(ObjectGuid guid);
/// Add a new Proposal
uint32 AddProposal(LfgProposal& proposal);
/// Checks if all players are queued
@@ -548,22 +547,22 @@ namespace lfg
/// Checks if given roles match, modifies given roles map with new roles
static uint8 CheckGroupRoles(LfgRolesMap& groles, bool removeLeaderFlag = true);
/// Checks if given players are ignoring each other
static bool HasIgnore(uint64 guid1, uint64 guid2);
static bool HasIgnore(ObjectGuid guid1, ObjectGuid guid2);
/// Sends queue status to player
static void SendLfgQueueStatus(uint64 guid, LfgQueueStatusData const& data);
static void SendLfgQueueStatus(ObjectGuid guid, LfgQueueStatusData const& data);
private:
TeamId GetTeam(uint64 guid);
void RestoreState(uint64 guid, char const* debugMsg);
void ClearState(uint64 guid, char const* debugMsg);
void SetDungeon(uint64 guid, uint32 dungeon);
void SetSelectedDungeons(uint64 guid, LfgDungeonSet const& dungeons);
void SetLockedDungeons(uint64 guid, LfgLockMap const& lock);
void DecreaseKicksLeft(uint64 guid);
void SetState(uint64 guid, LfgState state);
void SetCanOverrideRBState(uint64 guid, bool val);
TeamId GetTeam(ObjectGuid guid);
void RestoreState(ObjectGuid guid, char const* debugMsg);
void ClearState(ObjectGuid guid, char const* debugMsg);
void SetDungeon(ObjectGuid guid, uint32 dungeon);
void SetSelectedDungeons(ObjectGuid guid, LfgDungeonSet const& dungeons);
void SetLockedDungeons(ObjectGuid guid, LfgLockMap const& lock);
void DecreaseKicksLeft(ObjectGuid guid);
void SetState(ObjectGuid guid, LfgState state);
void SetCanOverrideRBState(ObjectGuid guid, bool val);
void GetCompatibleDungeons(LfgDungeonSet& dungeons, LfgGuidSet const& players, LfgLockPartyMap& lockMap);
void _SaveToDB(uint64 guid);
void _SaveToDB(ObjectGuid guid);
LFGDungeonData const* GetLFGDungeon(uint32 id);
// Proposals
@@ -571,19 +570,19 @@ namespace lfg
void MakeNewGroup(LfgProposal const& proposal);
// Generic
LFGQueue& GetQueue(uint64 guid);
LFGQueue& GetQueue(ObjectGuid guid);
LfgDungeonSet const& GetDungeonsByRandom(uint32 randomdungeon);
LfgType GetDungeonType(uint32 dungeon);
void SendLfgBootProposalUpdate(uint64 guid, LfgPlayerBoot const& boot);
void SendLfgJoinResult(uint64 guid, LfgJoinResultData const& data);
void SendLfgRoleChosen(uint64 guid, uint64 pguid, uint8 roles);
void SendLfgRoleCheckUpdate(uint64 guid, LfgRoleCheck const& roleCheck);
void SendLfgUpdateParty(uint64 guid, LfgUpdateData const& data);
void SendLfgUpdatePlayer(uint64 guid, LfgUpdateData const& data);
void SendLfgUpdateProposal(uint64 guid, LfgProposal const& proposal);
void SendLfgBootProposalUpdate(ObjectGuid guid, LfgPlayerBoot const& boot);
void SendLfgJoinResult(ObjectGuid guid, LfgJoinResultData const& data);
void SendLfgRoleChosen(ObjectGuid guid, ObjectGuid pguid, uint8 roles);
void SendLfgRoleCheckUpdate(ObjectGuid guid, LfgRoleCheck const& roleCheck);
void SendLfgUpdateParty(ObjectGuid guid, LfgUpdateData const& data);
void SendLfgUpdatePlayer(ObjectGuid guid, LfgUpdateData const& data);
void SendLfgUpdateProposal(ObjectGuid guid, LfgProposal const& proposal);
LfgGuidSet const& GetPlayers(uint64 guid);
LfgGuidSet const& GetPlayers(ObjectGuid guid);
// General variables
uint32 m_lfgProposalId; ///< used as internal counter for proposals