From f477021938b086080f7f5370e854b3a63f5900fd Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 9 Mar 2009 16:36:58 -0600 Subject: [7404] Fixed cheating in rated arena matches by alt+f4. Author: Triply --HG-- branch : trunk --- src/game/BattleGround.cpp | 39 +++++++++++++++++++++++++++------------ src/game/BattleGround.h | 6 ++++-- src/game/BattleGroundBE.cpp | 16 ++-------------- src/game/BattleGroundNA.cpp | 16 ++-------------- src/game/BattleGroundRL.cpp | 16 ++-------------- src/game/WorldSession.cpp | 2 +- src/shared/revision_nr.h | 2 +- 7 files changed, 39 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 316d82db626..28dd675a1b4 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -167,7 +167,7 @@ void BattleGround::Update(uint32 diff) m_RemovedPlayers.clear(); } - // remove offline players from bg after ~5 minutes + // remove offline players from bg after 5 minutes if(GetPlayersSize()) { for(std::map::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) @@ -176,19 +176,18 @@ void BattleGround::Update(uint32 diff) itr->second.LastOnlineTime += diff; if(plr) - itr->second.LastOnlineTime = 0; // update last online time + itr->second.LastOnlineTime = 0; // update last online time else - if(itr->second.LastOnlineTime >= MAX_OFFLINE_TIME) // 5 minutes - m_RemovedPlayers[itr->first] = 1; // add to remove list (BG) + if(itr->second.LastOnlineTime >= MAX_OFFLINE_TIME) + m_RemovedPlayers[itr->first] = 1; // add to remove list (BG) } } - //TODO: move this system to spell system and ressurect players correclt there! /*********************************************************/ /*** BATTLEGROUND RESSURECTION SYSTEM ***/ /*********************************************************/ - //this should be handled by spell system: + //this should be handled by spell system m_LastResurrectTime += diff; if (m_LastResurrectTime >= RESURRECTION_INTERVAL) { @@ -327,16 +326,13 @@ void BattleGround::Update(uint32 diff) //remove preparation if( isArena() ) { - //TODO : add arena sound (PlaySoundToAll(SOUND_ARENA_START); + //TODO : add arena sound PlaySoundToAll(SOUND_ARENA_START); for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if(Player *plr = objmgr.GetPlayer(itr->first)) plr->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION); - if(!GetPlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE)) - EndBattleGround(HORDE); - else if(GetPlayersCountByTeam(ALLIANCE) && !GetPlayersCountByTeam(HORDE)) - EndBattleGround(ALLIANCE); + CheckArenaWinConditions(); } else { @@ -346,7 +342,7 @@ void BattleGround::Update(uint32 diff) for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) if(Player* plr = objmgr.GetPlayer(itr->first)) plr->RemoveAurasDueToSpell(SPELL_PREPARATION); - //Announce BG starting: + //Announce BG starting if( sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE) ) { sWorld.SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName(), GetMinLevel(), GetMaxLevel()); @@ -1112,6 +1108,17 @@ void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 plr_guid, } } +// This method should be called when player logs out from running battleground +void BattleGround::EventPlayerLoggedOut(Player* player) +{ + if( GetStatus() == STATUS_IN_PROGRESS ) + { + if( isBattleGround() ) + EventPlayerDroppedFlag(player); + else + CheckArenaWinConditions(); + } +} /* This method should be called only once ... it adds pointer to queue */ void BattleGround::AddToBGFreeSlotQueue() @@ -1679,6 +1686,14 @@ void BattleGround::HandleKillUnit(Creature *creature, Player *killer) { } +void BattleGround::CheckArenaWinConditions() +{ + if( !GetAlivePlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE) ) + EndBattleGround(HORDE); + else if( GetPlayersCountByTeam(ALLIANCE) && !GetAlivePlayersCountByTeam(HORDE) ) + EndBattleGround(ALLIANCE); +} + void BattleGround::SetBgRaid( uint32 TeamID, Group *bg_raid ) { Group* &old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index ea691dc9750..6ddaa43fcc8 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -445,9 +445,10 @@ class BattleGround // used for rated arena battles void SetArenaTeamIdForTeam(uint32 Team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; } - uint32 GetArenaTeamIdForTeam(uint32 Team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(Team)]; } + uint32 GetArenaTeamIdForTeam(uint32 Team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(Team)]; } void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)] = RatingChange; } - int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; } + int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; } + void CheckArenaWinConditions(); /* Triggers handle */ // must be implemented in BG subclass @@ -460,6 +461,7 @@ class BattleGround virtual void EventPlayerDroppedFlag(Player* /*player*/) {} virtual void EventPlayerClickedOnFlag(Player* /*player*/, GameObject* /*target_obj*/) {} virtual void EventPlayerCapturedFlag(Player* /*player*/) {} + void EventPlayerLoggedOut(Player* player); /* Death related */ virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); diff --git a/src/game/BattleGroundBE.cpp b/src/game/BattleGroundBE.cpp index 9e976ac7330..f417c353c1c 100644 --- a/src/game/BattleGroundBE.cpp +++ b/src/game/BattleGroundBE.cpp @@ -94,10 +94,7 @@ void BattleGroundBE::RemovePlayer(Player* /*plr*/, uint64 /*guid*/) UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE)); - if(!GetAlivePlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE)) - EndBattleGround(HORDE); - else if(GetPlayersCountByTeam(ALLIANCE) && !GetAlivePlayersCountByTeam(HORDE)) - EndBattleGround(ALLIANCE); + CheckArenaWinConditions(); } void BattleGroundBE::HandleKillPlayer(Player *player, Player *killer) @@ -116,16 +113,7 @@ void BattleGroundBE::HandleKillPlayer(Player *player, Player *killer) UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE)); - if(!GetAlivePlayersCountByTeam(ALLIANCE)) - { - // all opponents killed - EndBattleGround(HORDE); - } - else if(!GetAlivePlayersCountByTeam(HORDE)) - { - // all opponents killed - EndBattleGround(ALLIANCE); - } + CheckArenaWinConditions(); } bool BattleGroundBE::HandlePlayerUnderMap(Player *player) diff --git a/src/game/BattleGroundNA.cpp b/src/game/BattleGroundNA.cpp index 70f44deac89..b4c1b22d2de 100644 --- a/src/game/BattleGroundNA.cpp +++ b/src/game/BattleGroundNA.cpp @@ -91,10 +91,7 @@ void BattleGroundNA::RemovePlayer(Player* /*plr*/, uint64 /*guid*/) UpdateWorldState(0xa0f, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(0xa10, GetAlivePlayersCountByTeam(HORDE)); - if(!GetAlivePlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE)) - EndBattleGround(HORDE); - else if(GetPlayersCountByTeam(ALLIANCE) && !GetAlivePlayersCountByTeam(HORDE)) - EndBattleGround(ALLIANCE); + CheckArenaWinConditions(); } void BattleGroundNA::HandleKillPlayer(Player *player, Player *killer) @@ -113,16 +110,7 @@ void BattleGroundNA::HandleKillPlayer(Player *player, Player *killer) UpdateWorldState(0xa0f, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(0xa10, GetAlivePlayersCountByTeam(HORDE)); - if(!GetAlivePlayersCountByTeam(ALLIANCE)) - { - // all opponents killed - EndBattleGround(HORDE); - } - else if(!GetAlivePlayersCountByTeam(HORDE)) - { - // all opponents killed - EndBattleGround(ALLIANCE); - } + CheckArenaWinConditions(); } bool BattleGroundNA::HandlePlayerUnderMap(Player *player) diff --git a/src/game/BattleGroundRL.cpp b/src/game/BattleGroundRL.cpp index 7ac6d4d1cd5..0e764d3f4c7 100644 --- a/src/game/BattleGroundRL.cpp +++ b/src/game/BattleGroundRL.cpp @@ -91,10 +91,7 @@ void BattleGroundRL::RemovePlayer(Player* /*plr*/, uint64 /*guid*/) UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE)); - if(!GetAlivePlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE)) - EndBattleGround(HORDE); - else if(GetPlayersCountByTeam(ALLIANCE) && !GetAlivePlayersCountByTeam(HORDE)) - EndBattleGround(ALLIANCE); + CheckArenaWinConditions(); } void BattleGroundRL::HandleKillPlayer(Player *player, Player *killer) @@ -113,16 +110,7 @@ void BattleGroundRL::HandleKillPlayer(Player *player, Player *killer) UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE)); - if(!GetAlivePlayersCountByTeam(ALLIANCE)) - { - // all opponents killed - EndBattleGround(HORDE); - } - else if(!GetAlivePlayersCountByTeam(HORDE)) - { - // all opponents killed - EndBattleGround(ALLIANCE); - } + CheckArenaWinConditions(); } bool BattleGroundRL::HandlePlayerUnderMap(Player *player) diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 8e7c2595923..01459930788 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -304,7 +304,7 @@ void WorldSession::LogoutPlayer(bool Save) } //drop a flag if player is carrying it if(BattleGround *bg = _player->GetBattleGround()) - bg->EventPlayerDroppedFlag(_player); + bg->EventPlayerLoggedOut(_player); ///- Teleport to home if the player is in an invalid instance if(!_player->m_InstanceValid && !_player->isGameMaster()) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 87863ccbe8e..8bc76cb6e07 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7403" + #define REVISION_NR "7404" #endif // __REVISION_NR_H__ -- cgit v1.2.3