From d22e1d3b7aad111dd1c0aecf87f3d37d6c90c382 Mon Sep 17 00:00:00 2001 From: stfx Date: Fri, 31 Aug 2012 15:24:03 +0200 Subject: [PATCH] [12165] Move opvpmgr based capture point saving / loading to opvp class Also improve capture point locking code and fix saving lock state in NA and GH Note: Keep in mind that capture points won't be activated before you call SetCapturePointSlider() function --- src/game/BattleGround/BattleGroundEY.cpp | 8 +-- src/game/GameObject.cpp | 68 +++++++++--------------- src/game/GameObject.h | 10 ++-- src/game/OutdoorPvP/OutdoorPvP.cpp | 18 ++++++- src/game/OutdoorPvP/OutdoorPvP.h | 7 ++- src/game/OutdoorPvP/OutdoorPvPEP.cpp | 2 + src/game/OutdoorPvP/OutdoorPvPGH.cpp | 12 +++-- src/game/OutdoorPvP/OutdoorPvPHP.cpp | 2 + src/game/OutdoorPvP/OutdoorPvPMgr.cpp | 9 ++-- src/game/OutdoorPvP/OutdoorPvPMgr.h | 10 ++-- src/game/OutdoorPvP/OutdoorPvPNA.cpp | 14 ++--- src/game/OutdoorPvP/OutdoorPvPTF.cpp | 16 +++--- src/game/OutdoorPvP/OutdoorPvPZM.cpp | 2 + src/shared/revision_nr.h | 2 +- 14 files changed, 97 insertions(+), 83 deletions(-) diff --git a/src/game/BattleGround/BattleGroundEY.cpp b/src/game/BattleGround/BattleGroundEY.cpp index d1416cdf5..553b7f0a3 100644 --- a/src/game/BattleGround/BattleGroundEY.cpp +++ b/src/game/BattleGround/BattleGroundEY.cpp @@ -190,19 +190,19 @@ void BattleGroundEY::HandleGameObjectCreate(GameObject* go) { case GO_CAPTURE_POINT_BLOOD_ELF_TOWER: m_towers[NODE_BLOOD_ELF_TOWER] = go->GetObjectGuid(); - go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); + go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE); break; case GO_CAPTURE_POINT_FEL_REAVER_RUINS: m_towers[NODE_FEL_REAVER_RUINS] = go->GetObjectGuid(); - go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); + go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE); break; case GO_CAPTURE_POINT_MAGE_TOWER: m_towers[NODE_MAGE_TOWER] = go->GetObjectGuid(); - go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); + go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE); break; case GO_CAPTURE_POINT_DRAENEI_RUINS: m_towers[NODE_DRAENEI_RUINS] = go->GetObjectGuid(); - go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); + go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE); break; } } diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index b63bb81fc..c9481ce6d 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -83,16 +83,13 @@ void GameObject::AddToWorld() void GameObject::RemoveFromWorld() { - // store the slider value for non instance, non locked capture points - if (!GetMap()->IsBattleGroundOrArena()) - { - if (GetGOInfo()->type == GAMEOBJECT_TYPE_CAPTURE_POINT && m_lootState == GO_ACTIVATED) - sOutdoorPvPMgr.SetCapturePointSlider(GetEntry(), m_captureSlider); - } - ///- Remove the gameobject from the accessor if (IsInWorld()) { + // Notify the outdoor pvp script + if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId())) + outdoorPvP->HandleGameObjectRemove(this); + // Remove GO from owner if (ObjectGuid owner_guid = GetOwnerGuid()) { @@ -165,19 +162,11 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa SetGoArtKit(0); // unknown what this is SetGoAnimProgress(animprogress); - // Notify the battleground script + // Notify the battleground or outdoor pvp script if (map->IsBattleGroundOrArena()) ((BattleGroundMap*)map)->GetBG()->HandleGameObjectCreate(this); - else - { - // set initial data and activate non instance capture points - if (goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT) - SetCapturePointSlider(sOutdoorPvPMgr.GetCapturePointSliderValue(goinfo->id)); - - // Notify the outdoor pvp script - if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId())) - outdoorPvP->HandleGameObjectCreate(this); - } + else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId())) + outdoorPvP->HandleGameObjectCreate(this); // Notify the map's instance data. // Only works if you create the object in it, not if it is moves to that map. @@ -1960,32 +1949,27 @@ bool GameObject::HasStaticDBSpawnData() const return sObjectMgr.GetGOData(GetGUIDLow()) != NULL; } -void GameObject::SetCapturePointSlider(int8 value) +void GameObject::SetCapturePointSlider(float value) { GameObjectInfo const* info = GetGOInfo(); - switch (value) + // only activate non-locked capture point + if (value >= 0) { - case CAPTURE_SLIDER_ALLIANCE_LOCKED: - m_captureSlider = CAPTURE_SLIDER_ALLIANCE; - break; - case CAPTURE_SLIDER_HORDE_LOCKED: - m_captureSlider = CAPTURE_SLIDER_HORDE; - break; - default: - m_captureSlider = value; - SetLootState(GO_ACTIVATED); - break; + m_captureSlider = value; + SetLootState(GO_ACTIVATED); } + else + m_captureSlider = -value; // set the state of the capture point based on the slider value - if (m_captureSlider == CAPTURE_SLIDER_ALLIANCE) + if ((int)m_captureSlider == CAPTURE_SLIDER_ALLIANCE) m_captureState = CAPTURE_STATE_WIN_ALLIANCE; - else if (m_captureSlider == CAPTURE_SLIDER_HORDE) + else if ((int)m_captureSlider == CAPTURE_SLIDER_HORDE) m_captureState = CAPTURE_STATE_WIN_HORDE; - else if (m_captureSlider > CAPTURE_SLIDER_NEUTRAL + info->capturePoint.neutralPercent * 0.5f) + else if (m_captureSlider > CAPTURE_SLIDER_MIDDLE + info->capturePoint.neutralPercent * 0.5f) m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; - else if (m_captureSlider < CAPTURE_SLIDER_NEUTRAL - info->capturePoint.neutralPercent * 0.5f) + else if (m_captureSlider < CAPTURE_SLIDER_MIDDLE - info->capturePoint.neutralPercent * 0.5f) m_captureState = CAPTURE_STATE_PROGRESS_HORDE; else m_captureState = CAPTURE_STATE_NEUTRAL; @@ -2006,7 +1990,7 @@ void GameObject::TickCapturePoint() GuidSet tempUsers(m_UniqueUsers); uint32 neutralPercent = info->capturePoint.neutralPercent; - uint32 oldValue = m_captureSlider; + int oldValue = m_captureSlider; int rangePlayers = 0; for (std::list::iterator itr = capturingPlayers.begin(); itr != capturingPlayers.end(); ++itr) @@ -2085,7 +2069,7 @@ void GameObject::TickCapturePoint() } // return if slider did not move a whole percent - if ((uint32)m_captureSlider == oldValue) + if ((int)m_captureSlider == oldValue) return; // on retail this is also sent to newly added players even though they already received a slider value @@ -2097,13 +2081,13 @@ void GameObject::TickCapturePoint() /* WIN EVENTS */ // alliance wins tower with max points - if (m_captureState != CAPTURE_STATE_WIN_ALLIANCE && (uint32)m_captureSlider == CAPTURE_SLIDER_ALLIANCE) + if (m_captureState != CAPTURE_STATE_WIN_ALLIANCE && (int)m_captureSlider == CAPTURE_SLIDER_ALLIANCE) { eventId = info->capturePoint.winEventID1; m_captureState = CAPTURE_STATE_WIN_ALLIANCE; } // horde wins tower with max points - else if (m_captureState != CAPTURE_STATE_WIN_HORDE && (uint32)m_captureSlider == CAPTURE_SLIDER_HORDE) + else if (m_captureState != CAPTURE_STATE_WIN_HORDE && (int)m_captureSlider == CAPTURE_SLIDER_HORDE) { eventId = info->capturePoint.winEventID2; m_captureState = CAPTURE_STATE_WIN_HORDE; @@ -2111,7 +2095,7 @@ void GameObject::TickCapturePoint() /* PROGRESS EVENTS */ // alliance takes the tower from neutral, contested or horde (if there is no neutral area) to alliance - else if (m_captureState != CAPTURE_STATE_PROGRESS_ALLIANCE && m_captureSlider > CAPTURE_SLIDER_NEUTRAL + neutralPercent * 0.5f && progressFaction == ALLIANCE) + else if (m_captureState != CAPTURE_STATE_PROGRESS_ALLIANCE && m_captureSlider > CAPTURE_SLIDER_MIDDLE + neutralPercent * 0.5f && progressFaction == ALLIANCE) { eventId = info->capturePoint.progressEventID1; @@ -2124,7 +2108,7 @@ void GameObject::TickCapturePoint() m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; } // horde takes the tower from neutral, contested or alliance (if there is no neutral area) to horde - else if (m_captureState != CAPTURE_STATE_PROGRESS_HORDE && m_captureSlider < CAPTURE_SLIDER_NEUTRAL - neutralPercent * 0.5f && progressFaction == HORDE) + else if (m_captureState != CAPTURE_STATE_PROGRESS_HORDE && m_captureSlider < CAPTURE_SLIDER_MIDDLE - neutralPercent * 0.5f && progressFaction == HORDE) { eventId = info->capturePoint.progressEventID2; @@ -2139,13 +2123,13 @@ void GameObject::TickCapturePoint() /* NEUTRAL EVENTS */ // alliance takes the tower from horde to neutral - else if (m_captureState != CAPTURE_STATE_NEUTRAL && m_captureSlider >= CAPTURE_SLIDER_NEUTRAL - neutralPercent * 0.5f && m_captureSlider <= CAPTURE_SLIDER_NEUTRAL + neutralPercent * 0.5f && progressFaction == ALLIANCE) + else if (m_captureState != CAPTURE_STATE_NEUTRAL && m_captureSlider >= CAPTURE_SLIDER_MIDDLE - neutralPercent * 0.5f && m_captureSlider <= CAPTURE_SLIDER_MIDDLE + neutralPercent * 0.5f && progressFaction == ALLIANCE) { eventId = info->capturePoint.neutralEventID1; m_captureState = CAPTURE_STATE_NEUTRAL; } // horde takes the tower from alliance to neutral - else if (m_captureState != CAPTURE_STATE_NEUTRAL && m_captureSlider >= CAPTURE_SLIDER_NEUTRAL - neutralPercent * 0.5f && m_captureSlider <= CAPTURE_SLIDER_NEUTRAL + neutralPercent * 0.5f && progressFaction == HORDE) + else if (m_captureState != CAPTURE_STATE_NEUTRAL && m_captureSlider >= CAPTURE_SLIDER_MIDDLE - neutralPercent * 0.5f && m_captureSlider <= CAPTURE_SLIDER_MIDDLE + neutralPercent * 0.5f && progressFaction == HORDE) { eventId = info->capturePoint.neutralEventID2; m_captureState = CAPTURE_STATE_NEUTRAL; diff --git a/src/game/GameObject.h b/src/game/GameObject.h index bb4bb9bdf..005d03a6c 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -611,10 +611,7 @@ enum CapturePointSlider { CAPTURE_SLIDER_ALLIANCE = 100, // full alliance CAPTURE_SLIDER_HORDE = 0, // full horde - CAPTURE_SLIDER_NEUTRAL = 50, // middle - - CAPTURE_SLIDER_ALLIANCE_LOCKED = -1, // used to store additional information - CAPTURE_SLIDER_HORDE_LOCKED = -2 + CAPTURE_SLIDER_MIDDLE = 50 // middle }; class Unit; @@ -771,7 +768,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject GameObject* LookupFishingHoleAround(float range); - void SetCapturePointSlider(int8 value); + void SetCapturePointSlider(float value); + float GetCapturePointSlider() const { return m_captureSlider; } GridReference& GetGridRef() { return m_gridRef; } @@ -785,7 +783,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject // For traps/goober this: spell casting cooldown, for doors/buttons: reset time. uint32 m_captureTimer; // (msecs) timer used for capture points - float m_captureSlider; + float m_captureSlider; // capture point slider value in range of [0..100] CapturePointState m_captureState; GuidSet m_SkillupSet; // players that already have skill-up at GO use diff --git a/src/game/OutdoorPvP/OutdoorPvP.cpp b/src/game/OutdoorPvP/OutdoorPvP.cpp index 8fb94606e..214e7d7f3 100644 --- a/src/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/game/OutdoorPvP/OutdoorPvP.cpp @@ -61,7 +61,7 @@ void OutdoorPvP::HandlePlayerLeaveZone(Player* player, bool isMainZone) */ void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value) { - for (GuidZoneMap::iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) + for (GuidZoneMap::const_iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) { // only send world state update to main zone if (!itr->second) @@ -72,6 +72,20 @@ void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value) } } +void OutdoorPvP::HandleGameObjectCreate(GameObject* go) +{ + // set initial data and activate capture points + if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_CAPTURE_POINT) + go->SetCapturePointSlider(sOutdoorPvPMgr.GetCapturePointSliderValue(go->GetEntry(), CAPTURE_SLIDER_MIDDLE)); +} + +void OutdoorPvP::HandleGameObjectRemove(GameObject* go) +{ + // save capture point slider value (negative value if locked) + if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_CAPTURE_POINT) + sOutdoorPvPMgr.SetCapturePointSlider(go->GetEntry(), go->getLootState() == GO_ACTIVATED ? go->GetCapturePointSlider() : -go->GetCapturePointSlider()); +} + /** Function that handles player kills in the main outdoor pvp zones @@ -110,7 +124,7 @@ void OutdoorPvP::HandlePlayerKill(Player* killer, Player* victim) // apply a team buff for the main and affected zones void OutdoorPvP::BuffTeam(Team team, uint32 spellId, bool remove /*= false*/) { - for (GuidZoneMap::iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) + for (GuidZoneMap::const_iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) { Player* player = sObjectMgr.GetPlayer(itr->first); if (player && player->GetTeam() == team) diff --git a/src/game/OutdoorPvP/OutdoorPvP.h b/src/game/OutdoorPvP/OutdoorPvP.h index 884a80ab2..78cc26fde 100644 --- a/src/game/OutdoorPvP/OutdoorPvP.h +++ b/src/game/OutdoorPvP/OutdoorPvP.h @@ -64,9 +64,12 @@ class OutdoorPvP // handle capture objective complete virtual void HandleObjectiveComplete(uint32 /*eventId*/, std::list /*players*/, Team /*team*/) {} - // Called when a creature or gameobject is created + // Called when a creature is created virtual void HandleCreatureCreate(Creature* /*creature*/) {} - virtual void HandleGameObjectCreate(GameObject* /*go*/) {} + + // Called when a gameobject is created or removed + virtual void HandleGameObjectCreate(GameObject* /*go*/); + virtual void HandleGameObjectRemove(GameObject* /*go*/); // Called on creature death virtual void HandleCreatureDeath(Creature* /*creature*/) {} diff --git a/src/game/OutdoorPvP/OutdoorPvPEP.cpp b/src/game/OutdoorPvP/OutdoorPvPEP.cpp index b292ac941..0fa96b638 100644 --- a/src/game/OutdoorPvP/OutdoorPvPEP.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPEP.cpp @@ -109,6 +109,8 @@ void OutdoorPvPEP::HandleCreatureCreate(Creature* creature) void OutdoorPvPEP::HandleGameObjectCreate(GameObject* go) { + OutdoorPvP::HandleGameObjectCreate(go); + switch (go->GetEntry()) { case GO_TOWER_BANNER_NORTHPASS: diff --git a/src/game/OutdoorPvP/OutdoorPvPGH.cpp b/src/game/OutdoorPvP/OutdoorPvPGH.cpp index f7a696c11..27bbd243b 100644 --- a/src/game/OutdoorPvP/OutdoorPvPGH.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPGH.cpp @@ -63,6 +63,8 @@ void OutdoorPvPGH::HandleCreatureDeath(Creature* creature) void OutdoorPvPGH::HandleGameObjectCreate(GameObject* go) { + OutdoorPvP::HandleGameObjectCreate(go); + if (go->GetEntry() == GO_VENTURE_BAY_LIGHTHOUSE) { m_capturePoint = go->GetObjectGuid(); @@ -137,8 +139,9 @@ void OutdoorPvPGH::LockLighthouse(const WorldObject* objRef) { if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint)) go->SetLootState(GO_JUST_DEACTIVATED); - - sOutdoorPvPMgr.SetCapturePointSlider(m_capturePoint, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE_LOCKED : CAPTURE_SLIDER_HORDE_LOCKED); + else + // if grid is unloaded, changing the saved slider value is enough + sOutdoorPvPMgr.SetCapturePointSlider(GO_VENTURE_BAY_LIGHTHOUSE, m_zoneOwner == ALLIANCE ? -CAPTURE_SLIDER_ALLIANCE : -CAPTURE_SLIDER_HORDE); } // Handle Lighthouse unlock when the commander is killed @@ -146,8 +149,7 @@ void OutdoorPvPGH::UnlockLighthouse(const WorldObject* objRef) { if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint)) go->SetCapturePointSlider(m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); - // no banner visual update needed because it already has the correct one else - // if grid is unloaded, resetting the slider value is enough - sOutdoorPvPMgr.SetCapturePointSlider(m_capturePoint, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); + // if grid is unloaded, resetting the saved slider value is enough + sOutdoorPvPMgr.SetCapturePointSlider(GO_VENTURE_BAY_LIGHTHOUSE, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); } diff --git a/src/game/OutdoorPvP/OutdoorPvPHP.cpp b/src/game/OutdoorPvP/OutdoorPvPHP.cpp index 55e12dbe8..96943a60d 100644 --- a/src/game/OutdoorPvP/OutdoorPvPHP.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPHP.cpp @@ -80,6 +80,8 @@ void OutdoorPvPHP::HandlePlayerLeaveZone(Player* player, bool isMainZone) void OutdoorPvPHP::HandleGameObjectCreate(GameObject* go) { + OutdoorPvP::HandleGameObjectCreate(go); + switch (go->GetEntry()) { case GO_TOWER_BANNER_OVERLOOK: diff --git a/src/game/OutdoorPvP/OutdoorPvPMgr.cpp b/src/game/OutdoorPvP/OutdoorPvPMgr.cpp index beaa48933..6c776a3e4 100644 --- a/src/game/OutdoorPvP/OutdoorPvPMgr.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPMgr.cpp @@ -19,7 +19,6 @@ #include "OutdoorPvPMgr.h" #include "Policies/SingletonImp.h" #include "OutdoorPvP.h" -#include "GameObject.h" #include "World.h" #include "Log.h" #include "OutdoorPvPEP.h" @@ -170,14 +169,14 @@ void OutdoorPvPMgr::Update(uint32 diff) Function that gets the capture point slider value @param capture point entry + @param default value being returned if no saved value for the capture point was found */ -int8 OutdoorPvPMgr::GetCapturePointSliderValue(uint32 entry) +float OutdoorPvPMgr::GetCapturePointSliderValue(uint32 entry, float defaultValue) { - std::map::iterator itr = m_capturePointSlider.find(entry); - + CapturePointSliderMap::const_iterator itr = m_capturePointSlider.find(entry); if (itr != m_capturePointSlider.end()) return itr->second; // return default value if we can't find any - return CAPTURE_SLIDER_NEUTRAL; + return defaultValue; } diff --git a/src/game/OutdoorPvP/OutdoorPvPMgr.h b/src/game/OutdoorPvP/OutdoorPvPMgr.h index 97d39c958..03910b457 100644 --- a/src/game/OutdoorPvP/OutdoorPvPMgr.h +++ b/src/game/OutdoorPvP/OutdoorPvPMgr.h @@ -101,9 +101,9 @@ class OutdoorPvPMgr void Update(uint32 diff); - // Handle capture point stuff - int8 GetCapturePointSliderValue(uint32 entry); - void SetCapturePointSlider(uint32 entry, int8 value) { m_capturePointSlider[entry] = value; } + // Save and load capture point slider values + float GetCapturePointSliderValue(uint32 entry, float defaultValue); + void SetCapturePointSlider(uint32 entry, float value) { m_capturePointSlider[entry] = value; } private: // return assigned outdoor pvp script @@ -112,7 +112,9 @@ class OutdoorPvPMgr // contains all outdoor pvp scripts OutdoorPvP* m_scripts[MAX_OPVP_ID]; - std::map m_capturePointSlider; + typedef std::map CapturePointSliderMap; + + CapturePointSliderMap m_capturePointSlider; // update interval ShortIntervalTimer m_updateTimer; diff --git a/src/game/OutdoorPvP/OutdoorPvPNA.cpp b/src/game/OutdoorPvP/OutdoorPvPNA.cpp index 29d41d924..bf6109825 100644 --- a/src/game/OutdoorPvP/OutdoorPvPNA.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPNA.cpp @@ -189,6 +189,8 @@ void OutdoorPvPNA::HandleCreatureDeath(Creature* creature) void OutdoorPvPNA::HandleGameObjectCreate(GameObject* go) { + OutdoorPvP::HandleGameObjectCreate(go); + switch (go->GetEntry()) { case GO_HALAA_BANNER: @@ -523,7 +525,7 @@ void OutdoorPvPNA::Update(uint32 diff) // Handle soldiers respawn on timer - this will summon a replacement for the dead soldier void OutdoorPvPNA::RespawnSoldier() { - for (GuidZoneMap::iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) + for (GuidZoneMap::const_iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) { // Find player who is in main zone (Nagrand) to get correct map reference if (!itr->second) @@ -544,8 +546,9 @@ void OutdoorPvPNA::LockHalaa(const WorldObject* objRef) { if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint)) go->SetLootState(GO_JUST_DEACTIVATED); - - sOutdoorPvPMgr.SetCapturePointSlider(m_capturePoint, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE_LOCKED : CAPTURE_SLIDER_HORDE_LOCKED); + else + // if grid is unloaded, changing the saved slider value is enough + sOutdoorPvPMgr.SetCapturePointSlider(GO_HALAA_BANNER, m_zoneOwner == ALLIANCE ? -CAPTURE_SLIDER_ALLIANCE : -CAPTURE_SLIDER_HORDE); } // Unlock Halaa when all the soldiers are killed @@ -553,8 +556,7 @@ void OutdoorPvPNA::UnlockHalaa(const WorldObject* objRef) { if (GameObject* go = objRef->GetMap()->GetGameObject(m_capturePoint)) go->SetCapturePointSlider(m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); - // no banner visual update needed because it already has the correct one else - // if grid is unloaded, resetting the slider value is enough - sOutdoorPvPMgr.SetCapturePointSlider(m_capturePoint, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); + // if grid is unloaded, resetting the saved slider value is enough + sOutdoorPvPMgr.SetCapturePointSlider(GO_HALAA_BANNER, m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE : CAPTURE_SLIDER_HORDE); } diff --git a/src/game/OutdoorPvP/OutdoorPvPTF.cpp b/src/game/OutdoorPvP/OutdoorPvPTF.cpp index 2fef35538..c1a17cc95 100644 --- a/src/game/OutdoorPvP/OutdoorPvPTF.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPTF.cpp @@ -88,6 +88,8 @@ void OutdoorPvPTF::HandlePlayerLeaveZone(Player* player, bool isMainZone) void OutdoorPvPTF::HandleGameObjectCreate(GameObject* go) { + OutdoorPvP::HandleGameObjectCreate(go); + switch (go->GetEntry()) { case GO_TOWER_BANNER_WEST: @@ -283,7 +285,7 @@ void OutdoorPvPTF::UnlockZone() SendUpdateWorldState(WORLD_STATE_TF_TOWER_COUNT_A, m_towersAlliance); SendUpdateWorldState(WORLD_STATE_TF_TOWER_COUNT_H, m_towersHorde); - for (GuidZoneMap::iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) + for (GuidZoneMap::const_iterator itr = m_zonePlayers.begin(); itr != m_zonePlayers.end(); ++itr) { // Find player who is in main zone (Terokkar Forest) to get correct map reference if (!itr->second) @@ -345,8 +347,9 @@ void OutdoorPvPTF::LockTowers(const WorldObject* objRef) { if (GameObject* go = objRef->GetMap()->GetGameObject(m_towerBanners[i])) go->SetLootState(GO_JUST_DEACTIVATED); - - sOutdoorPvPMgr.SetCapturePointSlider(terokkarTowers[i], m_zoneOwner == ALLIANCE ? CAPTURE_SLIDER_ALLIANCE_LOCKED : CAPTURE_SLIDER_HORDE_LOCKED); + else + // if grid is unloaded, changing the saved slider value is enough + sOutdoorPvPMgr.SetCapturePointSlider(terokkarTowers[i], m_zoneOwner == ALLIANCE ? -CAPTURE_SLIDER_ALLIANCE : -CAPTURE_SLIDER_HORDE); } } @@ -357,11 +360,12 @@ void OutdoorPvPTF::ResetTowers(const WorldObject* objRef) { if (GameObject* go = objRef->GetMap()->GetGameObject(m_towerBanners[i])) { - go->SetCapturePointSlider(CAPTURE_SLIDER_NEUTRAL); + go->SetCapturePointSlider(CAPTURE_SLIDER_MIDDLE); + // visual update needed because banner still has artkit from previous owner SetBannerVisual(go, CAPTURE_ARTKIT_NEUTRAL, CAPTURE_ANIM_NEUTRAL); } else - // if grid is unloaded, resetting the slider value is enough - sOutdoorPvPMgr.SetCapturePointSlider(terokkarTowers[i], CAPTURE_SLIDER_NEUTRAL); + // if grid is unloaded, resetting the saved slider value is enough + sOutdoorPvPMgr.SetCapturePointSlider(terokkarTowers[i], CAPTURE_SLIDER_MIDDLE); } } diff --git a/src/game/OutdoorPvP/OutdoorPvPZM.cpp b/src/game/OutdoorPvP/OutdoorPvPZM.cpp index cac866d98..b4cf0d98f 100644 --- a/src/game/OutdoorPvP/OutdoorPvPZM.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPZM.cpp @@ -117,6 +117,8 @@ void OutdoorPvPZM::HandleCreatureCreate(Creature* creature) void OutdoorPvPZM::HandleGameObjectCreate(GameObject* go) { + OutdoorPvP::HandleGameObjectCreate(go); + switch (go->GetEntry()) { case GO_ZANGA_BANNER_EAST: diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 86b999778..56ec76372 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 "12164" + #define REVISION_NR "12165" #endif // __REVISION_NR_H__