Core/Misc: Replace time(NULL) with GameTime::GetGameTime()

(cherry picked from commit 12701cb0c6)

 Conflicts:
	src/server/game/Achievements/AchievementMgr.cpp
	src/server/game/AuctionHouse/AuctionHouseMgr.cpp
	src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp
	src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp
	src/server/game/Battlefield/Battlefield.cpp
	src/server/game/Battlefield/Zones/BattlefieldWG.cpp
	src/server/game/Battlegrounds/BattlegroundMgr.cpp
	src/server/game/Calendar/CalendarMgr.h
	src/server/game/DungeonFinding/LFGQueue.cpp
	src/server/game/Entities/Corpse/Corpse.cpp
	src/server/game/Entities/Creature/Creature.cpp
	src/server/game/Entities/Item/Item.cpp
	src/server/game/Entities/Pet/Pet.cpp
	src/server/game/Entities/Player/Player.cpp
	src/server/game/Entities/Unit/Unit.cpp
	src/server/game/Globals/ObjectMgr.cpp
	src/server/game/Grids/ObjectGridLoader.cpp
	src/server/game/Guilds/Guild.cpp
	src/server/game/Handlers/AuctionHouseHandler.cpp
	src/server/game/Handlers/BattlefieldHandler.cpp
	src/server/game/Handlers/CalendarHandler.cpp
	src/server/game/Handlers/CharacterHandler.cpp
	src/server/game/Handlers/ChatHandler.cpp
	src/server/game/Handlers/LFGHandler.cpp
	src/server/game/Handlers/MailHandler.cpp
	src/server/game/Handlers/MiscHandler.cpp
	src/server/game/Handlers/MovementHandler.cpp
	src/server/game/Handlers/PetHandler.cpp
	src/server/game/Handlers/QueryHandler.cpp
	src/server/game/Handlers/TicketHandler.cpp
	src/server/game/Instances/InstanceSaveMgr.cpp
	src/server/game/Server/WorldSession.cpp
	src/server/game/Server/WorldSocket.cpp
	src/server/game/Spells/Auras/SpellAuras.cpp
	src/server/game/Tickets/TicketMgr.cpp
	src/server/game/Tickets/TicketMgr.h
	src/server/game/World/World.cpp
	src/server/scripts/Commands/cs_gobject.cpp
	src/server/scripts/Commands/cs_instance.cpp
	src/server/scripts/Commands/cs_list.cpp
	src/server/scripts/Northrend/zone_wintergrasp.cpp
	src/server/scripts/Spells/spell_item.cpp
This commit is contained in:
jackpoz
2017-12-10 12:39:37 +01:00
committed by funjoker
parent 76b2d37259
commit e17e4e6f07
68 changed files with 342 additions and 265 deletions

View File

@@ -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);
@@ -340,7 +341,7 @@ public:
Field* fields = result->Fetch();
time_t unbanDate = fields[3].GetInt64();
bool active = false;
if (fields[2].GetUInt8() && (!fields[1].GetInt64() || unbanDate >= time(nullptr)))
if (fields[2].GetUInt8() && (!fields[1].GetInt64() || unbanDate >= GameTime::GetGameTime()))
active = true;
bool permanent = (fields[1].GetInt64() == SI64LIT(0));
std::string banTime = permanent ? handler->GetTrinityString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetInt64(), true);

View File

@@ -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);

View File

@@ -28,6 +28,7 @@ EndScriptData */
#include "DB2Stores.h"
#include "GameEventMgr.h"
#include "GameObject.h"
#include "GameTime.h"
#include "Language.h"
#include "Log.h"
#include "MapManager.h"
@@ -323,7 +324,7 @@ public:
if (target)
{
int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - time(nullptr));
int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - GameTime::GetGameTime());
if (curRespawnDelay < 0)
curRespawnDelay = 0;

View File

@@ -25,6 +25,7 @@ EndScriptData */
#include "ScriptMgr.h"
#include "Chat.h"
#include "DB2Stores.h"
#include "GameTime.h"
#include "Group.h"
#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
@@ -89,7 +90,7 @@ public:
for (auto itr = binds->second.begin(); itr != binds->second.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->GetDifficultyID(), save->CanReset() ? "yes" : "no", timeleft.c_str());
counter++;
}
@@ -108,7 +109,7 @@ public:
for (auto itr = binds->second.begin(); itr != binds->second.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->GetDifficultyID(), save->CanReset() ? "yes" : "no", timeleft.c_str());
counter++;
}
@@ -154,7 +155,7 @@ public:
InstanceSave* save = itr->second.save;
if (itr->first != player->GetMapId() && (!MapId || MapId == itr->first) && (diff == -1 || diff == save->GetDifficultyID()))
{
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->GetDifficultyID(), save->CanReset() ? "yes" : "no", timeleft.c_str());
player->UnbindInstance(itr, binds);
counter++;

View File

@@ -29,6 +29,7 @@ EndScriptData */
#include "DatabaseEnv.h"
#include "DB2Stores.h"
#include "GameObject.h"
#include "GameTime.h"
#include "Language.h"
#include "MapManager.h"
#include "ObjectAccessor.h"
@@ -714,7 +715,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(UI64FMTD " | %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");
}
@@ -735,7 +736,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(UI64FMTD " | %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;

View File

@@ -1843,11 +1843,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);
@@ -2020,7 +2020,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);

View File

@@ -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"
@@ -823,7 +824,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;

View File

@@ -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
@@ -853,7 +853,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);
}
@@ -863,7 +863,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);
}
@@ -915,7 +915,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
@@ -1049,10 +1049,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);
@@ -1060,10 +1060,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);
@@ -1122,7 +1122,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);
}
@@ -1132,7 +1132,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);
}
@@ -1184,7 +1184,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
@@ -1322,10 +1322,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);
@@ -1333,10 +1333,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);

View File

@@ -16,6 +16,7 @@
*/
#include "ScriptMgr.h"
#include "GameTime.h"
#include "InstanceScript.h"
#include "vault_of_archavon.h"
@@ -64,13 +65,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;

View File

@@ -22,6 +22,7 @@
#include "DB2Stores.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);

View File

@@ -2386,7 +2386,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::fromEulerAnglesZYX(target->GetOrientation(), 0.0f, 0.0f), uint32(target->GetRespawnTime()-time(nullptr)));
GetCaster()->SummonGameObject(OBJECT_IMPRISONED_DOOMGUARD, *target, QuaternionData::fromEulerAnglesZYX(target->GetOrientation(), 0.0f, 0.0f), uint32(target->GetRespawnTime() - GameTime::GetGameTime()));
target->DespawnOrUnsummon();
}
}

View File

@@ -140,7 +140,7 @@ class spell_pal_ardent_defender : public SpellScriptLoader
int32 healAmount = int32(victim->CountPctFromMaxHealth(static_cast<uint32>(lroundf(_healPct * defenseFactor))));
victim->CastCustomSpell(victim, PAL_SPELL_ARDENT_DEFENDER_HEAL, &healAmount, nullptr, nullptr, true, nullptr, aurEff);
victim->ToPlayer()->AddSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, time(nullptr) + 120);
victim->ToPlayer()->AddSpellCooldown(PAL_SPELL_ARDENT_DEFENDER_HEAL, 0, GameTime::GetGameTime() + 120);
}
else if (remainingHealth < int32(allowedHealth))
{

View File

@@ -1786,7 +1786,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;
}
@@ -1806,7 +1806,7 @@ public:
{
case EVENT_TD_CHECK_COMBAT:
{
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime();
for (std::unordered_map<ObjectGuid, time_t>::iterator itr = _damageTimes.begin(); itr != _damageTimes.end();)
{
// If unit has not dealt damage to training dummy for 5 seconds, remove him from combat