aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSubv <s.v.h21@hotmail.com>2012-03-04 13:01:50 -0500
committerKandera <KanderaDev@gmail.com>2012-08-20 13:48:49 -0400
commitf9c9622f86b963dbd7cf57d6dc73577797f11fd8 (patch)
treefe7a3666f7ddc8ccb07486f8e11b9678e2efd100
parentce17607595a0fd83a0ed95bbccd132c5a5738598 (diff)
Battlefields/WG: Refactored duplicated code
-rw-r--r--src/server/game/Battlefield/Zones/BattlefieldWG.cpp59
-rw-r--r--src/server/game/Battlefield/Zones/BattlefieldWG.h6
2 files changed, 18 insertions, 47 deletions
diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
index 4c39f75938c..6fafbf823e9 100644
--- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
+++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
@@ -452,18 +452,10 @@ void BattlefieldWG::OnBattleEnd(bool endbytimer)
for (uint8 team = 0; team < 2; ++team)
{
for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
- {
if (Player* player = sObjectAccessor->FindPlayer(*itr))
- {
- player->RemoveAura(SPELL_TOWER_CONTROL);
- player->RemoveAurasDueToSpell(SPELL_RECRUIT);
- player->RemoveAurasDueToSpell(SPELL_CORPORAL);
- player->RemoveAurasDueToSpell(SPELL_LIEUTENANT);
- player->RemoveAurasDueToSpell(SPELL_TENACITY);
- player->RemoveAurasDueToSpell(SPELL_SPIRITUAL_IMMUNITY);
- }
- }
- m_PlayersInWar[team].clear();
+ RemoveAurasFromPlayer(player);
+
+ m_PlayersInWar[team].clear();
for (GuidSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
{
@@ -826,7 +818,7 @@ void BattlefieldWG::PromotePlayer(Player* killer)
}
}
-void BattlefieldWG::OnPlayerJoinWar(Player* player)
+void BattlefieldWG::RemoveAurasFromPlayer(Player* player)
{
player->RemoveAurasDueToSpell(SPELL_RECRUIT);
player->RemoveAurasDueToSpell(SPELL_CORPORAL);
@@ -835,6 +827,12 @@ void BattlefieldWG::OnPlayerJoinWar(Player* player)
player->RemoveAurasDueToSpell(SPELL_SPIRITUAL_IMMUNITY);
player->RemoveAurasDueToSpell(SPELL_TENACITY);
player->RemoveAurasDueToSpell(SPELL_ESSENCE_OF_WINTERGRASP);
+ player->RemoveAurasDueToSpell(SPELL_WINTERGRASP_RESTRICTED_FLIGHT_AREA);
+}
+
+void BattlefieldWG::OnPlayerJoinWar(Player* player)
+{
+ RemoveAurasFromPlayer(player);
player->CastSpell(player, SPELL_RECRUIT, true);
@@ -875,15 +873,7 @@ void BattlefieldWG::OnPlayerLeaveWar(Player* player)
{
if (player->GetVehicle()) // Remove vehicle of player if he go out.
player->GetVehicle()->Dismiss();
- player->RemoveAurasDueToSpell(SPELL_RECRUIT);
- player->RemoveAurasDueToSpell(SPELL_CORPORAL);
- player->RemoveAurasDueToSpell(SPELL_LIEUTENANT);
- player->RemoveAurasDueToSpell(SPELL_TOWER_CONTROL);
- player->RemoveAurasDueToSpell(SPELL_SPIRITUAL_IMMUNITY);
- player->RemoveAurasDueToSpell(SPELL_TENACITY);
- player->RemoveAurasDueToSpell(SPELL_WINTERGRASP_RESTRICTED_FLIGHT_AREA);
- player->RemoveAurasDueToSpell(SPELL_ESSENCE_OF_WINTERGRASP);
- player->RemoveAurasDueToSpell(SPELL_TOWER_CONTROL);
+ RemoveAurasFromPlayer(player);
}
player->RemoveAurasDueToSpell(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT);
player->RemoveAurasDueToSpell(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT);
@@ -893,18 +883,9 @@ void BattlefieldWG::OnPlayerLeaveWar(Player* player)
void BattlefieldWG::OnPlayerLeaveZone(Player* player)
{
- player->RemoveAurasDueToSpell(SPELL_ESSENCE_OF_WINTERGRASP);
if (!m_BattlefieldActive)
- {
- player->RemoveAurasDueToSpell(SPELL_RECRUIT);
- player->RemoveAurasDueToSpell(SPELL_CORPORAL);
- player->RemoveAurasDueToSpell(SPELL_LIEUTENANT);
- player->RemoveAurasDueToSpell(SPELL_TOWER_CONTROL);
- player->RemoveAurasDueToSpell(SPELL_SPIRITUAL_IMMUNITY);
- player->RemoveAurasDueToSpell(SPELL_TENACITY);
- player->RemoveAurasDueToSpell(SPELL_WINTERGRASP_RESTRICTED_FLIGHT_AREA);
- player->RemoveAurasDueToSpell(SPELL_TOWER_CONTROL);
- }
+ RemoveAurasFromPlayer(player);
+
player->RemoveAurasDueToSpell(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT);
player->RemoveAurasDueToSpell(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT);
player->RemoveAurasDueToSpell(SPELL_HORDE_CONTROL_PHASE_SHIFT);
@@ -913,20 +894,8 @@ void BattlefieldWG::OnPlayerLeaveZone(Player* player)
void BattlefieldWG::OnPlayerEnterZone(Player* player)
{
- player->RemoveAurasDueToSpell(SPELL_ESSENCE_OF_WINTERGRASP);
if (!m_BattlefieldActive)
- {
- player->RemoveAurasDueToSpell(SPELL_RECRUIT);
- player->RemoveAurasDueToSpell(SPELL_CORPORAL);
- player->RemoveAurasDueToSpell(SPELL_LIEUTENANT);
- player->RemoveAurasDueToSpell(SPELL_TOWER_CONTROL);
- player->RemoveAurasDueToSpell(SPELL_SPIRITUAL_IMMUNITY);
- player->RemoveAurasDueToSpell(SPELL_TENACITY);
- player->RemoveAurasDueToSpell(SPELL_WINTERGRASP_RESTRICTED_FLIGHT_AREA);
- player->RemoveAurasDueToSpell(SPELL_TOWER_CONTROL);
- if (player->GetTeamId() == GetDefenderTeam())
- player->AddAura(SPELL_ESSENCE_OF_WINTERGRASP, player);
- }
+ RemoveAurasFromPlayer(player);
player->AddAura(m_DefenderTeam == TEAM_HORDE ? SPELL_HORDE_CONTROL_PHASE_SHIFT : SPELL_ALLIANCE_CONTROL_PHASE_SHIFT, player);
// Send worldstate to player
diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h
index 9d70d0b5ce4..e46bf2b7e5b 100644
--- a/src/server/game/Battlefield/Zones/BattlefieldWG.h
+++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h
@@ -383,6 +383,8 @@ class BattlefieldWG : public Battlefield
void AddBrokenTower(TeamId team);
void DoCompleteOrIncrementAchievement(uint32 achievement, Player *player, uint8 incrementNumber = 1);
+
+ void RemoveAurasFromPlayer(Player* player);
/**
* \brief Called when battlefield is setup, at server start
@@ -390,13 +392,13 @@ class BattlefieldWG : public Battlefield
bool SetupBattlefield();
/// Return pointer to relic object
- GameObject *GetRelic()
+ GameObject* GetRelic()
{
return m_relic;
}
/// Define relic object
- void SetRelic(GameObject * relic)
+ void SetRelic(GameObject* relic)
{
m_relic = relic;
}