aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw12x <none@none>2008-12-22 18:36:25 +0100
committerw12x <none@none>2008-12-22 18:36:25 +0100
commit657ee403e37eae8cf0af89f09c44c64169c97234 (patch)
tree305ffbd5c2e82108359c668f7f07ea75c22e00f7
parent65ef38963ddc60e05491ca9d3e2685913c0038bb (diff)
Performance improvements in outdoorpvp handling.
--HG-- branch : trunk
-rw-r--r--src/game/OutdoorPvP.cpp8
-rw-r--r--src/game/OutdoorPvP.h6
-rw-r--r--src/game/OutdoorPvPEP.cpp16
-rw-r--r--src/game/OutdoorPvPHP.cpp8
-rw-r--r--src/game/OutdoorPvPMgr.cpp25
-rw-r--r--src/game/OutdoorPvPMgr.h6
-rw-r--r--src/game/OutdoorPvPNA.cpp4
-rw-r--r--src/game/OutdoorPvPTF.cpp12
-rw-r--r--src/game/OutdoorPvPZM.cpp8
9 files changed, 46 insertions, 47 deletions
diff --git a/src/game/OutdoorPvP.cpp b/src/game/OutdoorPvP.cpp
index df72ed28140..8d99fa4c165 100644
--- a/src/game/OutdoorPvP.cpp
+++ b/src/game/OutdoorPvP.cpp
@@ -28,7 +28,7 @@
OutdoorPvPObjective::OutdoorPvPObjective(OutdoorPvP * pvp)
: m_PvP(pvp), m_AllianceActivePlayerCount(0), m_HordeActivePlayerCount(0),
-m_ShiftTimer(0), m_ShiftPhase(0), m_ShiftMaxPhase(0), m_OldPhase(0),
+m_ShiftPhase(0), m_ShiftMaxPhase(0), m_OldPhase(0),
m_State(0), m_OldState(0), m_CapturePoint(0), m_NeutralValue(0), m_ShiftMaxCaptureSpeed(0), m_CapturePointCreature(0)
{
}
@@ -456,9 +456,6 @@ bool OutdoorPvP::Update(uint32 diff)
bool OutdoorPvPObjective::Update(uint32 diff)
{
uint32 Challenger = 0;
- if(m_ShiftTimer<diff)
- {
- m_ShiftTimer = OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
// get the difference of numbers
float fact_diff = (m_AllianceActivePlayerCount - m_HordeActivePlayerCount);
@@ -526,9 +523,6 @@ bool OutdoorPvPObjective::Update(uint32 diff)
}
return true;
- } else m_ShiftTimer-=diff;
-
- return false;
}
bool OutdoorPvPObjective::HandleCaptureCreaturePlayerMoveInLos(Player * p, Creature * c)
diff --git a/src/game/OutdoorPvP.h b/src/game/OutdoorPvP.h
index 870d79624ca..2ba5c0dadf0 100644
--- a/src/game/OutdoorPvP.h
+++ b/src/game/OutdoorPvP.h
@@ -24,8 +24,6 @@
#include <map>
#include <set>
-#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL 1000
-
#define OPVP_TRIGGER_CREATURE_ENTRY 12999
enum ObjectiveStates{
@@ -133,8 +131,6 @@ protected:
std::set<uint64> m_ActivePlayerGuids;
int32 m_AllianceActivePlayerCount;
int32 m_HordeActivePlayerCount;
- // time left to capture the objective
- uint32 m_ShiftTimer;
// total shift needed to capture the objective
float m_ShiftMaxPhase;
// maximum speed of capture
@@ -173,7 +169,7 @@ public:
// deletes all gos/creatures spawned by the pvp
void DeleteSpawns();
- typedef std::set<OutdoorPvPObjective *> OutdoorPvPObjectiveSet;
+ typedef std::vector<OutdoorPvPObjective *> OutdoorPvPObjectiveSet;
// called from Player::UpdateZone to add / remove buffs given by outdoor pvp events
virtual void HandlePlayerEnterZone(Player * plr, uint32 zone);
diff --git a/src/game/OutdoorPvPEP.cpp b/src/game/OutdoorPvPEP.cpp
index d2d58ea00f3..efc132aee0b 100644
--- a/src/game/OutdoorPvPEP.cpp
+++ b/src/game/OutdoorPvPEP.cpp
@@ -121,7 +121,7 @@ bool OutdoorPvPObjectiveEP_EWT::Update(uint32 diff)
// send this too, sometimes it resets :S
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
}
- return true;
+ return m_OldState != m_State;
}
return false;
}
@@ -296,7 +296,7 @@ bool OutdoorPvPObjectiveEP_NPT::Update(uint32 diff)
// send this too, sometimes it resets :S
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
}
- return true;
+ return m_OldState != m_State;
}
return false;
}
@@ -463,7 +463,7 @@ bool OutdoorPvPObjectiveEP_CGT::Update(uint32 diff)
// send this too, sometimes it resets :S
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
}
- return true;
+ return m_OldState != m_State;
}
return false;
}
@@ -629,7 +629,7 @@ bool OutdoorPvPObjectiveEP_PWT::Update(uint32 diff)
// send this too, sometimes it resets :S
SendUpdateWorldState(EP_UI_TOWER_SLIDER_N, m_NeutralValue);
}
- return true;
+ return m_OldState != m_State;
}
return false;
}
@@ -791,10 +791,10 @@ bool OutdoorPvPEP::SetupOutdoorPvP()
for(int i = 0; i < EPBuffZonesNum; ++i)
sOutdoorPvPMgr.AddZone(EPBuffZones[i],this);
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveEP_EWT(this));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveEP_PWT(this));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveEP_CGT(this));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveEP_NPT(this));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveEP_EWT(this));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveEP_PWT(this));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveEP_CGT(this));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveEP_NPT(this));
return true;
}
diff --git a/src/game/OutdoorPvPHP.cpp b/src/game/OutdoorPvPHP.cpp
index 5c59bb6b5e6..846e23c8107 100644
--- a/src/game/OutdoorPvPHP.cpp
+++ b/src/game/OutdoorPvPHP.cpp
@@ -72,11 +72,11 @@ bool OutdoorPvPHP::SetupOutdoorPvP()
for(int i = 0; i < OutdoorPvPHPBuffZonesNum; ++i)
sOutdoorPvPMgr.AddZone(OutdoorPvPHPBuffZones[i],this);
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveHP(this,HP_TOWER_BROKEN_HILL));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveHP(this,HP_TOWER_BROKEN_HILL));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveHP(this,HP_TOWER_OVERLOOK));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveHP(this,HP_TOWER_OVERLOOK));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveHP(this,HP_TOWER_STADIUM));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveHP(this,HP_TOWER_STADIUM));
return true;
}
@@ -277,7 +277,7 @@ bool OutdoorPvPObjectiveHP::Update(uint32 diff)
// send this too, sometimes the slider disappears, dunno why :(
SendUpdateWorldState(HP_UI_TOWER_SLIDER_DISPLAY, 1);
}
- return true;
+ return m_OldState != m_State;
}
return false;
}
diff --git a/src/game/OutdoorPvPMgr.cpp b/src/game/OutdoorPvPMgr.cpp
index 70a7d796e96..64a9649dae8 100644
--- a/src/game/OutdoorPvPMgr.cpp
+++ b/src/game/OutdoorPvPMgr.cpp
@@ -30,6 +30,7 @@ INSTANTIATE_SINGLETON_1( OutdoorPvPMgr );
OutdoorPvPMgr::OutdoorPvPMgr()
{
+ m_UpdateTimer = OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
//sLog.outDebug("Instantiating OutdoorPvPMgr");
}
@@ -54,7 +55,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
}
else
{
- m_OutdoorPvPSet.insert(pOP);
+ m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : HP successfully initiated.");
}
@@ -68,7 +69,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
}
else
{
- m_OutdoorPvPSet.insert(pOP);
+ m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : NA successfully initiated.");
}
@@ -82,7 +83,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
}
else
{
- m_OutdoorPvPSet.insert(pOP);
+ m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : TF successfully initiated.");
}
@@ -95,7 +96,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
}
else
{
- m_OutdoorPvPSet.insert(pOP);
+ m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : ZM successfully initiated.");
}
@@ -108,7 +109,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
}
else
{
- m_OutdoorPvPSet.insert(pOP);
+ m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : SI successfully initiated.");
}
@@ -121,7 +122,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
}
else
{
- m_OutdoorPvPSet.insert(pOP);
+ m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : EP successfully initiated.");
}
}
@@ -172,10 +173,14 @@ OutdoorPvP * OutdoorPvPMgr::GetOutdoorPvPToZoneId(uint32 zoneid)
void OutdoorPvPMgr::Update(uint32 diff)
{
- for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
- {
- (*itr)->Update(diff);
- }
+ if(m_UpdateTimer < diff)
+ {
+ for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
+ {
+ (*itr)->Update(diff);
+ }
+ m_UpdateTimer = OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
+ } else m_UpdateTimer -= diff;
}
bool OutdoorPvPMgr::HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go)
diff --git a/src/game/OutdoorPvPMgr.h b/src/game/OutdoorPvPMgr.h
index 4b2f914d3e6..8c058d8fc19 100644
--- a/src/game/OutdoorPvPMgr.h
+++ b/src/game/OutdoorPvPMgr.h
@@ -19,6 +19,8 @@
#ifndef OUTDOOR_PVP_MGR_H_
#define OUTDOOR_PVP_MGR_H_
+#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL 1000
+
#include "OutdoorPvP.h"
#include "Policies/Singleton.h"
@@ -61,7 +63,7 @@ public:
void HandleDropFlag(Player * plr, uint32 spellId);
- typedef std::set<OutdoorPvP*> OutdoorPvPSet;
+ typedef std::vector<OutdoorPvP*> OutdoorPvPSet;
typedef std::map<uint32 /* zoneid */, OutdoorPvP*> OutdoorPvPMap;
private:
// contains all initiated outdoor pvp events
@@ -70,6 +72,8 @@ private:
// maps the zone ids to an outdoor pvp event
// used in player event handling
OutdoorPvPMap m_OutdoorPvPMap;
+ // update interval
+ float m_UpdateTimer;
};
#define sOutdoorPvPMgr Trinity::Singleton<OutdoorPvPMgr>::Instance()
diff --git a/src/game/OutdoorPvPNA.cpp b/src/game/OutdoorPvPNA.cpp
index 9c29e28e088..b3049f29ed5 100644
--- a/src/game/OutdoorPvPNA.cpp
+++ b/src/game/OutdoorPvPNA.cpp
@@ -262,7 +262,7 @@ bool OutdoorPvPNA::SetupOutdoorPvP()
m_obj = new OutdoorPvPObjectiveNA(this);
if(!m_obj)
return false;
- m_OutdoorPvPObjectives.insert(m_obj);
+ m_OutdoorPvPObjectives.push_back(m_obj);
return true;
}
@@ -660,7 +660,7 @@ bool OutdoorPvPObjectiveNA::Update(uint32 diff)
SendUpdateWorldState(NA_UI_TOWER_SLIDER_POS, phase);
SendUpdateWorldState(NA_UI_TOWER_SLIDER_N, m_NeutralValue);
}
- return true;
+ return m_OldState != m_State;
}
return false;
}
diff --git a/src/game/OutdoorPvPTF.cpp b/src/game/OutdoorPvPTF.cpp
index 6a372ab73bc..a44b0e6642a 100644
--- a/src/game/OutdoorPvPTF.cpp
+++ b/src/game/OutdoorPvPTF.cpp
@@ -278,11 +278,11 @@ bool OutdoorPvPTF::SetupOutdoorPvP()
for(int i = 0; i < OutdoorPvPTFBuffZonesNum; ++i)
sOutdoorPvPMgr.AddZone(OutdoorPvPTFBuffZones[i],this);
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveTF(this,TF_TOWER_NW));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveTF(this,TF_TOWER_N));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveTF(this,TF_TOWER_NE));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveTF(this,TF_TOWER_SE));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveTF(this,TF_TOWER_S));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveTF(this,TF_TOWER_NW));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveTF(this,TF_TOWER_N));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveTF(this,TF_TOWER_NE));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveTF(this,TF_TOWER_SE));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveTF(this,TF_TOWER_S));
return true;
}
@@ -360,7 +360,7 @@ bool OutdoorPvPObjectiveTF::Update(uint32 diff)
// send this too, sometimes it resets :S
SendUpdateWorldState(TF_UI_TOWER_SLIDER_N, m_NeutralValue);
}
- return true;
+ return m_OldState != m_State;
}
return false;
}
diff --git a/src/game/OutdoorPvPZM.cpp b/src/game/OutdoorPvPZM.cpp
index 071a008225f..076b0325835 100644
--- a/src/game/OutdoorPvPZM.cpp
+++ b/src/game/OutdoorPvPZM.cpp
@@ -142,7 +142,7 @@ bool OutdoorPvPObjectiveZM_Beacon::Update(uint32 diff)
SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_pos, phase);
SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_n, m_NeutralValue);
}
- return true;
+ return m_OldState != m_State;
}
return false;
}
@@ -205,10 +205,10 @@ bool OutdoorPvPZM::SetupOutdoorPvP()
for(int i = 0; i < OutdoorPvPZMBuffZonesNum; ++i)
sOutdoorPvPMgr.AddZone(OutdoorPvPZMBuffZones[i],this);
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveZM_Beacon(this,ZM_BEACON_WEST));
- m_OutdoorPvPObjectives.insert(new OutdoorPvPObjectiveZM_Beacon(this,ZM_BEACON_EAST));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveZM_Beacon(this,ZM_BEACON_WEST));
+ m_OutdoorPvPObjectives.push_back(new OutdoorPvPObjectiveZM_Beacon(this,ZM_BEACON_EAST));
m_GraveYard = new OutdoorPvPObjectiveZM_GraveYard(this);
- m_OutdoorPvPObjectives.insert(m_GraveYard); // though the update function isn't used, the handleusego is!
+ m_OutdoorPvPObjectives.push_back(m_GraveYard); // though the update function isn't used, the handleusego is!
return true;
}