diff options
author | Shauren <shauren.trinity@gmail.com> | 2012-03-24 17:53:33 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2012-03-24 17:53:33 +0100 |
commit | 64701c51dc5232f538bbc2b4687b4ae2be9d904f (patch) | |
tree | ff87ff34c57f00c6a8a9f39e108f96afbc74394e /src/server/game/DungeonFinding/LFGScripts.cpp | |
parent | 47a597d406e131c76f81b73c06ec30d19038c39b (diff) |
Core/LFGScript: Split LFG script class to prevent crash caused by deallocating the same memory twice
Diffstat (limited to 'src/server/game/DungeonFinding/LFGScripts.cpp')
-rw-r--r-- | src/server/game/DungeonFinding/LFGScripts.cpp | 78 |
1 files changed, 42 insertions, 36 deletions
diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index 2966e799c58..6175addfae2 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -27,9 +27,45 @@ #include "LFGScripts.h" #include "LFGMgr.h" -LFGScripts::LFGScripts(): GroupScript("LFGScripts"), PlayerScript("LFGScripts") {} +LFGPlayerScript::LFGPlayerScript() : PlayerScript("LFGPlayerScript") +{ +} + +void LFGPlayerScript::OnLevelChanged(Player* player, uint8 /*oldLevel*/) +{ + sLFGMgr->InitializeLockedDungeons(player); +} -void LFGScripts::OnAddMember(Group* group, uint64 guid) +void LFGPlayerScript::OnLogout(Player* player) +{ + sLFGMgr->Leave(player); + LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE); + player->GetSession()->SendLfgUpdateParty(updateData); + player->GetSession()->SendLfgUpdatePlayer(updateData); + player->GetSession()->SendLfgUpdateSearch(false); + uint64 guid = player->GetGUID(); + // TODO - Do not remove, add timer before deleting + sLFGMgr->RemovePlayerData(guid); +} + +void LFGPlayerScript::OnLogin(Player* player) +{ + sLFGMgr->InitializeLockedDungeons(player); + // TODO - Restore LfgPlayerData and send proper status to player if it was in a group +} + +void LFGPlayerScript::OnBindToInstance(Player* player, Difficulty difficulty, uint32 mapId, bool /*permanent*/) +{ + MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); + if (mapEntry->IsDungeon() && difficulty > DUNGEON_DIFFICULTY_NORMAL) + sLFGMgr->InitializeLockedDungeons(player); +} + +LFGGroupScript::LFGGroupScript() : GroupScript("LFGGroupScript") +{ +} + +void LFGGroupScript::OnAddMember(Group* group, uint64 guid) { uint64 gguid = group->GetGUID(); if (!gguid) @@ -55,7 +91,7 @@ void LFGScripts::OnAddMember(Group* group, uint64 guid) sLFGMgr->Leave(player); } -void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, const char* reason) +void LFGGroupScript::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, uint64 kicker, char const* reason) { uint64 gguid = group->GetGUID(); if (!gguid || method == GROUP_REMOVEMETHOD_DEFAULT) @@ -102,7 +138,7 @@ void LFGScripts::OnRemoveMember(Group* group, uint64 guid, RemoveMethod method, sLFGMgr->OfferContinue(group); } -void LFGScripts::OnDisband(Group* group) +void LFGGroupScript::OnDisband(Group* group) { uint64 gguid = group->GetGUID(); sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnDisband [" UI64FMTD "]", gguid); @@ -110,7 +146,7 @@ void LFGScripts::OnDisband(Group* group) sLFGMgr->RemoveGroupData(gguid); } -void LFGScripts::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) +void LFGGroupScript::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid) { uint64 gguid = group->GetGUID(); if (!gguid) @@ -131,7 +167,7 @@ void LFGScripts::OnChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLe } } -void LFGScripts::OnInviteMember(Group* group, uint64 guid) +void LFGGroupScript::OnInviteMember(Group* group, uint64 guid) { uint64 gguid = group->GetGUID(); if (!gguid) @@ -140,33 +176,3 @@ void LFGScripts::OnInviteMember(Group* group, uint64 guid) sLog->outDebug(LOG_FILTER_LFG, "LFGScripts::OnInviteMember [" UI64FMTD "]: invite [" UI64FMTD "] leader [" UI64FMTD "]", gguid, guid, group->GetLeaderGUID()); sLFGMgr->Leave(NULL, group); } - -void LFGScripts::OnLevelChanged(Player* player, uint8 /*oldLevel*/) -{ - sLFGMgr->InitializeLockedDungeons(player); -} - -void LFGScripts::OnLogout(Player* player) -{ - sLFGMgr->Leave(player); - LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE); - player->GetSession()->SendLfgUpdateParty(updateData); - player->GetSession()->SendLfgUpdatePlayer(updateData); - player->GetSession()->SendLfgUpdateSearch(false); - uint64 guid = player->GetGUID(); - // TODO - Do not remove, add timer before deleting - sLFGMgr->RemovePlayerData(guid); -} - -void LFGScripts::OnLogin(Player* player) -{ - sLFGMgr->InitializeLockedDungeons(player); - // TODO - Restore LfgPlayerData and send proper status to player if it was in a group -} - -void LFGScripts::OnBindToInstance(Player* player, Difficulty difficulty, uint32 mapId, bool /*permanent*/) -{ - MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); - if (mapEntry->IsDungeon() && difficulty > DUNGEON_DIFFICULTY_NORMAL) - sLFGMgr->InitializeLockedDungeons(player); -} |