diff options
Diffstat (limited to 'src/server/game/DungeonFinding/LFGMgr.cpp')
-rw-r--r-- | src/server/game/DungeonFinding/LFGMgr.cpp | 70 |
1 files changed, 44 insertions, 26 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index bf13095942e..39d30a28c4f 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -15,28 +15,46 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "LFGMgr.h" #include "Common.h" -#include "SharedDefines.h" +#include "DatabaseEnv.h" #include "DBCStores.h" #include "DisableMgr.h" -#include "ObjectMgr.h" -#include "SocialMgr.h" -#include "LFGMgr.h" -#include "LFGScripts.h" +#include "GameEventMgr.h" +#include "Group.h" +#include "GroupMgr.h" +#include "InstanceSaveMgr.h" #include "LFGGroupData.h" #include "LFGPlayerData.h" +#include "LFGScripts.h" #include "LFGQueue.h" -#include "Group.h" +#include "Log.h" +#include "Map.h" +#include "MotionMaster.h" +#include "ObjectAccessor.h" +#include "ObjectMgr.h" #include "Player.h" #include "RBAC.h" -#include "GroupMgr.h" -#include "GameEventMgr.h" +#include "SharedDefines.h" +#include "SocialMgr.h" +#include "World.h" #include "WorldSession.h" -#include "InstanceSaveMgr.h" namespace lfg { +LFGDungeonData::LFGDungeonData() : id(0), name(), map(0), type(0), expansion(0), group(0), minlevel(0), + maxlevel(0), difficulty(REGULAR_DIFFICULTY), seasonal(false), x(0.0f), y(0.0f), z(0.0f), o(0.0f) +{ +} + +LFGDungeonData::LFGDungeonData(LFGDungeonEntry const* dbc) : id(dbc->ID), name(dbc->name[0]), map(dbc->map), + type(dbc->type), expansion(uint8(dbc->expansion)), group(uint8(dbc->grouptype)), + minlevel(uint8(dbc->minlevel)), maxlevel(uint8(dbc->maxlevel)), difficulty(Difficulty(dbc->difficulty)), + seasonal((dbc->flags & LFG_FLAG_SEASONAL) != 0), x(0.0f), y(0.0f), z(0.0f), o(0.0f) +{ +} + LFGMgr::LFGMgr(): m_QueueTimer(0), m_lfgProposalId(1), m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK)) { @@ -117,7 +135,7 @@ void LFGMgr::LoadRewards() uint32 count = 0; - Field* fields = NULL; + Field* fields = nullptr; do { fields = result->Fetch(); @@ -164,7 +182,7 @@ LFGDungeonData const* LFGMgr::GetLFGDungeon(uint32 id) if (itr != LfgDungeonStore.end()) return &(itr->second); - return NULL; + return nullptr; } void LFGMgr::LoadLFGDungeons(bool reload /* = false */) @@ -270,7 +288,7 @@ void LFGMgr::Update(uint32 diff) if (!isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; - time_t currTime = time(NULL); + time_t currTime = time(nullptr); // Remove obsolete role checks for (LfgRoleCheckContainer::iterator it = RoleChecksStore.begin(); it != RoleChecksStore.end();) @@ -424,7 +442,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const else { uint8 memberCount = 0; - for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && joinData.result == LFG_JOIN_OK; itr = itr->next()) + for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr && joinData.result == LFG_JOIN_OK; itr = itr->next()) { if (Player* plrg = itr->GetSource()) { @@ -522,7 +540,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const { // Create new rolecheck LfgRoleCheck& roleCheck = RoleChecksStore[gguid]; - roleCheck.cancelTime = time_t(time(NULL)) + LFG_TIME_ROLECHECK; + roleCheck.cancelTime = time_t(time(nullptr)) + LFG_TIME_ROLECHECK; roleCheck.state = LFG_ROLECHECK_INITIALITING; roleCheck.leader = guid; roleCheck.dungeons = dungeons; @@ -537,7 +555,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const SetState(gguid, LFG_STATE_ROLECHECK); // Send update to player LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_JOIN_QUEUE, dungeons, comment); - for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next()) { if (Player* plrg = itr->GetSource()) { @@ -560,7 +578,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const LfgRolesMap rolesMap; rolesMap[guid] = roles; LFGQueue& queue = GetQueue(guid); - queue.AddQueueData(guid, time(NULL), dungeons, rolesMap); + queue.AddQueueData(guid, time(nullptr), dungeons, rolesMap); if (!isContinue) { @@ -734,7 +752,7 @@ void LFGMgr::UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid /* = ObjectGuid:: { SetState(gguid, LFG_STATE_QUEUED); LFGQueue& queue = GetQueue(gguid); - queue.AddQueueData(gguid, time_t(time(NULL)), roleCheck.dungeons, roleCheck.roles); + queue.AddQueueData(gguid, time_t(time(nullptr)), roleCheck.dungeons, roleCheck.roles); RoleChecksStore.erase(itRoleCheck); } else if (roleCheck.state != LFG_ROLECHECK_INITIALITING) @@ -895,7 +913,7 @@ void LFGMgr::MakeNewGroup(LfgProposal const& proposal) LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId); ASSERT(dungeon); - Group* grp = proposal.group ? sGroupMgr->GetGroupByGUID(proposal.group.GetCounter()) : NULL; + Group* grp = proposal.group ? sGroupMgr->GetGroupByGUID(proposal.group.GetCounter()) : nullptr; for (GuidList::const_iterator it = players.begin(); it != players.end(); ++it) { ObjectGuid pguid = (*it); @@ -997,7 +1015,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept) bool sendUpdate = proposal.state != LFG_PROPOSAL_SUCCESS; proposal.state = LFG_PROPOSAL_SUCCESS; - time_t joinTime = time(NULL); + time_t joinTime = time(nullptr); LFGQueue& queue = GetQueue(guid); LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND); @@ -1166,7 +1184,7 @@ void LFGMgr::InitBoot(ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, st LfgPlayerBoot& boot = BootsStore[gguid]; boot.inProgress = true; - boot.cancelTime = time_t(time(NULL)) + LFG_TIME_BOOT; + boot.cancelTime = time_t(time(nullptr)) + LFG_TIME_BOOT; boot.reason = reason; boot.victim = victim; @@ -1254,7 +1272,7 @@ void LFGMgr::UpdateBoot(ObjectGuid guid, bool accept) */ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*/) { - LFGDungeonData const* dungeon = NULL; + LFGDungeonData const* dungeon = nullptr; Group* group = player->GetGroup(); if (group && group->isLFGGroup()) @@ -1303,7 +1321,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* if (!fromOpcode) { // Select a player inside to be teleported to - for (GroupReference* itr = group->GetFirstMember(); itr != NULL && !mapid; itr = itr->next()) + for (GroupReference* itr = group->GetFirstMember(); itr != nullptr && !mapid; itr = itr->next()) { Player* plrg = itr->GetSource(); if (plrg && plrg != player && plrg->GetMapId() == uint32(dungeon->map)) @@ -1375,7 +1393,7 @@ void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const* } uint32 rDungeonId = 0; - const LfgDungeonSet& dungeons = GetSelectedDungeons(guid); + LfgDungeonSet const& dungeons = GetSelectedDungeons(guid); if (!dungeons.empty()) rDungeonId = (*dungeons.begin()); @@ -1421,7 +1439,7 @@ void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const* // if we can take the quest, means that we haven't done this kind of "run", IE: First Heroic Random of Day. if (player->CanRewardQuest(quest, false)) - player->RewardQuest(quest, 0, NULL, false); + player->RewardQuest(quest, 0, nullptr, false); else { done = true; @@ -1429,7 +1447,7 @@ void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const* if (!quest) continue; // we give reward without informing client (retail does this) - player->RewardQuest(quest, 0, NULL, false); + player->RewardQuest(quest, 0, nullptr, false); } // Give rewards @@ -1465,7 +1483,7 @@ LfgDungeonSet const& LFGMgr::GetDungeonsByRandom(uint32 randomdungeon) */ LfgReward const* LFGMgr::GetRandomDungeonReward(uint32 dungeon, uint8 level) { - LfgReward const* rew = NULL; + LfgReward const* rew = nullptr; LfgRewardContainerBounds bounds = RewardMapStore.equal_range(dungeon & 0x00FFFFFF); for (LfgRewardContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { |