diff options
| author | xinef1 <w.szyszko2@gmail.com> | 2017-03-02 02:19:25 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2019-08-17 20:04:14 +0200 |
| commit | 60663d1374beef3103f4787152654034fa4a8897 (patch) | |
| tree | 38e07d44442ad903a9729536942e8e253a072274 /src/server/scripts | |
| parent | 98180ecdc179386270e93b80c0db8344b659557f (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
(cherrypicked from 7567cafec84080d26ea513242a1f540a823b8f9d)
Diffstat (limited to 'src/server/scripts')
10 files changed, 26 insertions, 16 deletions
diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index e7ce8d0845f..cd7adb4be82 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "Config.h" #include "DatabaseEnv.h" #include "DatabaseLoader.h" +#include "GameTime.h" #include "GitRevision.h" #include "Language.h" #include "Log.h" @@ -34,6 +35,7 @@ EndScriptData */ #include "Player.h" #include "RBAC.h" #include "Realm.h" +#include "UpdateTime.h" #include "Util.h" #include "VMapFactory.h" #include "World.h" @@ -256,8 +258,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->PSendSysMessage("%s", GitRevision::GetFullVersion()); handler->PSendSysMessage(LANG_CONNECTED_PLAYERS, playersNum, maxPlayersNum); @@ -455,7 +457,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 4712090b032..a052063bf26 100644 --- a/src/server/scripts/Events/fireworks_show.cpp +++ b/src/server/scripts/Events/fireworks_show.cpp @@ -20,6 +20,7 @@ #include "EventMap.h" #include "GameObject.h" #include "GameObjectAI.h" +#include "GameTime.h" #include "CreatureAIImpl.h" #include "GameEventMgr.h" #include "World.h" @@ -796,7 +797,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 d2f311b9082..dec0409d601 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -1842,7 +1842,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 6a9dac9f620..3d12ac2cf67 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp @@ -15,6 +15,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "GameTime.h" #include "ScriptMgr.h" #include "InstanceScript.h" #include "Log.h" @@ -339,7 +340,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 27fb04e55eb..d320fd3cd38 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "GameEventMgr.h" +#include "GameTime.h" #include "InstanceScript.h" #include "MotionMaster.h" #include "nexus.h" @@ -171,7 +172,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 40a49f5dfef..fde729203be 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 "InstanceScript.h" #include "ObjectAccessor.h" @@ -197,7 +198,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_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index bbf86c4d9be..148009a780a 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -26,6 +26,7 @@ #include "Battleground.h" #include "CellImpl.h" #include "DB2Stores.h" +#include "GameTime.h" #include "GridNotifiersImpl.h" #include "Group.h" #include "InstanceScript.h" @@ -3589,7 +3590,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 @@ -3603,7 +3604,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/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index 51a395f73db..157137fd386 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -38,6 +38,7 @@ EndContentData */ #include "ScriptMgr.h" #include "DB2Structure.h" #include "GameObject.h" +#include "GameTime.h" #include "MotionMaster.h" #include "ObjectAccessor.h" #include "ScriptedCreature.h" @@ -320,7 +321,7 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript { uint32 triggerId = areaTrigger->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) @@ -337,7 +338,7 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript break; } - _triggerTimes[triggerId] = sWorld->GetGameTime(); + _triggerTimes[triggerId] = GameTime::GetGameTime(); return false; } @@ -376,7 +377,7 @@ class AreaTrigger_at_area_52_entrance : public AreaTriggerScript if (!player->IsAlive()) return false; - if (sWorld->GetGameTime() - _triggerTimes[areaTrigger->ID] < SUMMON_COOLDOWN) + if (GameTime::GetGameTime() - _triggerTimes[areaTrigger->ID] < SUMMON_COOLDOWN) return false; switch (areaTrigger->ID) @@ -405,7 +406,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[areaTrigger->ID] = sWorld->GetGameTime(); + _triggerTimes[areaTrigger->ID] = GameTime::GetGameTime(); return false; } diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp index 598b721dfed..a6db3b29e5f 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" @@ -94,7 +95,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 f6c83e707e0..20db17af5bc 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -49,6 +49,7 @@ EndContentData */ #include "DB2Structure.h" #include "GameObject.h" #include "GameObjectAI.h" +#include "GameTime.h" #include "Log.h" #include "Map.h" #include "MotionMaster.h" @@ -1572,7 +1573,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; |
