From 12701cb0c6c45eb105ad449eb9a56e76d84d691e Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 10 Dec 2017 12:39:37 +0100 Subject: Core/Misc: Replace time(NULL) with GameTime::GetGameTime() --- src/server/scripts/Commands/cs_ban.cpp | 5 ++-- src/server/scripts/Commands/cs_event.cpp | 5 ++-- src/server/scripts/Commands/cs_gobject.cpp | 3 +- src/server/scripts/Commands/cs_instance.cpp | 7 +++-- src/server/scripts/Commands/cs_list.cpp | 5 ++-- src/server/scripts/Commands/cs_misc.cpp | 6 ++-- src/server/scripts/Commands/cs_npc.cpp | 3 +- .../boss_icecrown_gunship_battle.cpp | 32 +++++++++++----------- .../VaultOfArchavon/instance_vault_of_archavon.cpp | 7 +++-- src/server/scripts/Northrend/zone_wintergrasp.cpp | 3 +- src/server/scripts/Spells/spell_item.cpp | 2 +- src/server/scripts/World/npcs_special.cpp | 4 +-- 12 files changed, 45 insertions(+), 37 deletions(-) (limited to 'src/server/scripts') diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index 82a6ed477d8..3055a341375 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "CharacterCache.h" #include "Chat.h" #include "DatabaseEnv.h" +#include "GameTime.h" #include "Language.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" @@ -284,7 +285,7 @@ public: time_t unbanDate = time_t(fields[3].GetUInt32()); bool active = false; - if (fields[2].GetBool() && (fields[1].GetUInt64() == uint64(0) || unbanDate >= time(nullptr))) + if (fields[2].GetBool() && (fields[1].GetUInt64() == uint64(0) || unbanDate >= GameTime::GetGameTime())) active = true; bool permanent = (fields[1].GetUInt64() == uint64(0)); std::string banTime = permanent ? handler->GetTrinityString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt64(), true); @@ -342,7 +343,7 @@ public: Field* fields = result->Fetch(); time_t unbanDate = time_t(fields[3].GetUInt32()); bool active = false; - if (fields[2].GetUInt8() && (!fields[1].GetUInt32() || unbanDate >= time(nullptr))) + if (fields[2].GetUInt8() && (!fields[1].GetUInt32() || unbanDate >= GameTime::GetGameTime())) active = true; bool permanent = (fields[1].GetUInt32() == uint32(0)); std::string banTime = permanent ? handler->GetTrinityString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt32(), true); diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index 3612bc17e66..9ecae6c7bc7 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -25,6 +25,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" #include "GameEventMgr.h" +#include "GameTime.h" #include "Language.h" #include "Player.h" #include "RBAC.h" @@ -116,8 +117,8 @@ public: std::string endTimeStr = TimeToTimestampStr(eventData.end); uint32 delay = sGameEventMgr->NextCheck(eventId); - time_t nextTime = time(nullptr) + delay; - std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(nullptr) + delay) : "-"; + time_t nextTime = GameTime::GetGameTime() + delay; + std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(GameTime::GetGameTime() + delay) : "-"; std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE); std::string lengthStr = secsToTimeString(eventData.length * MINUTE); diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index fd4baf69037..971c7f4291f 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "DatabaseEnv.h" #include "DBCStores.h" #include "GameEventMgr.h" +#include "GameTime.h" #include "Language.h" #include "Log.h" #include "MapManager.h" @@ -327,7 +328,7 @@ public: if (target) { - int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - time(nullptr)); + int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - GameTime::GetGameTime()); if (curRespawnDelay < 0) curRespawnDelay = 0; diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp index 6855fe21efc..ae13150a726 100644 --- a/src/server/scripts/Commands/cs_instance.cpp +++ b/src/server/scripts/Commands/cs_instance.cpp @@ -24,6 +24,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" +#include "GameTime.h" #include "Group.h" #include "InstanceSaveMgr.h" #include "InstanceScript.h" @@ -85,7 +86,7 @@ public: for (Player::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr) { InstanceSave* save = itr->second.save; - std::string timeleft = GetTimeString(save->GetResetTime() - time(nullptr)); + std::string timeleft = GetTimeString(save->GetResetTime() - GameTime::GetGameTime()); handler->PSendSysMessage(LANG_COMMAND_LIST_BIND_INFO, itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", itr->second.extendState == EXTEND_STATE_EXPIRED ? "expired" : itr->second.extendState == EXTEND_STATE_EXTENDED ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); counter++; } @@ -101,7 +102,7 @@ public: for (Group::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr) { InstanceSave* save = itr->second.save; - std::string timeleft = GetTimeString(save->GetResetTime() - time(nullptr)); + std::string timeleft = GetTimeString(save->GetResetTime() - GameTime::GetGameTime()); handler->PSendSysMessage(LANG_COMMAND_LIST_BIND_INFO, itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", "-", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); counter++; } @@ -144,7 +145,7 @@ public: InstanceSave* save = itr->second.save; if (itr->first != player->GetMapId() && (!MapId || MapId == itr->first) && (diff == -1 || diff == save->GetDifficulty())) { - std::string timeleft = GetTimeString(save->GetResetTime() - time(nullptr)); + std::string timeleft = GetTimeString(save->GetResetTime() - GameTime::GetGameTime()); handler->PSendSysMessage(LANG_COMMAND_INST_UNBIND_UNBINDING, itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); player->UnbindInstance(itr, Difficulty(i)); counter++; diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index a61e15740d4..9a72ab0fafd 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -29,6 +29,7 @@ EndScriptData */ #include "DatabaseEnv.h" #include "DBCStores.h" #include "GameObject.h" +#include "GameTime.h" #include "Language.h" #include "MapManager.h" #include "ObjectAccessor.h" @@ -713,7 +714,7 @@ public: uint32 gridY = ri->gridId / MAX_NUMBER_OF_GRIDS; uint32 gridX = ri->gridId % MAX_NUMBER_OF_GRIDS; - std::string respawnTime = ri->respawnTime > time(NULL) ? secsToTimeString(uint64(ri->respawnTime - time(nullptr)), true) : stringOverdue; + std::string respawnTime = ri->respawnTime > GameTime::GetGameTime() ? secsToTimeString(uint64(ri->respawnTime - GameTime::GetGameTime()), true) : stringOverdue; handler->PSendSysMessage("%u | %u | [%02u,%02u] | %s (%u) | %s", ri->spawnId, ri->entry, gridX, gridY, GetZoneName(ri->zoneId, handler->GetSessionDbcLocale()), ri->zoneId, map->IsSpawnGroupActive(data->spawnGroupData->groupId) ? respawnTime.c_str() : "inactive"); } @@ -734,7 +735,7 @@ public: uint32 gridY = ri->gridId / MAX_NUMBER_OF_GRIDS; uint32 gridX = ri->gridId % MAX_NUMBER_OF_GRIDS; - std::string respawnTime = ri->respawnTime > time(NULL) ? secsToTimeString(uint64(ri->respawnTime - time(nullptr)), true) : stringOverdue; + std::string respawnTime = ri->respawnTime > GameTime::GetGameTime() ? secsToTimeString(uint64(ri->respawnTime - GameTime::GetGameTime()), true) : stringOverdue; handler->PSendSysMessage("%u | %u | [% 02u, % 02u] | %s (%u) | %s", ri->spawnId, ri->entry, gridX, gridY, GetZoneName(ri->zoneId, handler->GetSessionDbcLocale()), ri->zoneId, map->IsSpawnGroupActive(data->spawnGroupData->groupId) ? respawnTime.c_str() : "inactive"); } return true; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 95d7c9e4e27..5aa53c3ded9 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1796,11 +1796,11 @@ public: // Output III. LANG_PINFO_BANNED if ban exists and is applied if (banTime >= 0) - handler->PSendSysMessage(LANG_PINFO_BANNED, banType.c_str(), banReason.c_str(), banTime > 0 ? secsToTimeString(banTime - time(nullptr), true).c_str() : handler->GetTrinityString(LANG_PERMANENTLY), bannedBy.c_str()); + handler->PSendSysMessage(LANG_PINFO_BANNED, banType.c_str(), banReason.c_str(), banTime > 0 ? secsToTimeString(banTime - GameTime::GetGameTime(), true).c_str() : handler->GetTrinityString(LANG_PERMANENTLY), bannedBy.c_str()); // Output IV. LANG_PINFO_MUTED if mute is applied if (muteTime > 0) - handler->PSendSysMessage(LANG_PINFO_MUTED, muteReason.c_str(), secsToTimeString(muteTime - time(nullptr), true).c_str(), muteBy.c_str()); + handler->PSendSysMessage(LANG_PINFO_MUTED, muteReason.c_str(), secsToTimeString(muteTime - GameTime::GetGameTime(), true).c_str(), muteBy.c_str()); // Output V. LANG_PINFO_ACC_ACCOUNT handler->PSendSysMessage(LANG_PINFO_ACC_ACCOUNT, userName.c_str(), accId, security); @@ -1973,7 +1973,7 @@ public: if (target) { // Target is online, mute will be in effect right away. - int64 muteTime = time(nullptr) + notSpeakTime * MINUTE; + int64 muteTime = GameTime::GetGameTime() + notSpeakTime * MINUTE; target->GetSession()->m_muteTime = muteTime; stmt->setInt64(0, muteTime); std::string nameLink = handler->playerLink(targetName); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 28feb02715e..df9b778f283 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -27,6 +27,7 @@ EndScriptData */ #include "CreatureAI.h" #include "CreatureGroups.h" #include "DatabaseEnv.h" +#include "GameTime.h" #include "Language.h" #include "Log.h" #include "Map.h" @@ -775,7 +776,7 @@ public: uint32 nativeid = target->GetNativeDisplayId(); uint32 Entry = target->GetEntry(); - int64 curRespawnDelay = target->GetRespawnCompatibilityMode() ? target->GetRespawnTimeEx() - time(nullptr) : target->GetMap()->GetCreatureRespawnTime(target->GetSpawnId()) - time(nullptr); + int64 curRespawnDelay = target->GetRespawnCompatibilityMode() ? target->GetRespawnTimeEx() - GameTime::GetGameTime() : target->GetMap()->GetCreatureRespawnTime(target->GetSpawnId()) - GameTime::GetGameTime(); if (curRespawnDelay < 0) curRespawnDelay = 0; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index e344a3181fc..8dd5d0e6624 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -404,7 +404,7 @@ public: return false; bool summoned = false; - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); for (int32 i = first; i <= last; ++i) { if (_respawnCooldowns[i] > now) @@ -432,7 +432,7 @@ public: void ClearSlot(PassengerSlots slot) { _controlledSlots[slot].Clear(); - _respawnCooldowns[slot] = time(nullptr) + _slotInfo[slot].Cooldown; + _respawnCooldowns[slot] = GameTime::GetGameTime() + _slotInfo[slot].Cooldown; } bool SlotsNeedRefill(PassengerSlots first, PassengerSlots last) const @@ -859,7 +859,7 @@ class npc_high_overlord_saurfang_igb : public CreatureScript _controller.SetTransport(creature->GetTransport()); me->SetRegenerateHealth(false); me->m_CombatDistance = 70.0f; - _firstMageCooldown = time(nullptr) + 60; + _firstMageCooldown = GameTime::GetGameTime() + 60; _axethrowersYellCooldown = time_t(0); _rocketeersYellCooldown = time_t(0); } @@ -869,7 +869,7 @@ class npc_high_overlord_saurfang_igb : public CreatureScript ScriptedAI::InitializeAI(); _events.Reset(); - _firstMageCooldown = time(nullptr) + 60; + _firstMageCooldown = GameTime::GetGameTime() + 60; _axethrowersYellCooldown = time_t(0); _rocketeersYellCooldown = time_t(0); } @@ -921,7 +921,7 @@ class npc_high_overlord_saurfang_igb : public CreatureScript } else if (action == ACTION_SPAWN_MAGE) { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); if (_firstMageCooldown > now) _events.ScheduleEvent(EVENT_SUMMON_MAGE, (_firstMageCooldown - now) * IN_MILLISECONDS); else @@ -1055,10 +1055,10 @@ class npc_high_overlord_saurfang_igb : public CreatureScript case EVENT_CHECK_RIFLEMAN: if (_controller.SummonCreatures(SLOT_RIFLEMAN_1, Is25ManRaid() ? SLOT_RIFLEMAN_8 : SLOT_RIFLEMAN_4)) { - if (_axethrowersYellCooldown < time(nullptr)) + if (_axethrowersYellCooldown < GameTime::GetGameTime()) { Talk(SAY_SAURFANG_AXETHROWERS); - _axethrowersYellCooldown = time(nullptr) + 5; + _axethrowersYellCooldown = GameTime::GetGameTime() + 5; } } _events.ScheduleEvent(EVENT_CHECK_RIFLEMAN, 1000); @@ -1066,10 +1066,10 @@ class npc_high_overlord_saurfang_igb : public CreatureScript case EVENT_CHECK_MORTAR: if (_controller.SummonCreatures(SLOT_MORTAR_1, Is25ManRaid() ? SLOT_MORTAR_4 : SLOT_MORTAR_2)) { - if (_rocketeersYellCooldown < time(nullptr)) + if (_rocketeersYellCooldown < GameTime::GetGameTime()) { Talk(SAY_SAURFANG_ROCKETEERS); - _rocketeersYellCooldown = time(nullptr) + 5; + _rocketeersYellCooldown = GameTime::GetGameTime() + 5; } } _events.ScheduleEvent(EVENT_CHECK_MORTAR, 1000); @@ -1128,7 +1128,7 @@ class npc_muradin_bronzebeard_igb : public CreatureScript _controller.SetTransport(creature->GetTransport()); me->SetRegenerateHealth(false); me->m_CombatDistance = 70.0f; - _firstMageCooldown = time(nullptr) + 60; + _firstMageCooldown = GameTime::GetGameTime() + 60; _riflemanYellCooldown = time_t(0); _mortarYellCooldown = time_t(0); } @@ -1138,7 +1138,7 @@ class npc_muradin_bronzebeard_igb : public CreatureScript ScriptedAI::InitializeAI(); _events.Reset(); - _firstMageCooldown = time(nullptr) + 60; + _firstMageCooldown = GameTime::GetGameTime() + 60; _riflemanYellCooldown = time_t(0); _mortarYellCooldown = time_t(0); } @@ -1190,7 +1190,7 @@ class npc_muradin_bronzebeard_igb : public CreatureScript } else if (action == ACTION_SPAWN_MAGE) { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); if (_firstMageCooldown > now) _events.ScheduleEvent(EVENT_SUMMON_MAGE, (_firstMageCooldown - now) * IN_MILLISECONDS); else @@ -1328,10 +1328,10 @@ class npc_muradin_bronzebeard_igb : public CreatureScript case EVENT_CHECK_RIFLEMAN: if (_controller.SummonCreatures(SLOT_RIFLEMAN_1, Is25ManRaid() ? SLOT_RIFLEMAN_8 : SLOT_RIFLEMAN_4)) { - if (_riflemanYellCooldown < time(nullptr)) + if (_riflemanYellCooldown < GameTime::GetGameTime()) { Talk(SAY_MURADIN_RIFLEMAN); - _riflemanYellCooldown = time(nullptr) + 5; + _riflemanYellCooldown = GameTime::GetGameTime() + 5; } } _events.ScheduleEvent(EVENT_CHECK_RIFLEMAN, 1000); @@ -1339,10 +1339,10 @@ class npc_muradin_bronzebeard_igb : public CreatureScript case EVENT_CHECK_MORTAR: if (_controller.SummonCreatures(SLOT_MORTAR_1, Is25ManRaid() ? SLOT_MORTAR_4 : SLOT_MORTAR_2)) { - if (_mortarYellCooldown < time(nullptr)) + if (_mortarYellCooldown < GameTime::GetGameTime()) { Talk(SAY_MURADIN_MORTAR); - _mortarYellCooldown = time(nullptr) + 5; + _mortarYellCooldown = GameTime::GetGameTime() + 5; } } _events.ScheduleEvent(EVENT_CHECK_MORTAR, 1000); diff --git a/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp index df562d81546..b301dfadb13 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp @@ -16,6 +16,7 @@ */ #include "ScriptMgr.h" +#include "GameTime.h" #include "InstanceScript.h" #include "Map.h" #include "vault_of_archavon.h" @@ -65,13 +66,13 @@ class instance_vault_of_archavon : public InstanceMapScript switch (type) { case DATA_ARCHAVON: - ArchavonDeath = time(nullptr); + ArchavonDeath = GameTime::GetGameTime(); break; case DATA_EMALON: - EmalonDeath = time(nullptr); + EmalonDeath = GameTime::GetGameTime(); break; case DATA_KORALON: - KoralonDeath = time(nullptr); + KoralonDeath = GameTime::GetGameTime(); break; default: return true; diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index 051b346c83e..45aaa4c6721 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -22,6 +22,7 @@ #include "DBCStores.h" #include "GameObject.h" #include "GameObjectAI.h" +#include "GameTime.h" #include "ObjectMgr.h" #include "Player.h" #include "ScriptedCreature.h" @@ -309,7 +310,7 @@ class npc_wg_queue : public CreatureScript else { uint32 timer = wintergrasp->GetTimer() / 1000; - player->SendUpdateWorldState(4354, time(nullptr) + timer); + player->SendUpdateWorldState(4354, GameTime::GetGameTime() + timer); if (timer < 15 * MINUTE) { AddGossipItemFor(player, GOSSIP_ICON_CHAT, player->GetSession()->GetTrinityString(WG_NPCQUEUE_TEXTOPTION_JOIN), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 7756983e089..a2f5acf5be3 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -2378,7 +2378,7 @@ class spell_item_crystal_prison_dummy_dnd : public SpellScript if (Creature* target = GetHitCreature()) if (target->isDead() && !target->IsPet()) { - GetCaster()->SummonGameObject(OBJECT_IMPRISONED_DOOMGUARD, *target, QuaternionData(), uint32(target->GetRespawnTime()-time(nullptr))); + GetCaster()->SummonGameObject(OBJECT_IMPRISONED_DOOMGUARD, *target, QuaternionData(), uint32(target->GetRespawnTime() - GameTime::GetGameTime())); target->DespawnOrUnsummon(); } } diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index f7b6173ea22..047149f1f00 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -1791,7 +1791,7 @@ public: void DamageTaken(Unit* doneBy, uint32& damage) override { AddThreat(doneBy, float(damage)); // just to create threat reference - _damageTimes[doneBy->GetGUID()] = time(nullptr); + _damageTimes[doneBy->GetGUID()] = GameTime::GetGameTime(); damage = 0; } @@ -1811,7 +1811,7 @@ public: { case EVENT_TD_CHECK_COMBAT: { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); for (std::unordered_map::iterator itr = _damageTimes.begin(); itr != _damageTimes.end();) { // If unit has not dealt damage to training dummy for 5 seconds, remove him from combat -- cgit v1.2.3