diff options
| author | xinef1 <w.szyszko2@gmail.com> | 2017-03-02 02:19:25 +0100 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2017-03-01 22:19:25 -0300 |
| commit | 7567cafec84080d26ea513242a1f540a823b8f9d (patch) | |
| tree | f6f37a7cc4d06db0dbb0e08a01f8a18cf47ac955 /src/server/scripts/World | |
| parent | 7011aabb56f061fc889ec42ce32b7605ceb35b53 (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/World')
| -rw-r--r-- | src/server/scripts/World/areatrigger_scripts.cpp | 9 | ||||
| -rw-r--r-- | src/server/scripts/World/duel_reset.cpp | 3 | ||||
| -rw-r--r-- | src/server/scripts/World/go_scripts.cpp | 3 |
3 files changed, 9 insertions, 6 deletions
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; |
