Core/Dungeon Finder: Code cleanup and minor optimizations

- Extend LfgState to keep control of the state of group and players using LFG
- Move scripts to its own class and initialize only if Dungeon finder is enabled
- Updated comments to doxygen format
- Use constructor initialization list
- All variables are declared in the inner most scope
- Fix some mem leaks
- Remove no longer needed code (Cleaner)
- Normalize handler function names

--HG--
branch : trunk
This commit is contained in:
Spp
2010-12-05 17:50:26 +01:00
parent 71c2698faf
commit e621f5fe98
16 changed files with 1015 additions and 1024 deletions
+4 -9
View File
@@ -18,6 +18,8 @@
#ifndef _LFG_H
#define _LFG_H
#include "Common.h"
enum LfgRoles
{
ROLE_NONE = 0x00,
@@ -27,13 +29,6 @@ enum LfgRoles
ROLE_DAMAGE = 0x08,
};
enum LfgState
{
LFG_STATE_NONE = 0, // Not using LFG / LFR
LFG_STATE_LFG = 1, // Using Dungeon finder
LFG_STATE_LFR = 2, // Using Raid finder
};
enum LfgUpdateType
{
LFG_UPDATETYPE_LEADER = 1,
@@ -55,10 +50,10 @@ typedef std::set<uint32> LfgDungeonSet;
struct LookingForGroup
{
LookingForGroup(): roles(0), update(true), state(LFG_STATE_NONE) {}
LookingForGroup(): roles(0), state(LFG_STATE_NONE), oldState(LFG_STATE_NONE) {}
uint8 roles;
bool update;
LfgState state;
LfgState oldState;
LfgDungeonSet applyDungeons; // Dungeons the player have applied for
std::string comment;
};
File diff suppressed because it is too large Load Diff
+200 -168
View File
@@ -27,113 +27,144 @@ class Player;
enum LFGenum
{
LFG_TIME_ROLECHECK = 2*MINUTE,
LFG_TIME_BOOT = 2*MINUTE,
LFG_TIME_PROPOSAL = 2*MINUTE,
LFG_TANKS_NEEDED = 1,
LFG_HEALERS_NEEDED = 1,
LFG_DPS_NEEDED = 3,
LFG_QUEUEUPDATE_INTERVAL = 15*IN_MILLISECONDS,
LFG_SPELL_DUNGEON_COOLDOWN = 71328,
LFG_SPELL_DUNGEON_DESERTER = 71041,
LFG_SPELL_LUCK_OF_THE_DRAW = 72221,
LFG_TIME_ROLECHECK = 2*MINUTE,
LFG_TIME_BOOT = 2*MINUTE,
LFG_TIME_PROPOSAL = 2*MINUTE,
LFG_TANKS_NEEDED = 1,
LFG_HEALERS_NEEDED = 1,
LFG_DPS_NEEDED = 3,
LFG_QUEUEUPDATE_INTERVAL = 15*IN_MILLISECONDS,
LFG_SPELL_DUNGEON_COOLDOWN = 71328,
LFG_SPELL_DUNGEON_DESERTER = 71041,
LFG_SPELL_LUCK_OF_THE_DRAW = 72221,
};
/// Determines the type of instance
enum LfgType
{
LFG_TYPE_NONE = 0, // Internal use only
LFG_TYPE_DUNGEON = 1,
LFG_TYPE_RAID = 2,
LFG_TYPE_QUEST = 3,
LFG_TYPE_ZONE = 4,
LFG_TYPE_HEROIC = 5,
LFG_TYPE_RANDOM = 6,
LFG_TYPE_NONE = 0, // Internal use only
LFG_TYPE_DUNGEON = 1,
LFG_TYPE_RAID = 2,
LFG_TYPE_QUEST = 3,
LFG_TYPE_ZONE = 4,
LFG_TYPE_HEROIC = 5,
LFG_TYPE_RANDOM = 6,
};
/// Proposal states
enum LfgProposalState
{
LFG_PROPOSAL_INITIATING = 0,
LFG_PROPOSAL_FAILED = 1,
LFG_PROPOSAL_SUCCESS = 2,
LFG_PROPOSAL_INITIATING = 0,
LFG_PROPOSAL_FAILED = 1,
LFG_PROPOSAL_SUCCESS = 2,
};
/// Instance lock types
enum LfgLockStatusType
{
LFG_LOCKSTATUS_OK = 0, // Internal use only
LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION = 1,
LFG_LOCKSTATUS_TOO_LOW_LEVEL = 2,
LFG_LOCKSTATUS_TOO_HIGH_LEVEL = 3,
LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE = 4,
LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE = 5,
LFG_LOCKSTATUS_RAID_LOCKED = 6,
LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL = 1001,
LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL = 1002,
LFG_LOCKSTATUS_QUEST_NOT_COMPLETED = 1022,
LFG_LOCKSTATUS_MISSING_ITEM = 1025,
LFG_LOCKSTATUS_NOT_IN_SEASON = 1031,
LFG_LOCKSTATUS_OK = 0, // Internal use only
LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION = 1,
LFG_LOCKSTATUS_TOO_LOW_LEVEL = 2,
LFG_LOCKSTATUS_TOO_HIGH_LEVEL = 3,
LFG_LOCKSTATUS_TOO_LOW_GEAR_SCORE = 4,
LFG_LOCKSTATUS_TOO_HIGH_GEAR_SCORE = 5,
LFG_LOCKSTATUS_RAID_LOCKED = 6,
LFG_LOCKSTATUS_ATTUNEMENT_TOO_LOW_LEVEL = 1001,
LFG_LOCKSTATUS_ATTUNEMENT_TOO_HIGH_LEVEL = 1002,
LFG_LOCKSTATUS_QUEST_NOT_COMPLETED = 1022,
LFG_LOCKSTATUS_MISSING_ITEM = 1025,
LFG_LOCKSTATUS_NOT_IN_SEASON = 1031,
};
/// Teleport errors
enum LfgTeleportError
{
LFG_TELEPORTERROR_OK = 0, // Internal use
LFG_TELEPORTERROR_PLAYER_DEAD = 1,
LFG_TELEPORTERROR_FALLING = 2,
//LFG_TELEPORTERROR_UNK2 = 3, // You can't do that right now
LFG_TELEPORTERROR_FATIGUE = 4,
//LFG_TELEPORTERROR_UNK3 = 5, // No reaction
LFG_TELEPORTERROR_INVALID_LOCATION = 6,
//LFG_TELEPORTERROR_UNK4 = 7, // You can't do that right now
//LFG_TELEPORTERROR_UNK5 = 8, // You can't do that right now
// 3, 7, 8 = "You can't do that right now" | 5 = No client reaction
LFG_TELEPORTERROR_OK = 0, // Internal use
LFG_TELEPORTERROR_PLAYER_DEAD = 1,
LFG_TELEPORTERROR_FALLING = 2,
LFG_TELEPORTERROR_FATIGUE = 4,
LFG_TELEPORTERROR_INVALID_LOCATION = 6,
};
/// Queue join results
enum LfgJoinResult
{
LFG_JOIN_OK = 0, // Joined (no client msg)
LFG_JOIN_FAILED = 1, // RoleCheck Failed
LFG_JOIN_GROUPFULL = 2, // Your group is full
//LFG_JOIN_UNK3 = 3, // No client reaction
LFG_JOIN_INTERNAL_ERROR = 4, // Internal LFG Error
LFG_JOIN_NOT_MEET_REQS = 5, // You do not meet the requirements for the chosen dungeons
LFG_JOIN_PARTY_NOT_MEET_REQS = 6, // One or more party members do not meet the requirements for the chosen dungeons
LFG_JOIN_MIXED_RAID_DUNGEON = 7, // You cannot mix dungeons, raids, and random when picking dungeons
LFG_JOIN_MULTI_REALM = 8, // The dungeon you chose does not support players from multiple realms
LFG_JOIN_DISCONNECTED = 9, // One or more party members are pending invites or disconnected
LFG_JOIN_PARTY_INFO_FAILED = 10, // Could not retrieve information about some party members
LFG_JOIN_DUNGEON_INVALID = 11, // One or more dungeons was not valid
LFG_JOIN_DESERTER = 12, // You can not queue for dungeons until your deserter debuff wears off
LFG_JOIN_PARTY_DESERTER = 13, // One or more party members has a deserter debuff
LFG_JOIN_RANDOM_COOLDOWN = 14, // You can not queue for random dungeons while on random dungeon cooldown
LFG_JOIN_PARTY_RANDOM_COOLDOWN = 15, // One or more party members are on random dungeon cooldown
LFG_JOIN_TOO_MUCH_MEMBERS = 16, // You can not enter dungeons with more that 5 party members
LFG_JOIN_USING_BG_SYSTEM = 17, // You can not use the dungeon system while in BG or arenas
//LFG_JOIN_FAILED2 = 18, // RoleCheck Failed
// 3 = No client reaction | 18 = "Rolecheck failed"
LFG_JOIN_OK = 0, // Joined (no client msg)
LFG_JOIN_FAILED = 1, // RoleCheck Failed
LFG_JOIN_GROUPFULL = 2, // Your group is full
LFG_JOIN_INTERNAL_ERROR = 4, // Internal LFG Error
LFG_JOIN_NOT_MEET_REQS = 5, // You do not meet the requirements for the chosen dungeons
LFG_JOIN_PARTY_NOT_MEET_REQS = 6, // One or more party members do not meet the requirements for the chosen dungeons
LFG_JOIN_MIXED_RAID_DUNGEON = 7, // You cannot mix dungeons, raids, and random when picking dungeons
LFG_JOIN_MULTI_REALM = 8, // The dungeon you chose does not support players from multiple realms
LFG_JOIN_DISCONNECTED = 9, // One or more party members are pending invites or disconnected
LFG_JOIN_PARTY_INFO_FAILED = 10, // Could not retrieve information about some party members
LFG_JOIN_DUNGEON_INVALID = 11, // One or more dungeons was not valid
LFG_JOIN_DESERTER = 12, // You can not queue for dungeons until your deserter debuff wears off
LFG_JOIN_PARTY_DESERTER = 13, // One or more party members has a deserter debuff
LFG_JOIN_RANDOM_COOLDOWN = 14, // You can not queue for random dungeons while on random dungeon cooldown
LFG_JOIN_PARTY_RANDOM_COOLDOWN = 15, // One or more party members are on random dungeon cooldown
LFG_JOIN_TOO_MUCH_MEMBERS = 16, // You can not enter dungeons with more that 5 party members
LFG_JOIN_USING_BG_SYSTEM = 17, // You can not use the dungeon system while in BG or arenas
};
enum LfgRoleCheckResult
/// Role check states
enum LfgRoleCheckState
{
LFG_ROLECHECK_FINISHED = 1, // Role check finished
LFG_ROLECHECK_INITIALITING = 2, // Role check begins
LFG_ROLECHECK_MISSING_ROLE = 3, // Someone didn't selected a role after 2 mins
LFG_ROLECHECK_WRONG_ROLES = 4, // Can't form a group with that role selection
LFG_ROLECHECK_ABORTED = 5, // Someone leave the group
LFG_ROLECHECK_NO_ROLE = 6, // Someone selected no role
LFG_ROLECHECK_FINISHED = 1, // Role check finished
LFG_ROLECHECK_INITIALITING = 2, // Role check begins
LFG_ROLECHECK_MISSING_ROLE = 3, // Someone didn't selected a role after 2 mins
LFG_ROLECHECK_WRONG_ROLES = 4, // Can't form a group with that role selection
LFG_ROLECHECK_ABORTED = 5, // Someone leave the group
LFG_ROLECHECK_NO_ROLE = 6, // Someone selected no role
};
/// Answer state (Also used to check compatibilites)
enum LfgAnswer
{
LFG_ANSWER_PENDING = -1,
LFG_ANSWER_DENY = 0,
LFG_ANSWER_AGREE = 1,
LFG_ANSWER_PENDING = -1,
LFG_ANSWER_DENY = 0,
LFG_ANSWER_AGREE = 1,
};
// Dungeon and reason why player can't join
// Forward declaration (just to have all typedef together)
struct LfgReward;
struct LfgLockStatus;
struct LfgQueueInfo;
struct LfgRoleCheck;
struct LfgProposal;
struct LfgProposalPlayer;
struct LfgPlayerBoot;
typedef std::set<uint64> LfgGuidSet;
typedef std::list<uint64> LfgGuidList;
typedef std::set<Player*> PlayerSet;
typedef std::list<Player*> LfgPlayerList;
typedef std::multimap<uint32, LfgReward const*> LfgRewardMap;
typedef std::pair<LfgRewardMap::const_iterator, LfgRewardMap::const_iterator> LfgRewardMapBounds;
typedef std::map<std::string, LfgAnswer> LfgCompatibleMap;
typedef std::map<uint64, LfgDungeonSet*> LfgDungeonMap;
typedef std::set<LfgLockStatus*> LfgLockStatusSet;
typedef std::map<uint32, LfgLockStatusSet*> LfgLockStatusMap;
typedef std::map<uint32, uint8> LfgRolesMap;
typedef std::map<uint32, LfgAnswer> LfgAnswerMap;
typedef std::map<uint32, LfgRoleCheck*> LfgRoleCheckMap;
typedef std::map<uint64, LfgQueueInfo*> LfgQueueInfoMap;
typedef std::map<uint32, LfgProposal*> LfgProposalMap;
typedef std::map<uint32, LfgProposalPlayer*> LfgProposalPlayerMap;
typedef std::map<uint32, LfgPlayerBoot*> LfgPlayerBootMap;
/// Dungeon and reason why player can't join
struct LfgLockStatus
{
uint32 dungeon;
LfgLockStatusType lockstatus;
uint32 dungeon; ///< Dungeon Id
LfgLockStatusType lockstatus; ///< Lock type
};
// Reward info
/// Reward info
struct LfgReward
{
uint32 maxLevel;
@@ -156,34 +187,29 @@ struct LfgReward
}
};
typedef std::map<uint32, uint8> LfgRolesMap;
typedef std::map<uint32, LfgAnswer> LfgAnswerMap;
typedef std::list<uint64> LfgGuidList;
typedef std::map<uint64, LfgDungeonSet*> LfgDungeonMap;
// Stores player or group queue info
/// Stores player or group queue info
struct LfgQueueInfo
{
LfgQueueInfo(): tanks(LFG_TANKS_NEEDED), healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) {};
time_t joinTime; // Player queue join time (to calculate wait times)
uint8 tanks; // Tanks needed
uint8 healers; // Healers needed
uint8 dps; // Dps needed
LfgDungeonSet dungeons; // Selected Player/Group Dungeon/s
LfgRolesMap roles; // Selected Player Role/s
time_t joinTime; ///< Player queue join time (to calculate wait times)
uint8 tanks; ///< Tanks needed
uint8 healers; ///< Healers needed
uint8 dps; ///< Dps needed
LfgDungeonSet dungeons; ///< Selected Player/Group Dungeon/s
LfgRolesMap roles; ///< Selected Player Role/s
};
/// Stores player data related to proposal to join
struct LfgProposalPlayer
{
LfgProposalPlayer(): role(0), accept(LFG_ANSWER_PENDING), groupLowGuid(0) {};
uint8 role; // Proposed role
LfgAnswer accept; // Accept status (-1 not answer | 0 Not agree | 1 agree)
uint32 groupLowGuid; // Original group guid (Low guid) 0 if no original group
uint8 role; ///< Proposed role
LfgAnswer accept; ///< Accept status (-1 not answer | 0 Not agree | 1 agree)
uint32 groupLowGuid; ///< Original group guid (Low guid) 0 if no original group
};
typedef std::map<uint32, LfgProposalPlayer*> LfgProposalPlayerMap;
// Stores all Dungeon Proposal after matching candidates
/// Stores group data related to proposal to join
struct LfgProposal
{
LfgProposal(uint32 dungeon): dungeonId(dungeon), state(LFG_PROPOSAL_INITIATING), groupLowGuid(0), leaderLowGuid(0) {}
@@ -195,89 +221,88 @@ struct LfgProposal
players.clear();
queues.clear();
};
uint32 dungeonId; // Dungeon to join
LfgProposalState state; // State of the proposal
uint32 groupLowGuid; // Proposal group (0 if new)
uint32 leaderLowGuid; // Leader guid.
time_t cancelTime; // Time when we will cancel this proposal
LfgGuidList queues; // Queue Ids to remove/readd
LfgProposalPlayerMap players; // Player current groupId
uint32 dungeonId; ///< Dungeon to join
LfgProposalState state; ///< State of the proposal
uint32 groupLowGuid; ///< Proposal group (0 if new)
uint32 leaderLowGuid; ///< Leader guid.
time_t cancelTime; ///< Time when we will cancel this proposal
LfgGuidList queues; ///< Queue Ids to remove/readd
LfgProposalPlayerMap players; ///< Players data
};
// Stores all rolecheck info of a group that wants to join LFG
/// Stores all rolecheck info of a group that wants to join
struct LfgRoleCheck
{
time_t cancelTime;
LfgRolesMap roles;
LfgRoleCheckResult result;
LfgDungeonSet dungeons;
uint32 leader;
time_t cancelTime; ///< Time when the rolecheck will fail
LfgRolesMap roles; ///< Player selected roles
LfgRoleCheckState result; ///< State of the rolecheck
LfgDungeonSet dungeons; ///< Dungeons group is applying for
uint32 leader; ///< Leader of the group
};
// Stores information of a current vote to kick someone from a group
/// Stores information of a current vote to kick someone from a group
struct LfgPlayerBoot
{
time_t cancelTime; // Time left to vote
bool inProgress; // Vote in progress
LfgAnswerMap votes; // Player votes (-1 not answer | 0 Not agree | 1 agree)
uint32 victimLowGuid; // Player guid to be kicked (can't vote)
uint8 votedNeeded; // Votes needed to kick the player
std::string reason; // kick reason
time_t cancelTime; ///< Time left to vote
bool inProgress; ///< Vote in progress
LfgAnswerMap votes; ///< Player votes (-1 not answer | 0 Not agree | 1 agree)
uint32 victimLowGuid; ///< Player guid to be kicked (can't vote)
uint8 votedNeeded; ///< Votes needed to kick the player
std::string reason; ///< kick reason
};
typedef std::set<Player*> PlayerSet;
typedef std::set<LfgLockStatus*> LfgLockStatusSet;
typedef std::map<uint32, LfgLockStatusSet*> LfgLockStatusMap;
typedef std::map<uint64, LfgQueueInfo*> LfgQueueInfoMap;
typedef std::map<uint32, LfgRoleCheck*> LfgRoleCheckMap;
typedef std::map<uint32, LfgProposal*> LfgProposalMap;
typedef std::map<uint32, LfgPlayerBoot*> LfgPlayerBootMap;
typedef std::multimap<uint32, LfgReward const*> LfgRewardMap;
typedef std::pair<LfgRewardMap::const_iterator, LfgRewardMap::const_iterator> LfgRewardMapBounds;
typedef std::list<Player*> LfgPlayerList;
typedef std::set<uint64> LfgGuidSet;
typedef std::map<std::string, LfgAnswer> LfgCompatibleMap;
class LFGMgr
{
friend class ACE_Singleton<LFGMgr, ACE_Null_Mutex>;
public:
LFGMgr();
~LFGMgr();
void Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string comment);
void Leave(Player* plr, Group* grp = NULL);
void OfferContinue(Group* grp);
void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false);
void UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept);
void UpdateBoot(Player* plr, bool accept);
void UpdateRoleCheck(Group* grp, Player* plr = NULL, bool newRoleCheck = false);
void Update(uint32 diff);
bool isRandomDungeon(uint32 dungeonId);
void InitBoot(Group* grp, uint32 plowGuid, uint32 vlowGuid, std::string reason);
// Reward
void LoadDungeonEncounters();
void LoadRewards();
void RewardDungeonDoneFor(const uint32 dungeonId, Player* player);
uint32 GetDungeonIdForAchievement(uint32 achievementId);
LfgLockStatusMap* GetPartyLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons = NULL);
LfgDungeonSet* GetRandomDungeons(uint8 level, uint8 expansion);
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons = NULL, bool useEntry = true);
LfgReward const* GetRandomDungeonReward(uint32 dungeon, uint8 level);
private:
void Cleaner();
void AddGuidToNewQueue(uint64 guid);
// Queue
void Join(Player* plr, uint8 roles, LfgDungeonSet* dungeons, std::string comment);
void Leave(Player* plr, Group* grp = NULL);
bool RemoveFromQueue(uint64 guid);
// Role Check
void UpdateRoleCheck(Group* grp, Player* plr = NULL, bool newRoleCheck = false);
// Proposals
void UpdateProposal(uint32 proposalId, uint32 lowGuid, bool accept);
// Teleportation
void TeleportPlayer(Player* plr, bool out, bool fromOpcode = false);
// Vote kick
void InitBoot(Group* grp, uint32 plowGuid, uint32 vlowGuid, std::string reason);
void UpdateBoot(Player* plr, bool accept);
void OfferContinue(Group* grp);
// Lock info
LfgLockStatusMap* GetPartyLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons = NULL);
LfgLockStatusSet* GetPlayerLockStatusDungeons(Player* plr, LfgDungeonSet* dungeons = NULL, bool useEntry = true);
// Generic
bool isRandomDungeon(uint32 dungeonId);
LfgDungeonSet* GetRandomDungeons(uint8 level, uint8 expansion);
private:
// Queue
void AddToQueue(uint64& guid);
bool RemoveFromQueue(uint64& guid);
// Proposals
void RemoveProposal(LfgProposalMap::iterator itProposal, LfgUpdateType type);
// Group Matching
LfgProposal* FindNewGroups(LfgGuidList check, LfgGuidList all);
bool CheckGroupRoles(LfgRolesMap &groles, bool removeLeaderFlag = true);
bool CheckCompatibility(LfgGuidList check, LfgProposal*& pProposal);
LfgDungeonSet* CheckCompatibleDungeons(LfgDungeonMap* dungeonsMap, PlayerSet* players);
@@ -285,35 +310,42 @@ class LFGMgr
void SetCompatibles(std::string concatenatedGuids, bool compatibles);
LfgAnswer GetCompatibles(std::string concatenatedGuids);
void RemoveFromCompatibles(uint64 guid);
std::string ConcatenateGuids(LfgGuidList check);
std::string ConcatenateDungeons(LfgDungeonSet* dungeons);
// Lock info
LfgLockStatusMap* GetGroupLockStatusDungeons(PlayerSet* pPlayers, LfgDungeonSet* dungeons, bool useEntry = true);
// Generic
LfgDungeonSet* GetDungeonsByRandom(uint32 randomdungeon);
LfgDungeonSet* GetAllDungeons();
LfgType GetDungeonType(uint32 dungeon);
std::string ConcatenateGuids(LfgGuidList check);
std::string ConcatenateDungeons(LfgDungeonSet* dungeons);
LfgRewardMap m_RewardMap; // Stores rewards for random dungeons
std::map<uint32, uint32> m_EncountersByAchievement; // Stores dungeon ids associated with achievements (for rewards)
LfgDungeonMap m_CachedDungeonMap; // Stores all dungeons by groupType
LfgQueueInfoMap m_QueueInfoMap; // Queued groups
LfgGuidList m_currentQueue; // Ordered list. Used to find groups
LfgGuidList m_newToQueue; // New groups to add to queue
LfgCompatibleMap m_CompatibleMap; // Compatible dungeons
LfgProposalMap m_Proposals; // Current Proposals
LfgPlayerBootMap m_Boots; // Current player kicks
LfgRoleCheckMap m_RoleChecks; // Current Role checks
uint32 m_QueueTimer; // used to check interval of update
uint32 m_lfgProposalId; // used as internal counter for proposals
int32 m_WaitTimeAvg;
int32 m_WaitTimeTank;
int32 m_WaitTimeHealer;
int32 m_WaitTimeDps;
uint32 m_NumWaitTimeAvg;
uint32 m_NumWaitTimeTank;
uint32 m_NumWaitTimeHealer;
uint32 m_NumWaitTimeDps;
bool m_update;
// General variables
bool m_update; ///< Doing an update?
uint32 m_QueueTimer; ///< used to check interval of update
uint32 m_lfgProposalId; ///< used as internal counter for proposals
int32 m_WaitTimeAvg; ///< Average wait time to find a group queuing as multiple roles
int32 m_WaitTimeTank; ///< Average wait time to find a group queuing as tank
int32 m_WaitTimeHealer; ///< Average wait time to find a group queuing as healer
int32 m_WaitTimeDps; ///< Average wait time to find a group queuing as dps
uint32 m_NumWaitTimeAvg; ///< Num of players used to calc avs wait time
uint32 m_NumWaitTimeTank; ///< Num of players used to calc tank wait time
uint32 m_NumWaitTimeHealer; ///< Num of players used to calc healers wait time
uint32 m_NumWaitTimeDps; ///< Num of players used to calc dps wait time
LfgDungeonMap m_CachedDungeonMap; ///< Stores all dungeons by groupType
// Reward System
LfgRewardMap m_RewardMap; ///< Stores rewards for random dungeons
std::map<uint32, uint32> m_EncountersByAchievement;///< Stores dungeon ids associated with achievements (for rewards)
// Queue
LfgQueueInfoMap m_QueueInfoMap; ///< Queued groups
LfgGuidList m_currentQueue; ///< Ordered list. Used to find groups
LfgGuidList m_newToQueue; ///< New groups to add to queue
LfgCompatibleMap m_CompatibleMap; ///< Compatible dungeons
// Rolecheck - Proposal - Vote Kicks
LfgRoleCheckMap m_RoleChecks; ///< Current Role checks
LfgProposalMap m_Proposals; ///< Current Proposals
LfgPlayerBootMap m_Boots; ///< Current player kicks
};
#define sLFGMgr (*ACE_Singleton<LFGMgr, ACE_Null_Mutex>::instance())
@@ -0,0 +1,165 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Interaction between core and LFGScripts
*/
#include "Common.h"
#include "SharedDefines.h"
#include "Player.h"
#include "Group.h"
#include "ScriptPCH.h"
#include "LFGScripts.h"
#include "LFGMgr.h"
LFGScripts::LFGScripts(): GroupScript("LFGScripts"), PlayerScript("LFGScripts") {}
void LFGScripts::OnAddMember(Group* group, uint64 guid)
{
uint64 gguid = group->GetGUID();
if (!gguid)
return;
sLog.outDebug("LFGScripts::OnAddMember [" UI64FMTD "]: added [" UI64FMTD "]", gguid, guid);
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player *plrg = itr->getSource())
{
plrg->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
}
}
// TODO - if group is queued and new player is added convert to rolecheck without notify the current players queued
if (group->GetLfgState() == LFG_STATE_QUEUED)
sLFGMgr.Leave(NULL, group);
Player *plr = sObjectMgr.GetPlayer(guid);
if (plr && plr->GetLfgState() == LFG_STATE_QUEUED)
sLFGMgr.Leave(plr);
}
void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod& method, uint64 kicker, const char* reason)
{
uint64 gguid = group->GetGUID();
if (!gguid || method == GROUP_REMOVEMETHOD_DEFAULT)
return;
sLog.outDebug("LFGScripts::OnRemoveMember [" UI64FMTD "]: remove [" UI64FMTD "] Method: %d Kicker: [" UI64FMTD "] Reason: %s", gguid, guid, method, kicker, (reason ? reason : ""));
if (group->GetLfgState() == LFG_STATE_QUEUED)
{
// TODO - Do not remove, just remove the one leaving and rejoin queue with all other data
sLFGMgr.Leave(NULL, group);
}
if (!group->isLFGGroup())
return;
if (method == GROUP_REMOVEMETHOD_KICK) // Player have been kicked
{
// TODO - Update internal kick cooldown of kicker
std::string str_reason = "";
if (reason)
str_reason = std::string(reason);
sLFGMgr.InitBoot(group, GUID_LOPART(kicker), GUID_LOPART(guid), str_reason);
return;
}
if (Player *plr = sObjectMgr.GetPlayer(guid))
{
/*
if (method == GROUP_REMOVEMETHOD_LEAVE)
// Add deserter flag
else if (group->isLfgKickActive())
// Update internal kick cooldown of kicked
*/
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
if (plr->GetMap()->IsDungeon()) // Teleport player out the dungeon
sLFGMgr.TeleportPlayer(plr, true);
}
if (group->GetLfgState() != LFG_STATE_FINISHED_DUNGEON)// Need more players to finish the dungeon
sLFGMgr.OfferContinue(group);
}
void LFGScripts::OnDisband(Group* group)
{
uint64 gguid = group->GetGUID();
if (!gguid)
return;
sLog.outDebug("LFGScripts::OnDisband [" UI64FMTD "]", gguid);
if (group->GetLfgState() == LFG_STATE_QUEUED)
sLFGMgr.Leave(NULL, group);
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player *plrg = itr->getSource())
{
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_GROUP_DISBAND);
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
if (plrg->GetMap()->IsDungeon()) // Teleport player out the dungeon
sLFGMgr.TeleportPlayer(plrg, true);
}
}
}
void LFGScripts::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid)
{
uint64 gguid = group->GetGUID();
if (!gguid)
return;
sLog.outDebug("LFGScripts::OnChangeLeader [" UI64FMTD "]: old [" UI64FMTD "] new [" UI64FMTD "]", gguid, newLeaderGuid, oldLeaderGuid);
Player *plr = sObjectMgr.GetPlayer(newLeaderGuid);
if (plr)
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
plr = sObjectMgr.GetPlayer(oldLeaderGuid);
if (plr)
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_GROUP_DISBAND);
}
void LFGScripts::OnInviteMember(Group* group, uint64 guid)
{
uint64 gguid = group->GetGUID();
if (!gguid)
return;
sLog.outDebug("LFGScripts::OnInviteMember [" UI64FMTD "]: invite [" UI64FMTD "] leader [" UI64FMTD "]", gguid, guid, group->GetLeaderGUID());
sLFGMgr.Leave(NULL, group);
}
void LFGScripts::OnLevelChanged(Player* /*player*/, uint8 /*newLevel*/)
{
// TODO - Invalidate LockStatus from cache
}
void LFGScripts::OnLogout(Player* player)
{
sLFGMgr.Leave(player);
player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
player->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
player->GetSession()->SendLfgUpdateSearch(false);
}
void LFGScripts::OnLogin(Player* /*player*/)
{
// TODO - Restore LfgPlayerData and send proper status to player if it was in a group
}
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Interaction between core and LFGScripts
*/
#include "Common.h"
#include "SharedDefines.h"
#include "ScriptPCH.h"
class Player;
class Group;
class LFGScripts: public GroupScript, PlayerScript
{
public:
LFGScripts();
// Group Hooks
void OnAddMember(Group* group, uint64 guid);
void OnRemoveMember(Group* group, uint64 guid, RemoveMethod& method, uint64 kicker, const char* reason);
void OnDisband(Group* group);
void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid);
void OnInviteMember(Group* group, uint64 guid);
// Player Hooks
void OnLevelChanged(Player* player, uint8 newLevel);
void OnLogout(Player* player);
void OnLogin(Player* player);
};
+2 -2
View File
@@ -22190,13 +22190,13 @@ PartyResult Player::CanUninviteFromGroup() const
if (grp->GetLfgKicks() == GROUP_MAX_LFG_KICKS)
return ERR_PARTY_LFG_BOOT_LIMIT;
if (grp->isLfgKickActive())
if (GetLfgState() == LFG_STATE_BOOT)
return ERR_PARTY_LFG_BOOT_IN_PROGRESS;
if (grp->GetMembersCount() <= GROUP_LFG_KICK_VOTES_NEEDED)
return ERR_PARTY_LFG_BOOT_TOO_FEW_PLAYERS;
if (grp->isLfgDungeonComplete())
if (GetLfgState() == LFG_STATE_FINISHED_DUNGEON)
return ERR_PARTY_LFG_BOOT_DUNGEON_COMPLETE;
if (grp->isRollLootActive())
+21 -4
View File
@@ -2260,10 +2260,27 @@ class Player : public Unit, public GridObject<Player>
void SetLfgComment(std::string _comment) { m_LookingForGroup.comment = _comment; }
uint8 GetLfgRoles() { return m_LookingForGroup.roles; }
void SetLfgRoles(uint8 _roles) { m_LookingForGroup.roles = _roles; }
bool GetLfgUpdate() { return m_LookingForGroup.update; }
void SetLfgUpdate(bool update) { m_LookingForGroup.update = update; }
LfgState GetLfgState() { return m_LookingForGroup.state; }
void SetLfgState(LfgState state) { m_LookingForGroup.state = state; }
LfgState GetLfgState() const { return m_LookingForGroup.state; }
void SetLfgState(LfgState state)
{
switch(state)
{
case LFG_STATE_NONE:
case LFG_STATE_DUNGEON:
case LFG_STATE_FINISHED_DUNGEON:
m_LookingForGroup.oldState = state;
// No break on purpose
default:
m_LookingForGroup.state = state;
}
}
void ClearLfgState()
{
m_LookingForGroup.applyDungeons.clear();
m_LookingForGroup.roles = ROLE_NONE;
m_LookingForGroup.state = m_LookingForGroup.oldState;
}
bool isUsingLfg() { return GetLfgState() != LFG_STATE_NONE; }
typedef std::set<uint32> DFQuestsDoneList;
+11 -43
View File
@@ -53,24 +53,11 @@ Loot* Roll::getLoot()
return getTarget();
}
Group::Group()
Group::Group() : m_leaderGuid(0), m_groupType(GROUPTYPE_NORMAL), m_bgGroup(NULL),
m_lootMethod(FREE_FOR_ALL), m_looterGuid(0), m_lootThreshold(ITEM_QUALITY_UNCOMMON),
m_subGroupsCounts(NULL), m_guid(0), m_counter(0), m_maxEnchantingLevel(0),
m_LfgState(LFG_STATE_NONE), m_LfgOldState(LFG_STATE_NONE), m_LfgDungeonEntry(0), m_Lfgkicks(0)
{
m_leaderGuid = 0;
m_groupType = GroupType(0);
m_bgGroup = NULL;
m_lootMethod = LootMethod(0);
m_looterGuid = 0;
m_lootThreshold = ITEM_QUALITY_UNCOMMON;
m_subGroupsCounts = NULL;
m_guid = 0;
m_counter = 0;
m_maxEnchantingLevel= 0;
m_LfgQueued = false;
m_LfgStatus = LFG_STATUS_NOT_SAVED;
m_LfgDungeonEntry = 0;
m_Lfgkicks = 0;
m_LfgkicksActive = false;
for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
m_targetIcons[i] = 0;
}
@@ -1119,7 +1106,7 @@ void Group::SendUpdate()
data << uint8(citr->roles);
if (isLFGGroup())
{
data << uint8(m_LfgStatus);
data << uint8(m_LfgState == LFG_STATE_FINISHED_DUNGEON ? 2 : 0); // FIXME - Dungeon save status? 2 = done
data << uint32(m_LfgDungeonEntry);
}
@@ -1936,30 +1923,21 @@ void Group::SetLootThreshold(ItemQualities threshold)
m_lootThreshold = threshold;
}
void Group::SetLfgQueued(bool queued)
void Group::SetLfgState(LfgState state)
{
m_LfgQueued = queued;
m_LfgState = state;
}
bool Group::isLfgQueued()
LfgState Group::GetLfgState()
{
return m_LfgQueued;
return m_LfgState;
}
void Group::SetLfgStatus(uint8 status)
void Group::RestoreLfgState()
{
m_LfgStatus = status;
m_LfgState = m_LfgOldState;
}
uint8 Group::GetLfgStatus()
{
return m_LfgStatus;
}
bool Group::isLfgDungeonComplete() const
{
return m_LfgStatus == LFG_STATUS_COMPLETE;
}
void Group::SetLfgDungeonEntry(uint32 dungeonEntry)
{
@@ -1974,16 +1952,6 @@ uint32 Group::GetLfgDungeonEntry(bool id /* = true*/)
return m_LfgDungeonEntry;
}
bool Group::isLfgKickActive() const
{
return m_LfgkicksActive;
}
void Group::SetLfgKickActive(bool active)
{
m_LfgkicksActive = active;
}
uint8 Group::GetLfgKicks() const
{
return m_Lfgkicks;
+5 -17
View File
@@ -55,13 +55,6 @@ enum RollVote
NOT_VALID = 5
};
enum LfgDungeonStatus
{
LFG_STATUS_SAVED = 0,
LFG_STATUS_NOT_SAVED = 1,
LFG_STATUS_COMPLETE = 2,
};
enum GroupMemberOnlineStatus
{
MEMBER_STATUS_OFFLINE = 0x0000,
@@ -202,15 +195,11 @@ class Group
void Disband(bool hideDestroy=false);
// Dungeon Finder
void SetLfgQueued(bool queued);
bool isLfgQueued();
void SetLfgStatus(uint8 status);
uint8 GetLfgStatus();
bool isLfgDungeonComplete() const;
void SetLfgState(LfgState state);
LfgState GetLfgState();
void RestoreLfgState();
void SetLfgDungeonEntry(uint32 dungeonEntry);
uint32 GetLfgDungeonEntry(bool id = true);
bool isLfgKickActive() const;
void SetLfgKickActive(bool active);
uint8 GetLfgKicks() const;
void SetLfgKicks(uint8 kicks);
void SetLfgRoles(uint64 guid, const uint8 roles);
@@ -357,10 +346,9 @@ class Group
uint64 m_guid;
uint32 m_counter; // used only in SMSG_GROUP_LIST
uint32 m_maxEnchantingLevel;
bool m_LfgQueued;
uint8 m_LfgStatus;
LfgState m_LfgState;
LfgState m_LfgOldState;
uint32 m_LfgDungeonEntry;
uint8 m_Lfgkicks;
bool m_LfgkicksActive;
};
#endif
@@ -2874,4 +2874,16 @@ enum RemoveMethod
GROUP_REMOVEMETHOD_LEAVE = 2,
};
enum LfgState
{
LFG_STATE_NONE, // Not using LFG / LFR
LFG_STATE_ROLECHECK, // Rolecheck active
LFG_STATE_QUEUED, // Queued
LFG_STATE_PROPOSAL, // Proposal active
LFG_STATE_BOOT, // Vote kick active
LFG_STATE_DUNGEON, // In LFG Group, in a Dungeon
LFG_STATE_FINISHED_DUNGEON, // In LFG Group, in a finished Dungeon
LFG_STATE_RAIDBROWSER, // Using Raid finder
};
#endif
@@ -76,7 +76,6 @@ void AddSC_npc_innkeeper();
void AddSC_npcs_special();
void AddSC_npc_taxi();
void AddSC_achievement_scripts();
void AddSC_dungeon_finder();
//eastern kingdoms
void AddSC_alterac_valley(); //Alterac Valley
@@ -664,7 +663,6 @@ void AddWorldScripts()
AddSC_npc_taxi();
AddSC_achievement_scripts();
AddSC_chat_log();
AddSC_dungeon_finder();
#endif
}
@@ -137,7 +137,7 @@ void WorldSession::HandleLfgSetRolesOpcode(WorldPacket &recv_data)
sLFGMgr.UpdateRoleCheck(grp, GetPlayer());
}
void WorldSession::HandleSetLfgCommentOpcode(WorldPacket & recv_data)
void WorldSession::HandleLfgSetCommentOpcode(WorldPacket & recv_data)
{
std::string comment;
recv_data >> comment;
@@ -535,7 +535,7 @@ void WorldSession::SendLfgBootPlayer(LfgPlayerBoot* pBoot)
SendPacket(&data);
}
void WorldSession::SendUpdateProposal(uint32 proposalId, LfgProposal* pProp)
void WorldSession::SendLfgUpdateProposal(uint32 proposalId, LfgProposal* pProp)
{
if (!pProp)
return;
@@ -554,7 +554,7 @@ void WorldSession::SendUpdateProposal(uint32 proposalId, LfgProposal* pProp)
Group* grp = dLowGuid ? sObjectMgr.GetGroupByGUID(dLowGuid) : NULL;
if (grp)
{
isContinue = grp->isLFGGroup() && !grp->isLfgDungeonComplete();
isContinue = grp->isLFGGroup() && grp->GetLfgState() != LFG_STATE_FINISHED_DUNGEON;
isSameDungeon = GetPlayer()->GetGroup() == grp && isContinue;
}
+1 -1
View File
@@ -896,7 +896,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x363*/ { "SMSG_LFG_ROLE_CHECK_UPDATE", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x364*/ { "SMSG_LFG_JOIN_RESULT", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x365*/ { "SMSG_LFG_QUEUE_STATUS", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x366*/ { "CMSG_SET_LFG_COMMENT", STATUS_LOGGEDIN, &WorldSession::HandleSetLfgCommentOpcode },
/*0x366*/ { "CMSG_SET_LFG_COMMENT", STATUS_LOGGEDIN, &WorldSession::HandleLfgSetCommentOpcode },
/*0x367*/ { "SMSG_LFG_UPDATE_PLAYER", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x368*/ { "SMSG_LFG_UPDATE_PARTY", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x369*/ { "SMSG_LFG_UPDATE_LIST", STATUS_NEVER, &WorldSession::Handle_ServerSide },
+2 -2
View File
@@ -718,7 +718,7 @@ class WorldSession
void HandleHearthAndResurrect(WorldPacket& recv_data);
// Looking for Dungeon/Raid
void HandleSetLfgCommentOpcode(WorldPacket & recv_data);
void HandleLfgSetCommentOpcode(WorldPacket & recv_data);
void HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& recv_data);
void HandleLfgPartyLockInfoRequestOpcode(WorldPacket& recv_data);
void HandleLfgJoinOpcode(WorldPacket &recv_data);
@@ -739,7 +739,7 @@ class WorldSession
void SendLfgQueueStatus(uint32 dungeon, int32 waitTime, int32 avgWaitTime, int32 waitTimeTanks, int32 waitTimeHealer, int32 waitTimeDps, uint32 queuedTime, uint8 tanks, uint8 healers, uint8 dps);
void SendLfgPlayerReward(uint32 rdungeonEntry, uint32 sdungeonEntry, uint8 done, const LfgReward *reward, const Quest *qRew);
void SendLfgBootPlayer(LfgPlayerBoot *pBoot);
void SendUpdateProposal(uint32 proposalId, LfgProposal *pProp);
void SendLfgUpdateProposal(uint32 proposalId, LfgProposal *pProp);
void SendLfgDisabled();
void SendLfgOfferContinue(uint32 dungeonEntry);
void SendLfgTeleportError(uint8 err);
-1
View File
@@ -7,7 +7,6 @@ set(scripts_STAT_SRCS
World/boss_taerar.cpp
World/boss_ysondre.cpp
World/chat_log.cpp
World/dungeon_finder.cpp
World/go_scripts.cpp
World/guards.cpp
World/item_scripts.cpp
-163
View File
@@ -1,163 +0,0 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Interaction between core and LFGMgr
*/
#include "ScriptPCH.h"
#include "LFGMgr.h"
#include "Group.h"
class DungeonFinderScript: public GroupScript, PlayerScript
{
public:
DungeonFinderScript(): GroupScript("DungeonFinderScript"), PlayerScript("DungeonFinderScript") { }
void OnAddMember(Group* group, uint64 guid)
{
uint64 gguid = group->GetGUID();
sLog.outDebug("OnAddMember [" UI64FMTD "]: added [" UI64FMTD "]", gguid, guid);
if (!gguid)
return;
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player *plrg = itr->getSource())
{
plrg->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
}
}
if (group->isLfgQueued())
sLFGMgr.Leave(NULL, group);
Player *plr = sObjectMgr.GetPlayer(guid);
if (plr && plr->isUsingLfg())
sLFGMgr.Leave(plr);
}
void OnRemoveMember(Group* group, uint64 guid, RemoveMethod& method, uint64 kicker, const char* reason)
{
uint64 gguid = group->GetGUID();
sLog.outDebug("OnRemoveMember [" UI64FMTD "]: remove [" UI64FMTD "] Method: %d Kicker: [" UI64FMTD "] Reason: %s", gguid, guid, method, kicker, (reason ? reason : ""));
if (!gguid)
return;
if (group->isLfgQueued())
{
// TODO - Do not remove, just remove the one leaving and rejoin queue with all other data
sLFGMgr.Leave(NULL, group);
}
if (!group->isLFGGroup())
return;
if (method == GROUP_REMOVEMETHOD_KICK) // Player have been kicked
{
// TODO - Update internal kick cooldown of kicker
std::string str_reason = "";
if (reason)
str_reason = std::string(reason);
sLFGMgr.InitBoot(group, GUID_LOPART(kicker), GUID_LOPART(guid), str_reason);
return;
}
if (Player *plr = sObjectMgr.GetPlayer(guid))
{
/*
if (method == GROUP_REMOVEMETHOD_LEAVE)
// Add deserter flag
else if (group->isLfgKickActive())
// Update internal kick cooldown of kicked
*/
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
if (plr->GetMap()->IsDungeon()) // Teleport player out the dungeon
sLFGMgr.TeleportPlayer(plr, true);
}
if (!group->isLfgDungeonComplete()) // Need more players to finish the dungeon
sLFGMgr.OfferContinue(group);
}
void OnDisband(Group* group)
{
uint64 gguid = group->GetGUID();
sLog.outDebug("OnDisband [" UI64FMTD "]", gguid);
if (!gguid)
return;
if (group->isLfgQueued())
sLFGMgr.Leave(NULL, group);
for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
if (Player *plrg = itr->getSource())
{
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_GROUP_DISBAND);
plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
if (plrg->GetMap()->IsDungeon()) // Teleport player out the dungeon
sLFGMgr.TeleportPlayer(plrg, true);
}
}
}
void OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid)
{
uint64 gguid = group->GetGUID();
sLog.outDebug("OnChangeLeader [" UI64FMTD "]: old [" UI64FMTD "] new [" UI64FMTD "]", gguid, newLeaderGuid, oldLeaderGuid);
if (!gguid)
return;
Player *plr = sObjectMgr.GetPlayer(newLeaderGuid);
if (plr)
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_LEADER);
plr = sObjectMgr.GetPlayer(oldLeaderGuid);
if (plr)
plr->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_GROUP_DISBAND);
}
void OnInviteMember(Group* group, uint64 guid)
{
uint64 gguid = group->GetGUID();
sLog.outDebug("OnInviteMember [" UI64FMTD "]: invite [" UI64FMTD "] leader [" UI64FMTD "]", gguid, guid, group->GetLeaderGUID());
if (!gguid)
return;
sLFGMgr.Leave(NULL, group);
}
void OnLevelChanged(Player* /*player*/, uint8 /*newLevel*/)
{
}
void OnLogout(Player* player)
{
sLFGMgr.Leave(player);
player->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
player->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
player->GetSession()->SendLfgUpdateSearch(false);
}
};
void AddSC_dungeon_finder()
{
new DungeonFinderScript();
}