diff options
Diffstat (limited to 'src')
62 files changed, 321 insertions, 243 deletions
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index f904614960a..c1991491027 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -624,7 +624,7 @@ void AchievementMgr::LoadFromDB(PreparedQueryResult achievementResult, PreparedQ continue; } - if (criteria->StartTimer && time_t(date + criteria->StartTimer) < time(nullptr)) + if (criteria->StartTimer && time_t(date + criteria->StartTimer) < GameTime::GetGameTime()) continue; CriteriaProgress& progress = m_criteriaProgress[id]; @@ -684,7 +684,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8); data << GetPlayer()->GetPackGUID(); data << uint32(achievement->ID); - data.AppendPackedTime(time(nullptr)); + data.AppendPackedTime(GameTime::GetGameTime()); data << uint32(0); GetPlayer()->SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true); } @@ -1380,7 +1380,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry, } progress->changed = true; - progress->date = time(nullptr); // set the date to the latest update. + progress->date = GameTime::GetGameTime(); // set the date to the latest update. uint32 timeElapsed = 0; bool timedCompleted = false; @@ -1496,7 +1496,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) SendAchievementEarned(achievement); CompletedAchievementData& ca = m_completedAchievements[achievement->ID]; - ca.date = time(nullptr); + ca.date = GameTime::GetGameTime(); ca.changed = true; if (achievement->Flags & (ACHIEVEMENT_FLAG_REALM_FIRST_REACH | ACHIEVEMENT_FLAG_REALM_FIRST_KILL)) diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index d4faa188493..e0204232916 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -546,7 +546,7 @@ void AuctionHouseMgr::UpdatePendingAuctions() { AuctionEntry* AH = (*AHitr); ++AHitr; - AH->expire_time = time(nullptr); + AH->expire_time = GameTime::GetGameTime(); AH->DeleteFromDB(trans); AH->SaveToDB(trans); } @@ -861,7 +861,7 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket& data, Item* sourceItem) const data << uint32(bid ? GetAuctionOutBid() : 0); // Minimal outbid data << uint32(buyout); // Auction->buyout - data << uint32((expire_time - time(nullptr)) * IN_MILLISECONDS); // time left + data << uint32((expire_time - GameTime::GetGameTime()) * IN_MILLISECONDS); // time left data << uint64(bidder); // auction->bidder current data << uint32(bid); // current bid return true; diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp index 4d7ad22eef5..adc2b115710 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp @@ -16,6 +16,7 @@ */ #include "AuctionHouseBotBuyer.h" +#include "GameTime.h" #include "DatabaseEnv.h" #include "Item.h" #include "ItemTemplate.h" @@ -97,7 +98,7 @@ bool AuctionBotBuyer::Update(AuctionHouseType houseType) uint32 AuctionBotBuyer::GetItemInformation(BuyerConfiguration& config) { config.SameItemInfo.clear(); - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); uint32 count = 0; AuctionHouseObject* house = sAuctionMgr->GetAuctionsMap(config.GetHouseType()); @@ -237,7 +238,7 @@ bool AuctionBotBuyer::RollBidChance(BuyerItemInfo const* ahInfo, Item const* ite void AuctionBotBuyer::PrepareListOfEntry(BuyerConfiguration& config) { // now - 5 seconds to leave out all old entries but keep the ones just updated a moment ago - time_t now = time(nullptr) - 5; + time_t now = GameTime::GetGameTime() - 5; for (CheckEntryMap::iterator itr = config.EligibleItems.begin(); itr != config.EligibleItems.end();) { @@ -253,7 +254,7 @@ void AuctionBotBuyer::PrepareListOfEntry(BuyerConfiguration& config) // Tries to bid and buy items based on their prices and chances set in configs void AuctionBotBuyer::BuyAndBidItems(BuyerConfiguration& config) { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config.GetHouseType()); CheckEntryMap& items = config.EligibleItems; diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp index 7c1ba67d547..326b2ad1498 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp @@ -20,6 +20,7 @@ #include "Containers.h" #include "DatabaseEnv.h" #include "DBCStores.h" +#include "GameTime.h" #include "Item.h" #include "Log.h" #include "ObjectMgr.h" @@ -926,7 +927,7 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config) auctionEntry->bid = 0; auctionEntry->deposit = sAuctionMgr->GetAuctionDeposit(ahEntry, etime, item, stackCount); auctionEntry->auctionHouseEntry = ahEntry; - auctionEntry->expire_time = time(nullptr) + urand(config.GetMinTime(), config.GetMaxTime()) * HOUR; + auctionEntry->expire_time = GameTime::GetGameTime() + urand(config.GetMinTime(), config.GetMaxTime()) * HOUR; item->SaveToDB(trans); sAuctionMgr->AddAItem(item); diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 92b78216cb0..1f59dac2dbe 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -21,6 +21,7 @@ #include "CellImpl.h" #include "CreatureTextMgr.h" #include "DBCStores.h" +#include "GameTime.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "Group.h" @@ -83,7 +84,7 @@ void Battlefield::HandlePlayerEnterZone(Player* player, uint32 /*zone*/) else // No more vacant places { /// @todo Send a packet to announce it to player - m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(nullptr) + 10; + m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10; InvitePlayerToQueue(player); } } @@ -162,7 +163,7 @@ bool Battlefield::Update(uint32 diff) // Kick players who chose not to accept invitation to the battle if (m_uiKickDontAcceptTimer <= diff) { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team) for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); ++itr) if (itr->second <= now) @@ -248,7 +249,7 @@ void Battlefield::InvitePlayersInZoneToWar() if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) InvitePlayerToWar(player); else // Battlefield is full of players - m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(nullptr) + 10; + m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10; } } } @@ -273,7 +274,7 @@ void Battlefield::InvitePlayerToWar(Player* player) if (player->getLevel() < m_MinLevel) { if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0) - m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(nullptr) + 10; + m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10; return; } @@ -282,7 +283,7 @@ void Battlefield::InvitePlayerToWar(Player* player) return; m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID()); - m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = time(nullptr) + m_TimeForAcceptInvite; + m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + m_TimeForAcceptInvite; player->GetSession()->SendBfInvitePlayerToWar(m_BattleId, m_ZoneId, m_TimeForAcceptInvite); } diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index bd5f47f67c9..3362e5ffa77 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -24,6 +24,7 @@ #include "Battleground.h" #include "CreatureTextMgr.h" #include "GameObject.h" +#include "GameTime.h" #include "Log.h" #include "MapManager.h" #include "ObjectAccessor.h" @@ -1153,7 +1154,7 @@ void BattlefieldWG::FillInitialWorldStates(WorldPacket& data) data << uint32(BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE) << uint32(IsWarTime() ? 1 : 0); for (uint32 i = 0; i < 2; ++i) - data << ClockWorldState[i] << uint32(time(nullptr) + (m_Timer / 1000)); + data << ClockWorldState[i] << uint32(GameTime::GetGameTime() + (m_Timer / 1000)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H) << uint32(GetData(BATTLEFIELD_WG_DATA_VEHICLE_H)); data << uint32(BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_H) << uint32(GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H)); diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index e22a2ee38ee..7a2389586c0 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -36,6 +36,7 @@ #include "DisableMgr.h" #include "Formulas.h" #include "GameEventMgr.h" +#include "GameTime.h" #include "Map.h" #include "MapManager.h" #include "SharedDefines.h" @@ -166,7 +167,7 @@ void BattlegroundMgr::Update(uint32 diff) { if (m_AutoDistributionTimeChecker < diff) { - if (time(nullptr) > m_NextAutoDistributionTime) + if (GameTime::GetGameTime() > m_NextAutoDistributionTime) { sArenaTeamMgr->DistributeArenaPoints(); m_NextAutoDistributionTime = m_NextAutoDistributionTime + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld->getIntConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS); @@ -630,7 +631,7 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution() return; time_t wstime = time_t(sWorld->getWorldState(WS_ARENA_DISTRIBUTION_TIME)); - time_t curtime = time(nullptr); + time_t curtime = GameTime::GetGameTime(); TC_LOG_DEBUG("bg.battleground", "Initializing Automatic Arena Point Distribution"); if (wstime < curtime) { diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index 057d410ebdf..462a4e39335 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -18,6 +18,7 @@ #include "CalendarMgr.h" #include "CharacterCache.h" #include "DatabaseEnv.h" +#include "GameTime.h" #include "Guild.h" #include "GuildMgr.h" #include "Log.h" @@ -27,6 +28,9 @@ #include "Player.h" #include "WorldPacket.h" +CalendarInvite::CalendarInvite() : _inviteId(1), _eventId(0), _invitee(), _senderGUID(), _statusTime(GameTime::GetGameTime()), +_status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _text("") { } + CalendarInvite::~CalendarInvite() { sCalendarMgr->FreeInviteId(_inviteId); diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index ded691c241d..8d7787af6dc 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -146,8 +146,7 @@ struct TC_GAME_API CalendarInvite _text = calendarInvite.GetText(); } - CalendarInvite() : _inviteId(1), _eventId(0), _invitee(), _senderGUID(), _statusTime(time(nullptr)), - _status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _text("") { } + CalendarInvite(); CalendarInvite(uint64 inviteId, uint64 eventId, ObjectGuid invitee, ObjectGuid senderGUID, time_t statusTime, CalendarInviteStatus status, CalendarModerationRank rank, std::string text) : diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 344759a2022..1ac95401f57 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -21,6 +21,7 @@ #include "DBCStores.h" #include "DisableMgr.h" #include "GameEventMgr.h" +#include "GameTime.h" #include "Group.h" #include "GroupMgr.h" #include "InstanceSaveMgr.h" @@ -288,7 +289,7 @@ void LFGMgr::Update(uint32 diff) if (!isOptionEnabled(LFG_OPTION_ENABLE_DUNGEON_FINDER | LFG_OPTION_ENABLE_RAID_BROWSER)) return; - time_t currTime = time(nullptr); + time_t currTime = GameTime::GetGameTime(); // Remove obsolete role checks for (LfgRoleCheckContainer::iterator it = RoleChecksStore.begin(); it != RoleChecksStore.end();) @@ -540,7 +541,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const { // Create new rolecheck LfgRoleCheck& roleCheck = RoleChecksStore[gguid]; - roleCheck.cancelTime = time_t(time(nullptr)) + LFG_TIME_ROLECHECK; + roleCheck.cancelTime = time_t(GameTime::GetGameTime()) + LFG_TIME_ROLECHECK; roleCheck.state = LFG_ROLECHECK_INITIALITING; roleCheck.leader = guid; roleCheck.dungeons = dungeons; @@ -578,7 +579,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const LfgRolesMap rolesMap; rolesMap[guid] = roles; LFGQueue& queue = GetQueue(guid); - queue.AddQueueData(guid, time(nullptr), dungeons, rolesMap); + queue.AddQueueData(guid, GameTime::GetGameTime(), dungeons, rolesMap); if (!isContinue) { @@ -752,7 +753,7 @@ void LFGMgr::UpdateRoleCheck(ObjectGuid gguid, ObjectGuid guid /* = ObjectGuid:: { SetState(gguid, LFG_STATE_QUEUED); LFGQueue& queue = GetQueue(gguid); - queue.AddQueueData(gguid, time_t(time(nullptr)), roleCheck.dungeons, roleCheck.roles); + queue.AddQueueData(gguid, GameTime::GetGameTime(), roleCheck.dungeons, roleCheck.roles); RoleChecksStore.erase(itRoleCheck); } else if (roleCheck.state != LFG_ROLECHECK_INITIALITING) @@ -1015,7 +1016,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, ObjectGuid guid, bool accept) bool sendUpdate = proposal.state != LFG_PROPOSAL_SUCCESS; proposal.state = LFG_PROPOSAL_SUCCESS; - time_t joinTime = time(nullptr); + time_t joinTime = GameTime::GetGameTime(); LFGQueue& queue = GetQueue(guid); LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND); @@ -1184,7 +1185,7 @@ void LFGMgr::InitBoot(ObjectGuid gguid, ObjectGuid kicker, ObjectGuid victim, st LfgPlayerBoot& boot = BootsStore[gguid]; boot.inProgress = true; - boot.cancelTime = time_t(time(nullptr)) + LFG_TIME_BOOT; + boot.cancelTime = GameTime::GetGameTime() + LFG_TIME_BOOT; boot.reason = reason; boot.victim = victim; diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index 2843275dfd1..550133f580a 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -19,6 +19,7 @@ #include "Containers.h" #include "DBCStructure.h" #include "DBCStores.h" +#include "GameTime.h" #include "Group.h" #include "LFGQueue.h" #include "LFGMgr.h" @@ -80,6 +81,10 @@ char const* GetCompatibleString(LfgCompatibility compatibles) } } +LfgQueueData::LfgQueueData() : joinTime(GameTime::GetGameTime()), tanks(LFG_TANKS_NEEDED), +healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) +{ } + std::string LFGQueue::GetDetailedMatchRoles(GuidList const& check) const { if (check.empty()) @@ -540,7 +545,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check) } // Create a new proposal - proposal.cancelTime = time(nullptr) + LFG_TIME_PROPOSAL; + proposal.cancelTime = GameTime::GetGameTime() + LFG_TIME_PROPOSAL; proposal.state = LFG_PROPOSAL_INITIATING; proposal.leader.Clear(); proposal.dungeonId = Trinity::Containers::SelectRandomContainerElement(proposalDungeons); diff --git a/src/server/game/DungeonFinding/LFGQueue.h b/src/server/game/DungeonFinding/LFGQueue.h index 474b7a0bbdc..35e7989c2be 100644 --- a/src/server/game/DungeonFinding/LFGQueue.h +++ b/src/server/game/DungeonFinding/LFGQueue.h @@ -51,9 +51,7 @@ struct LfgCompatibilityData /// Stores player or group queue info struct LfgQueueData { - LfgQueueData(): joinTime(time_t(time(nullptr))), tanks(LFG_TANKS_NEEDED), - healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) - { } + LfgQueueData(); LfgQueueData(time_t _joinTime, LfgDungeonSet const& _dungeons, LfgRolesMap const& _roles): joinTime(_joinTime), tanks(LFG_TANKS_NEEDED), healers(LFG_HEALERS_NEEDED), diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index 37b29df81fa..feaf49d6fea 100644 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -19,6 +19,7 @@ #include "CharacterCache.h" #include "Common.h" #include "Corpse.h" +#include "GameTime.h" #include "Log.h" #include "Map.h" #include "Player.h" @@ -37,7 +38,7 @@ Corpse::Corpse(CorpseType type) : WorldObject(type != CORPSE_BONES), m_type(type m_valuesCount = CORPSE_END; - m_time = time(nullptr); + m_time = GameTime::GetGameTime(); lootRecipient = nullptr; } @@ -133,6 +134,11 @@ void Corpse::DeleteFromDB(ObjectGuid const& ownerGuid, SQLTransaction& trans) CharacterDatabase.ExecuteOrAppend(trans, stmt); } +void Corpse::ResetGhostTime() +{ + m_time = GameTime::GetGameTime(); +} + bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields) { // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h index 1d37cdebfff..51715b29639 100644 --- a/src/server/game/Entities/Corpse/Corpse.h +++ b/src/server/game/Entities/Corpse/Corpse.h @@ -67,7 +67,7 @@ class TC_GAME_API Corpse : public WorldObject, public GridObject<Corpse> ObjectGuid GetOwnerGUID() const { return GetGuidValue(CORPSE_FIELD_OWNER); } time_t const& GetGhostTime() const { return m_time; } - void ResetGhostTime() { m_time = time(nullptr); } + void ResetGhostTime(); CorpseType GetType() const { return m_type; } CellCoord const& GetCellCoord() const { return _cellCoord; } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index d514011f047..7a8cce89778 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -53,6 +53,9 @@ #include "WorldPacket.h" #include <G3D/g3dmath.h> +VendorItemCount::VendorItemCount(uint32 _item, uint32 _count) + : itemId(_item), count(_count), lastIncrementTime(GameTime::GetGameTime()) { } + TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const { TrainerSpellMap::const_iterator itr = spellList.find(spell_id); @@ -367,7 +370,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool destroyForNearbyPlayers) if (m_respawnCompatibilityMode) { - m_corpseRemoveTime = time(nullptr); + m_corpseRemoveTime = GameTime::GetGameTime(); setDeathState(DEAD); RemoveAllAuras(); loot.clear(); @@ -380,7 +383,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool destroyForNearbyPlayers) // Should get removed later, just keep "compatibility" with scripts if (setSpawnTime) - m_respawnTime = std::max<time_t>(time(nullptr) + respawnDelay, m_respawnTime); + m_respawnTime = std::max<time_t>(GameTime::GetGameTime() + respawnDelay, m_respawnTime); // if corpse was removed during falling, the falling will continue and override relocation to respawn position if (IsFalling()) @@ -413,7 +416,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool destroyForNearbyPlayers) if (setSpawnTime) { uint32 respawnDelay = m_respawnDelay; - m_respawnTime = std::max<time_t>(time(nullptr) + respawnDelay, m_respawnTime); + m_respawnTime = std::max<time_t>(GameTime::GetGameTime() + respawnDelay, m_respawnTime); SaveRespawnTime(0, false); } @@ -640,7 +643,7 @@ void Creature::Update(uint32 diff) break; case DEAD: { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); if (m_respawnTime <= now) { @@ -697,7 +700,7 @@ void Creature::Update(uint32 diff) } else m_groupLootTimer -= diff; } - else if (m_corpseRemoveTime <= time(nullptr)) + else if (m_corpseRemoveTime <= GameTime::GetGameTime()) { RemoveCorpse(false); TC_LOG_DEBUG("entities.unit", "Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY)); @@ -1547,7 +1550,7 @@ bool Creature::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap, // Is the creature script objecting to us spawning? If yes, delay by a little bit (then re-check in ::Update) if (m_respawnCompatibilityMode && !m_respawnTime && !sScriptMgr->CanSpawn(spawnId, GetEntry(), GetCreatureData(), map)) - m_respawnTime = time(nullptr)+urand(4,7); + m_respawnTime = GameTime::GetGameTime() + urand(4,7); if (m_respawnTime) // respawn on Update { @@ -1698,7 +1701,7 @@ bool Creature::IsInvisibleDueToDespawn() const if (Unit::IsInvisibleDueToDespawn()) return true; - if (IsAlive() || isDying() || m_corpseRemoveTime > time(nullptr)) + if (IsAlive() || isDying() || m_corpseRemoveTime > GameTime::GetGameTime()) return false; return true; @@ -1816,7 +1819,7 @@ void Creature::setDeathState(DeathState s) if (s == JUST_DIED) { - m_corpseRemoveTime = time(nullptr) + m_corpseDelay; + m_corpseRemoveTime = GameTime::GetGameTime() + m_corpseDelay; uint32 respawnDelay = m_respawnDelay; if (uint32 scalingMode = sWorld->getIntConfig(CONFIG_RESPAWN_DYNAMICMODE)) @@ -1827,14 +1830,14 @@ void Creature::setDeathState(DeathState s) if (IsDungeonBoss() && !m_respawnDelay) m_respawnTime = std::numeric_limits<time_t>::max(); // never respawn in this instance else - m_respawnTime = time(nullptr) + respawnDelay + m_corpseDelay; + m_respawnTime = GameTime::GetGameTime() + respawnDelay + m_corpseDelay; } else { if (IsDungeonBoss() && !m_respawnDelay) m_respawnTime = std::numeric_limits<time_t>::max(); // never respawn in this instance else - m_respawnTime = time(nullptr) + respawnDelay; + m_respawnTime = GameTime::GetGameTime() + respawnDelay; } // always save boss respawn time at death to prevent crash cheating @@ -2016,7 +2019,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds const& forceRespawn uint32 respawnDelay = m_respawnDelay; if (uint32 scalingMode = sWorld->getIntConfig(CONFIG_RESPAWN_DYNAMICMODE)) GetMap()->ApplyDynamicModeRespawnScaling(this, m_spawnId, respawnDelay, scalingMode); - m_respawnTime = time(nullptr) + respawnDelay; + m_respawnTime = GameTime::GetGameTime() + respawnDelay; SaveRespawnTime(); } @@ -2293,7 +2296,7 @@ void Creature::SaveRespawnTime(uint32 forceDelay, bool savetodb) return; } - time_t thisRespawnTime = forceDelay ? time(nullptr) + forceDelay : m_respawnTime; + time_t thisRespawnTime = forceDelay ? GameTime::GetGameTime() + forceDelay : m_respawnTime; GetMap()->SaveRespawnTime(SPAWN_TYPE_CREATURE, m_spawnId, GetEntry(), thisRespawnTime, GetMap()->GetZoneId(GetHomePosition()), Trinity::ComputeGridCoord(GetHomePosition().GetPositionX(), GetHomePosition().GetPositionY()).GetId(), savetodb && m_creatureData && m_creatureData->dbData); } @@ -2497,13 +2500,18 @@ bool Creature::HasSpell(uint32 spellID) const time_t Creature::GetRespawnTimeEx() const { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); if (m_respawnTime > now) return m_respawnTime; else return now; } +void Creature::SetRespawnTime(uint32 respawn) +{ + m_respawnTime = respawn ? GameTime::GetGameTime() + respawn : 0; +} + void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, float* dist) const { if (m_creatureData) @@ -2534,7 +2542,7 @@ void Creature::AllLootRemovedFromCorpse() if (LootTemplates_Skinning.HaveLootFor(GetCreatureTemplate()->SkinLootId)) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); // Do not reset corpse remove time if corpse is already removed if (m_corpseRemoveTime <= now) return; @@ -2602,7 +2610,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) VendorItemCount* vCount = &*itr; - time_t ptime = time(nullptr); + time_t ptime = GameTime::GetGameTime(); if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item)) @@ -2640,7 +2648,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us VendorItemCount* vCount = &*itr; - time_t ptime = time(nullptr); + time_t ptime = GameTime::GetGameTime(); if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) if (ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(vItem->item)) @@ -3080,7 +3088,12 @@ bool Creature::IsMovementPreventedByCasting() const void Creature::StartPickPocketRefillTimer() { - _pickpocketLootRestore = time(nullptr) + sWorld->getIntConfig(CONFIG_CREATURE_PICKPOCKET_REFILL); + _pickpocketLootRestore = GameTime::GetGameTime() + sWorld->getIntConfig(CONFIG_CREATURE_PICKPOCKET_REFILL); +} + +bool Creature::CanGeneratePickPocketLoot() const +{ + return _pickpocketLootRestore <= GameTime::GetGameTime(); } void Creature::SetTextRepeatId(uint8 textGroup, uint8 id) diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index e39e1e13311..5e230da9e4b 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -40,8 +40,7 @@ enum MovementGeneratorType : uint8; struct VendorItemCount { - VendorItemCount(uint32 _item, uint32 _count) - : itemId(_item), count(_count), lastIncrementTime(time(nullptr)) { } + VendorItemCount(uint32 _item, uint32 _count); uint32 itemId; uint32 count; @@ -187,7 +186,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma Loot loot; void StartPickPocketRefillTimer(); void ResetPickPocketRefillTimer() { _pickpocketLootRestore = 0; } - bool CanGeneratePickPocketLoot() const { return _pickpocketLootRestore <= time(nullptr); } + bool CanGeneratePickPocketLoot() const; ObjectGuid GetLootRecipientGUID() const { return m_lootRecipient; } Player* GetLootRecipient() const; Group* GetLootRecipientGroup() const; @@ -235,7 +234,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma time_t const& GetRespawnTime() const { return m_respawnTime; } time_t GetRespawnTimeEx() const; - void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(nullptr) + respawn : 0; } + void SetRespawnTime(uint32 respawn); void Respawn(bool force = false); void SaveRespawnTime(uint32 forceDelay = 0, bool savetodb = true) override; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 358d0eb93a1..9b1878b24d4 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -464,7 +464,7 @@ void GameObject::Update(uint32 diff) case GAMEOBJECT_TYPE_FISHINGNODE: { // fishing code (bobber ready) - if (time(nullptr) > m_respawnTime - FISHING_BOBBER_READY_TIME) + if (GameTime::GetGameTime() > m_respawnTime - FISHING_BOBBER_READY_TIME) { // splash bobber (bobber ready now) Unit* caster = GetOwner(); @@ -498,7 +498,7 @@ void GameObject::Update(uint32 diff) { if (m_respawnTime > 0) // timer on { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); if (m_respawnTime <= now) // timer expired { ObjectGuid dbtableHighGuid(HighGuid::GameObject, GetEntry(), m_spawnId); @@ -776,7 +776,7 @@ void GameObject::Update(uint32 diff) uint32 respawnDelay = m_respawnDelayTime; if (uint32 scalingMode = sWorld->getIntConfig(CONFIG_RESPAWN_DYNAMICMODE)) GetMap()->ApplyDynamicModeRespawnScaling(this, this->m_spawnId, respawnDelay, scalingMode); - m_respawnTime = time(nullptr) + respawnDelay; + m_respawnTime = GameTime::GetGameTime() + respawnDelay; // if option not set then object will be saved at grid unload // Otherwise just save respawn time to map object memory @@ -987,7 +987,7 @@ bool GameObject::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap m_respawnTime = GetMap()->GetGORespawnTime(m_spawnId); // ready to respawn - if (m_respawnTime && m_respawnTime <= time(nullptr)) + if (m_respawnTime && m_respawnTime <= GameTime::GetGameTime()) { m_respawnTime = 0; GetMap()->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, m_spawnId); @@ -1094,7 +1094,7 @@ Unit* GameObject::GetOwner() const void GameObject::SaveRespawnTime(uint32 forceDelay, bool savetodb) { - if (m_goData && m_respawnTime > time(nullptr) && m_spawnedByDefault) + if (m_goData && m_respawnTime > GameTime::GetGameTime() && m_spawnedByDefault) { if (m_respawnCompatibilityMode) { @@ -1102,7 +1102,7 @@ void GameObject::SaveRespawnTime(uint32 forceDelay, bool savetodb) return; } - uint32 thisRespawnTime = forceDelay ? time(nullptr) + forceDelay : m_respawnTime; + uint32 thisRespawnTime = forceDelay ? GameTime::GetGameTime() + forceDelay : m_respawnTime; GetMap()->SaveRespawnTime(SPAWN_TYPE_GAMEOBJECT, m_spawnId, GetEntry(), thisRespawnTime, GetZoneId(), Trinity::ComputeGridCoord(GetPositionX(), GetPositionY()).GetId(), m_goData->dbData ? savetodb : false); } } @@ -1164,11 +1164,26 @@ uint8 GameObject::getLevelForTarget(WorldObject const* target) const return 1; } +time_t GameObject::GetRespawnTimeEx() const +{ + time_t now = GameTime::GetGameTime(); + if (m_respawnTime > now) + return m_respawnTime; + else + return now; +} + +void GameObject::SetRespawnTime(int32 respawn) +{ + m_respawnTime = respawn > 0 ? GameTime::GetGameTime() + respawn : 0; + m_respawnDelayTime = respawn > 0 ? respawn : 0; +} + void GameObject::Respawn() { if (m_spawnedByDefault && m_respawnTime > 0) { - m_respawnTime = time(nullptr); + m_respawnTime = GameTime::GetGameTime(); GetMap()->RemoveRespawnTime(SPAWN_TYPE_GAMEOBJECT, m_spawnId, true); } } @@ -2246,6 +2261,11 @@ void GameObject::SetLootState(LootState state, Unit* unit) } } +void GameObject::SetLootGenerationTime() +{ + m_lootGenerationTime = GameTime::GetGameTime(); +} + void GameObject::SetGoState(GOState state) { SetByteValue(GAMEOBJECT_BYTES_1, 0, state); diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 784af8fda27..d12b3305796 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -137,20 +137,9 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> uint32 GetSpellId() const { return m_spellId;} time_t GetRespawnTime() const { return m_respawnTime; } - time_t GetRespawnTimeEx() const - { - time_t now = time(nullptr); - if (m_respawnTime > now) - return m_respawnTime; - else - return now; - } + time_t GetRespawnTimeEx() const; - void SetRespawnTime(int32 respawn) - { - m_respawnTime = respawn > 0 ? time(nullptr) + respawn : 0; - m_respawnDelayTime = respawn > 0 ? respawn : 0; - } + void SetRespawnTime(int32 respawn); void Respawn(); bool isSpawned() const { @@ -191,7 +180,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> void AddLootMode(uint16 lootMode) { m_LootMode |= lootMode; } void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; } void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; } - void SetLootGenerationTime() { m_lootGenerationTime = time(nullptr); } + void SetLootGenerationTime(); uint32 GetLootGenerationTime() const { return m_lootGenerationTime; } void AddToSkillupList(ObjectGuid::LowType PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); } diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 7556c7d007c..9ecf8e9522b 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -22,6 +22,7 @@ #include "ConditionMgr.h" #include "DatabaseEnv.h" #include "DBCStores.h" +#include "GameTime.h" #include "ItemEnchantmentMgr.h" #include "Log.h" #include "LootItemStorage.h" @@ -256,7 +257,7 @@ Item::Item() m_container = nullptr; m_lootGenerated = false; mb_in_trade = false; - m_lastPlayedTimeUpdate = time(nullptr); + m_lastPlayedTimeUpdate = GameTime::GetGameTime(); m_refundRecipient = 0; m_paidMoney = 0; @@ -1119,7 +1120,7 @@ void Item::UpdatePlayedTime(Player* owner) // Get current played time uint32 current_playtime = GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME); // Calculate time elapsed since last played time update - time_t curtime = time(nullptr); + time_t curtime = GameTime::GetGameTime(); uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate); uint32 new_playtime = current_playtime + elapsed; // Check if the refund timer has expired yet @@ -1140,7 +1141,7 @@ void Item::UpdatePlayedTime(Player* owner) uint32 Item::GetPlayedTime() { - time_t curtime = time(nullptr); + time_t curtime = GameTime::GetGameTime(); uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate); return GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + elapsed; } diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 9b5ab8ff2c6..96e9746bbbe 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -237,7 +237,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c break; } - SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); // cast can't be helped here + SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped here SetCreatorGUID(owner->GetGUID()); InitStatsForLevel(petlevel); @@ -318,7 +318,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c InitTalentForLevel(); // set original talents points before spell loading - uint32 timediff = uint32(time(nullptr) - fields[14].GetUInt32()); + uint32 timediff = uint32(GameTime::GetGameTime() - fields[14].GetUInt32()); _LoadAuras(timediff); // load action bar, if data broken will fill later by default spells. @@ -467,7 +467,7 @@ void Pet::SavePetToDB(PetSaveMode mode) stmt->setUInt32(11, curmana); stmt->setUInt32(12, GetPower(POWER_HAPPINESS)); stmt->setString(13, GenerateActionBarData()); - stmt->setUInt32(14, time(nullptr)); + stmt->setUInt32(14, GameTime::GetGameTime()); stmt->setUInt32(15, GetUInt32Value(UNIT_CREATED_BY_SPELL)); stmt->setUInt8(16, getPetType()); trans->Append(stmt); @@ -546,7 +546,7 @@ void Pet::Update(uint32 diff) { case CORPSE: { - if (getPetType() != HUNTER_PET || m_corpseRemoveTime <= time(nullptr)) + if (getPetType() != HUNTER_PET || m_corpseRemoveTime <= GameTime::GetGameTime()) { Remove(PET_SAVE_NOT_IN_SLOT); //hunters' pets never get removed because of death, NEVER! return; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 48a515e0b07..8167076a00f 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -265,7 +265,7 @@ Player::Player(WorldSession* session): Unit(true) m_bgBattlegroundQueueID[j].invitedToInstance = 0; } - m_logintime = time(nullptr); + m_logintime = GameTime::GetGameTime(); m_Last_tick = m_logintime; m_Played_time[PLAYED_TIME_TOTAL] = 0; m_Played_time[PLAYED_TIME_LEVEL] = 0; @@ -342,7 +342,7 @@ Player::Player(WorldSession* session): Unit(true) m_spellPenetrationItemMod = 0; // Honor System - m_lastHonorUpdateTime = time(nullptr); + m_lastHonorUpdateTime = GameTime::GetGameTime(); m_IsBGRandomWinner = false; @@ -572,7 +572,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo SetArenaPoints(sWorld->getIntConfig(CONFIG_START_ARENA_POINTS)); // Played time - m_Last_tick = time(nullptr); + m_Last_tick = GameTime::GetGameTime(); m_Played_time[PLAYED_TIME_TOTAL] = 0; m_Played_time[PLAYED_TIME_LEVEL] = 0; @@ -1033,7 +1033,7 @@ void Player::Update(uint32 p_time) return; // undelivered mail - if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(nullptr)) + if (m_nextMailDelivereTime && m_nextMailDelivereTime <= GameTime::GetGameTime()) { SendNewMail(); ++unReadMails; @@ -1055,7 +1055,7 @@ void Player::Update(uint32 p_time) Unit::Update(p_time); SetCanDelayTeleport(false); - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); UpdatePvPFlag(now); @@ -1194,7 +1194,7 @@ void Player::Update(uint32 p_time) { if (roll_chance_i(3) && _restTime > 0) // freeze update { - time_t currTime = time(nullptr); + time_t currTime = GameTime::GetGameTime(); time_t timeDiff = currTime - _restTime; if (timeDiff >= 10) // freeze update { @@ -2943,7 +2943,7 @@ void Player::UpdateNextMailTimeAndUnreads() { // calculate next delivery time (min. from non-delivered mails // and recalculate unReadMail - time_t cTime = time(nullptr); + time_t cTime = GameTime::GetGameTime(); m_nextMailDelivereTime = 0; unReadMails = 0; for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) @@ -2960,7 +2960,7 @@ void Player::UpdateNextMailTimeAndUnreads() void Player::AddNewMailDeliverTime(time_t deliver_time) { - if (deliver_time <= time(nullptr)) // ready now + if (deliver_time <= GameTime::GetGameTime()) // ready now { ++unReadMails; SendNewMail(); @@ -3848,7 +3848,7 @@ bool Player::ResetTalents(bool no_cost) UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, 1); m_resetTalentsCost = cost; - m_resetTalentsTime = time(nullptr); + m_resetTalentsTime = GameTime::GetGameTime(); } /* when prev line will dropped use next line @@ -4436,7 +4436,7 @@ void Player::DeleteOldCharacters(uint32 keepDays) TC_LOG_INFO("entities.player", "Player::DeleteOldCharacters: Deleting all characters which have been deleted %u days before...", keepDays); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_OLD_CHARS); - stmt->setUInt32(0, uint32(time(nullptr) - time_t(keepDays * DAY))); + stmt->setUInt32(0, uint32(GameTime::GetGameTime() - time_t(keepDays * DAY))); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) @@ -6669,8 +6669,8 @@ void Player::RewardReputation(Quest const* quest) void Player::UpdateHonorFields() { /// called when rewarding honor and at each save - time_t now = time_t(time(nullptr)); - time_t today = time_t(time(nullptr) / DAY) * DAY; + time_t now = GameTime::GetGameTime(); + time_t today = GameTime::GetGameTime() / DAY * DAY; if (m_lastHonorUpdateTime < today) { @@ -8358,7 +8358,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) // loot was generated and respawntime has passed since then, allow to recreate loot // to avoid bugs, this rule covers spawned gameobjects only - if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && go->GetLootGenerationTime() + go->GetRespawnDelay() < time(nullptr)) + if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && go->GetLootGenerationTime() + go->GetRespawnDelay() < GameTime::GetGameTime()) go->SetLootState(GO_READY); if (go->getLootState() == GO_READY) @@ -9381,7 +9381,7 @@ void Player::SendBattlefieldWorldStates() const { SendUpdateWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, wg->IsWarTime() ? 0 : 1); uint32 timer = wg->IsWarTime() ? 0 : (wg->GetTimer() / 1000); // 0 - Time to next battle - SendUpdateWorldState(ClockWorldState[1], uint32(time(nullptr) + timer)); + SendUpdateWorldState(ClockWorldState[1], uint32(GameTime::GetGameTime() + timer)); } } } @@ -13207,7 +13207,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetEntry(), slot); m_items[slot] = pItem; - time_t base = time(nullptr); + time_t base = GameTime::GetGameTime(); uint32 etime = uint32(base - m_logintime + (30 * 3600)); uint32 eslot = slot - BUYBACK_SLOT_START; @@ -14915,7 +14915,7 @@ void Player::AddQuest(Quest const* quest, Object* questGiver) AddTimedQuest(quest_id); questStatusData.Timer = timeAllowed * IN_MILLISECONDS; - qtime = static_cast<uint32>(time(nullptr)) + timeAllowed; + qtime = static_cast<uint32>(GameTime::GetGameTime()) + timeAllowed; } else questStatusData.Timer = 0; @@ -17409,7 +17409,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) SaveRecallPosition(); - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); time_t logoutTime = time_t(fields[27].GetUInt32()); // since last logout (in seconds) @@ -18785,7 +18785,7 @@ void Player::SendRaidInfo() size_t p_counter = data.wpos(); data << uint32(counter); // placeholder - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { @@ -19143,7 +19143,7 @@ void Player::SaveToDB(bool create /*=false*/) stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]); stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]); stmt->setFloat(index++, finiteAlways(m_rest_bonus)); - stmt->setUInt32(index++, uint32(time(nullptr))); + stmt->setUInt32(index++, uint32(GameTime::GetGameTime())); stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0)); //save, far from tavern/city //save, but in tavern/city @@ -19268,7 +19268,7 @@ void Player::SaveToDB(bool create /*=false*/) stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]); stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]); stmt->setFloat(index++, finiteAlways(m_rest_bonus)); - stmt->setUInt32(index++, uint32(time(nullptr))); + stmt->setUInt32(index++, uint32(GameTime::GetGameTime())); stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0)); //save, far from tavern/city //save, but in tavern/city @@ -20078,7 +20078,7 @@ void Player::UpdateSpeakTime() if (GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHAT_SPAM)) return; - time_t current = time(nullptr); + time_t current = GameTime::GetGameTime(); if (m_speakTime > current) { uint32 max_count = sWorld->getIntConfig(CONFIG_CHATFLOOD_MESSAGE_COUNT); @@ -21773,7 +21773,7 @@ void Player::UpdatePvPState(bool onlyFFA) else // in friendly area { if (IsPvP() && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) && !pvpInfo.EndTimer) - pvpInfo.EndTimer = time(nullptr); // start toggle-off + pvpInfo.EndTimer = GameTime::GetGameTime(); // start toggle-off } } @@ -21793,7 +21793,7 @@ void Player::UpdatePvP(bool state, bool _override) } else { - pvpInfo.EndTimer = time(nullptr); + pvpInfo.EndTimer = GameTime::GetGameTime(); SetPvP(state); } } @@ -22997,7 +22997,7 @@ void Player::SetDailyQuestStatus(uint32 quest_id) if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) { SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx, quest_id); - m_lastDailyQuestTime = time(nullptr); // last daily quest time + m_lastDailyQuestTime = GameTime::GetGameTime(); // last daily quest time m_DailyQuestChanged = true; break; } @@ -23005,7 +23005,7 @@ void Player::SetDailyQuestStatus(uint32 quest_id) } else { m_DFQuests.insert(quest_id); - m_lastDailyQuestTime = time(nullptr); + m_lastDailyQuestTime = GameTime::GetGameTime(); m_DailyQuestChanged = true; } } @@ -23352,7 +23352,7 @@ void Player::UpdateForQuestWorldObjects() bool Player::HasSummonPending() const { - return m_summon_expire >= time(nullptr); + return m_summon_expire >= GameTime::GetGameTime(); } void Player::SendSummonRequestFrom(Unit* summoner) @@ -23368,7 +23368,7 @@ void Player::SendSummonRequestFrom(Unit* summoner) if (HasAura(23445)) return; - m_summon_expire = time(nullptr) + MAX_PLAYER_SUMMON_DELAY; + m_summon_expire = GameTime::GetGameTime() + MAX_PLAYER_SUMMON_DELAY; m_summon_location.WorldRelocate(*summoner); WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); @@ -23387,7 +23387,7 @@ void Player::SummonIfPossible(bool agree) } // expire and auto declined - if (m_summon_expire < time(nullptr)) + if (m_summon_expire < GameTime::GetGameTime()) return; // stop taxi flight at summon @@ -23846,7 +23846,7 @@ uint32 Player::GetCorpseReclaimDelay(bool pvp) const else if (!sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE)) return 0; - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); // 0..2 full period // should be ceil(x)-1 but not floor(x) uint64 count = (now < m_deathExpireTime - 1) ? (m_deathExpireTime - 1 - now) / DEATH_EXPIRE_STEP : 0; @@ -23861,7 +23861,7 @@ void Player::UpdateCorpseReclaimDelay() (!pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))) return; - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); if (now < m_deathExpireTime) { @@ -23905,7 +23905,7 @@ int32 Player::CalculateCorpseReclaimDelay(bool load) const } time_t expected_time = corpse->GetGhostTime() + copseReclaimDelay[count]; - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); if (now >= expected_time) return -1; @@ -26473,7 +26473,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); pet->SetFullHealth(); pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); - pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); // cast can't be helped in this case + pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped in this case break; default: break; @@ -26586,7 +26586,7 @@ void Player::SetRestFlag(RestFlag restFlag, uint32 triggerId /*= 0*/) if (!oldRestMask && _restFlagMask) // only set flag/time on the first rest state { - _restTime = time(nullptr); + _restTime = GameTime::GetGameTime(); SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 1f0b9d04368..821692bff55 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12685,7 +12685,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true); // if charmed two demons the same session, the 2nd gets the 1st one's name - SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); // cast can't be helped + SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped } } playerCharmer->CharmSpellInitialize(); diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 7f5fa2188bb..a46472ed814 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -22,6 +22,7 @@ #include "DBCStores.h" #include "DatabaseEnv.h" #include "GameObjectAI.h" +#include "GameTime.h" #include "Language.h" #include "Log.h" #include "MapManager.h" @@ -44,7 +45,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const default: case GAMEEVENT_NORMAL: { - time_t currenttime = time(nullptr); + time_t currenttime = GameTime::GetGameTime(); // Get the event information return mGameEvent[entry].start < currenttime && currenttime < mGameEvent[entry].end @@ -61,7 +62,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const // if inactive world event, check the prerequisite events case GAMEEVENT_WORLD_INACTIVE: { - time_t currenttime = time(nullptr); + time_t currenttime = GameTime::GetGameTime(); for (std::set<uint16>::const_iterator itr = mGameEvent[entry].prerequisite_events.begin(); itr != mGameEvent[entry].prerequisite_events.end(); ++itr) { if ((mGameEvent[*itr].state != GAMEEVENT_WORLD_NEXTPHASE && mGameEvent[*itr].state != GAMEEVENT_WORLD_FINISHED) || // if prereq not in nextphase or finished state, then can't start this one @@ -77,7 +78,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const uint32 GameEventMgr::NextCheck(uint16 entry) const { - time_t currenttime = time(nullptr); + time_t currenttime = GameTime::GetGameTime(); // for NEXTPHASE state world events, return the delay to start the next event, so the followup event will be checked correctly if ((mGameEvent[entry].state == GAMEEVENT_WORLD_NEXTPHASE || mGameEvent[entry].state == GAMEEVENT_WORLD_FINISHED) && mGameEvent[entry].nextstart >= currenttime) @@ -137,13 +138,13 @@ bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite) ApplyNewEvent(event_id); if (overwrite) { - mGameEvent[event_id].start = time(nullptr); + mGameEvent[event_id].start = GameTime::GetGameTime(); if (data.end <= data.start) data.end = data.start + data.length; } // When event is started, set its worldstate to current time - sWorld->setWorldState(event_id, time(nullptr)); + sWorld->setWorldState(event_id, GameTime::GetGameTime()); return false; } else @@ -184,7 +185,7 @@ void GameEventMgr::StopEvent(uint16 event_id, bool overwrite) if (overwrite && !serverwide_evt) { - data.start = time(nullptr) - data.length * MINUTE; + data.start = GameTime::GetGameTime() - data.length * MINUTE; if (data.end <= data.start) data.end = data.start + data.length; } @@ -1054,7 +1055,7 @@ void GameEventMgr::StartArenaSeason() uint32 GameEventMgr::Update() // return the next event delay in ms { - time_t currenttime = time(nullptr); + time_t currenttime = GameTime::GetGameTime(); uint32 nextEventDelay = max_ge_check_delay; // 1 day uint32 calcDelay; std::set<uint16> activate, deactivate; @@ -1642,7 +1643,7 @@ bool GameEventMgr::CheckOneGameEventConditions(uint16 event_id) // set the followup events' start time if (!mGameEvent[event_id].nextstart) { - time_t currenttime = time(nullptr); + time_t currenttime = GameTime::GetGameTime(); mGameEvent[event_id].nextstart = currenttime + mGameEvent[event_id].length * 60; } return true; @@ -1758,7 +1759,7 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event) bool singleDate = ((holiday->Date[0] >> 24) & 0x1F) == 31; // Events with fixed date within year have - 1 - time_t curTime = time(nullptr); + time_t curTime = GameTime::GetGameTime(); for (int i = 0; i < MAX_HOLIDAY_DATES && holiday->Date[i]; ++i) { uint32 date = holiday->Date[i]; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index ad7fae97289..f7d63afb3f1 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -26,6 +26,7 @@ #include "DisableMgr.h" #include "GameObject.h" #include "GameObjectAIFactory.h" +#include "GameTime.h" #include "GossipDef.h" #include "GroupMgr.h" #include "GuildMgr.h" @@ -5811,7 +5812,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) { uint32 oldMSTime = getMSTime(); - time_t curTime = time(nullptr); + time_t curTime = GameTime::GetGameTime(); tm lt; localtime_r(&curTime, <); uint64 basetime(curTime); diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp index 080f43ad8e4..6b2c6c0f24f 100644 --- a/src/server/game/Grids/ObjectGridLoader.cpp +++ b/src/server/game/Grids/ObjectGridLoader.cpp @@ -24,6 +24,7 @@ #include "DynamicObject.h" #include "Log.h" #include "GameObject.h" +#include "GameTime.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "World.h" @@ -143,7 +144,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T> // If script is blocking spawn, don't spawn but queue for a re-check in a little bit if (!(group->flags & SPAWNGROUP_FLAG_COMPATIBILITY_MODE) && !sScriptMgr->CanSpawn(guid, cdata->id, cdata, map)) { - map->SaveRespawnTime(SPAWN_TYPE_CREATURE, guid, cdata->id, time(nullptr) + urand(4,7), map->GetZoneId(cdata->spawnPoint), Trinity::ComputeGridCoord(cdata->spawnPoint.GetPositionX(), cdata->spawnPoint.GetPositionY()).GetId(), false); + map->SaveRespawnTime(SPAWN_TYPE_CREATURE, guid, cdata->id, GameTime::GetGameTime() + urand(4,7), map->GetZoneId(cdata->spawnPoint), Trinity::ComputeGridCoord(cdata->spawnPoint.GetPositionX(), cdata->spawnPoint.GetPositionY()).GetId(), false); delete obj; continue; } diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 98d066996fd..468421a3b6e 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -24,6 +24,7 @@ #include "Chat.h" #include "Config.h" #include "DatabaseEnv.h" +#include "GameTime.h" #include "GuildMgr.h" #include "Language.h" #include "Log.h" @@ -173,6 +174,8 @@ inline uint32 Guild::LogHolder::GetNextGUID() return m_nextGUID; } +Guild::LogEntry::LogEntry(ObjectGuid::LowType guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(GameTime::GetGameTime()) { } + // EventLogEntry void Guild::EventLogEntry::SaveToDB(SQLTransaction& trans) const { @@ -206,7 +209,7 @@ void Guild::EventLogEntry::WritePacket(WorldPacket& data) const if (m_eventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || m_eventType == GUILD_EVENT_LOG_DEMOTE_PLAYER) data << uint8(m_newRank); // Event timestamp - data << uint32(::time(nullptr) - m_timestamp); + data << uint32(GameTime::GetGameTime() - m_timestamp); } // BankEventLogEntry @@ -256,7 +259,7 @@ void Guild::BankEventLogEntry::WritePacket(WorldPacket& data) const data << uint32(m_itemOrMoney); } - data << uint32(time(nullptr) - m_timestamp); + data << uint32(GameTime::GetGameTime() - m_timestamp); } // RankInfo @@ -612,7 +615,7 @@ Guild::Member::Member(ObjectGuid::LowType guildId, ObjectGuid guid, uint8 rankId m_level(0), m_class(0), m_flags(GUILDMEMBER_STATUS_NONE), - m_logoutTime(::time(nullptr)), + m_logoutTime(GameTime::GetGameTime()), m_accountId(0), m_rankId(rankId) { @@ -677,6 +680,11 @@ void Guild::Member::ChangeRank(SQLTransaction& trans, uint8 newRank) CharacterDatabase.ExecuteOrAppend(trans, stmt); } +void Guild::Member::UpdateLogoutTime() +{ + m_logoutTime = GameTime::GetGameTime(); +} + void Guild::Member::SaveToDB(SQLTransaction& trans) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_MEMBER); @@ -748,7 +756,7 @@ void Guild::Member::WritePacket(WorldPacket& data, bool sendOfficerNote) const << uint32(m_zoneId); if (!m_flags) - data << float(float(::time(nullptr) - m_logoutTime) / DAY); + data << float(float(GameTime::GetGameTime() - m_logoutTime) / DAY); data << m_publicNote; @@ -1225,7 +1233,7 @@ bool Guild::Create(Player* pLeader, std::string const& name) m_info = ""; m_motd = "No message set."; m_bankMoney = 0; - m_createdDate = ::time(nullptr); + m_createdDate = GameTime::GetGameTime(); _CreateLogHolders(); TC_LOG_DEBUG("guild", "GUILD: creating guild [%s] for leader %s (%u)", diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index 4c904dd8e37..8d5de22a310 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -309,7 +309,7 @@ class TC_GAME_API Guild void ChangeRank(SQLTransaction& trans, uint8 newRank); - inline void UpdateLogoutTime() { m_logoutTime = ::time(nullptr); } + inline void UpdateLogoutTime(); inline bool IsRank(uint8 rankId) const { return m_rankId == rankId; } inline bool IsRankNotLower(uint8 rankId) const { return m_rankId <= rankId; } inline bool IsSamePlayer(ObjectGuid guid) const { return m_guid == guid; } @@ -344,7 +344,7 @@ class TC_GAME_API Guild class LogEntry { public: - LogEntry(ObjectGuid::LowType guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(nullptr)) { } + LogEntry(ObjectGuid::LowType guildId, uint32 guid); LogEntry(ObjectGuid::LowType guildId, uint32 guid, time_t timestamp) : m_guildId(guildId), m_guid(guid), m_timestamp(timestamp) { } virtual ~LogEntry() { } diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 89db6ee6e69..44f7d478198 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -23,6 +23,7 @@ #include "Creature.h" #include "DatabaseEnv.h" #include "DBCStructure.h" +#include "GameTime.h" #include "Item.h" #include "Language.h" #include "Log.h" @@ -307,7 +308,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) AH->bidder = 0; AH->bid = 0; AH->buyout = buyout; - AH->expire_time = time(nullptr) + auctionTime; + AH->expire_time = GameTime::GetGameTime() + auctionTime; AH->deposit = deposit; AH->etime = etime; AH->auctionHouseEntry = auctionHouseEntry; @@ -364,7 +365,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) AH->bidder = 0; AH->bid = 0; AH->buyout = buyout; - AH->expire_time = time(nullptr) + auctionTime; + AH->expire_time = GameTime::GetGameTime() + auctionTime; AH->deposit = deposit; AH->etime = etime; AH->auctionHouseEntry = auctionHouseEntry; diff --git a/src/server/game/Handlers/BattlefieldHandler.cpp b/src/server/game/Handlers/BattlefieldHandler.cpp index cbf6b0b87a9..a912abfd5ec 100644 --- a/src/server/game/Handlers/BattlefieldHandler.cpp +++ b/src/server/game/Handlers/BattlefieldHandler.cpp @@ -18,6 +18,7 @@ #include "WorldSession.h" #include "Battlefield.h" #include "BattlefieldMgr.h" +#include "GameTime.h" #include "Log.h" #include "Opcodes.h" #include "Player.h" @@ -37,7 +38,7 @@ void WorldSession::SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint3 WorldPacket data(SMSG_BATTLEFIELD_MGR_ENTRY_INVITE, 12); data << uint32(battleId); data << uint32(zoneId); - data << uint32(time(nullptr) + acceptTime); + data << uint32(GameTime::GetGameTime() + acceptTime); SendPacket(&data); } diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 4384ff82474..b239a771615 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -42,6 +42,7 @@ Copied events should probably have a new owner #include "DatabaseEnv.h" #include "DBCStores.h" #include "GameEventMgr.h" +#include "GameTime.h" #include "Guild.h" #include "GuildMgr.h" #include "InstanceSaveMgr.h" @@ -58,7 +59,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) ObjectGuid guid = _player->GetGUID(); TC_LOG_DEBUG("network", "CMSG_CALENDAR_GET_CALENDAR [%s]", guid.ToString().c_str()); - time_t currTime = time(nullptr); + time_t currTime = GameTime::GetGameTime(); WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance @@ -239,7 +240,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData) // prevent events in the past // To Do: properly handle timezones and remove the "- time_t(86400L)" hack - if (time_t(eventPackedTime) < (time(nullptr) - time_t(86400L))) + if (time_t(eventPackedTime) < (GameTime::GetGameTime() - time_t(86400L))) { recvData.rfinish(); return; @@ -332,7 +333,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recvData) // prevent events in the past // To Do: properly handle timezones and remove the "- time_t(86400L)" hack - if (time_t(eventPackedTime) < (time(nullptr) - time_t(86400L))) + if (time_t(eventPackedTime) < (GameTime::GetGameTime() - time_t(86400L))) { recvData.rfinish(); return; @@ -389,7 +390,7 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recvData) // prevent events in the past // To Do: properly handle timezones and remove the "- time_t(86400L)" hack - if (time_t(eventTime) < (time(nullptr) - time_t(86400L))) + if (time_t(eventTime) < (GameTime::GetGameTime() - time_t(86400L))) { recvData.rfinish(); return; @@ -532,7 +533,7 @@ void WorldSession::HandleCalendarEventSignup(WorldPacket& recvData) } CalendarInviteStatus status = tentative ? CALENDAR_STATUS_TENTATIVE : CALENDAR_STATUS_SIGNED_UP; - CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, guid, guid, time(nullptr), status, CALENDAR_RANK_PLAYER, ""); + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, guid, guid, GameTime::GetGameTime(), status, CALENDAR_RANK_PLAYER, ""); sCalendarMgr->AddInvite(calendarEvent, invite); sCalendarMgr->SendCalendarClearPendingAction(guid); } @@ -564,7 +565,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) { invite->SetStatus(CalendarInviteStatus(status)); - invite->SetStatusTime(time(nullptr)); + invite->SetStatusTime(GameTime::GetGameTime()); sCalendarMgr->UpdateInvite(invite); sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite); @@ -733,7 +734,7 @@ void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData) void WorldSession::SendCalendarRaidLockout(InstanceSave const* save, bool add) { TC_LOG_DEBUG("network", "%s", add ? "SMSG_CALENDAR_RAID_LOCKOUT_ADDED" : "SMSG_CALENDAR_RAID_LOCKOUT_REMOVED"); - time_t currTime = time(nullptr); + time_t currTime = GameTime::GetGameTime(); WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_REMOVED, (add ? 4 : 0) + 4 + 4 + 4 + 8); if (add) @@ -758,7 +759,7 @@ void WorldSession::SendCalendarRaidLockoutUpdated(InstanceSave const* save) TC_LOG_DEBUG("network", "SMSG_CALENDAR_RAID_LOCKOUT_UPDATED [%s] Map: %u, Difficulty %u", guid.ToString().c_str(), save->GetMapId(), save->GetDifficulty()); - time_t currTime = time(nullptr); + time_t currTime = GameTime::GetGameTime(); WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, 4 + 4 + 4 + 4 + 8); data.AppendPackedTime(currTime); diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index df8f418c245..1bab6418e6c 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -125,7 +125,7 @@ bool LoginQueryHolder::Initialize() stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_MAILCOUNT); stmt->setUInt32(0, lowGuid); - stmt->setUInt64(1, uint64(time(nullptr))); + stmt->setUInt64(1, uint64(GameTime::GetGameTime())); res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_MAIL_COUNT, stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_MAILDATE); diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp index 259bc08838e..bc43cd8b84e 100644 --- a/src/server/game/Handlers/ChatHandler.cpp +++ b/src/server/game/Handlers/ChatHandler.cpp @@ -25,6 +25,7 @@ #include "Chat.h" #include "DatabaseEnv.h" #include "DBCStores.h" +#include "GameTime.h" #include "GridNotifiersImpl.h" #include "Group.h" #include "Guild.h" @@ -161,7 +162,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) if (!sender->CanSpeak()) { - std::string timeStr = secsToTimeString(m_muteTime - time(nullptr)); + std::string timeStr = secsToTimeString(m_muteTime - GameTime::GetGameTime()); SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str()); recvData.rfinish(); // Prevent warnings return; @@ -577,7 +578,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData) if (!GetPlayer()->CanSpeak()) { - std::string timeStr = secsToTimeString(m_muteTime - time(nullptr)); + std::string timeStr = secsToTimeString(m_muteTime - GameTime::GetGameTime()); SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str()); return; } diff --git a/src/server/game/Handlers/DuelHandler.cpp b/src/server/game/Handlers/DuelHandler.cpp index c520100b470..14e31ee77a5 100644 --- a/src/server/game/Handlers/DuelHandler.cpp +++ b/src/server/game/Handlers/DuelHandler.cpp @@ -19,6 +19,7 @@ #include "Common.h" #include "WorldPacket.h" #include "WorldSession.h" +#include "GameTime.h" #include "Log.h" #include "Player.h" @@ -43,7 +44,7 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) TC_LOG_DEBUG("network", "Player 1 is: %u (%s)", player->GetGUID().GetCounter(), player->GetName().c_str()); TC_LOG_DEBUG("network", "Player 2 is: %u (%s)", plTarget->GetGUID().GetCounter(), plTarget->GetName().c_str()); - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); player->duel->startTimer = now; plTarget->duel->startTimer = now; diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp index 499d51f21ec..2eb6af77a46 100644 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -17,6 +17,7 @@ #include "LFGMgr.h" #include "Log.h" +#include "GameTime.h" #include "Group.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" @@ -528,7 +529,7 @@ void WorldSession::SendLfgBootProposalUpdate(lfg::LfgPlayerBoot const& boot) lfg::LfgAnswer playerVote = boot.votes.find(guid)->second; uint8 votesNum = 0; uint8 agreeNum = 0; - uint32 secsleft = uint8((boot.cancelTime - time(nullptr)) / 1000); + uint32 secsleft = uint8((boot.cancelTime - GameTime::GetGameTime()) / 1000); for (lfg::LfgAnswerContainer::const_iterator it = boot.votes.begin(); it != boot.votes.end(); ++it) { if (it->second != lfg::LFG_ANSWER_PENDING) diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index 3d1b995cd1e..9ce773e84d5 100644 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -20,6 +20,7 @@ #include "CharacterCache.h" #include "DatabaseEnv.h" #include "DBCStores.h" +#include "GameTime.h" #include "Item.h" #include "Language.h" #include "Log.h" @@ -397,7 +398,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket& recvData) Player* player = _player; Mail* m = player->GetMail(mailId); - if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(nullptr)) + if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime()) { player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR); return; @@ -463,7 +464,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData) Player* player = _player; Mail* m = player->GetMail(mailId); - if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(nullptr)) + if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime()) { player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR); return; @@ -564,7 +565,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket& recvData) Player* player = _player; Mail* m = player->GetMail(mailId); - if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(nullptr)) + if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime()) { player->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR); return; @@ -613,7 +614,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData) WorldPacket data(SMSG_MAIL_LIST_RESULT, (200)); // guess size data << uint32(0); // real mail's count data << uint8(0); // mail's count - time_t cur_time = time(nullptr); + time_t cur_time = GameTime::GetGameTime(); for (PlayerMails::iterator itr = player->GetMailBegin(); itr != player->GetMailEnd(); ++itr) { @@ -660,7 +661,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData) data << uint32((*itr)->stationery); // stationery (Stationery.dbc) data << uint32((*itr)->money); // Gold data << uint32((*itr)->checked); // flags - data << float(float((*itr)->expire_time-time(nullptr))/DAY); // Time + data << float(float((*itr)->expire_time - GameTime::GetGameTime())/DAY); // Time data << uint32((*itr)->mailTemplateId); // mail template (MailTemplate.dbc) data << (*itr)->subject; // Subject string - once 00, when mail type = 3, max 256 data << (*itr)->body; // message? max 8000 @@ -724,7 +725,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket& recvData) Player* player = _player; Mail* m = player->GetMail(mailId); - if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(nullptr) || (m->checked & MAIL_CHECK_MASK_COPIED)) + if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime() || (m->checked & MAIL_CHECK_MASK_COPIED)) { player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR); return; @@ -786,7 +787,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recvData*/) data << uint32(0); // count uint32 count = 0; - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); std::set<uint32> sentSenders; for (PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) { diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 9a130fab45f..ee186e3c490 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -404,7 +404,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recvData*/) GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } - LogoutRequest(time(nullptr)); + LogoutRequest(GameTime::GetGameTime()); } void WorldSession::HandlePlayerLogoutOpcode(WorldPacket& /*recvData*/) @@ -466,7 +466,7 @@ void WorldSession::HandleTogglePvP(WorldPacket& recvData) else { if (!GetPlayer()->pvpInfo.IsHostile && GetPlayer()->IsPvP()) - GetPlayer()->pvpInfo.EndTimer = time(nullptr); // start toggle-off + GetPlayer()->pvpInfo.EndTimer = GameTime::GetGameTime(); // start toggle-off } //if (OutdoorPvP* pvp = _player->GetOutdoorPvP()) @@ -551,7 +551,7 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket& recvData) return; // prevent resurrect before 30-sec delay after body release not finished - if (time_t(corpse->GetGhostTime() + _player->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP)) > time_t(time(nullptr))) + if (time_t(corpse->GetGhostTime() + _player->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP)) > GameTime::GetGameTime()) return; if (!corpse->IsWithinDistInMap(_player, CORPSE_RECLAIM_RADIUS, true)) @@ -1478,7 +1478,7 @@ void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket& /*recvData*/) TC_LOG_DEBUG("network", "WORLD: CMSG_WORLD_STATE_UI_TIMER_UPDATE"); WorldPacket data(SMSG_WORLD_STATE_UI_TIMER_UPDATE, 4); - data << uint32(time(nullptr)); + data << uint32(GameTime::GetGameTime()); SendPacket(&data); } diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index a8b365e5db2..7d6d27efd47 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -164,7 +164,7 @@ void WorldSession::HandleMoveWorldportAck() { if (time_t timeReset = sInstanceSaveMgr->GetResetTimeFor(mEntry->MapID, diff)) { - uint32 timeleft = uint32(timeReset - time(nullptr)); + uint32 timeleft = uint32(timeReset - GameTime::GetGameTime()); GetPlayer()->SendInstanceResetWarning(mEntry->MapID, diff, timeleft, true); } } diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index c2018e438b5..d285681fa9f 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -675,7 +675,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData) CharacterDatabase.CommitTransaction(trans); - pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); // cast can't be helped + pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped } void WorldSession::HandlePetAbandon(WorldPacket& recvData) diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index a2566c9a7f0..c5258d1b770 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -21,6 +21,7 @@ #include "Common.h" #include "DatabaseEnv.h" #include "DBCStores.h" +#include "GameTime.h" #include "Log.h" #include "MapManager.h" #include "NPCHandler.h" @@ -83,8 +84,8 @@ void WorldSession::HandleQueryTimeOpcode(WorldPacket & /*recvData*/) void WorldSession::SendQueryTimeResponse() { WorldPacket data(SMSG_QUERY_TIME_RESPONSE, 4+4); - data << uint32(time(nullptr)); - data << uint32(sWorld->GetNextDailyQuestsResetTime() - time(nullptr)); + data << uint32(GameTime::GetGameTime()); + data << uint32(sWorld->GetNextDailyQuestsResetTime() - GameTime::GetGameTime()); SendPacket(&data); } diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index 6510875ed7a..09cae9ada8d 100644 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -19,6 +19,7 @@ #include "WorldSession.h" #include "Common.h" #include "DatabaseEnv.h" +#include "GameTime.h" #include "Language.h" #include "Log.h" #include "ObjectMgr.h" @@ -251,7 +252,7 @@ void WorldSession::HandleReportLag(WorldPacket& recvData) stmt->setFloat (4, y); stmt->setFloat (5, z); stmt->setUInt32(6, GetLatency()); - stmt->setUInt32(7, time(nullptr)); + stmt->setUInt32(7, GameTime::GetGameTime()); CharacterDatabase.Execute(stmt); } diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index a4b53c3ab78..6b010315afe 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -21,6 +21,7 @@ #include "Config.h" #include "DatabaseEnv.h" #include "DBCStores.h" +#include "GameTime.h" #include "GridNotifiers.h" #include "GridStates.h" #include "Group.h" @@ -105,7 +106,7 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance resetTime = GetResetTimeFor(mapId, difficulty); else { - resetTime = time(nullptr) + 2 * HOUR; + resetTime = GameTime::GetGameTime() + 2 * HOUR; // normally this will be removed soon after in InstanceMap::Add, prevent error ScheduleReset(true, resetTime, InstResetEvent(0, mapId, difficulty, instanceId)); } @@ -300,7 +301,7 @@ void InstanceSaveManager::LoadInstances() void InstanceSaveManager::LoadResetTimes() { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); time_t today = (now / DAY) * DAY; // NOTE: Use DirectPExecute for tables that will be queried later @@ -511,12 +512,12 @@ void InstanceSaveManager::ForceGlobalReset(uint32 mapId, Difficulty difficulty) ScheduleReset(false, 0, InstResetEvent(1, mapId, difficulty, 0)); ScheduleReset(false, 0, InstResetEvent(4, mapId, difficulty, 0)); // force global reset on the instance - _ResetOrWarnAll(mapId, difficulty, false, time(nullptr)); + _ResetOrWarnAll(mapId, difficulty, false, GameTime::GetGameTime()); } void InstanceSaveManager::Update() { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); time_t t; while (!m_resetTimeQueue.empty()) @@ -633,7 +634,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b return; TC_LOG_DEBUG("misc", "InstanceSaveManager::ResetOrWarnAll: Processing map %s (%u) on difficulty %u (warn? %u)", mapEntry->name[0], mapid, uint8(difficulty), warn); - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); if (!warn) { diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp index 780b98346ac..b6455522587 100644 --- a/src/server/game/Mails/Mail.cpp +++ b/src/server/game/Mails/Mail.cpp @@ -22,6 +22,7 @@ #include "CalendarMgr.h" #include "CharacterCache.h" #include "DatabaseEnv.h" +#include "GameTime.h" #include "Item.h" #include "Log.h" #include "LootMgr.h" @@ -190,7 +191,7 @@ void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, uint32 mailId = sObjectMgr->GenerateMailID(); - time_t deliver_time = time(nullptr) + deliver_delay; + time_t deliver_time = GameTime::GetGameTime() + deliver_delay; //expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour uint32 expire_delay; diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 43b82be7723..2c989718bff 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2977,7 +2977,7 @@ bool Map::CheckRespawn(RespawnInfo* info) ObjectGuid thisGUID = ObjectGuid((info->type == SPAWN_TYPE_GAMEOBJECT) ? HighGuid::GameObject : HighGuid::Unit, info->entry, info->spawnId); if (time_t linkedTime = GetLinkedRespawnTime(thisGUID)) { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); time_t respawnTime; if (linkedTime == std::numeric_limits<time_t>::max()) respawnTime = linkedTime; @@ -3008,7 +3008,7 @@ bool Map::CheckRespawn(RespawnInfo* info) { if (!sScriptMgr->CanSpawn(info->spawnId, info->entry, sObjectMgr->GetCreatureData(info->spawnId), this)) { // if a script blocks our respawn, schedule next check in a little bit - info->respawnTime = time(nullptr) + urand(4, 7); + info->respawnTime = GameTime::GetGameTime() + urand(4, 7); return false; } } @@ -3181,7 +3181,7 @@ void Map::RemoveRespawnTime(RespawnVector& respawnData, bool doRespawn, SQLTrans void Map::ProcessRespawns() { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); while (!_respawnTimes.empty()) { RespawnInfo* next = _respawnTimes.top(); @@ -3278,7 +3278,7 @@ bool Map::SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn, bool force, std::v continue; time_t respawnTime = GetRespawnTime(data->type, data->spawnId); - if (respawnTime && respawnTime > time(nullptr)) + if (respawnTime && respawnTime > GameTime::GetGameTime()) { if (!force && !ignoreRespawn) continue; @@ -3734,7 +3734,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) // increase current instances (hourly limit) if (!group || !group->isLFGGroup()) - player->AddInstanceEnterTime(GetInstanceId(), time(nullptr)); + player->AddInstanceEnterTime(GetInstanceId(), GameTime::GetGameTime()); // get or create an instance save for the map InstanceSave* mapSave = sInstanceSaveMgr->GetInstanceSave(GetInstanceId()); @@ -4506,7 +4506,7 @@ Corpse* Map::ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia /*= void Map::RemoveOldCorpses() { - time_t now = time(nullptr); + time_t now = GameTime::GetGameTime(); std::vector<ObjectGuid> corpses; corpses.reserve(_corpsesByPlayer.size()); diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 58f9bbda64d..1cc034b6833 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -281,7 +281,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) bool deletePacket = true; std::vector<WorldPacket*> requeuePackets; uint32 processedPackets = 0; - time_t currentTime = time(nullptr); + time_t currentTime = GameTime::GetGameTime(); while (m_Socket && _recvQueue.next(packet, updater)) { @@ -405,9 +405,8 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) //logout procedure should happen only in World::UpdateSessions() method!!! if (updater.ProcessLogout()) { - time_t currTime = time(nullptr); ///- If necessary, log the player out - if (ShouldLogOut(currTime) && !m_playerLoading) + if (ShouldLogOut(currentTime) && !m_playerLoading) LogoutPlayer(true); if (m_Socket && GetPlayer() && _warden) @@ -752,7 +751,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string c void WorldSession::SendAccountDataTimes(uint32 mask) { WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4 + 1 + 4 + NUM_ACCOUNT_DATA_TYPES * 4); - data << uint32(time(nullptr)); // Server time + data << uint32(GameTime::GetGameTime()); // Server time data << uint8(1); data << uint32(mask); // type mask for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i) diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index f759e2d27dd..5d402ed35ab 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -19,6 +19,7 @@ #include "WorldSocket.h" #include "BigNumber.h" #include "DatabaseEnv.h" +#include "GameTime.h" #include "Opcodes.h" #include "PacketLog.h" #include "Random.h" @@ -552,7 +553,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes //! Negative mutetime indicates amount of seconds to be muted effective on next login - which is now. if (mutetime < 0) { - mutetime = time(nullptr) + llabs(mutetime); + mutetime = GameTime::GetGameTime() + llabs(mutetime); PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME_LOGIN); stmt->setInt64(0, mutetime); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 42c129899fb..a6213736961 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -342,7 +342,7 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne Aura::Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, ObjectGuid casterGUID) : m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()), -m_castItemGuid(castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_applyTime(time(nullptr)), +m_castItemGuid(castItem ? castItem->GetGUID() : ObjectGuid::Empty), m_applyTime(GameTime::GetGameTime()), m_owner(owner), m_timeCla(0), m_updateTargetMapInterval(0), m_casterLevel(caster ? caster->getLevel() : m_spellInfo->SpellLevel), m_procCharges(0), m_stackAmount(1), m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false), m_dropEvent(nullptr), diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index 1260ff6937b..6f97e97b8e7 100644 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -21,6 +21,7 @@ #include "Chat.h" #include "Common.h" #include "DatabaseEnv.h" +#include "GameTime.h" #include "Language.h" #include "Log.h" #include "ObjectAccessor.h" @@ -30,7 +31,7 @@ #include "WorldPacket.h" #include "WorldSession.h" -inline float GetAge(uint64 t) { return float(time(nullptr) - t) / DAY; } +inline float GetAge(uint64 t) { return float(GameTime::GetGameTime() - t) / DAY; } /////////////////////////////////////////////////////////////////////////////////////////////////// // GM ticket @@ -38,7 +39,7 @@ GmTicket::GmTicket() : _id(0), _type(TICKET_TYPE_OPEN), _posX(0), _posY(0), _pos _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needResponse(false), _needMoreHelp(false) { } -GmTicket::GmTicket(Player* player) : _type(TICKET_TYPE_OPEN), _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(time(nullptr)), _lastModifiedTime(time(nullptr)), +GmTicket::GmTicket(Player* player) : _type(TICKET_TYPE_OPEN), _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(GameTime::GetGameTime()), _lastModifiedTime(GameTime::GetGameTime()), _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needResponse(false), _needMoreHelp(false) { @@ -173,7 +174,7 @@ void GmTicket::SendResponse(WorldSession* session) const std::string GmTicket::FormatMessageString(ChatHandler& handler, bool detailed) const { - time_t curTime = time(nullptr); + time_t curTime = GameTime::GetGameTime(); std::stringstream ss; ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _id); @@ -214,6 +215,12 @@ std::string GmTicket::FormatMessageString(ChatHandler& handler, char const* szCl return ss.str(); } +void GmTicket::SetMessage(std::string const& message) +{ + _message = message; + _lastModifiedTime = uint64(GameTime::GetGameTime()); +} + void GmTicket::SetUnassigned() { _assignedTo.Clear(); @@ -264,7 +271,7 @@ void GmTicket::SetChatLog(std::list<uint32> time, std::string const& log) /////////////////////////////////////////////////////////////////////////////////////////////////// // Ticket manager TicketMgr::TicketMgr() : _status(true), _lastTicketId(0), _lastSurveyId(0), _openTicketCount(0), - _lastChange(time(nullptr)) { } + _lastChange(GameTime::GetGameTime()) { } TicketMgr::~TicketMgr() { @@ -407,6 +414,11 @@ void TicketMgr::RemoveTicket(uint32 ticketId) } } +void TicketMgr::UpdateLastChange() +{ + _lastChange = uint64(GameTime::GetGameTime()); +} + void TicketMgr::ShowList(ChatHandler& handler, bool onlineOnly) const { handler.SendSysMessage(onlineOnly ? LANG_COMMAND_TICKETSHOWONLINELIST : LANG_COMMAND_TICKETSHOWLIST); diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index 199265b1aec..be22a4317e1 100644 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -123,11 +123,7 @@ public: void SetClosedBy(ObjectGuid value) { _closedBy = value; _type = TICKET_TYPE_CLOSED; } void SetResolvedBy(ObjectGuid value) { _resolvedBy = value; } void SetCompleted() { _completed = true; } - void SetMessage(std::string const& message) - { - _message = message; - _lastModifiedTime = uint64(time(nullptr)); - } + void SetMessage(std::string const& message); void SetComment(std::string const& comment) { _comment = comment; } void SetViewed() { _viewed = true; } void SetUnassigned(); @@ -224,7 +220,7 @@ public: void SetStatus(bool status) { _status = status; } uint64 GetLastChange() const { return _lastChange; } - void UpdateLastChange() { _lastChange = uint64(time(nullptr)); } + void UpdateLastChange(); uint32 GenerateTicketId() { return ++_lastTicketId; } uint32 GetOpenTicketCount() const { return _openTicketCount; } diff --git a/src/server/game/Time/GameTime.cpp b/src/server/game/Time/GameTime.cpp index 8884d4612be..192702d570e 100644 --- a/src/server/game/Time/GameTime.cpp +++ b/src/server/game/Time/GameTime.cpp @@ -22,7 +22,7 @@ namespace GameTime { time_t const StartTime = time(nullptr); - time_t GameTime = 0; + time_t GameTime = time(nullptr); uint32 GameMSTime = 0; std::chrono::system_clock::time_point GameTimeSystemPoint = std::chrono::system_clock::time_point::min(); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index d3f42088e32..bfbdccca283 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -138,7 +138,7 @@ World::World() _guidWarn = false; _guidAlert = false; _warnDiff = 0; - _warnShutdownTime = time(nullptr); + _warnShutdownTime = GameTime::GetGameTime(); } /// World destructor @@ -362,7 +362,7 @@ bool World::HasRecentlyDisconnected(WorldSession* session) { for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end();) { - if (difftime(i->second, time(nullptr)) < tolerance) + if (difftime(i->second, GameTime::GetGameTime()) < tolerance) { if (i->first == session->GetAccountId()) return true; @@ -1503,7 +1503,7 @@ void World::SetInitialWorldSettings() uint32 startupBegin = getMSTime(); ///- Initialize the random number generator - srand((unsigned int)time(nullptr)); + srand((unsigned int)GameTime::GetGameTime()); ///- Initialize detour memory management dtAllocSetCustom(dtCustomAlloc, dtCustomFree); @@ -2979,7 +2979,7 @@ void World::UpdateSessions(uint32 diff) if (!pSession->Update(diff, updater)) // As interval = 0 { if (!RemoveQueuedPlayer(itr->second) && itr->second && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) - m_disconnects[itr->second->GetAccountId()] = time(nullptr); + m_disconnects[itr->second->GetAccountId()] = GameTime::GetGameTime(); RemoveQueuedPlayer(pSession); m_sessions.erase(itr); delete pSession; @@ -3099,7 +3099,7 @@ void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount) void World::InitWeeklyQuestResetTime() { time_t wstime = uint64(sWorld->getWorldState(WS_WEEKLY_QUEST_RESET_TIME)); - time_t curtime = time(nullptr); + time_t curtime = GameTime::GetGameTime(); m_NextWeeklyQuestReset = wstime < curtime ? curtime : time_t(wstime); } @@ -3118,7 +3118,7 @@ void World::InitDailyQuestResetTime(bool loading) } // FIX ME: client not show day start time - time_t curTime = time(nullptr); + time_t curTime = GameTime::GetGameTime(); tm localTm; localtime_r(&curTime, &localTm); localTm.tm_hour = getIntConfig(CONFIG_DAILY_QUEST_RESET_TIME_HOUR); @@ -3141,7 +3141,7 @@ void World::InitDailyQuestResetTime(bool loading) void World::InitMonthlyQuestResetTime() { time_t wstime = uint64(sWorld->getWorldState(WS_MONTHLY_QUEST_RESET_TIME)); - time_t curtime = time(nullptr); + time_t curtime = GameTime::GetGameTime(); m_NextMonthlyQuestReset = wstime < curtime ? curtime : time_t(wstime); } @@ -3149,10 +3149,10 @@ void World::InitRandomBGResetTime() { time_t bgtime = uint64(sWorld->getWorldState(WS_BG_DAILY_RESET_TIME)); if (!bgtime) - m_NextRandomBGReset = time_t(time(nullptr)); // game time not yet init + m_NextRandomBGReset = time_t(GameTime::GetGameTime()); // game time not yet init // generate time by config - time_t curTime = time(nullptr); + time_t curTime = GameTime::GetGameTime(); tm localTm; localtime_r(&curTime, &localTm); localTm.tm_hour = getIntConfig(CONFIG_RANDOM_BG_RESET_HOUR); @@ -3177,10 +3177,10 @@ void World::InitGuildResetTime() { time_t gtime = uint64(getWorldState(WS_GUILD_DAILY_RESET_TIME)); if (!gtime) - m_NextGuildReset = time_t(time(nullptr)); // game time not yet init + m_NextGuildReset = time_t(GameTime::GetGameTime()); // game time not yet init // generate time by config - time_t curTime = time(nullptr); + time_t curTime = GameTime::GetGameTime(); tm localTm; localtime_r(&curTime, &localTm); localTm.tm_hour = getIntConfig(CONFIG_GUILD_RESET_HOUR); @@ -3265,7 +3265,7 @@ void World::ResetMonthlyQuests() itr->second->GetPlayer()->ResetMonthlyQuestStatus(); // generate time - time_t curTime = time(nullptr); + time_t curTime = GameTime::GetGameTime(); tm localTm; localtime_r(&curTime, &localTm); 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<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 |