aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/World
diff options
context:
space:
mode:
authorxinef1 <w.szyszko2@gmail.com>2017-03-02 02:19:25 +0100
committerShauren <shauren.trinity@gmail.com>2019-08-17 20:04:14 +0200
commit60663d1374beef3103f4787152654034fa4a8897 (patch)
tree38e07d44442ad903a9729536942e8e253a072274 /src/server/scripts/World
parent98180ecdc179386270e93b80c0db8344b659557f (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/World')
-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
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 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;