aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts
diff options
context:
space:
mode:
authorxinef1 <w.szyszko2@gmail.com>2017-03-02 02:19:25 +0100
committerariel- <ariel-@users.noreply.github.com>2017-03-01 22:19:25 -0300
commit7567cafec84080d26ea513242a1f540a823b8f9d (patch)
treef6f37a7cc4d06db0dbb0e08a01f8a18cf47ac955 /src/server/scripts
parent7011aabb56f061fc889ec42ce32b7605ceb35b53 (diff)
Ensure that all actions are compared to fixed point in time (ie. world update start) (#18910)
- Actions will not be dependent on processing moment - Increased GameObjects cooldown resolution to milliseconds, fixes arming time of traps to be exactly one second and not something from range (1000, 1999) - Created GameTime namespace and UpdateTime class and moved there some code out of world
Diffstat (limited to 'src/server/scripts')
-rw-r--r--src/server/scripts/Commands/cs_server.cpp8
-rw-r--r--src/server/scripts/Events/fireworks_show.cpp3
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp2
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp3
-rw-r--r--src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp3
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp3
-rw-r--r--src/server/scripts/Spells/spell_druid.cpp9
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp5
-rw-r--r--src/server/scripts/Spells/spell_paladin.cpp3
-rw-r--r--src/server/scripts/World/areatrigger_scripts.cpp9
-rw-r--r--src/server/scripts/World/duel_reset.cpp3
-rw-r--r--src/server/scripts/World/go_scripts.cpp3
12 files changed, 33 insertions, 21 deletions
diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp
index 285ac4e3e96..50b9b37031f 100644
--- a/src/server/scripts/Commands/cs_server.cpp
+++ b/src/server/scripts/Commands/cs_server.cpp
@@ -30,6 +30,8 @@ EndScriptData */
#include "ScriptMgr.h"
#include "GitRevision.h"
#include "Util.h"
+#include "GameTime.h"
+#include "UpdateTime.h"
class server_commandscript : public CommandScript
{
@@ -108,8 +110,8 @@ public:
uint32 queuedClientsNum = sWorld->GetQueuedSessionCount();
uint32 maxActiveClientsNum = sWorld->GetMaxActiveSessionCount();
uint32 maxQueuedClientsNum = sWorld->GetMaxQueuedSessionCount();
- std::string uptime = secsToTimeString(sWorld->GetUptime());
- uint32 updateTime = sWorld->GetUpdateTime();
+ std::string uptime = secsToTimeString(GameTime::GetUptime());
+ uint32 updateTime = sWorldUpdateTime.GetLastUpdateTime();
handler->SendSysMessage(GitRevision::GetFullVersion());
handler->PSendSysMessage(LANG_CONNECTED_PLAYERS, playersNum, maxPlayersNum);
@@ -304,7 +306,7 @@ public:
if (newTime < 0)
return false;
- sWorld->SetRecordDiffInterval(newTime);
+ sWorldUpdateTime.SetRecordUpdateTimeInterval(newTime);
printf("Record diff every %i ms\n", newTime);
return true;
diff --git a/src/server/scripts/Events/fireworks_show.cpp b/src/server/scripts/Events/fireworks_show.cpp
index 85858fa569d..97c0e33b944 100644
--- a/src/server/scripts/Events/fireworks_show.cpp
+++ b/src/server/scripts/Events/fireworks_show.cpp
@@ -19,6 +19,7 @@
#include "GameObjectAI.h"
#include "CreatureAIImpl.h"
#include "GameEventMgr.h"
+#include "GameTime.h"
enum FireworksShowTypeObjects
{
@@ -792,7 +793,7 @@ public:
{
_events.Update(diff);
- time_t time = sWorld->GetGameTime();
+ time_t time = GameTime::GetGameTime();
tm localTm;
localtime_r(&time, &localTm);
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp
index 733c381271f..186920ad07c 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp
@@ -1837,7 +1837,7 @@ class spell_icc_sprit_alarm : public SpellScriptLoader
}
if (GameObject* trap = GetCaster()->FindNearestGameObject(trapId, 5.0f))
- trap->SetRespawnTime(trap->GetGOInfo()->GetAutoCloseTime());
+ trap->SetRespawnTime(trap->GetGOInfo()->GetAutoCloseTime() / IN_MILLISECONDS);
std::list<Creature*> wards;
GetCaster()->GetCreatureListWithEntryInGrid(wards, NPC_DEATHBOUND_WARD, 150.0f);
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp
index 3db0b1d4fca..c80f4e2bbea 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp
@@ -16,6 +16,7 @@
*/
#include "Player.h"
+#include "GameTime.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
@@ -327,7 +328,7 @@ struct boss_four_horsemen_baseAI : public BossAI
}
Talk(SAY_DEATH);
- _timeDied = getMSTime();
+ _timeDied = GameTime::GetGameTimeMS();
for (Horseman boss : horsemen)
{
if (Creature* cBoss = getHorsemanHandle(boss))
diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp
index d6309982d81..26a427dbbe6 100644
--- a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp
+++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp
@@ -17,6 +17,7 @@
*/
#include "GameEventMgr.h"
+#include "GameTime.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "nexus.h"
@@ -167,7 +168,7 @@ public:
while (time[i] != 0)
++i;
- time[i] = sWorld->GetGameTime();
+ time[i] = GameTime::GetGameTime();
if (i == 2 && (time[2] - time[1] < 5) && (time[1] - time[0] < 5))
++splitPersonality;
}
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp
index 30d6aa65ec5..164f6c814ca 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp
@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "GameTime.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
@@ -194,7 +195,7 @@ class boss_ignis : public CreatureScript
me->RemoveAuraFromStack(SPELL_STRENGHT);
// Shattered Achievement
- time_t secondKill = sWorld->GetGameTime();
+ time_t secondKill = GameTime::GetGameTime();
if ((secondKill - _firstConstructKill) < 5)
_shattered = true;
_firstConstructKill = secondKill;
diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp
index 7e406b86635..812cc20a971 100644
--- a/src/server/scripts/Spells/spell_druid.cpp
+++ b/src/server/scripts/Spells/spell_druid.cpp
@@ -22,6 +22,7 @@
*/
#include "Player.h"
+#include "GameTime.h"
#include "ScriptMgr.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
@@ -234,7 +235,7 @@ class spell_dru_eclipse : public SpellScriptLoader
if (!spellInfo || !(spellInfo->SpellFamilyFlags[0] & 4)) // Starfire
return false;
- return _solarProcCooldownEnd <= std::chrono::steady_clock::now();
+ return _solarProcCooldownEnd <= GameTime::GetGameTimeSteadyPoint();
}
bool CheckLunar(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
@@ -247,14 +248,14 @@ class spell_dru_eclipse : public SpellScriptLoader
if (!roll_chance_i(60))
return false;
- return _lunarProcCooldownEnd <= std::chrono::steady_clock::now();
+ return _lunarProcCooldownEnd <= GameTime::GetGameTimeSteadyPoint();
}
void ProcSolar(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
- _solarProcCooldownEnd = std::chrono::steady_clock::now() + Seconds(30);
+ _solarProcCooldownEnd = GameTime::GetGameTimeSteadyPoint() + Seconds(30);
eventInfo.GetActor()->CastSpell(eventInfo.GetActor(), SPELL_DRUID_ECLIPSE_SOLAR_PROC, TRIGGERED_FULL_MASK, nullptr, aurEff);
}
@@ -262,7 +263,7 @@ class spell_dru_eclipse : public SpellScriptLoader
{
PreventDefaultAction();
- _lunarProcCooldownEnd = std::chrono::steady_clock::now() + Seconds(30);
+ _lunarProcCooldownEnd = GameTime::GetGameTimeSteadyPoint() + Seconds(30);
eventInfo.GetActor()->CastSpell(eventInfo.GetActor(), SPELL_DRUID_ECLIPSE_LUNAR_PROC, TRIGGERED_FULL_MASK, nullptr, aurEff);
}
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index effb3fb9b5c..0a5890f4a5d 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -23,6 +23,7 @@
*/
#include "ScriptMgr.h"
+#include "GameTime.h"
#include "Battleground.h"
#include "Cell.h"
#include "CellImpl.h"
@@ -3570,7 +3571,7 @@ class spell_gen_turkey_marker : public SpellScriptLoader
void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
// store stack apply times, so we can pop them while they expire
- _applyTimes.push_back(getMSTime());
+ _applyTimes.push_back(GameTime::GetGameTimeMS());
Unit* target = GetTarget();
// on stack 15 cast the achievement crediting spell
@@ -3584,7 +3585,7 @@ class spell_gen_turkey_marker : public SpellScriptLoader
return;
// pop stack if it expired for us
- if (_applyTimes.front() + GetMaxDuration() < getMSTime())
+ if (_applyTimes.front() + GetMaxDuration() < GameTime::GetGameTimeMS())
ModStackAmount(-1, AURA_REMOVE_BY_EXPIRE);
}
diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp
index 6dc6681a7a1..20d632b3c2a 100644
--- a/src/server/scripts/Spells/spell_paladin.cpp
+++ b/src/server/scripts/Spells/spell_paladin.cpp
@@ -22,6 +22,7 @@
*/
#include "Player.h"
+#include "GameTime.h"
#include "ScriptMgr.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
@@ -1988,7 +1989,7 @@ class spell_pal_sacred_shield_dummy : public SpellScriptLoader
if (!caster)
return;
- std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
+ std::chrono::steady_clock::time_point now = GameTime::GetGameTimeSteadyPoint();
if (_cooldownEnd > now)
return;
diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp
index 72ae363c743..a3fb056ba8f 100644
--- a/src/server/scripts/World/areatrigger_scripts.cpp
+++ b/src/server/scripts/World/areatrigger_scripts.cpp
@@ -35,6 +35,7 @@ at_brewfest
at_area_52_entrance
EndContentData */
+#include "GameTime.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "Player.h"
@@ -314,7 +315,7 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript
{
uint32 triggerId = trigger->id;
// Second trigger happened too early after first, skip for now
- if (sWorld->GetGameTime() - _triggerTimes[triggerId] < AREATRIGGER_TALK_COOLDOWN)
+ if (GameTime::GetGameTime() - _triggerTimes[triggerId] < AREATRIGGER_TALK_COOLDOWN)
return false;
switch (triggerId)
@@ -331,7 +332,7 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript
break;
}
- _triggerTimes[triggerId] = sWorld->GetGameTime();
+ _triggerTimes[triggerId] = GameTime::GetGameTime();
return false;
}
@@ -371,7 +372,7 @@ class AreaTrigger_at_area_52_entrance : public AreaTriggerScript
return false;
uint32 triggerId = trigger->id;
- if (sWorld->GetGameTime() - _triggerTimes[trigger->id] < SUMMON_COOLDOWN)
+ if (GameTime::GetGameTime() - _triggerTimes[trigger->id] < SUMMON_COOLDOWN)
return false;
switch (triggerId)
@@ -400,7 +401,7 @@ class AreaTrigger_at_area_52_entrance : public AreaTriggerScript
player->SummonCreature(NPC_SPOTLIGHT, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 5000);
player->AddAura(SPELL_A52_NEURALYZER, player);
- _triggerTimes[trigger->id] = sWorld->GetGameTime();
+ _triggerTimes[trigger->id] = GameTime::GetGameTime();
return false;
}
diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp
index d792a1cb47f..3d8692780b6 100644
--- a/src/server/scripts/World/duel_reset.cpp
+++ b/src/server/scripts/World/duel_reset.cpp
@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "GameTime.h"
#include "ScriptMgr.h"
#include "Player.h"
#include "Pet.h"
@@ -103,7 +104,7 @@ class DuelResetScript : public PlayerScript
// remove cooldowns on spells that have < 10 min CD > 30 sec and has no onHold
player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool
{
- SpellHistory::Clock::time_point now = SpellHistory::Clock::now();
+ SpellHistory::Clock::time_point now = GameTime::GetGameTimeSystemPoint();
uint32 cooldownDuration = itr->second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(itr->second.CooldownEnd - now).count() : 0;
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first);
return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS
diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp
index e237b3d7286..ccdde9eb799 100644
--- a/src/server/scripts/World/go_scripts.cpp
+++ b/src/server/scripts/World/go_scripts.cpp
@@ -53,6 +53,7 @@ EndContentData */
#include "Player.h"
#include "WorldSession.h"
#include "GameEventMgr.h"
+#include "GameTime.h"
/*######
## go_cat_figurine
@@ -1644,7 +1645,7 @@ public:
{
if (eventId == GAME_EVENT_HOURLY_BELLS && start)
{
- time_t time = sWorld->GetGameTime();
+ time_t time = GameTime::GetGameTime();
tm localTm;
localtime_r(&time, &localTm);
uint8 _rings = (localTm.tm_hour - 1) % 12 + 1;