diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 3d151546b..9ca9cbae2 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -9,7 +9,6 @@ #include "Pet.h" #include "Player.h" #include "DBCStores.h" -#include "GameTime.h" #include "Spell.h" #include "ObjectAccessor.h" #include "SpellMgr.h" @@ -52,7 +51,7 @@ bool PetAI::_needToStop() if (!me->_CanDetectFeignDeathOf(me->GetVictim())) return true; - if (me->isTargetNotAcceptableByMMaps(me->GetVictim()->GetGUID(), GameTime::GetGameTime(), me->GetVictim())) + if (me->isTargetNotAcceptableByMMaps(me->GetVictim()->GetGUID(), sWorld->GetGameTime(), me->GetVictim())) return true; return !me->CanCreatureAttack(me->GetVictim()); @@ -434,7 +433,7 @@ Unit* PetAI::SelectNextTarget(bool allowAutoSelect) const // Check pet attackers first so we don't drag a bunch of targets to the owner if (Unit* myAttacker = me->getAttackerForHelper()) - if (!myAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(myAttacker) && me->CanCreatureAttack(myAttacker) && !me->isTargetNotAcceptableByMMaps(myAttacker->GetGUID(), GameTime::GetGameTime(), myAttacker)) + if (!myAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(myAttacker) && me->CanCreatureAttack(myAttacker) && !me->isTargetNotAcceptableByMMaps(myAttacker->GetGUID(), sWorld->GetGameTime(), myAttacker)) return myAttacker; // Check pet's attackers first to prevent dragging mobs back to owner @@ -455,13 +454,13 @@ Unit* PetAI::SelectNextTarget(bool allowAutoSelect) const // Check owner attackers if (Unit* ownerAttacker = owner->getAttackerForHelper()) - if (!ownerAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(ownerAttacker) && me->CanCreatureAttack(ownerAttacker) && !me->isTargetNotAcceptableByMMaps(ownerAttacker->GetGUID(), GameTime::GetGameTime(), ownerAttacker)) + if (!ownerAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(ownerAttacker) && me->CanCreatureAttack(ownerAttacker) && !me->isTargetNotAcceptableByMMaps(ownerAttacker->GetGUID(), sWorld->GetGameTime(), ownerAttacker)) return ownerAttacker; // Check owner victim // 3.0.2 - Pets now start attacking their owners victim in defensive mode as soon as the hunter does if (Unit* ownerVictim = owner->GetVictim()) - if (me->_CanDetectFeignDeathOf(ownerVictim) && me->CanCreatureAttack(ownerVictim) && !me->isTargetNotAcceptableByMMaps(ownerVictim->GetGUID(), GameTime::GetGameTime(), ownerVictim)) + if (me->_CanDetectFeignDeathOf(ownerVictim) && me->CanCreatureAttack(ownerVictim) && !me->isTargetNotAcceptableByMMaps(ownerVictim->GetGUID(), sWorld->GetGameTime(), ownerVictim)) return ownerVictim; // Neither pet or owner had a target and aggressive pets can pick any target diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 7bd45cf51..77e73b38b 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -10,7 +10,6 @@ #include "Spell.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "GameTime.h" #include "Cell.h" #include "CellImpl.h" #include "ObjectMgr.h" @@ -418,9 +417,9 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea() if (me->IsInEvadeMode() || !me->IsInCombat()) return false; - if (_evadeCheckCooldown == GameTime::GetGameTime()) + if (_evadeCheckCooldown == time(NULL)) return false; - _evadeCheckCooldown = GameTime::GetGameTime(); + _evadeCheckCooldown = time(NULL); if (!CheckEvadeIfOutOfCombatArea()) return false; diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 89ca7b254..d98b1ac31 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -17,7 +17,6 @@ #include "DBCEnums.h" #include "DisableMgr.h" #include "GameEventMgr.h" -#include "GameTime.h" #include "GridNotifiersImpl.h" #include "Guild.h" #include "GuildMgr.h" @@ -435,7 +434,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un birthday_tm.tm_year += birthday_login.nth_birthday; time_t birthday = mktime(&birthday_tm); - time_t now = GameTime::GetGameTime(); + time_t now = sWorld->GetGameTime(); return now <= birthday + DAY && now >= birthday; } case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_KNOWN_TITLE: @@ -643,7 +642,7 @@ void AchievementMgr::LoadFromDB(PreparedQueryResult achievementResult, PreparedQ continue; } - if (criteria->timeLimit && time_t(date + criteria->timeLimit) < GameTime::GetGameTime()) + if (criteria->timeLimit && time_t(date + criteria->timeLimit) < time(NULL)) continue; CriteriaProgress& progress = m_criteriaProgress[id]; @@ -702,7 +701,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8); data.append(GetPlayer()->GetPackGUID()); data << uint32(achievement->ID); - data.AppendPackedTime(GameTime::GetGameTime()); + data.AppendPackedTime(time(NULL)); data << uint32(0); GetPlayer()->SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true); } @@ -2044,7 +2043,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry, } progress->changed = true; - progress->date = GameTime::GetGameTime(); // set the date to the latest update. + progress->date = time(NULL); // set the date to the latest update. uint32 timeElapsed = 0; bool timedCompleted = false; @@ -2164,7 +2163,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) SendAchievementEarned(achievement); CompletedAchievementData& ca = m_completedAchievements[achievement->ID]; - ca.date = GameTime::GetGameTime(); + ca.date = time(NULL); ca.changed = true; sScriptMgr->OnAchievementComplete(GetPlayer(), achievement); diff --git a/src/server/game/ArenaSpectator/ArenaSpectator.h b/src/server/game/ArenaSpectator/ArenaSpectator.h index 42d31785e..f60cf9d9f 100644 --- a/src/server/game/ArenaSpectator/ArenaSpectator.h +++ b/src/server/game/ArenaSpectator/ArenaSpectator.h @@ -6,7 +6,6 @@ #include "World.h" #include "Map.h" #include "Battleground.h" -#include "GameTime.h" #include "Pet.h" #include "SpellAuras.h" #include "SpellAuraEffects.h" @@ -179,7 +178,7 @@ namespace ArenaSpectator SpellCooldowns const& sc = plr->GetSpellCooldownMap(); for (SpellCooldowns::const_iterator itrc = sc.begin(); itrc != sc.end(); ++itrc) if (itrc->second.sendToSpectator && itrc->second.maxduration >= SPECTATOR_COOLDOWN_MIN*IN_MILLISECONDS && itrc->second.maxduration <= SPECTATOR_COOLDOWN_MAX*IN_MILLISECONDS) - if (uint32 cd = (getMSTimeDiff(GameTime::GetGameTimeMS(), itrc->second.end)/1000)) + if (uint32 cd = (getMSTimeDiff(World::GetGameTimeMS(), itrc->second.end)/1000)) SendCommand_Cooldown(p, itr->first, "ACD", itrc->first, cd, itrc->second.maxduration/1000); // send all visible "AUR" diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index ab3bf503a..4aba5703b 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -18,7 +18,6 @@ #include "Item.h" #include "Language.h" #include "Logging/Log.h" -#include "GameTime.h" #include #include "AvgDiffTracker.h" #include "AsyncAuctionListing.h" @@ -425,7 +424,7 @@ bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction) void AuctionHouseObject::Update() { - time_t checkTime = GameTime::GetGameTime() + 60; + time_t checkTime = sWorld->GetGameTime() + 60; ///- Handle expired auctions // If storage is empty, no need to update. next == NULL in this case. @@ -523,7 +522,7 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player return true; } - time_t curTime = GameTime::GetGameTime(); + time_t curTime = sWorld->GetGameTime(); int loc_idx = player->GetSession()->GetSessionDbLocaleIndex(); int locdbc_idx = player->GetSession()->GetSessionDbcLocale(); @@ -532,7 +531,7 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player { if (AsyncAuctionListingMgr::IsAuctionListingAllowed() == false) // pussywizard: World::Update is waiting for us... if ((itrcounter++) % 100 == 0) // check condition every 100 iterations - if (avgDiffTracker.getAverage() >= 30 || getMSTimeDiff(GameTime::GetGameTimeMS(), getMSTime()) >= 10) // pussywizard: stop immediately if diff is high or waiting too long + if (avgDiffTracker.getAverage() >= 30 || getMSTimeDiff(World::GetGameTimeMS(), getMSTime()) >= 10) // pussywizard: stop immediately if diff is high or waiting too long return false; AuctionEntry* Aentry = itr->second; @@ -670,7 +669,7 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket& data) const data << uint32(bid ? GetAuctionOutBid() : 0); // Minimal outbid data << uint32(buyout); // Auction->buyout - data << uint32((expire_time - GameTime::GetGameTime()) * IN_MILLISECONDS); // time left + data << uint32((expire_time - time(NULL)) * IN_MILLISECONDS); // time left data << uint64(bidder); // auction->bidder current data << uint32(bid); // current bid return true; diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index f33a82a50..21b532056 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -8,7 +8,6 @@ #include "BattlefieldMgr.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "Map.h" #include "MapManager.h" #include "Group.h" @@ -78,7 +77,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()] = GameTime::GetGameTime() + (player->IsGameMaster() ? 30*MINUTE : 10); + m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + (player->IsGameMaster() ? 30*MINUTE : 10); InvitePlayerToQueue(player); } } @@ -168,7 +167,7 @@ bool Battlefield::Update(uint32 diff) // Kick players who chose not to accept invitation to the battle if (m_uiKickDontAcceptTimer <= diff) { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); for (int team = 0; team < 2; team++) for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); ++itr) if (itr->second <= now) @@ -254,7 +253,7 @@ void Battlefield::InvitePlayersInZoneToWar() if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) InvitePlayerToWar(player); else if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0)// Battlefield is full of players - m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10; + m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10; } } } @@ -278,7 +277,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()] = GameTime::GetGameTime() + 10; + m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10; return; } @@ -287,7 +286,7 @@ void Battlefield::InvitePlayerToWar(Player* player) return; m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID()); - m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + m_TimeForAcceptInvite; + m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = time(NULL) + m_TimeForAcceptInvite; player->GetSession()->SendBfInvitePlayerToWar(m_BattleId, m_ZoneId, m_TimeForAcceptInvite); } diff --git a/src/server/game/Battlefield/BattlefieldHandler.cpp b/src/server/game/Battlefield/BattlefieldHandler.cpp index 08b9c081c..cdb20b6c4 100644 --- a/src/server/game/Battlefield/BattlefieldHandler.cpp +++ b/src/server/game/Battlefield/BattlefieldHandler.cpp @@ -7,7 +7,6 @@ #include "Common.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "WorldPacket.h" #include "WorldSession.h" @@ -26,7 +25,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((GameTime::GetGameTime() + p_time)); + data << uint32((time(NULL) + p_time)); //Sending the packet to player SendPacket(&data); diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 6ebc3b35f..708891200 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -10,7 +10,6 @@ #include "BattlefieldWG.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "Opcodes.h" #include "Player.h" #include "SpellAuras.h" @@ -889,7 +888,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(GameTime::GetGameTime() + (m_Timer / 1000)); + data << ClockWorldState[i] << uint32(time(NULL) + (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) << GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H); diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 9beabab3a..32d47992e 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -9,7 +9,6 @@ #include "ArenaTeamMgr.h" #include "World.h" #include "WorldPacket.h" -#include "GameTime.h" #include "ArenaTeam.h" #include "BattlegroundMgr.h" @@ -130,7 +129,7 @@ void BattlegroundMgr::Update(uint32 diff) { if (m_AutoDistributionTimeChecker < diff) { - if (GameTime::GetGameTime() > m_NextAutoDistributionTime) + if (time(NULL) > m_NextAutoDistributionTime) { sArenaTeamMgr->DistributeArenaPoints(); m_NextAutoDistributionTime = m_NextAutoDistributionTime + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld->getIntConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS); @@ -695,7 +694,7 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution() return; time_t wstime = time_t(sWorld->getWorldState(WS_ARENA_DISTRIBUTION_TIME)); - time_t curtime = GameTime::GetGameTime(); + time_t curtime = time(NULL); sLog->outString("AzerothCore Battleground: Initializing Automatic Arena Point Distribution"); if (wstime < curtime) { @@ -1052,7 +1051,7 @@ void BattlegroundMgr::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, T if (bg->isArena() && bg->isRated()) bg->SetArenaTeamIdForTeam(ginfo->teamId, ginfo->ArenaTeamId); - ginfo->RemoveInviteTime = GameTime::GetGameTimeMS() + INVITE_ACCEPT_WAIT_TIME; + ginfo->RemoveInviteTime = World::GetGameTimeMS() + INVITE_ACCEPT_WAIT_TIME; // loop through the players for (std::set::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr) diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 2e324b191..a35cece87 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -8,7 +8,6 @@ #include "ArenaTeamMgr.h" #include "BattlegroundMgr.h" #include "BattlegroundQueue.h" -#include "GameTime.h" #include "Chat.h" #include "Group.h" #include "Log.h" @@ -125,7 +124,7 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PvPDiffi ginfo->ArenaTeamId = arenateamid; ginfo->IsRated = isRated; ginfo->IsInvitedToBGInstanceGUID = 0; - ginfo->JoinTime = GameTime::GetGameTimeMS(); + ginfo->JoinTime = World::GetGameTimeMS(); ginfo->RemoveInviteTime = 0; ginfo->teamId = leader->GetTeamId(); ginfo->ArenaTeamRating = ArenaRating; @@ -211,7 +210,7 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, PvPDiffi void BattlegroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo) { - uint32 timeInQueue = std::max(1, getMSTimeDiff(ginfo->JoinTime, GameTime::GetGameTimeMS())); + uint32 timeInQueue = std::max(1, getMSTimeDiff(ginfo->JoinTime, World::GetGameTimeMS())); // team_index: bg alliance - TEAM_ALLIANCE, bg horde - TEAM_HORDE, arena skirmish - TEAM_ALLIANCE, arena rated - TEAM_HORDE uint8 team_index; @@ -539,7 +538,7 @@ bool BattlegroundQueue::CheckPremadeMatch(BattlegroundBracketId bracket_id, uint // this happens if timer has expired or group size lowered uint32 premade_time = sWorld->getIntConfig(CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH); - uint32 time_before = GameTime::GetGameTimeMS() >= premade_time ? GameTime::GetGameTimeMS() - premade_time : 0; + uint32 time_before = World::GetGameTimeMS() >= premade_time ? World::GetGameTimeMS() - premade_time : 0; for (uint32 i = 0; i < BG_TEAMS_COUNT; i++) if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i].empty()) @@ -790,7 +789,7 @@ void BattlegroundQueue::BattlegroundQueueUpdate(BattlegroundBracketId bracket_id { // pussywizard: everything inside this section is mine, do NOT destroy! - const uint32 currMSTime = GameTime::GetGameTimeMS(); + const uint32 currMSTime = World::GetGameTimeMS(); const uint32 discardTime = sBattlegroundMgr->GetRatingDiscardTimer(); const uint32 maxDefaultRatingDifference = (MaxPlayersPerTeam > 2 ? 300 : 200); const uint32 maxCountedMMR = 2500; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index 2d49299ab..812c68d3d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -10,7 +10,6 @@ #include "Creature.h" #include "Language.h" #include "Object.h" -#include "GameTime.h" #include "Player.h" #include "Util.h" #include "WorldSession.h" @@ -57,7 +56,7 @@ void BattlegroundEY::PostUpdateImpl(uint32 diff) AddPoints(TEAM_ALLIANCE, BG_EY_TickPoints[_ownedPointsCount[TEAM_ALLIANCE] - 1]); if (_ownedPointsCount[TEAM_HORDE] > 0) AddPoints(TEAM_HORDE, BG_EY_TickPoints[_ownedPointsCount[TEAM_HORDE] - 1]); - _bgEvents.ScheduleEvent(BG_EY_EVENT_ADD_POINTS, BG_EY_FPOINTS_TICK_TIME - (GameTime::GetGameTimeMS() % BG_EY_FPOINTS_TICK_TIME)); + _bgEvents.ScheduleEvent(BG_EY_EVENT_ADD_POINTS, BG_EY_FPOINTS_TICK_TIME - (World::GetGameTimeMS() % BG_EY_FPOINTS_TICK_TIME)); break; case BG_EY_EVENT_FLAG_ON_GROUND: RespawnFlagAfterDrop(); @@ -67,7 +66,7 @@ void BattlegroundEY::PostUpdateImpl(uint32 diff) break; case BG_EY_EVENT_CHECK_CPOINTS: UpdatePointsState(); - _bgEvents.ScheduleEvent(BG_EY_EVENT_CHECK_CPOINTS, BG_EY_FPOINTS_CHECK_TIME - (GameTime::GetGameTimeMS() % BG_EY_FPOINTS_CHECK_TIME)); + _bgEvents.ScheduleEvent(BG_EY_EVENT_CHECK_CPOINTS, BG_EY_FPOINTS_CHECK_TIME - (World::GetGameTimeMS() % BG_EY_FPOINTS_CHECK_TIME)); break; } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index 725cbeace..fc2a6fcb1 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -11,7 +11,6 @@ #include "WorldPacket.h" #include "GameObject.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "Vehicle.h" #include "Transport.h" #include "WorldSession.h" @@ -128,7 +127,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) { // Check if creature respawn time is properly saved RespawnMap::iterator itr = respawnMap.find(catapult->GetGUIDLow()); - if (itr == respawnMap.end() || GameTime::GetGameTime() < itr->second) + if (itr == respawnMap.end() || time(NULL) < itr->second) continue; catapult->Relocate(BG_IC_DocksVehiclesCatapults[j].GetPositionX(), BG_IC_DocksVehiclesCatapults[j].GetPositionY(), BG_IC_DocksVehiclesCatapults[j].GetPositionZ(), BG_IC_DocksVehiclesCatapults[j].GetOrientation()); @@ -146,7 +145,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) { // Check if creature respawn time is properly saved RespawnMap::iterator itr = respawnMap.find(glaiveThrower->GetGUIDLow()); - if (itr == respawnMap.end() || GameTime::GetGameTime() < itr->second) + if (itr == respawnMap.end() || time(NULL) < itr->second) continue; glaiveThrower->Relocate(BG_IC_DocksVehiclesGlaives[j].GetPositionX(), BG_IC_DocksVehiclesGlaives[j].GetPositionY(), BG_IC_DocksVehiclesGlaives[j].GetPositionZ(), BG_IC_DocksVehiclesGlaives[j].GetOrientation()); @@ -175,7 +174,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) { // Check if creature respawn time is properly saved RespawnMap::iterator itr = respawnMap.find(siege->GetGUIDLow()); - if (itr == respawnMap.end() || GameTime::GetGameTime() < itr->second) + if (itr == respawnMap.end() || time(NULL) < itr->second) continue; siege->Relocate(BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(), BG_IC_WorkshopVehicles[4].GetPositionZ(), BG_IC_WorkshopVehicles[4].GetOrientation()); @@ -193,7 +192,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) { // Check if creature respawn time is properly saved RespawnMap::iterator itr = respawnMap.find(demolisher->GetGUIDLow()); - if (itr == respawnMap.end() || GameTime::GetGameTime() < itr->second) + if (itr == respawnMap.end() || time(NULL) < itr->second) continue; demolisher->Relocate(BG_IC_WorkshopVehicles[u].GetPositionX(), BG_IC_WorkshopVehicles[u].GetPositionY(), BG_IC_WorkshopVehicles[u].GetPositionZ(), BG_IC_WorkshopVehicles[u].GetOrientation()); @@ -521,7 +520,7 @@ void BattlegroundIC::HandleKillUnit(Creature* unit, Player* killer) // Xinef: Add to respawn list if (entry == NPC_DEMOLISHER || entry == NPC_SIEGE_ENGINE_H || entry == NPC_SIEGE_ENGINE_A || entry == NPC_GLAIVE_THROWER_A || entry == NPC_GLAIVE_THROWER_H || entry == NPC_CATAPULT) - respawnMap[unit->GetGUIDLow()] = GameTime::GetGameTime() + VEHICLE_RESPAWN_TIME; + respawnMap[unit->GetGUIDLow()] = time(NULL) + VEHICLE_RESPAWN_TIME; } } @@ -868,7 +867,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture) if (!siegeVehicle->IsVehicleInUse()) Unit::Kill(siegeEngine, siegeEngine); - respawnMap[siegeEngine->GetGUIDLow()] = GameTime::GetGameTime() + VEHICLE_RESPAWN_TIME; + respawnMap[siegeEngine->GetGUIDLow()] = time(NULL) + VEHICLE_RESPAWN_TIME; } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 5990eca92..b28340a9c 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -9,7 +9,6 @@ #include "Player.h" #include "GameObject.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "WorldPacket.h" #include "WorldSession.h" #include "GameGraveyard.h" @@ -1060,11 +1059,11 @@ void BattlegroundSA::UpdateDemolisherSpawns() // Demolisher is not in list if (DemoliserRespawnList.find(i) == DemoliserRespawnList.end()) { - DemoliserRespawnList[i] = GameTime::GetGameTimeMS()+30000; + DemoliserRespawnList[i] = World::GetGameTimeMS()+30000; } else { - if (DemoliserRespawnList[i] < GameTime::GetGameTimeMS()) + if (DemoliserRespawnList[i] < World::GetGameTimeMS()) { Demolisher->Relocate(BG_SA_NpcSpawnlocs[i][0], BG_SA_NpcSpawnlocs[i][1], BG_SA_NpcSpawnlocs[i][2], BG_SA_NpcSpawnlocs[i][3]); diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt index b7ee3bc33..98e60ffa7 100644 --- a/src/server/game/CMakeLists.txt +++ b/src/server/game/CMakeLists.txt @@ -49,7 +49,6 @@ file(GLOB_RECURSE sources_Spells Spells/*.cpp Spells/*.h) file(GLOB_RECURSE sources_Texts Texts/*.cpp Texts/*.h) file(GLOB_RECURSE sources_Tools Tools/*.cpp Tools/*.h) file(GLOB_RECURSE sources_Tickets Tickets/*.cpp Tickets/*.h) -file(GLOB_RECURSE sources_Time Time/*.cpp Time/*.h) file(GLOB_RECURSE sources_Warden Warden/*.cpp Warden/*.h) file(GLOB_RECURSE sources_Weather Weather/*.cpp Weather/*.h) file(GLOB_RECURSE sources_World World/*.cpp World/*.h) @@ -104,7 +103,6 @@ set(game_STAT_SRCS ${sources_Texts} ${sources_Tools} ${sources_Tickets} - ${sources_Time} ${sources_Warden} ${sources_Weather} ${sources_World} @@ -205,7 +203,6 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Texts ${CMAKE_CURRENT_SOURCE_DIR}/Tools ${CMAKE_CURRENT_SOURCE_DIR}/Tickets - ${CMAKE_CURRENT_SOURCE_DIR}/Time ${CMAKE_CURRENT_SOURCE_DIR}/Warden ${CMAKE_CURRENT_SOURCE_DIR}/Warden/Modules ${CMAKE_CURRENT_SOURCE_DIR}/Weather diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index e06b4cf03..ec1d5dd15 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -8,14 +8,10 @@ #include "QueryResult.h" #include "Log.h" #include "Player.h" -#include "GameTime.h" #include "GuildMgr.h" #include "ObjectAccessor.h" #include "Opcodes.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 d4bf966b5..c17ee23c4 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -130,7 +130,8 @@ struct CalendarInvite _text = calendarInvite.GetText(); } - CalendarInvite(); + CalendarInvite() : _inviteId(1), _eventId(0), _invitee(0), _senderGUID(0), _statusTime(time(NULL)), + _status(CALENDAR_STATUS_INVITED), _rank(CALENDAR_RANK_PLAYER), _text("") { } CalendarInvite(uint64 inviteId, uint64 eventId, uint64 invitee, uint64 senderGUID, time_t statusTime, CalendarInviteStatus status, CalendarModerationRank rank, std::string text) : diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index d2d6134dd..337fdb305 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -7,7 +7,6 @@ #include "ChannelMgr.h" #include "Chat.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "SocialMgr.h" #include "World.h" #include "DatabaseEnv.h" @@ -23,7 +22,6 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId, _channelDBId(channelDBId), _teamId(teamId), _ownerGUID(0), - lastSpeakTime(0), _name(name), _password("") { @@ -85,7 +83,7 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId, bool Channel::IsBanned(uint64 guid) const { BannedContainer::const_iterator itr = bannedStore.find(GUID_LOPART(guid)); - return itr != bannedStore.end() && itr->second > GameTime::GetGameTime(); + return itr != bannedStore.end() && itr->second > time(NULL); } void Channel::UpdateChannelInDB() const @@ -200,6 +198,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass) PlayerInfo pinfo; pinfo.player = guid; pinfo.flags = MEMBER_FLAG_NONE; + pinfo.lastSpeakTime = 0; pinfo.plrPtr = player; playersStore[guid] = pinfo; @@ -406,8 +405,8 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b { if (!IsBanned(victim)) { - bannedStore[GUID_LOPART(victim)] = GameTime::GetGameTime() + CHANNEL_BAN_DURATION; - AddChannelBanToDB(GUID_LOPART(victim), GameTime::GetGameTime() + CHANNEL_BAN_DURATION); + bannedStore[GUID_LOPART(victim)] = time(NULL) + CHANNEL_BAN_DURATION; + AddChannelBanToDB(GUID_LOPART(victim), time(NULL) + CHANNEL_BAN_DURATION); if (notify) { @@ -787,9 +786,9 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang) else if (playersStore.size() >= 10) speakDelay = 5; - if (IsAllowedToSpeak(speakDelay)) + if (!pinfo.IsAllowedToSpeak(speakDelay)) { - std::string timeStr = secsToTimeString(lastSpeakTime + speakDelay - GameTime::GetGameTime()); + std::string timeStr = secsToTimeString(pinfo.lastSpeakTime + speakDelay - sWorld->GetGameTime()); if (_channelRights.speakMessage.length() > 0) player->GetSession()->SendNotification("%s", _channelRights.speakMessage.c_str()); player->GetSession()->SendNotification("You must wait %s before speaking again.", timeStr.c_str()); @@ -1236,14 +1235,3 @@ void Channel::RemoveWatching(Player* p) if (itr != playersWatchingStore.end()) playersWatchingStore.erase(itr); } - -bool Channel::IsAllowedToSpeak(uint32 speakDelay) -{ - if (lastSpeakTime+speakDelay <= GameTime::GetGameTime()) - { - lastSpeakTime = GameTime::GetGameTime(); - return true; - } - else - return false; -} diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index fda61d23b..78b42f6ad 100644 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -12,7 +12,6 @@ #include #include "Common.h" -#include "GameTime.h" #include "Opcodes.h" #include "WorldPacket.h" @@ -140,6 +139,7 @@ class Channel { uint64 player; uint8 flags; + uint32 lastSpeakTime; // pussywizard Player* plrPtr; // pussywizard bool HasFlag(uint8 flag) const { return flags & flag; } @@ -162,6 +162,16 @@ class Channel if (state) flags |= MEMBER_FLAG_MUTED; else flags &= ~MEMBER_FLAG_MUTED; } + bool IsAllowedToSpeak(uint32 speakDelay) // pussywizard + { + if (lastSpeakTime+speakDelay <= sWorld->GetGameTime()) + { + lastSpeakTime = sWorld->GetGameTime(); + return true; + } + else + return false; + } }; public: @@ -209,7 +219,6 @@ class Channel // pussywizard: void AddWatching(Player* p); void RemoveWatching(Player* p); - bool IsAllowedToSpeak(uint32 speakDelay); // pussywizard private: // initial packet data (notify type and channel name) @@ -311,7 +320,6 @@ class Channel uint32 _channelDBId; TeamId _teamId; uint64 _ownerGUID; - uint32 lastSpeakTime; std::string _name; std::string _password; ChannelRights _channelRights; diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index df734ed4b..2c6399738 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -11,7 +11,6 @@ #include "Map.h" #include "Player.h" #include "ObjectAccessor.h" -#include "GameTime.h" #include "UnitEvents.h" #include "SpellAuras.h" #include "SpellMgr.h" @@ -296,7 +295,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR HostileReference* currentRef = NULL; bool found = false; bool noPriorityTargetFound = false; - uint32 currTime = GameTime::GetGameTime(); + uint32 currTime = sWorld->GetGameTime(); // pussywizard: currentVictim is needed to compare if threat was exceeded by 10%/30% for melee/range targets (only then switching current target) if (currentVictim) diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index cbe0fad8c..95a7aec98 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -9,7 +9,6 @@ #include "DBCStores.h" #include "DisableMgr.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "SocialMgr.h" #include "Language.h" #include "LFGMgr.h" @@ -261,7 +260,7 @@ void LFGMgr::Update(uint32 tdiff, uint8 task) if (task == 0) { - time_t currTime = GameTime::GetGameTime(); + time_t currTime = time(NULL); // Remove obsolete role checks for (LfgRoleCheckContainer::iterator it = RoleChecksStore.begin(); it != RoleChecksStore.end();) @@ -651,7 +650,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const // Create new rolecheck LfgRoleCheck& roleCheck = RoleChecksStore[gguid]; roleCheck.roles.clear(); // pussywizard: NEW rolecheck, not old one with trash data >_> - roleCheck.cancelTime = time_t(GameTime::GetGameTime()) + LFG_TIME_ROLECHECK; + roleCheck.cancelTime = time_t(time(NULL)) + LFG_TIME_ROLECHECK; roleCheck.state = LFG_ROLECHECK_INITIALITING; roleCheck.leader = guid; roleCheck.dungeons = dungeons; @@ -689,7 +688,7 @@ void LFGMgr::JoinLfg(Player* player, uint8 roles, LfgDungeonSet& dungeons, const LfgRolesMap rolesMap; rolesMap[guid] = roles; LFGQueue& queue = GetQueue(guid); - queue.AddQueueData(guid, GameTime::GetGameTime(), dungeons, rolesMap); + queue.AddQueueData(guid, time(NULL), dungeons, rolesMap); if (!isContinue) { @@ -888,7 +887,7 @@ void LFGMgr::UpdateRaidBrowser(uint32 diff) m_raidBrowserUpdateTimer[team] = 0; } - if (getMSTimeDiff(GameTime::GetGameTimeMS(), getMSTime()) > (70*7)/5) // prevent lagging + if (getMSTimeDiff(World::GetGameTimeMS(), getMSTime()) > (70*7)/5) // prevent lagging return; uint64 guid, groupGuid, instanceGuid; @@ -1356,7 +1355,7 @@ void LFGMgr::UpdateRoleCheck(uint64 gguid, uint64 guid /* = 0 */, uint8 roles /* { SetState(gguid, LFG_STATE_QUEUED); LFGQueue& queue = GetQueue(gguid); - queue.AddQueueData(gguid, time_t(GameTime::GetGameTime()), roleCheck.dungeons, roleCheck.roles); + queue.AddQueueData(gguid, time_t(time(NULL)), roleCheck.dungeons, roleCheck.roles); RoleChecksStore.erase(itRoleCheck); } else if (roleCheck.state != LFG_ROLECHECK_INITIALITING) @@ -1633,7 +1632,7 @@ void LFGMgr::UpdateProposal(uint32 proposalId, uint64 guid, bool accept) bool sendUpdate = proposal.state != LFG_PROPOSAL_SUCCESS; proposal.state = LFG_PROPOSAL_SUCCESS; - time_t joinTime = GameTime::GetGameTime(); + time_t joinTime = time(NULL); LFGQueue& queue = GetQueue(guid); LfgUpdateData updateData = LfgUpdateData(LFG_UPDATETYPE_GROUP_FOUND); @@ -1819,7 +1818,7 @@ void LFGMgr::InitBoot(uint64 gguid, uint64 kicker, uint64 victim, std::string co LfgPlayerBoot& boot = BootsStore[gguid]; boot.inProgress = true; - boot.cancelTime = time_t(GameTime::GetGameTime()) + LFG_TIME_BOOT; + boot.cancelTime = time_t(time(NULL)) + 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 4d70bac93..30ae2a4ec 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -18,7 +18,6 @@ #include "Containers.h" #include "DBCStructure.h" #include "DBCStores.h" -#include "GameTime.h" #include "Group.h" #include "LFGQueue.h" #include "LFGMgr.h" @@ -30,9 +29,6 @@ namespace lfg { -LfgQueueData::LfgQueueData() : joinTime(GameTime::GetGameTime()), lastRefreshTime(joinTime), tanks(LFG_TANKS_NEEDED), healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) -{ } - void LFGQueue::AddToQueue(uint64 guid, bool failedProposal) { //sLog->outString("ADD AddToQueue: %u, failed proposal: %u", GUID_LOPART(guid), failedProposal ? 1 : 0); @@ -413,7 +409,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const return LFG_COMPATIBILITY_PENDING; // Create a new proposal - proposal.cancelTime = GameTime::GetGameTime() + LFG_TIME_PROPOSAL; + proposal.cancelTime = time(NULL) + LFG_TIME_PROPOSAL; proposal.state = LFG_PROPOSAL_INITIATING; proposal.leader = 0; proposal.dungeonId = Trinity::Containers::SelectRandomContainerElement(proposalDungeons); @@ -449,7 +445,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const void LFGQueue::UpdateQueueTimers(uint32 diff) { - time_t currTime = GameTime::GetGameTime(); + time_t currTime = time(NULL); bool sendQueueStatus = false; if (m_QueueStatusTimer > LFG_QUEUEUPDATE_INTERVAL) diff --git a/src/server/game/DungeonFinding/LFGQueue.h b/src/server/game/DungeonFinding/LFGQueue.h index 9add4342f..8aa9e3442 100644 --- a/src/server/game/DungeonFinding/LFGQueue.h +++ b/src/server/game/DungeonFinding/LFGQueue.h @@ -28,7 +28,9 @@ enum LfgCompatibility /// Stores player or group queue info struct LfgQueueData { - LfgQueueData(); + LfgQueueData(): joinTime(time_t(time(NULL))), lastRefreshTime(joinTime), tanks(LFG_TANKS_NEEDED), + healers(LFG_HEALERS_NEEDED), dps(LFG_DPS_NEEDED) + { } LfgQueueData(time_t _joinTime, LfgDungeonSet const& _dungeons, LfgRolesMap const& _roles): joinTime(_joinTime), lastRefreshTime(_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 2e5a71b79..608a2f1a6 100644 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -6,7 +6,6 @@ #include "Common.h" #include "Corpse.h" -#include "GameTime.h" #include "Player.h" #include "UpdateMask.h" #include "ObjectAccessor.h" @@ -24,7 +23,7 @@ Corpse::Corpse(CorpseType type) : WorldObject(type != CORPSE_BONES), m_type(type m_valuesCount = CORPSE_END; - m_time = GameTime::GetGameTime(); + m_time = time(NULL); lootRecipient = NULL; } @@ -133,11 +132,6 @@ void Corpse::DeleteFromDB(SQLTransaction& trans) trans->Append(stmt); } -void Corpse::ResetGhostTime() -{ - m_time = GameTime::GetGameTime(); -} - bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields) { uint32 ownerGuid = fields[17].GetUInt32(); diff --git a/src/server/game/Entities/Corpse/Corpse.h b/src/server/game/Entities/Corpse/Corpse.h index 005811251..8bb7e6c08 100644 --- a/src/server/game/Entities/Corpse/Corpse.h +++ b/src/server/game/Entities/Corpse/Corpse.h @@ -54,7 +54,7 @@ class Corpse : public WorldObject, public GridObject uint64 GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); } time_t const& GetGhostTime() const { return m_time; } - void ResetGhostTime(); + void ResetGhostTime() { m_time = time(NULL); } CorpseType GetType() const { return m_type; } GridCoord const& GetGridCoord() const { return _gridCoord; } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index f2ba1c102..d6905da26 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -14,7 +14,6 @@ #include "DatabaseEnv.h" #include "Formulas.h" #include "GameEventMgr.h" -#include "GameTime.h" #include "GossipDef.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -47,9 +46,6 @@ #include "LuaEngine.h" #endif -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); @@ -272,7 +268,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool skipVisibility) if (getDeathState() != CORPSE) return; - m_corpseRemoveTime = GameTime::GetGameTime(); + m_corpseRemoveTime = time(NULL); setDeathState(DEAD); RemoveAllAuras(); if (!skipVisibility) // pussywizard @@ -285,7 +281,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool skipVisibility) // Should get removed later, just keep "compatibility" with scripts if (setSpawnTime) { - m_respawnTime = GameTime::GetGameTime() + respawnDelay; + m_respawnTime = time(NULL) + respawnDelay; //SaveRespawnTime(); } @@ -510,7 +506,7 @@ void Creature::Update(uint32 diff) break; case DEAD: { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (m_respawnTime <= now) { bool allowed = IsAIEnabled ? AI()->CanRespawn() : true; // First check if there are any scripts that object to us respawning @@ -552,7 +548,7 @@ void Creature::Update(uint32 diff) } else m_groupLootTimer -= diff; } - else if (m_corpseRemoveTime <= GameTime::GetGameTime()) + else if (m_corpseRemoveTime <= time(NULL)) { RemoveCorpse(false); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) @@ -1481,7 +1477,7 @@ bool Creature::IsInvisibleDueToDespawn() const if (Unit::IsInvisibleDueToDespawn()) return true; - if (IsAlive() || m_corpseRemoveTime > GameTime::GetGameTime()) + if (IsAlive() || m_corpseRemoveTime > time(NULL)) return false; return true; @@ -1546,8 +1542,8 @@ void Creature::setDeathState(DeathState s, bool despawn) if (s == JUST_DIED) { - m_corpseRemoveTime = GameTime::GetGameTime() + m_corpseDelay; - m_respawnTime = GameTime::GetGameTime() + m_respawnDelay + m_corpseDelay; + m_corpseRemoveTime = time(NULL) + m_corpseDelay; + m_respawnTime = time(NULL) + m_respawnDelay + m_corpseDelay; // always save boss respawn time at death to prevent crash cheating if (GetMap()->IsDungeon() || isWorldBoss() || GetCreatureTemplate()->rank >= CREATURE_ELITE_ELITE) @@ -2130,7 +2126,7 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const // pussywizard: don't check distance to home position if recently damaged (allow kiting away from spawnpoint!) // xinef: this should include taunt auras - if (!isWorldBoss() && (GetLastDamagedTime() > GameTime::GetGameTime() || HasAuraType(SPELL_AURA_MOD_TAUNT))) + if (!isWorldBoss() && (GetLastDamagedTime() > sWorld->GetGameTime() || HasAuraType(SPELL_AURA_MOD_TAUNT))) return true; } @@ -2298,7 +2294,7 @@ void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs { for (uint8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) if (idSchoolMask & (1 << i)) - m_ProhibitSchoolTime[i] = GameTime::GetGameTimeMS() + unTimeMs; + m_ProhibitSchoolTime[i] = World::GetGameTimeMS() + unTimeMs; } bool Creature::IsSpellProhibited(SpellSchoolMask idSchoolMask) const @@ -2309,7 +2305,7 @@ bool Creature::IsSpellProhibited(SpellSchoolMask idSchoolMask) const for (uint8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) if (idSchoolMask & (1 << i)) - if (m_ProhibitSchoolTime[i] >= GameTime::GetGameTimeMS()) + if (m_ProhibitSchoolTime[i] >= World::GetGameTimeMS()) return true; return false; @@ -2317,7 +2313,7 @@ bool Creature::IsSpellProhibited(SpellSchoolMask idSchoolMask) const void Creature::_AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time) { - m_CreatureSpellCooldowns[spell_id] = GameTime::GetGameTimeMS()+end_time; + m_CreatureSpellCooldowns[spell_id] = World::GetGameTimeMS()+end_time; } void Creature::AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool /*needSendToClient*/, bool /*forceSendToSpectator*/) @@ -2364,13 +2360,13 @@ uint32 Creature::GetSpellCooldown(uint32 spell_id) const if (itr == m_CreatureSpellCooldowns.end()) return 0; - return itr->second > GameTime::GetGameTimeMS() ? itr->second - GameTime::GetGameTimeMS() : 0; + return itr->second > World::GetGameTimeMS() ? itr->second - World::GetGameTimeMS() : 0; } bool Creature::HasSpellCooldown(uint32 spell_id) const { CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id); - return (itr != m_CreatureSpellCooldowns.end() && itr->second > GameTime::GetGameTimeMS()); + return (itr != m_CreatureSpellCooldowns.end() && itr->second > World::GetGameTimeMS()); } bool Creature::HasSpell(uint32 spellID) const @@ -2384,18 +2380,13 @@ bool Creature::HasSpell(uint32 spellID) const time_t Creature::GetRespawnTimeEx() const { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); 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_DBTableGuid) @@ -2440,7 +2431,7 @@ void Creature::AllLootRemovedFromCorpse() { if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE)) { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (m_corpseRemoveTime <= now) return; @@ -2454,7 +2445,7 @@ void Creature::AllLootRemovedFromCorpse() // corpse skinnable, but without skinning flag, and then skinned, corpse will despawn next update if (cinfo && cinfo->SkinLootId) - m_corpseRemoveTime = GameTime::GetGameTime(); + m_corpseRemoveTime = time(NULL); else m_corpseRemoveTime -= diff; } @@ -2508,7 +2499,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) VendorItemCount* vCount = &*itr; - time_t ptime = GameTime::GetGameTime(); + time_t ptime = time(NULL); if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) { @@ -2547,7 +2538,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us VendorItemCount* vCount = &*itr; - time_t ptime = GameTime::GetGameTime(); + time_t ptime = time(NULL); if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime) { @@ -2866,13 +2857,3 @@ float Creature::GetAttackDistance(Unit const* player) const return (retDistance*aggroRate); } - -void Creature::SetPickPocketLootTime() -{ - lootPickPocketRestoreTime = GameTime::GetGameTime() + MINUTE + GetCorpseDelay() + GetRespawnTime(); -} - -bool Creature::CanGeneratePickPocketLoot() const -{ - return (lootPickPocketRestoreTime == 0 || lootPickPocketRestoreTime < GameTime::GetGameTime()); -} diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 35d32db7c..40e204624 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -370,7 +370,8 @@ struct VendorItemData struct VendorItemCount { - VendorItemCount(uint32 _item, uint32 _count); + explicit VendorItemCount(uint32 _item, uint32 _count) + : itemId(_item), count(_count), lastIncrementTime(time(NULL)) {} uint32 itemId; uint32 count; @@ -572,8 +573,8 @@ class Creature : public Unit, public GridObject, public MovableMapObje Group* GetLootRecipientGroup() const; bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; } bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party. - bool CanGeneratePickPocketLoot() const; - void SetPickPocketLootTime(); + bool CanGeneratePickPocketLoot() const { return lootPickPocketRestoreTime == 0 || lootPickPocketRestoreTime < time(NULL); } + void SetPickPocketLootTime() { lootPickPocketRestoreTime = time(NULL) + MINUTE + GetCorpseDelay() + GetRespawnTime(); } void ResetPickPocketLootTime() { lootPickPocketRestoreTime = 0; } void SetLootRecipient (Unit* unit, bool withGroup = true); @@ -626,7 +627,7 @@ class Creature : public Unit, public GridObject, public MovableMapObje time_t const& GetRespawnTime() const { return m_respawnTime; } time_t GetRespawnTimeEx() const; - void SetRespawnTime(uint32 respawn); + void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; } void Respawn(bool force = false); void SaveRespawnTime(); diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.cpp b/src/server/game/Entities/DynamicObject/DynamicObject.cpp index 3d67a4487..ab00926c3 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.cpp +++ b/src/server/game/Entities/DynamicObject/DynamicObject.cpp @@ -10,7 +10,6 @@ #include "World.h" #include "ObjectAccessor.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "GridNotifiers.h" #include "CellImpl.h" #include "GridNotifiersImpl.h" @@ -108,7 +107,7 @@ bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spe SetByteValue(DYNAMICOBJECT_BYTES, 0, type); SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId); SetFloatValue(DYNAMICOBJECT_RADIUS, radius); - SetUInt32Value(DYNAMICOBJECT_CASTTIME, GameTime::GetGameTimeMS()); + SetUInt32Value(DYNAMICOBJECT_CASTTIME, World::GetGameTimeMS()); if (IsWorldObject()) setActive(true); //must before add to map to be put in world container diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index b4f19427b..cee784535 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -6,7 +6,6 @@ #include #include "GameObjectAI.h" -#include "GameTime.h" #include "BattlegroundAV.h" #include "CellImpl.h" #include "CreatureAISelector.h" @@ -377,9 +376,9 @@ void GameObject::Update(uint32 diff) GameObjectTemplate const* goInfo = GetGOInfo(); // Bombs if (goInfo->trap.type == 2) - m_cooldownTime = GameTime::GetGameTimeMS()+10*IN_MILLISECONDS; // Hardcoded tooltip value + m_cooldownTime = World::GetGameTimeMS()+10*IN_MILLISECONDS; // Hardcoded tooltip value else if (GetOwner()) - m_cooldownTime = GameTime::GetGameTimeMS()+goInfo->trap.startDelay*IN_MILLISECONDS; + m_cooldownTime = World::GetGameTimeMS()+goInfo->trap.startDelay*IN_MILLISECONDS; m_lootState = GO_READY; break; @@ -387,7 +386,7 @@ void GameObject::Update(uint32 diff) case GAMEOBJECT_TYPE_FISHINGNODE: { // fishing code (bobber ready) - if (GameTime::GetGameTime() > m_respawnTime - FISHING_BOBBER_READY_TIME) + if (time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME) { // splash bobber (bobber ready now) Unit* caster = GetOwner(); @@ -411,7 +410,7 @@ void GameObject::Update(uint32 diff) } case GAMEOBJECT_TYPE_SUMMONING_RITUAL: { - if (GameTime::GetGameTimeMS() < m_cooldownTime) + if (World::GetGameTimeMS() < m_cooldownTime) return; GameObjectTemplate const* info = GetGOInfo(); if (info->summoningRitual.animSpell) @@ -485,7 +484,7 @@ void GameObject::Update(uint32 diff) { if (m_respawnTime > 0) // timer on { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (m_respawnTime <= now) // timer expired { uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_GAMEOBJECT); @@ -561,7 +560,7 @@ void GameObject::Update(uint32 diff) GameObjectTemplate const* goInfo = GetGOInfo(); if (goInfo->type == GAMEOBJECT_TYPE_TRAP) { - if (GameTime::GetGameTimeMS() < m_cooldownTime) + if (World::GetGameTimeMS() < m_cooldownTime) break; // Type 2 - Bomb (will go away after casting it's spell) @@ -621,7 +620,7 @@ void GameObject::Update(uint32 diff) if (goInfo->trap.spellId) CastSpell(target, goInfo->trap.spellId); - m_cooldownTime = GameTime::GetGameTimeMS()+(goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4))*IN_MILLISECONDS; // template or 4 seconds + m_cooldownTime = World::GetGameTimeMS()+(goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4))*IN_MILLISECONDS; // template or 4 seconds if (goInfo->trap.type == 1) SetLootState(GO_JUST_DEACTIVATED); @@ -653,11 +652,11 @@ void GameObject::Update(uint32 diff) { case GAMEOBJECT_TYPE_DOOR: case GAMEOBJECT_TYPE_BUTTON: - if (GetGOInfo()->GetAutoCloseTime() && GameTime::GetGameTimeMS() >= m_cooldownTime) + if (GetGOInfo()->GetAutoCloseTime() && World::GetGameTimeMS() >= m_cooldownTime) ResetDoorOrButton(); break; case GAMEOBJECT_TYPE_GOOBER: - if (GameTime::GetGameTimeMS() >= m_cooldownTime) + if (World::GetGameTimeMS() >= m_cooldownTime) { RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); @@ -729,7 +728,7 @@ void GameObject::Update(uint32 diff) return; } - m_respawnTime = GameTime::GetGameTime() + m_respawnDelayTime; + m_respawnTime = time(NULL) + m_respawnDelayTime; // if option not set then object will be saved at grid unload if (GetMap()->IsDungeon()) @@ -942,7 +941,7 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap) m_respawnTime = GetMap()->GetGORespawnTime(m_DBTableGuid); // ready to respawn - if (m_respawnTime && m_respawnTime <= GameTime::GetGameTime()) + if (m_respawnTime && m_respawnTime <= time(NULL)) { m_respawnTime = 0; GetMap()->RemoveGORespawnTime(m_DBTableGuid); @@ -1026,7 +1025,7 @@ Unit* GameObject::GetOwner() const void GameObject::SaveRespawnTime() { - if (m_goData && m_goData->dbData && m_respawnTime > GameTime::GetGameTime() && m_spawnedByDefault) + if (m_goData && m_goData->dbData && m_respawnTime > time(NULL) && m_spawnedByDefault) GetMap()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime); } @@ -1081,26 +1080,11 @@ bool GameObject::IsInvisibleDueToDespawn() const return false; } -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 = GameTime::GetGameTime(); + m_respawnTime = time(NULL); GetMap()->RemoveGORespawnTime(m_DBTableGuid); } } @@ -1228,7 +1212,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f SwitchDoorOrButton(true, alternative); SetLootState(GO_ACTIVATED, user); - m_cooldownTime = GameTime::GetGameTimeMS()+time_to_restore; + m_cooldownTime = World::GetGameTimeMS()+time_to_restore; } void GameObject::SetGoArtKit(uint8 kit) @@ -1295,10 +1279,10 @@ void GameObject::Use(Unit* user) // If cooldown data present in template if (uint32 cooldown = GetGOInfo()->GetCooldown()) { - if (GameTime::GetGameTimeMS() < m_cooldownTime) + if (World::GetGameTimeMS() < m_cooldownTime) return; - m_cooldownTime = GameTime::GetGameTimeMS()+cooldown*IN_MILLISECONDS; + m_cooldownTime = World::GetGameTimeMS()+cooldown*IN_MILLISECONDS; } switch (GetGoType()) @@ -1332,7 +1316,7 @@ void GameObject::Use(Unit* user) if (goInfo->trap.spellId) CastSpell(user, goInfo->trap.spellId); - m_cooldownTime = GameTime::GetGameTimeMS()+(goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4))*IN_MILLISECONDS; // template or 4 seconds + m_cooldownTime = World::GetGameTimeMS()+(goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4))*IN_MILLISECONDS; // template or 4 seconds if (goInfo->trap.type == 1) // Deactivate after trigger SetLootState(GO_JUST_DEACTIVATED); @@ -1485,7 +1469,7 @@ void GameObject::Use(Unit* user) if (info->goober.customAnim) SendCustomAnim(GetGoAnimProgress()); - m_cooldownTime = GameTime::GetGameTimeMS()+info->GetAutoCloseTime(); + m_cooldownTime = World::GetGameTimeMS()+info->GetAutoCloseTime(); // cast this spell later if provided spellId = info->goober.spellId; @@ -1659,7 +1643,7 @@ void GameObject::Use(Unit* user) if (!info->summoningRitual.animSpell) m_cooldownTime = 0; else // channel ready, maintain this - m_cooldownTime = GameTime::GetGameTimeMS()+5*IN_MILLISECONDS; + m_cooldownTime = World::GetGameTimeMS()+5*IN_MILLISECONDS; } return; @@ -2212,11 +2196,6 @@ 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 63d95d3b0..ffb85fc05 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -700,9 +700,20 @@ class GameObject : public WorldObject, public GridObject, public Mov uint32 GetSpellId() const { return m_spellId;} time_t GetRespawnTime() const { return m_respawnTime; } - time_t GetRespawnTimeEx() const; - - void SetRespawnTime(int32 respawn); + time_t GetRespawnTimeEx() const + { + time_t now = time(NULL); + if (m_respawnTime > now) + return m_respawnTime; + else + return now; + } + + void SetRespawnTime(int32 respawn) + { + m_respawnTime = respawn > 0 ? time(NULL) + respawn : 0; + m_respawnDelayTime = respawn > 0 ? respawn : 0; + } void Respawn(); bool isSpawned() const { @@ -771,7 +782,7 @@ class GameObject : public WorldObject, public GridObject, public Mov bool HasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; } uint32 m_groupLootTimer; // (msecs)timer used for group loot uint32 lootingGroupLowGUID; // used to find group which is looting - void SetLootGenerationTime(); + void SetLootGenerationTime() { m_lootGenerationTime = time(NULL); } uint32 GetLootGenerationTime() const { return m_lootGenerationTime; } bool hasQuest(uint32 quest_id) const; diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index d0f0c4247..e7c60566d 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -9,7 +9,6 @@ #include "ObjectMgr.h" #include "WorldPacket.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "ItemEnchantmentMgr.h" #include "SpellMgr.h" #include "SpellInfo.h" @@ -237,7 +236,7 @@ Item::Item() m_container = NULL; m_lootGenerated = false; mb_in_trade = false; - m_lastPlayedTimeUpdate = GameTime::GetGameTime(); + m_lastPlayedTimeUpdate = time(NULL); m_refundRecipient = 0; m_paidMoney = 0; @@ -1141,7 +1140,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 = GameTime::GetGameTime(); + time_t curtime = time(NULL); uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate); uint32 new_playtime = current_playtime + elapsed; // Check if the refund timer has expired yet @@ -1162,7 +1161,7 @@ void Item::UpdatePlayedTime(Player* owner) uint32 Item::GetPlayedTime() { - time_t curtime = GameTime::GetGameTime(); + time_t curtime = time(NULL); uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate); return GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + elapsed; } diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 698cf8ba6..b63514c40 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -15,7 +15,6 @@ #include "Player.h" #include "Vehicle.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "UpdateData.h" #include "UpdateMask.h" #include "Util.h" @@ -941,7 +940,7 @@ void MovementInfo::OutDebug() sLog->outString("guid " UI64FMTD, guid); sLog->outString("flags %u", flags); sLog->outString("flags2 %u", flags2); - sLog->outString("time %u current time " UI64FMTD "", flags2, uint64(::GameTime::GetGameTime())); + sLog->outString("time %u current time " UI64FMTD "", flags2, uint64(::time(NULL))); sLog->outString("position: `%s`", pos.ToString().c_str()); if (flags & MOVEMENTFLAG_ONTRANSPORT) { @@ -2886,13 +2885,13 @@ void WorldObject::AddToNotify(uint16 f) { uint32 EVENT_VISIBILITY_DELAY = u->FindMap() ? DynamicVisibilityMgr::GetVisibilityNotifyDelay(u->FindMap()->GetEntry()->map_type) : 1000; - uint32 diff = getMSTimeDiff(u->m_last_notify_mstime, GameTime::GetGameTimeMS()); + uint32 diff = getMSTimeDiff(u->m_last_notify_mstime, World::GetGameTimeMS()); if (diff >= EVENT_VISIBILITY_DELAY/2) EVENT_VISIBILITY_DELAY /= 2; else EVENT_VISIBILITY_DELAY -= diff; u->m_delayed_unit_relocation_timer = EVENT_VISIBILITY_DELAY; - u->m_last_notify_mstime = GameTime::GetGameTimeMS()+EVENT_VISIBILITY_DELAY-1; + u->m_last_notify_mstime = World::GetGameTimeMS()+EVENT_VISIBILITY_DELAY-1; } else if (f & NOTIFY_AI_RELOCATION) { diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 75f5b882b..59adaf393 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -9,7 +9,6 @@ #include "Log.h" #include "WorldPacket.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "SpellMgr.h" #include "Pet.h" #include "Formulas.h" @@ -238,7 +237,7 @@ void Pet::SavePetToDB(PetSaveMode mode, bool logout) stmt->setUInt32(12, curhealth); stmt->setUInt32(13, curmana); stmt->setUInt32(14, GetPower(POWER_HAPPINESS)); - stmt->setUInt32(15, GameTime::GetGameTime()); + stmt->setUInt32(15, time(NULL)); std::ostringstream ss; for (uint32 i = ACTION_BAR_INDEX_START; i < ACTION_BAR_INDEX_END; ++i) @@ -322,7 +321,7 @@ void Pet::Update(uint32 diff) { case CORPSE: { - if (getPetType() != HUNTER_PET || m_corpseRemoveTime <= GameTime::GetGameTime()) + if (getPetType() != HUNTER_PET || m_corpseRemoveTime <= time(NULL)) { Remove(PET_SAVE_NOT_IN_SLOT); //hunters' pets never get removed because of death, NEVER! return; @@ -1060,7 +1059,7 @@ void Pet::_LoadSpellCooldowns(PreparedQueryResult result) if (result) { - time_t curTime = GameTime::GetGameTime(); + time_t curTime = time(NULL); PacketCooldowns cooldowns; WorldPacket data; @@ -1106,8 +1105,8 @@ void Pet::_SaveSpellCooldowns(SQLTransaction& trans, bool logout) stmt->setUInt32(0, m_charmInfo->GetPetNumber()); trans->Append(stmt); - time_t curTime = GameTime::GetGameTime(); - uint32 checkTime = GameTime::GetGameTimeMS() + 30*IN_MILLISECONDS; + time_t curTime = time(NULL); + uint32 checkTime = World::GetGameTimeMS() + 30*IN_MILLISECONDS; // remove oudated and save active CreatureSpellCooldowns::iterator itr, itr2; @@ -1115,11 +1114,11 @@ void Pet::_SaveSpellCooldowns(SQLTransaction& trans, bool logout) { itr2 = itr; ++itr; - if (itr2->second <= GameTime::GetGameTimeMS()+1000) + if (itr2->second <= World::GetGameTimeMS()+1000) m_CreatureSpellCooldowns.erase(itr2); else if (logout || itr2->second > checkTime) { - uint32 cooldown = ((itr2->second-GameTime::GetGameTimeMS())/IN_MILLISECONDS) + curTime; + uint32 cooldown = ((itr2->second-World::GetGameTimeMS())/IN_MILLISECONDS) + curTime; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL_COOLDOWN); stmt->setUInt32(0, m_charmInfo->GetPetNumber()); stmt->setUInt32(1, itr2->first); @@ -2144,7 +2143,7 @@ void Pet::HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 as pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); pet->SetFullHealth(); pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); - pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped in this case + pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped in this case } map->AddToMap(pet->ToCreature(), true); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 308dedfdd..b64487f59 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -27,7 +27,6 @@ #include "DisableMgr.h" #include "Formulas.h" #include "GameEventMgr.h" -#include "GameTime.h" #include "GossipDef.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -775,7 +774,7 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this) for (uint8 j = 0; j < PLAYER_MAX_BATTLEGROUND_QUEUES; ++j) m_bgBattlegroundQueueID[j] = BATTLEGROUND_QUEUE_NONE; - m_logintime = GameTime::GetGameTime(); + m_logintime = time(NULL); m_Last_tick = m_logintime; m_Played_time[PLAYED_TIME_TOTAL] = 0; m_Played_time[PLAYED_TIME_LEVEL] = 0; @@ -848,7 +847,7 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this) m_spellPenetrationItemMod = 0; // Honor System - m_lastHonorUpdateTime = GameTime::GetGameTime(); + m_lastHonorUpdateTime = time(NULL); m_IsBGRandomWinner = false; @@ -1102,7 +1101,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo) } // Played time - m_Last_tick = GameTime::GetGameTime(); + m_Last_tick = time(NULL); m_Played_time[PLAYED_TIME_TOTAL] = 0; m_Played_time[PLAYED_TIME_LEVEL] = 0; @@ -1545,7 +1544,7 @@ void Player::Update(uint32 p_time) sScriptMgr->OnBeforePlayerUpdate(this, p_time); // undelivered mail - if (m_nextMailDelivereTime && m_nextMailDelivereTime <= GameTime::GetGameTime()) + if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL)) { SendNewMail(); ++unReadMails; @@ -1559,7 +1558,7 @@ void Player::Update(uint32 p_time) Unit::Update(p_time); SetMustDelayTeleport(false); - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); UpdatePvPFlag(now); @@ -1710,7 +1709,7 @@ void Player::Update(uint32 p_time) { if (now > m_Last_tick && _restTime > 0) // freeze update { - time_t currTime = GameTime::GetGameTime(); + time_t currTime = time(NULL); time_t timeDiff = currTime - _restTime; if (timeDiff >= 10) // freeze update { @@ -1959,7 +1958,7 @@ void Player::setDeathState(DeathState s, bool /*despawn = false*/) void Player::SetRestState(uint32 triggerId) { _innTriggerId = triggerId; - _restTime = GameTime::GetGameTime(); + _restTime = time(NULL); SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); } @@ -2275,7 +2274,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (MustDelayTeleport()) { SetHasDelayedTeleport(true); - SetSemaphoreTeleportNear(GameTime::GetGameTime()); + SetSemaphoreTeleportNear(time(NULL)); //lets save teleport destination for player teleportStore_dest = WorldLocation(mapid, x, y, z, orientation); teleportStore_options = options; @@ -2297,11 +2296,11 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // this will be used instead of the current location in SaveToDB teleportStore_dest = WorldLocation(mapid, x, y, z, orientation); - SetFallInformation(GameTime::GetGameTime(), z); + SetFallInformation(time(NULL), z); // code for finish transfer called in WorldSession::HandleMovementOpcodes() // at client packet MSG_MOVE_TELEPORT_ACK - SetSemaphoreTeleportNear(GameTime::GetGameTime()); + SetSemaphoreTeleportNear(time(NULL)); // near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing if (!GetSession()->PlayerLogout()) { @@ -2337,7 +2336,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (MustDelayTeleport()) { SetHasDelayedTeleport(true); - SetSemaphoreTeleportFar(GameTime::GetGameTime()); + SetSemaphoreTeleportFar(time(NULL)); //lets save teleport destination for player teleportStore_dest = WorldLocation(mapid, x, y, z, orientation); teleportStore_options = options; @@ -2404,7 +2403,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati } teleportStore_dest = WorldLocation(mapid, x, y, z, orientation); - SetFallInformation(GameTime::GetGameTime(), z); + SetFallInformation(time(NULL), z); // if the player is saved before worldportack (at logout for example) // this will be used instead of the current location in SaveToDB @@ -2423,7 +2422,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // move packet sent by client always after far teleport // code for finish transfer to new map called in WorldSession::HandleMoveWorldportAckOpcode at client packet - SetSemaphoreTeleportFar(GameTime::GetGameTime()); + SetSemaphoreTeleportFar(time(NULL)); } } return true; @@ -3469,8 +3468,8 @@ void Player::InitStatsForLevel(bool reapplyMods) void Player::SendInitialSpells() { - uint32 curTime = GameTime::GetGameTimeMS(); - uint32 infTime = GameTime::GetGameTimeMS()+infinityCooldownDelayCheck; + uint32 curTime = World::GetGameTimeMS(); + uint32 infTime = World::GetGameTimeMS()+infinityCooldownDelayCheck; uint16 spellCount = 0; @@ -3598,7 +3597,7 @@ void Player::UpdateNextMailTimeAndUnreads() { // calculate next delivery time (min. from non-delivered mails // and recalculate unReadMail - time_t cTime = GameTime::GetGameTime(); + time_t cTime = time(NULL); m_nextMailDelivereTime = 0; unReadMails = 0; for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) @@ -3615,7 +3614,7 @@ void Player::UpdateNextMailTimeAndUnreads() void Player::AddNewMailDeliverTime(time_t deliver_time) { - if (deliver_time <= GameTime::GetGameTime()) // ready now + if (deliver_time <= time(NULL)) // ready now { ++unReadMails; SendNewMail(); @@ -4258,7 +4257,7 @@ void Player::RemoveCategoryCooldown(uint32 cat) void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns) { // remove cooldowns on spells that have < 10 min CD - uint32 infTime = GameTime::GetGameTimeMS()+infinityCooldownDelayCheck; + uint32 infTime = World::GetGameTimeMS()+infinityCooldownDelayCheck; SpellCooldowns::iterator itr, next; for (itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); itr = next) { @@ -4290,7 +4289,7 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns) void Player::RemoveAllSpellCooldown() { - uint32 infTime = GameTime::GetGameTimeMS()+infinityCooldownDelayCheck; + uint32 infTime = World::GetGameTimeMS()+infinityCooldownDelayCheck; if (!m_spellCooldowns.empty()) { for (SpellCooldowns::const_iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); ++itr) @@ -4309,7 +4308,7 @@ void Player::_LoadSpellCooldowns(PreparedQueryResult result) if (result) { - time_t curTime = GameTime::GetGameTime(); + time_t curTime = time(NULL); do { @@ -4345,8 +4344,8 @@ void Player::_SaveSpellCooldowns(SQLTransaction& trans, bool logout) stmt->setUInt32(0, GetGUIDLow()); trans->Append(stmt); - time_t curTime = GameTime::GetGameTime(); - uint32 curMSTime = GameTime::GetGameTimeMS(); + time_t curTime = time(NULL); + uint32 curMSTime = World::GetGameTimeMS(); uint32 infTime = curMSTime + infinityCooldownDelayCheck; bool first_round = true; @@ -4400,7 +4399,7 @@ uint32 Player::resetTalentsCost() const return 10*GOLD; else { - uint64 months = (GameTime::GetGameTime() - m_resetTalentsTime)/MONTH; + uint64 months = (sWorld->GetGameTime() - m_resetTalentsTime)/MONTH; if (months > 0) { // This cost will be reduced by a rate of 5 gold per month @@ -4509,7 +4508,7 @@ bool Player::resetTalents(bool noResetCost) UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, 1); m_resetTalentsCost = resetCost; - m_resetTalentsTime = GameTime::GetGameTime(); + m_resetTalentsTime = time(NULL); } return true; @@ -5050,7 +5049,7 @@ void Player::DeleteOldCharacters(uint32 keepDays) sLog->outString("Player::DeleteOldChars: Deleting all characters which have been deleted %u days before...", keepDays); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_OLD_CHARS); - stmt->setUInt32(0, uint32(GameTime::GetGameTime() - time_t(keepDays * DAY))); + stmt->setUInt32(0, uint32(time(NULL) - time_t(keepDays * DAY))); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) @@ -7167,8 +7166,8 @@ void Player::RewardReputation(Quest const* quest) void Player::UpdateHonorFields() { /// called when rewarding honor and at each save - time_t now = time_t(GameTime::GetGameTime()); - time_t today = time_t(GameTime::GetGameTime() / DAY * DAY); + time_t now = time_t(time(NULL)); + time_t today = time_t(time(NULL) / DAY) * DAY; if (m_lastHonorUpdateTime < today) { @@ -8978,7 +8977,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) // Xinef: loot was generated and respawntime has passed since then, allow to recreate loot // Xinef: to avoid bugs, this rule covers spawned gameobjects only - if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && go->GetLootGenerationTime()+go->GetRespawnDelay() < GameTime::GetGameTime()) + if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && go->GetLootGenerationTime()+go->GetRespawnDelay() < time(NULL)) go->SetLootState(GO_READY); if (go->getLootState() == GO_READY) @@ -10016,7 +10015,7 @@ void Player::SendBattlefieldWorldStates() SendUpdateWorldState(BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE, wg->IsWarTime() ? 1 : 0); for (uint32 i = 0; i < 2; ++i) - SendUpdateWorldState(ClockWorldState[i], uint32(GameTime::GetGameTime() + (wg->GetTimer() / 1000))); + SendUpdateWorldState(ClockWorldState[i], uint32(time(NULL) + (wg->GetTimer() / 1000))); } } } @@ -13917,7 +13916,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) #endif m_items[slot] = pItem; - time_t base = GameTime::GetGameTime(); + time_t base = time(NULL); uint32 etime = uint32(base - m_logintime + (30 * 3600)); uint32 eslot = slot - BUYBACK_SLOT_START; @@ -15671,7 +15670,7 @@ void Player::AddQuest(Quest const* quest, Object* questGiver) AddTimedQuest(quest_id); questStatusData.Timer = timeAllowed * IN_MILLISECONDS; - qtime = static_cast(GameTime::GetGameTime()) + timeAllowed; + qtime = static_cast(time(NULL)) + timeAllowed; } else questStatusData.Timer = 0; @@ -18060,7 +18059,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) SaveRecallPosition(); - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); time_t logoutTime = time_t(fields[27].GetUInt32()); // since last logout (in seconds) @@ -18228,7 +18227,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) SetUInt32Value(PLAYER_CHOSEN_TITLE, curTitle); // has to be called after last Relocate() in Player::LoadFromDB - SetFallInformation(GameTime::GetGameTime(), GetPositionZ()); + SetFallInformation(time(NULL), GetPositionZ()); _LoadSpellCooldowns(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_SPELL_COOLDOWNS)); @@ -19096,10 +19095,10 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) { AddTimedQuest(quest_id); - if (quest_time <= GameTime::GetGameTime()) + if (quest_time <= sWorld->GetGameTime()) questStatusData.Timer = 1; else - questStatusData.Timer = uint32((quest_time - GameTime::GetGameTime()) * IN_MILLISECONDS); + questStatusData.Timer = uint32((quest_time - sWorld->GetGameTime()) * IN_MILLISECONDS); } else quest_time = 0; @@ -19364,7 +19363,7 @@ void Player::SendRaidInfo() size_t p_counter = data.wpos(); data << uint32(counter); // placeholder - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { @@ -20034,7 +20033,7 @@ void Player::_SaveQuestStatus(SQLTransaction& trans) stmt->setUInt32(index++, statusItr->first); stmt->setUInt8(index++, uint8(statusItr->second.Status)); stmt->setBool(index++, statusItr->second.Explored); - stmt->setUInt32(index++, uint32(statusItr->second.Timer / IN_MILLISECONDS+ GameTime::GetGameTime())); + stmt->setUInt32(index++, uint32(statusItr->second.Timer / IN_MILLISECONDS+ sWorld->GetGameTime())); for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) stmt->setUInt16(index++, statusItr->second.CreatureOrGOCount[i]); @@ -20957,7 +20956,7 @@ void Player::PetSpellInitialize() uint8 cooldownsCount = pet->m_CreatureSpellCooldowns.size(); data << uint8(cooldownsCount); - uint32 curTime = GameTime::GetGameTimeMS(); + uint32 curTime = World::GetGameTimeMS(); for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr) { @@ -21051,7 +21050,7 @@ void Player::VehicleSpellInitialize() // Cooldowns data << uint8(cooldownCount); - uint32 curTime = GameTime::GetGameTimeMS(); + uint32 curTime = World::GetGameTimeMS(); for (CreatureSpellCooldowns::const_iterator itr = vehicle->m_CreatureSpellCooldowns.begin(); itr != vehicle->m_CreatureSpellCooldowns.end(); ++itr) { @@ -22232,7 +22231,7 @@ void Player::UpdatePvPState(bool onlyFFA) else // in friendly area { if (IsPvP() && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) && pvpInfo.EndTimer == 0) - pvpInfo.EndTimer = GameTime::GetGameTime(); // start toggle-off + pvpInfo.EndTimer = time(NULL); // start toggle-off } } @@ -22245,7 +22244,7 @@ void Player::UpdatePvP(bool state, bool _override) } else { - pvpInfo.EndTimer = GameTime::GetGameTime(); + pvpInfo.EndTimer = time(NULL); SetPvP(state); } RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER); @@ -22369,7 +22368,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 ite void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, uint32 end_time, bool needSendToClient, bool forceSendToSpectator) { SpellCooldown sc; - sc.end = GameTime::GetGameTimeMS()+end_time; + sc.end = World::GetGameTimeMS()+end_time; sc.itemid = itemid; sc.maxduration = end_time; sc.sendToSpectator = false; @@ -22652,7 +22651,7 @@ void Player::LeaveBattleground(Battleground* bg) } // xinef: reset corpse reclaim time - m_deathExpireTime = GameTime::GetGameTime(); + m_deathExpireTime = time(NULL); // pussywizard: clear movement, because after porting player will move to arena cords GetMotionMaster()->MovementExpired(); @@ -23121,7 +23120,7 @@ void Player::SendInitialPacketsBeforeAddToMap() SendEquipmentSetList(); data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4); - data.AppendPackedTime(GameTime::GetGameTime()); + data.AppendPackedTime(sWorld->GetGameTime()); data << float(0.01666667f); // game speed data << uint32(0); // added in 3.1.2 GetSession()->SendPacket(&data); @@ -23303,7 +23302,7 @@ void Player::ApplyEquipCooldown(Item* pItem) // Don't replace longer cooldowns by equip cooldown if we have any. SpellCooldowns::iterator itr = m_spellCooldowns.find(spellData.SpellId); - if (itr != m_spellCooldowns.end() && itr->second.itemid == pItem->GetEntry() && itr->second.end > GameTime::GetGameTime() + 30) + if (itr != m_spellCooldowns.end() && itr->second.itemid == pItem->GetEntry() && itr->second.end > time(NULL) + 30) continue; // xinef: dont apply eqiup cooldown for spells with this attribute @@ -23475,7 +23474,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 = GameTime::GetGameTime(); // last daily quest time + m_lastDailyQuestTime = time(NULL); // last daily quest time m_DailyQuestChanged = true; break; } @@ -23483,7 +23482,7 @@ void Player::SetDailyQuestStatus(uint32 quest_id) } else { m_DFQuests.insert(quest_id); - m_lastDailyQuestTime = GameTime::GetGameTime(); + m_lastDailyQuestTime = time(NULL); m_DailyQuestChanged = true; } } @@ -23741,7 +23740,7 @@ void Player::SummonIfPossible(bool agree, uint32 summoner_guid) } // expire and auto declined - if (m_summon_expire < GameTime::GetGameTime()) + if (m_summon_expire < time(NULL)) return; // drop flag at summon @@ -24263,7 +24262,7 @@ uint32 Player::GetCorpseReclaimDelay(bool pvp) const else if (!sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE)) return 0; - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); // 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; @@ -24278,7 +24277,7 @@ void Player::UpdateCorpseReclaimDelay() (!pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))) return; - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (now < m_deathExpireTime) { @@ -24322,7 +24321,7 @@ int32 Player::CalculateCorpseReclaimDelay(bool load) } time_t expected_time = corpse->GetGhostTime() + copseReclaimDelay[count]; - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (now >= expected_time) return -1; @@ -26288,7 +26287,7 @@ void Player::_SaveCharacter(bool create, SQLTransaction& trans) stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]); stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]); stmt->setFloat(index++, finiteAlways(_restBonus)); - stmt->setUInt32(index++, uint32(GameTime::GetGameTime())); + stmt->setUInt32(index++, uint32(time(NULL))); stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0)); //save, far from tavern/city //save, but in tavern/city @@ -26420,7 +26419,7 @@ void Player::_SaveCharacter(bool create, SQLTransaction& trans) stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]); stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]); stmt->setFloat(index++, finiteAlways(_restBonus)); - stmt->setUInt32(index++, uint32(GameTime::GetGameTime())); + stmt->setUInt32(index++, uint32(time(NULL))); stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0)); //save, far from tavern/city //save, but in tavern/city @@ -26868,7 +26867,7 @@ void Player::ResetTimeSync() m_timeSyncCounter = 0; m_timeSyncTimer = 0; m_timeSyncClient = 0; - m_timeSyncServer = GameTime::GetGameTimeMS(); + m_timeSyncServer = World::GetGameTimeMS(); } void Player::SendTimeSync() @@ -26879,7 +26878,7 @@ void Player::SendTimeSync() // Schedule next sync in 10 sec m_timeSyncTimer = 10000; - m_timeSyncServer = GameTime::GetGameTimeMS(); + m_timeSyncServer = World::GetGameTimeMS(); } void Player::SetReputation(uint32 factionentry, uint32 value) @@ -27331,7 +27330,7 @@ void Player::_LoadBrewOfTheMonth(PreparedQueryResult result) lastEventId = fields[0].GetUInt32(); } - time_t curtime = GameTime::GetGameTime(); + time_t curtime = time(NULL); tm localTime; ACE_OS::localtime_r(&curtime, &localTime); @@ -27414,7 +27413,7 @@ bool Player::SetCanFly(bool apply, bool packetOnly /*= false*/) return false; if (!apply) - SetFallInformation(GameTime::GetGameTime(), GetPositionZ()); + SetFallInformation(time(NULL), GetPositionZ()); WorldPacket data(apply ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY, 12); data.append(GetPackGUID()); @@ -27498,36 +27497,3 @@ void Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy AsynchPetSummon* asynchPetInfo = new AsynchPetSummon(entry, pos, petType, duration, createdBySpell, casterGUID); Pet::LoadPetFromDB(this, asynchLoadType, entry, 0, false, asynchPetInfo); } - -void Player::SetSummonPoint(uint32 mapid, float x, float y, float z, uint32 delay, bool asSpectator) -{ - m_summon_expire = GameTime::GetGameTime() + (delay ? delay : MAX_PLAYER_SUMMON_DELAY); - m_summon_mapid = mapid; - m_summon_x = x; - m_summon_y = y; - m_summon_z = z; - m_summon_asSpectator = asSpectator; -} - -bool Player::IsSummonAsSpectator() const -{ - return m_summon_asSpectator && m_summon_expire >= GameTime::GetGameTime(); -} - -bool Player::HasSpellCooldown(uint32 spell_id) const -{ - SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); - return itr != m_spellCooldowns.end() && itr->second.end > GameTime::GetGameTimeMS(); -} - -bool Player::HasSpellItemCooldown(uint32 spell_id, uint32 itemid) const -{ - SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); - return itr != m_spellCooldowns.end() && itr->second.end > GameTime::GetGameTimeMS() && itr->second.itemid == itemid; -} - -uint32 Player::GetSpellCooldownDelay(uint32 spell_id) const -{ - SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); - return uint32(itr != m_spellCooldowns.end() && itr->second.end > GameTime::GetGameTimeMS() ? itr->second.end - GameTime::GetGameTimeMS() : 0); -} diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 46b5841fc..d3b1f8fd1 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1104,8 +1104,16 @@ class Player : public Unit, public GridObject } bool TeleportToEntryPoint(); - void SetSummonPoint(uint32 mapid, float x, float y, float z, uint32 delay = 0, bool asSpectator = false); - bool IsSummonAsSpectator() const; + void SetSummonPoint(uint32 mapid, float x, float y, float z, uint32 delay = 0, bool asSpectator = false) + { + m_summon_expire = time(NULL) + (delay ? delay : MAX_PLAYER_SUMMON_DELAY); + m_summon_mapid = mapid; + m_summon_x = x; + m_summon_y = y; + m_summon_z = z; + m_summon_asSpectator = asSpectator; + } + bool IsSummonAsSpectator() const { return m_summon_asSpectator && m_summon_expire >= time(NULL); } void SetSummonAsSpectator(bool on) { m_summon_asSpectator = on; } void SummonIfPossible(bool agree, uint32 summoner_guid); time_t GetSummonExpireTimer() const { return m_summon_expire; } @@ -1730,9 +1738,21 @@ class Player : public Unit, public GridObject static uint32 const infinityCooldownDelay = 0x9A7EC800; // used for set "infinity cooldowns" for spells and check, MONTH*IN_MILLISECONDS static uint32 const infinityCooldownDelayCheck = 0x4D3F6400; //MONTH*IN_MILLISECONDS/2; - virtual bool HasSpellCooldown(uint32 spell_id) const; - virtual bool HasSpellItemCooldown(uint32 spell_id, uint32 itemid) const; - uint32 GetSpellCooldownDelay(uint32 spell_id) const; + virtual bool HasSpellCooldown(uint32 spell_id) const + { + SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); + return itr != m_spellCooldowns.end() && itr->second.end > World::GetGameTimeMS(); + } + virtual bool HasSpellItemCooldown(uint32 spell_id, uint32 itemid) const + { + SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); + return itr != m_spellCooldowns.end() && itr->second.end > World::GetGameTimeMS() && itr->second.itemid == itemid; + } + uint32 GetSpellCooldownDelay(uint32 spell_id) const + { + SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); + return uint32(itr != m_spellCooldowns.end() && itr->second.end > World::GetGameTimeMS() ? itr->second.end - World::GetGameTimeMS() : 0); + } void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false); virtual void AddSpellCooldown(uint32 spell_id, uint32 itemid, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false); void ModifySpellCooldown(uint32 spellId, int32 cooldown); diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 1fc2999f1..7001d2bad 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -16,7 +16,6 @@ #include "Vehicle.h" #include "MapReference.h" #include "Player.h" -#include "GameTime.h" #include "Cell.h" #include "CellImpl.h" #include "WorldModel.h" @@ -282,7 +281,7 @@ void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll) if (Player* plr = passenger->ToPlayer()) { sScriptMgr->OnRemovePassenger(ToTransport(), plr); - plr->SetFallInformation(GameTime::GetGameTime(), plr->GetPositionZ()); + plr->SetFallInformation(time(NULL), plr->GetPositionZ()); } if (withAll) @@ -956,7 +955,7 @@ void StaticTransport::RemovePassenger(WorldObject* passenger, bool withAll) if (Player* plr = passenger->ToPlayer()) { sScriptMgr->OnRemovePassenger(ToTransport(), plr); - plr->SetFallInformation(GameTime::GetGameTime(), plr->GetPositionZ()); + plr->SetFallInformation(time(NULL), plr->GetPositionZ()); } if (withAll) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 5601f7eca..6fb8b3869 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -278,12 +278,12 @@ i_motionMaster(new MotionMaster(this)), m_regenTimer(0), m_ThreatManager(this), bool GlobalCooldownMgr::HasGlobalCooldown(SpellInfo const* spellInfo) const { GlobalCooldownList::const_iterator itr = m_GlobalCooldowns.find(spellInfo->StartRecoveryCategory); - return itr != m_GlobalCooldowns.end() && itr->second.duration && getMSTimeDiff(itr->second.cast_time, GameTime::GetGameTimeMS()) < itr->second.duration; + return itr != m_GlobalCooldowns.end() && itr->second.duration && getMSTimeDiff(itr->second.cast_time, World::GetGameTimeMS()) < itr->second.duration; } void GlobalCooldownMgr::AddGlobalCooldown(SpellInfo const* spellInfo, uint32 gcd) { - m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, GameTime::GetGameTimeMS()); + m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, World::GetGameTimeMS()); } void GlobalCooldownMgr::CancelGlobalCooldown(SpellInfo const* spellInfo) @@ -446,7 +446,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 T data << uint8(0); // new in 3.1 data << GetPositionX() << GetPositionY() << GetPositionZ() + GetHoverHeight(); - data << GameTime::GetGameTimeMS(); + data << World::GetGameTimeMS(); data << uint8(0); data << uint32(sf); data << TransitTime; // Time in between points @@ -894,7 +894,7 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage { // Part of Evade mechanics. DoT's and Thorns / Retribution Aura do not contribute to this if (damagetype != DOT && damage > 0 && !IS_PLAYER_GUID(victim->GetOwnerGUID()) && (!spellProto || !spellProto->HasAura(SPELL_AURA_DAMAGE_SHIELD))) - victim->ToCreature()->SetLastDamagedTime(GameTime::GetGameTime()+MAX_AGGRO_RESET_TIME); + victim->ToCreature()->SetLastDamagedTime(sWorld->GetGameTime()+MAX_AGGRO_RESET_TIME); if (attacker) victim->AddThreat(attacker, float(damage), damageSchoolMask, spellProto); @@ -5137,7 +5137,7 @@ uint32 Unit::GetDiseasesByCaster(uint64 casterGUID, uint8 mode) { Aura* aura = (*i)->GetBase(); if (aura && !aura->IsRemoved() && aura->GetDuration() > 0) - if ((aura->GetApplyTime() + aura->GetMaxDuration()/1000 + 8) > (GameTime::GetGameTime() + aura->GetDuration()/1000)) + if ((aura->GetApplyTime() + aura->GetMaxDuration()/1000 + 8) > (time(NULL) + aura->GetDuration()/1000)) aura->SetDuration(aura->GetDuration()+3000); } } @@ -6819,7 +6819,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere if (AuraEffect* aurEff = victim->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x100000, 0, 0, GetGUID())) if (Aura* aur = aurEff->GetBase()) if (!aur->IsRemoved() && aur->GetDuration() > 0) - if ((aur->GetApplyTime() + aur->GetMaxDuration()/1000 + 5) > (GameTime::GetGameTime() + aur->GetDuration()/1000) ) + if ((aur->GetApplyTime() + aur->GetMaxDuration()/1000 + 5) > (time(NULL) + aur->GetDuration()/1000) ) { aur->SetDuration(aur->GetDuration()+2000); return true; @@ -12334,7 +12334,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4); data.append(GetPackGUID()); - data << uint32(GameTime::GetGameTime()); // Packet counter + data << uint32(sWorld->GetGameTime()); // Packet counter data << player->GetCollisionHeight(true); player->GetSession()->SendPacket(&data); } @@ -12354,7 +12354,7 @@ void Unit::Dismount() { WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4); data.append(GetPackGUID()); - data << uint32(GameTime::GetGameTime()); // Packet counter + data << uint32(sWorld->GetGameTime()); // Packet counter data << thisPlayer->GetCollisionHeight(false); thisPlayer->GetSession()->SendPacket(&data); } @@ -13543,17 +13543,17 @@ Unit* Creature::SelectVictim() // pussywizard: if victim is not acceptable only due to mmaps, it may be for example a knockback, wait for a few secs before evading if (!target && !isWorldBoss() && !GetInstanceId() && IsAlive() && (!CanHaveThreatList() || !getThreatManager().isThreatListEmpty())) if (Unit* v = GetVictim()) - if (isTargetNotAcceptableByMMaps(v->GetGUID(), GameTime::GetGameTime(), v)) + if (isTargetNotAcceptableByMMaps(v->GetGUID(), sWorld->GetGameTime(), v)) if (_CanDetectFeignDeathOf(v) && CanCreatureAttack(v)) { if (m_mmapNotAcceptableStartTime) { - if (GameTime::GetGameTime() <= m_mmapNotAcceptableStartTime+4) + if (sWorld->GetGameTime() <= m_mmapNotAcceptableStartTime+4) return NULL; } else { - m_mmapNotAcceptableStartTime = GameTime::GetGameTime(); + m_mmapNotAcceptableStartTime = sWorld->GetGameTime(); return NULL; } } @@ -13792,7 +13792,7 @@ DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) return DIMINISHING_LEVEL_1; // If last spell was casted more than 15 seconds ago - reset the count. - if (i->stack == 0 && getMSTimeDiff(i->hitTime, GameTime::GetGameTimeMS()) > 15000) + if (i->stack == 0 && getMSTimeDiff(i->hitTime, World::GetGameTimeMS()) > 15000) { i->hitCount = DIMINISHING_LEVEL_1; return DIMINISHING_LEVEL_1; @@ -13815,7 +13815,7 @@ void Unit::IncrDiminishing(DiminishingGroup group) i->hitCount += 1; return; } - m_Diminishing.push_back(DiminishingReturn(group, GameTime::GetGameTimeMS(), DIMINISHING_LEVEL_2)); + m_Diminishing.push_back(DiminishingReturn(group, World::GetGameTimeMS(), DIMINISHING_LEVEL_2)); } float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration, Unit* caster, DiminishingLevels Level, int32 limitduration) @@ -13894,7 +13894,7 @@ void Unit::ApplyDiminishingAura(DiminishingGroup group, bool apply) i->stack -= 1; // Remember time after last aura from group removed if (i->stack == 0) - i->hitTime = GameTime::GetGameTimeMS(); + i->hitTime = World::GetGameTimeMS(); } break; } @@ -15919,7 +15919,7 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) bool Unit::IsUnderLastManaUseEffect() const { - return getMSTimeDiff(m_lastManaUse, GameTime::GetGameTimeMS()) < 5000; + return getMSTimeDiff(m_lastManaUse, World::GetGameTimeMS()) < 5000; } void Unit::SetContestedPvP(Player* attackedPlayer) @@ -17106,7 +17106,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(GameTime::GetGameTime())); // cast can't be helped + SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped } } GetMotionMaster()->MoveFollow(charmer, PET_FOLLOW_DIST, GetFollowAngle()); @@ -18331,7 +18331,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) AddUnitState(UNIT_STATE_MOVE); if (player) - player->SetFallInformation(GameTime::GetGameTime(), GetPositionZ()); + player->SetFallInformation(time(NULL), GetPositionZ()); else if (HasUnitMovementFlag(MOVEMENTFLAG_ROOT)) { WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8); @@ -18412,7 +18412,7 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const else *data << uint32(GetUnitMovementFlags()); // movement flags *data << uint16(GetExtraUnitMovementFlags()); // 2.3.0 - *data << uint32(GameTime::GetGameTimeMS()); // time / counter + *data << uint32(World::GetGameTimeMS()); // time / counter *data << GetPositionX(); *data << GetPositionY(); *data << GetPositionZ() + GetHoverHeight(); diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 6b39e08d9..050f89005 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -14,7 +14,6 @@ #include "MapManager.h" #include "GossipDef.h" #include "Player.h" -#include "GameTime.h" #include "BattlegroundMgr.h" #include "UnitAI.h" #include "GameObjectAI.h" @@ -31,7 +30,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const default: case GAMEEVENT_NORMAL: { - time_t currenttime = GameTime::GetGameTime(); + time_t currenttime = time(NULL); // Get the event information return mGameEvent[entry].start < currenttime && currenttime < mGameEvent[entry].end @@ -48,7 +47,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const // if inactive world event, check the prerequisite events case GAMEEVENT_WORLD_INACTIVE: { - time_t currenttime = GameTime::GetGameTime(); + time_t currenttime = time(NULL); for (std::set::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 @@ -64,7 +63,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const uint32 GameEventMgr::NextCheck(uint16 entry) const { - time_t currenttime = GameTime::GetGameTime(); + time_t currenttime = time(NULL); // 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) @@ -124,7 +123,7 @@ bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite) ApplyNewEvent(event_id); if (overwrite) { - mGameEvent[event_id].start = GameTime::GetGameTime(); + mGameEvent[event_id].start = time(NULL); if (data.end <= data.start) data.end = data.start + data.length; } @@ -172,7 +171,7 @@ void GameEventMgr::StopEvent(uint16 event_id, bool overwrite) if (overwrite && !serverwide_evt) { - data.start = GameTime::GetGameTime() - data.length * MINUTE; + data.start = time(NULL) - data.length * MINUTE; if (data.end <= data.start) data.end = data.start + data.length; } @@ -1087,7 +1086,7 @@ void GameEventMgr::StartArenaSeason() uint32 GameEventMgr::Update() // return the next event delay in ms { - time_t currenttime = GameTime::GetGameTime(); + time_t currenttime = time(NULL); uint32 nextEventDelay = max_ge_check_delay; // 1 day uint32 calcDelay; std::set activate, deactivate; @@ -1669,7 +1668,7 @@ bool GameEventMgr::CheckOneGameEventConditions(uint16 event_id) // set the followup events' start time if (!mGameEvent[event_id].nextstart) { - time_t currenttime = GameTime::GetGameTime(); + time_t currenttime = time(NULL); mGameEvent[event_id].nextstart = currenttime + mGameEvent[event_id].length * 60; } return true; @@ -1766,7 +1765,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 = GameTime::GetGameTime(); + time_t curTime = time(NULL); for (int i = 0; i < MAX_HOLIDAY_DATES && holiday->Date[i]; ++i) { uint32 date = holiday->Date[i]; diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index 4d511170c..a33054fe6 100644 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -21,7 +21,6 @@ #include "Opcodes.h" #include "Pet.h" #include "Player.h" -#include "GameTime.h" #include "Vehicle.h" #include "World.h" #include "WorldPacket.h" @@ -382,7 +381,7 @@ Corpse* ObjectAccessor::ConvertCorpseForPlayer(uint64 player_guid, bool insignia void ObjectAccessor::RemoveOldCorpses() { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); Player2CorpsesMapType::iterator next; for (Player2CorpsesMapType::iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); itr = next) { diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 2574e8d86..608e06fc5 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -11,7 +11,6 @@ #include "Chat.h" #include "Common.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "DisableMgr.h" #include "GameEventMgr.h" #include "GossipDef.h" @@ -1024,7 +1023,7 @@ void ObjectMgr::LoadCreatureAddons() void ObjectMgr::LoadGameObjectAddons() { - uint32 oldMSTime = GameTime::GetGameTimeMS(); + uint32 oldMSTime = getMSTime(); // 0 1 2 QueryResult result = WorldDatabase.Query("SELECT guid, invisibilityType, invisibilityValue FROM gameobject_addon"); @@ -5507,7 +5506,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) { uint32 oldMSTime = getMSTime(); - time_t curTime = GameTime::GetGameTime(); + time_t curTime = time(NULL); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_EXPIRED_MAIL); stmt->setUInt32(0, curTime); diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index eda7fffbf..2ae9af475 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -6,7 +6,6 @@ #include "Common.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "Group.h" #include "GroupMgr.h" #include "Log.h" @@ -2327,13 +2326,3 @@ void Group::ToggleGroupMemberFlag(member_witerator slot, uint8 flag, bool apply) slot->flags &= ~flag; } -uint32 Group::GetDifficultyChangePreventionTime() const -{ - return _difficultyChangePreventionTime > GameTime::GetGameTime() ? _difficultyChangePreventionTime - GameTime::GetGameTime() : 0; -} - -void Group::SetDifficultyChangePrevention(DifficultyPreventionChangeType type) -{ - _difficultyChangePreventionTime = GameTime::GetGameTime() + MINUTE; - _difficultyChangePreventionType = type; -} \ No newline at end of file diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index c586019ca..484e191ef 100644 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -299,9 +299,13 @@ class Group bool IsLfgHeroic() const { return isLFGGroup() && (m_lfgGroupFlags & GROUP_LFG_FLAG_IS_HEROIC); } // Difficulty Change - uint32 GetDifficultyChangePreventionTime() const; + uint32 GetDifficultyChangePreventionTime() const { return _difficultyChangePreventionTime > time(NULL) ? _difficultyChangePreventionTime - time(NULL) : 0; } DifficultyPreventionChangeType GetDifficultyChangePreventionReason() const { return _difficultyChangePreventionType; } - void SetDifficultyChangePrevention(DifficultyPreventionChangeType type); + void SetDifficultyChangePrevention(DifficultyPreventionChangeType type) + { + _difficultyChangePreventionTime = time(NULL) + MINUTE; + _difficultyChangePreventionType = type; + } protected: void _homebindIfInstance(Player* player); diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 201054ab1..0bc5b990b 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -9,7 +9,6 @@ #include "Chat.h" #include "Config.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "Guild.h" #include "GuildMgr.h" #include "Language.h" @@ -161,8 +160,6 @@ inline uint32 Guild::LogHolder::GetNextGUID() return m_nextGUID; } -Guild::LogEntry::LogEntry(uint32 guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(GameTime::GetGameTime()) { } - // EventLogEntry void Guild::EventLogEntry::SaveToDB(SQLTransaction& trans) const { @@ -196,7 +193,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(::GameTime::GetGameTime() - m_timestamp); + data << uint32(::time(NULL) - m_timestamp); } // BankEventLogEntry @@ -246,7 +243,7 @@ void Guild::BankEventLogEntry::WritePacket(WorldPacket& data) const data << uint32(m_itemOrMoney); } - data << uint32(GameTime::GetGameTime() - m_timestamp); + data << uint32(time(NULL) - m_timestamp); } // RankInfo @@ -641,11 +638,6 @@ void Guild::Member::ChangeRank(uint8 newRank) CharacterDatabase.Execute(stmt); } -void Guild::Member::UpdateLogoutTime() -{ - m_logoutTime = GameTime::GetGameTime(); -} - void Guild::Member::SaveToDB(SQLTransaction& trans) const { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_MEMBER); @@ -716,7 +708,7 @@ void Guild::Member::WritePacket(WorldPacket& data, bool sendOfficerNote) const << uint32(m_zoneId); if (!m_flags) - data << float(float(::GameTime::GetGameTime() - m_logoutTime) / DAY); + data << float(float(::time(NULL) - m_logoutTime) / DAY); data << m_publicNote; @@ -1169,7 +1161,7 @@ bool Guild::Create(Player* pLeader, std::string const& name) m_info = ""; m_motd = "No message set."; m_bankMoney = 0; - m_createdDate = GameTime::GetGameTime(); + m_createdDate = sWorld->GetGameTime(); _CreateLogHolders(); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index e7fa9b0ac..4a8c68d78 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -281,6 +281,7 @@ public: // pussywizard: public class Member m_level(0), m_class(0), m_flags(GUILDMEMBER_STATUS_NONE), + m_logoutTime(::time(NULL)), m_accountId(0), m_rankId(rankId) { @@ -319,7 +320,7 @@ public: // pussywizard: public class Member void ChangeRank(uint8 newRank); - inline void UpdateLogoutTime(); + inline void UpdateLogoutTime() { m_logoutTime = ::time(NULL); } inline bool IsRank(uint8 rankId) const { return m_rankId == rankId; } inline bool IsRankNotLower(uint8 rankId) const { return m_rankId <= rankId; } inline bool IsSamePlayer(uint64 guid) const { return m_guid == guid; } @@ -374,7 +375,7 @@ private: class LogEntry { public: - LogEntry(uint32 guildId, uint32 guid); + LogEntry(uint32 guildId, uint32 guid) : m_guildId(guildId), m_guid(guid), m_timestamp(::time(NULL)) { } LogEntry(uint32 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 1d1e18d87..15a46dbfd 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -13,7 +13,6 @@ #include "AuctionHouseMgr.h" #include "Log.h" #include "Language.h" -#include "GameTime.h" #include "Opcodes.h" #include "UpdateMask.h" #include "Util.h" @@ -279,7 +278,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recvData) AH->bidder = 0; AH->bid = 0; AH->buyout = buyout; - AH->expire_time = GameTime::GetGameTime() + auctionTime; + AH->expire_time = time(NULL) + auctionTime; AH->deposit = deposit; AH->auctionHouseEntry = auctionHouseEntry; @@ -321,7 +320,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recvData) AH->bidder = 0; AH->bid = 0; AH->buyout = buyout; - AH->expire_time = GameTime::GetGameTime() + auctionTime; + AH->expire_time = time(NULL) + auctionTime; AH->deposit = deposit; AH->auctionHouseEntry = auctionHouseEntry; @@ -649,7 +648,7 @@ void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recvData) { // pussywizard: const uint32 delay = 4500; - const uint32 now = GameTime::GetGameTimeMS(); + const uint32 now = World::GetGameTimeMS(); if (_lastAuctionListOwnerItemsMSTime > now) // list is pending return; uint32 diff = getMSTimeDiff(_lastAuctionListOwnerItemsMSTime, now); @@ -666,7 +665,7 @@ void WorldSession::HandleAuctionListOwnerItemsEvent(WorldPacket & recvData) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_LIST_OWNER_ITEMS"); #endif - _lastAuctionListOwnerItemsMSTime = GameTime::GetGameTimeMS(); // pussywizard + _lastAuctionListOwnerItemsMSTime = World::GetGameTimeMS(); // pussywizard uint32 listfrom; uint64 guid; @@ -741,7 +740,7 @@ void WorldSession::HandleAuctionListItems(WorldPacket & recvData) // pussywizard: const uint32 delay = 2000; - const uint32 now = GameTime::GetGameTimeMS(); + const uint32 now = World::GetGameTimeMS(); uint32 diff = getMSTimeDiff(_lastAuctionListItemsMSTime, now); if (diff > delay) diff = delay; diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 8fa3039c2..c44fc0505 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -14,7 +14,6 @@ #include "ArenaTeam.h" #include "BattlegroundMgr.h" #include "Battleground.h" -#include "GameTime.h" #include "Chat.h" #include "Language.h" #include "Log.h" @@ -536,7 +535,7 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recvData*/) if (!bg) continue; - uint32 remainingTime = (GameTime::GetGameTimeMS() < ginfo.RemoveInviteTime ? getMSTimeDiff(GameTime::GetGameTimeMS(), ginfo.RemoveInviteTime) : 1); + uint32 remainingTime = (World::GetGameTimeMS() < ginfo.RemoveInviteTime ? getMSTimeDiff(World::GetGameTimeMS(), ginfo.RemoveInviteTime) : 1); sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_WAIT_JOIN, remainingTime, 0, ginfo.ArenaType, TEAM_NEUTRAL, bg->isRated(), ginfo.BgTypeId); SendPacket(&data); } @@ -553,7 +552,7 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recvData*/) continue; uint32 avgWaitTime = bgQueue.GetAverageQueueWaitTime(&ginfo); - sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bgt, i, STATUS_WAIT_QUEUE, avgWaitTime, getMSTimeDiff(ginfo.JoinTime, GameTime::GetGameTimeMS()), ginfo.ArenaType, TEAM_NEUTRAL, ginfo.IsRated); + sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bgt, i, STATUS_WAIT_QUEUE, avgWaitTime, getMSTimeDiff(ginfo.JoinTime, World::GetGameTimeMS()), ginfo.ArenaType, TEAM_NEUTRAL, ginfo.IsRated); SendPacket(&data); } } diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index eb07cce17..b77e30cad 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -31,7 +31,6 @@ Copied events should probably have a new owner #include "ObjectMgr.h" #include "ObjectAccessor.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "GuildMgr.h" #include "ArenaTeamMgr.h" #include "WorldSession.h" @@ -42,7 +41,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) uint64 guid = _player->GetGUID(); sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid); - time_t currTime = GameTime::GetGameTime(); + time_t currTime = time(NULL); WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance @@ -229,7 +228,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) < (GameTime::GetGameTime() - time_t(86400L))) + if (time_t(eventPackedTime) < (time(NULL) - time_t(86400L))) { recvData.rfinish(); return; @@ -321,7 +320,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) < (GameTime::GetGameTime() - time_t(86400L))) + if (time_t(eventPackedTime) < (time(NULL) - time_t(86400L))) { recvData.rfinish(); return; @@ -378,7 +377,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) < (GameTime::GetGameTime() - time_t(86400L))) + if (time_t(eventTime) < (time(NULL) - time_t(86400L))) { recvData.rfinish(); return; @@ -518,7 +517,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, GameTime::GetGameTime(), status, CALENDAR_RANK_PLAYER, ""); + CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), eventId, guid, guid, time(NULL), status, CALENDAR_RANK_PLAYER, ""); sCalendarMgr->AddInvite(calendarEvent, invite); sCalendarMgr->SendCalendarClearPendingAction(guid); } @@ -550,7 +549,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recvData) if (CalendarInvite* invite = sCalendarMgr->GetInvite(inviteId)) { invite->SetStatus(CalendarInviteStatus(status)); - invite->SetStatusTime(GameTime::GetGameTime()); + invite->SetStatusTime(time(NULL)); sCalendarMgr->UpdateInvite(invite); sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite); @@ -614,7 +613,7 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData) { invite->SetStatus((CalendarInviteStatus)status); // not sure if we should set response time when moderator changes invite status - //invite->SetStatusTime(GameTime::GetGameTime()); + //invite->SetStatusTime(time(NULL)); sCalendarMgr->UpdateInvite(invite); sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite); @@ -714,7 +713,7 @@ void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData) void WorldSession::SendCalendarRaidLockout(InstanceSave const* save, bool add) { sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", add ? "SMSG_CALENDAR_RAID_LOCKOUT_ADDED" : "SMSG_CALENDAR_RAID_LOCKOUT_REMOVED"); - time_t currTime = GameTime::GetGameTime(); + time_t currTime = time(NULL); WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_REMOVED, (add ? 4 : 0) + 4 + 4 + 4 + 8); if (add) @@ -732,7 +731,7 @@ void WorldSession::SendCalendarRaidLockout(InstanceSave const* save, bool add) void WorldSession::SendCalendarRaidLockoutUpdated(InstanceSave const* save, bool isExtended) { - time_t currTime = GameTime::GetGameTime(); + time_t currTime = time(NULL); time_t resetTime = isExtended ? save->GetExtendedResetTime() : save->GetResetTime(); time_t resetTimeOp = isExtended ? save->GetResetTime() : save->GetExtendedResetTime(); WorldPacket data(SMSG_CALENDAR_RAID_LOCKOUT_UPDATED, 4 + 4 + 4 + 4 + 8); diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index d3863f670..79065a3ba 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -13,7 +13,6 @@ #include "Chat.h" #include "Common.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "Group.h" #include "Guild.h" #include "GuildMgr.h" @@ -110,7 +109,7 @@ bool LoginQueryHolder::Initialize() stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_MAILCOUNT); stmt->setUInt32(0, lowGuid); - stmt->setUInt64(1, uint64(GameTime::GetGameTime())); + stmt->setUInt64(1, uint64(time(NULL))); res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_MAIL_COUNT, stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_MAILDATE); @@ -1003,7 +1002,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) stmt->setUInt32(1, GetAccountId()); LoginDatabase.Execute(stmt); - pCurrChar->SetInGameTime(GameTime::GetGameTimeMS()); + pCurrChar->SetInGameTime(World::GetGameTimeMS()); // announce group about member online (must be after add to player list to receive announce to self) if (Group* group = pCurrChar->GetGroup()) @@ -1018,7 +1017,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) if (mapDiff->resetTime) if (time_t timeReset = sInstanceSaveMgr->GetResetTimeFor(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty())) { - uint32 timeleft = uint32(timeReset - GameTime::GetGameTime()); + uint32 timeleft = uint32(timeReset - time(NULL)); pCurrChar->SendInstanceResetWarning(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty(), timeleft, true); } @@ -1264,7 +1263,7 @@ void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar) uint32 currZone, currArea; pCurrChar->GetZoneAndAreaId(currZone, currArea, false); pCurrChar->SendInitWorldStates(currZone, currArea); - pCurrChar->SetInGameTime(GameTime::GetGameTimeMS()); + pCurrChar->SetInGameTime(World::GetGameTimeMS()); // Xinef: we need to resend all spell mods for (uint16 Opcode = SMSG_SET_FLAT_SPELL_MODIFIER; Opcode <= SMSG_SET_PCT_SPELL_MODIFIER; ++Opcode) // PCT = FLAT+1 @@ -1309,7 +1308,7 @@ void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar) if (mapDiff->resetTime) if (time_t timeReset = sInstanceSaveMgr->GetResetTimeFor(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty())) { - uint32 timeleft = uint32(timeReset - GameTime::GetGameTime()); + uint32 timeleft = uint32(timeReset - time(NULL)); GetPlayer()->SendInstanceResetWarning(pCurrChar->GetMap()->GetId(), pCurrChar->GetMap()->GetDifficulty(), timeleft, true); } diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp index 3441f45f4..0b3eafe93 100644 --- a/src/server/game/Handlers/ChatHandler.cpp +++ b/src/server/game/Handlers/ChatHandler.cpp @@ -279,7 +279,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData) if (!_player->CanSpeak()) { - std::string timeStr = secsToTimeString(m_muteTime - GameTime::GetGameTime()); + std::string timeStr = secsToTimeString(m_muteTime - time(NULL)); SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str()); return; } @@ -666,7 +666,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recvData) if (!GetPlayer()->CanSpeak()) { - std::string timeStr = secsToTimeString(m_muteTime - GameTime::GetGameTime()); + std::string timeStr = secsToTimeString(m_muteTime - time(NULL)); 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 970c82a90..806d96dae 100644 --- a/src/server/game/Handlers/DuelHandler.cpp +++ b/src/server/game/Handlers/DuelHandler.cpp @@ -7,7 +7,6 @@ #include "Common.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "GameTime.h" #include "Log.h" #include "Opcodes.h" #include "UpdateData.h" @@ -36,7 +35,7 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) sLog->outStaticDebug("Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName().c_str()); #endif - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); 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 90c782506..ac0c80258 100644 --- a/src/server/game/Handlers/LFGHandler.cpp +++ b/src/server/game/Handlers/LFGHandler.cpp @@ -6,7 +6,6 @@ #include "LFGMgr.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "Group.h" #include "Player.h" #include "Opcodes.h" @@ -549,7 +548,7 @@ void WorldSession::SendLfgBootProposalUpdate(lfg::LfgPlayerBoot const& boot) lfg::LfgAnswer playerVote = boot.votes.find(guid)->second; uint8 votesNum = 0; uint8 agreeNum = 0; - uint32 secsleft = boot.cancelTime - GameTime::GetGameTime(); + uint32 secsleft = boot.cancelTime - time(NULL); 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 6f18f5740..ed845cf63 100644 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -9,7 +9,6 @@ #include "WorldPacket.h" #include "WorldSession.h" #include "Opcodes.h" -#include "GameTime.h" #include "Log.h" #include "World.h" #include "ObjectMgr.h" @@ -366,7 +365,7 @@ void WorldSession::HandleMailReturnToSender(WorldPacket & recvData) Player* player = _player; Mail* m = player->GetMail(mailId); - if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime()) + if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { player->SendMailResult(mailId, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR); return; @@ -431,7 +430,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recvData) Player* player = _player; Mail* m = player->GetMail(mailId); - if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime()) + if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { player->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR); return; @@ -531,7 +530,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket& recvData) Player* player = _player; Mail* m = player->GetMail(mailId); - if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > GameTime::GetGameTime()) + if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) { player->SendMailResult(mailId, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR); return; @@ -580,7 +579,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 = GameTime::GetGameTime(); + time_t cur_time = time(NULL); for (PlayerMails::iterator itr = player->GetMailBegin(); itr != player->GetMailEnd(); ++itr) { @@ -627,7 +626,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-GameTime::GetGameTime())/DAY); // Time + data << float(float((*itr)->expire_time-time(NULL))/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 @@ -691,7 +690,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 > GameTime::GetGameTime() || (m->checked & MAIL_CHECK_MASK_COPIED)) + if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL) || (m->checked & MAIL_CHECK_MASK_COPIED)) { player->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR); return; @@ -758,7 +757,7 @@ void WorldSession::HandleQueryNextMailTime(WorldPacket & /*recvData*/) data << uint32(0); // count uint32 count = 0; - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); std::set 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 7d2833772..ccaacf408 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -15,7 +15,6 @@ #include "World.h" #include "ObjectMgr.h" #include "GuildMgr.h" -#include "GameTime.h" #include "WorldSession.h" #include "BigNumber.h" #include "SHA1.h" @@ -219,7 +218,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_WHO Message"); - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (now < timeWhoCommandAllowed) return; timeWhoCommandAllowed = now + 3; @@ -467,7 +466,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/) GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } - LogoutRequest(GameTime::GetGameTime()); + LogoutRequest(time(NULL)); } void WorldSession::HandlePlayerLogoutOpcode(WorldPacket & /*recv_data*/) @@ -818,7 +817,7 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) 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(GameTime::GetGameTime())) + if (time_t(corpse->GetGhostTime() + _player->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP)) > time_t(time(NULL))) return; if (!corpse->IsWithinDistInMap(_player, CORPSE_RECLAIM_RADIUS, true)) @@ -1525,7 +1524,7 @@ void WorldSession::HandleTimeSyncResp(WorldPacket & recv_data) { uint32 counter, clientTicks; recv_data >> counter >> clientTicks; - //uint32 ourTicks = clientTicks + (GameTime::GetGameTimeMS() - _player->m_timeSyncServer); + //uint32 ourTicks = clientTicks + (World::GetGameTimeMS() - _player->m_timeSyncServer); _player->m_timeSyncClient = clientTicks; } @@ -1859,7 +1858,7 @@ void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket& /*recv_data*/) #endif WorldPacket data(SMSG_WORLD_STATE_UI_TIMER_UPDATE, 4); - data << uint32(GameTime::GetGameTime()); + data << uint32(time(NULL)); SendPacket(&data); } diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index 6939a41b6..e62bf28cf 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -152,7 +152,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() _player->SetIsSpectator(false); GetPlayer()->SetPendingSpectatorForBG(0); - timeWhoCommandAllowed = GameTime::GetGameTime() + sWorld->GetNextWhoListUpdateDelaySecs() + 1; // after exiting arena Subscribe will scan for a player and cached data says he is still in arena, so disallow until next update + timeWhoCommandAllowed = time(NULL) + sWorld->GetNextWhoListUpdateDelaySecs() + 1; // after exiting arena Subscribe will scan for a player and cached data says he is still in arena, so disallow until next update if (uint32 inviteInstanceId = _player->GetPendingSpectatorInviteInstanceId()) { @@ -193,7 +193,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (mapDiff->resetTime) if (time_t timeReset = sInstanceSaveMgr->GetResetTimeFor(mEntry->MapID, diff)) { - uint32 timeleft = uint32(timeReset - GameTime::GetGameTime()); + uint32 timeleft = uint32(timeReset - time(NULL)); GetPlayer()->SendInstanceResetWarning(mEntry->MapID, diff, timeleft, true); } allowMount = mInstance->AllowMount; @@ -408,7 +408,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recvData) if (mover->GetGUID() != _player->GetGUID()) movementInfo.flags &= ~MOVEMENTFLAG_WALKING; - uint32 mstime = GameTime::GetGameTimeMS(); + uint32 mstime = World::GetGameTimeMS(); /*----------------------*/ if(m_clientTimeDelay == 0) m_clientTimeDelay = mstime > movementInfo.time ? std::min(mstime - movementInfo.time, (uint32)100) : 0; diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index b0f8b6664..3417ea75b 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -8,7 +8,6 @@ #include "WorldPacket.h" #include "WorldSession.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "SpellMgr.h" #include "Log.h" #include "Opcodes.h" @@ -129,7 +128,7 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result, Map* map = owner->GetMap(); uint32 guid = sObjectMgr->GenerateLowGuid(HIGHGUID_PET); Pet* pet = new Pet(owner, pet_type); - LoadPetFromDBQueryHolder* holder = new LoadPetFromDBQueryHolder(pet_number, current, uint32(GameTime::GetGameTime() - fields[14].GetUInt32()), fields[13].GetString(), savedhealth, savedmana); + LoadPetFromDBQueryHolder* holder = new LoadPetFromDBQueryHolder(pet_number, current, uint32(time(NULL) - fields[14].GetUInt32()), fields[13].GetString(), savedhealth, savedmana); if (!pet->Create(guid, map, owner->GetPhaseMask(), petentry, pet_number) || !holder->Initialize()) { delete pet; @@ -199,7 +198,7 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result, break; } - pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped here + pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped here pet->SetCreatorGUID(owner->GetGUID()); owner->SetMinion(pet, true); @@ -553,7 +552,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid // pussywizard: if (Creature* creaturePet = pet->ToCreature()) - if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit) || creaturePet->isTargetNotAcceptableByMMaps(TargetUnit->GetGUID(), GameTime::GetGameTime(), TargetUnit)) + if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit) || creaturePet->isTargetNotAcceptableByMMaps(TargetUnit->GetGUID(), sWorld->GetGameTime(), TargetUnit)) return; // Not let attack through obstructions @@ -1192,7 +1191,7 @@ void WorldSession::HandlePetRename(WorldPacket & recvData) CharacterDatabase.CommitTransaction(trans); - pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped + pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // 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 bdc94f1e5..02aa82755 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -7,7 +7,6 @@ #include "Common.h" #include "Language.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "WorldPacket.h" #include "WorldSession.h" #include "Opcodes.h" @@ -73,8 +72,8 @@ void WorldSession::HandleQueryTimeOpcode(WorldPacket & /*recvData*/) void WorldSession::SendQueryTimeResponse() { WorldPacket data(SMSG_QUERY_TIME_RESPONSE, 4+4); - data << uint32(GameTime::GetGameTime()); - data << uint32(sWorld->GetNextDailyQuestsResetTime() - GameTime::GetGameTime()); + data << uint32(time(NULL)); + data << uint32(sWorld->GetNextDailyQuestsResetTime() - time(NULL)); SendPacket(&data); } diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index 52ae83d49..2e00ca48b 100644 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -9,7 +9,6 @@ #include "Language.h" #include "ObjectMgr.h" #include "Opcodes.h" -#include "GameTime.h" #include "Player.h" #include "TicketMgr.h" #include "Util.h" @@ -238,7 +237,7 @@ void WorldSession::HandleReportLag(WorldPacket& recv_data) stmt->setFloat (4, y); stmt->setFloat (5, z); stmt->setUInt32(6, GetLatency()); - stmt->setUInt32(7, GameTime::GetGameTime()); + stmt->setUInt32(7, time(NULL)); CharacterDatabase.Execute(stmt); } diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index 06b654e35..dc4af75ce 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -20,7 +20,6 @@ #include "ObjectMgr.h" #include "World.h" #include "Group.h" -#include "GameTime.h" #include "InstanceScript.h" #include "ScriptMgr.h" @@ -78,7 +77,7 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance } else { - resetTime = GameTime::GetGameTime() + 3*DAY; // normals expire after 3 days even if someone is still bound to them, cleared on startup + resetTime = time(NULL) + 3*DAY; // normals expire after 3 days even if someone is still bound to them, cleared on startup extendedResetTime = 0; } InstanceSave* save = new InstanceSave(mapId, instanceId, difficulty, resetTime, extendedResetTime); @@ -240,7 +239,7 @@ void InstanceSaveManager::LoadInstances() void InstanceSaveManager::LoadResetTimes() { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); time_t today = (now / DAY) * DAY; // load the global respawn times for raid/heroic instances @@ -405,7 +404,7 @@ void InstanceSaveManager::ScheduleReset(time_t time, InstResetEvent event) void InstanceSaveManager::Update() { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); time_t t; bool resetOccurred = false; @@ -504,7 +503,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b if (!mapEntry->Instanceable()) return; - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (!warn) { diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp index 2dc0706bf..6683fe2f1 100644 --- a/src/server/game/Mails/Mail.cpp +++ b/src/server/game/Mails/Mail.cpp @@ -9,7 +9,6 @@ #include "Log.h" #include "World.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "Player.h" #include "Unit.h" #include "BattlegroundMgr.h" @@ -176,7 +175,7 @@ void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, uint32 mailId = sObjectMgr->GenerateMailID(); - time_t deliver_time = GameTime::GetGameTime() + deliver_delay; + time_t deliver_time = time(NULL) + 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 f57b2d862..107d978f5 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -23,7 +23,6 @@ #include "Vehicle.h" #include "VMapFactory.h" #include "LFGMgr.h" -#include "GameTime.h" #include "Chat.h" #ifdef ELUNA #include "LuaEngine.h" @@ -2649,7 +2648,7 @@ bool InstanceMap::AddPlayerToMap(Player* player) // increase current instances (hourly limit) // xinef: specific instances are still limited if (!group || !group->isLFGGroup() || !group->IsLfgRandomInstance()) - player->AddInstanceEnterTime(GetInstanceId(), GameTime::GetGameTime()); + player->AddInstanceEnterTime(GetInstanceId(), time(NULL)); if (!playerBind->perm && !mapSave->CanReset() && (!group || !group->isLFGGroup() || !group->IsLfgRandomInstance())) { @@ -2995,7 +2994,7 @@ void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t& respawnTime) return; } - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (GetInstanceResetPeriod() > 0 && respawnTime-now+5 >= GetInstanceResetPeriod()) respawnTime = now+YEAR; @@ -3029,7 +3028,7 @@ void Map::SaveGORespawnTime(uint32 dbGuid, time_t& respawnTime) return; } - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (GetInstanceResetPeriod() > 0 && respawnTime-now+5 >= GetInstanceResetPeriod()) respawnTime = now+YEAR; diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 2ae63bbc9..d681dcff3 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -7,7 +7,6 @@ #include "MotionMaster.h" #include "CreatureAISelector.h" #include "Creature.h" -#include "GameTime.h" #include "ConfusedMovementGenerator.h" #include "FleeingMovementGenerator.h" @@ -536,7 +535,7 @@ void MotionMaster::MoveFall(uint32 id /*=0*/, bool addFlagForNPC) { _owner->AddUnitMovementFlag(MOVEMENTFLAG_FALLING); _owner->m_movementInfo.SetFallTime(0); - _owner->ToPlayer()->SetFallInformation(GameTime::GetGameTime(), _owner->GetPositionZ()); + _owner->ToPlayer()->SetFallInformation(time(NULL), _owner->GetPositionZ()); } else if (_owner->GetTypeId() == TYPEID_UNIT && addFlagForNPC) // pussywizard { diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index 87c763430..2cd1496d3 100644 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -13,7 +13,6 @@ #include "MoveSplineInit.h" #include "MoveSpline.h" #include "Player.h" -#include "GameTime.h" #include "Spell.h" #include "BattlegroundRV.h" #include "VehicleDefines.h" @@ -67,7 +66,7 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T* owner, bool ini if (useMMaps && !inRange && (!isPlayerPet || i_target->GetPositionZ()-z > 50.0f)) { //useMMaps = false; - owner->m_targetsNotAcceptable[i_target->GetGUID()] = MMapTargetData(GameTime::GetGameTime()+DISALLOW_TIME_AFTER_FAIL, owner, i_target.getTarget()); + owner->m_targetsNotAcceptable[i_target->GetGUID()] = MMapTargetData(sWorld->GetGameTime()+DISALLOW_TIME_AFTER_FAIL, owner, i_target.getTarget()); return; } @@ -175,7 +174,7 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T* owner, bool ini } } - if (!forceDest && getMSTimeDiff(lastPathingFailMSTime, GameTime::GetGameTimeMS()) < 1000) + if (!forceDest && getMSTimeDiff(lastPathingFailMSTime, World::GetGameTimeMS()) < 1000) { lastOwnerXYZ.Relocate(-5000.0f, -5000.0f, -5000.0f); return; @@ -187,8 +186,8 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T* owner, bool ini float maxDist = MELEE_RANGE + owner->GetMeleeReach() + i_target->GetMeleeReach(); if (!forceDest && (i_path->GetPathType() & PATHFIND_NOPATH || (!i_offset && !isPlayerPet && i_target->GetExactDistSq(i_path->GetActualEndPosition().x, i_path->GetActualEndPosition().y, i_path->GetActualEndPosition().z) > maxDist*maxDist))) { - lastPathingFailMSTime = GameTime::GetGameTimeMS(); - owner->m_targetsNotAcceptable[i_target->GetGUID()] = MMapTargetData(GameTime::GetGameTime()+DISALLOW_TIME_AFTER_FAIL, owner, i_target.getTarget()); + lastPathingFailMSTime = World::GetGameTimeMS(); + owner->m_targetsNotAcceptable[i_target->GetGUID()] = MMapTargetData(sWorld->GetGameTime()+DISALLOW_TIME_AFTER_FAIL, owner, i_target.getTarget()); return; } else diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index b7243347e..4c76aa74e 100644 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -9,7 +9,6 @@ #include "ObjectMgr.h" #include "World.h" #include "Transport.h" -#include "GameTime.h" //Flightmaster grid preloading #include "MapManager.h" //Creature-specific headers @@ -318,7 +317,7 @@ void FlightPathMovementGenerator::DoFinalize(Player* player) // this prevent cheating with landing point at lags // when client side flight end early in comparison server side player->StopMoving(); - player->SetFallInformation(GameTime::GetGameTime(), player->GetPositionZ()); + player->SetFallInformation(time(NULL), player->GetPositionZ()); } player->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_TAXI_BENCHMARK); @@ -407,7 +406,7 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/) if (i_currentNode >= i_path.size() - 1) { player->CleanupAfterTaxiFlight(); - player->SetFallInformation(GameTime::GetGameTime(), player->GetPositionZ()); + player->SetFallInformation(time(NULL), player->GetPositionZ()); if (player->pvpInfo.IsHostile) player->CastSpell(player, 2479, true); diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 1d6477e56..4609933d5 100644 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -12,7 +12,6 @@ #include "MapManager.h" #include "MapRefManager.h" #include "ObjectMgr.h" -#include "GameTime.h" #include "Pet.h" #include "ScriptedCreature.h" #include "ScriptMgr.h" @@ -44,7 +43,7 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O sa.ownerGUID = ownerGUID; sa.script = &iter->second; - m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(GameTime::GetGameTime() + iter->first), sa)); + m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(sWorld->GetGameTime() + iter->first), sa)); if (iter->first == 0) immedScript = true; @@ -74,7 +73,7 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou sa.ownerGUID = ownerGUID; sa.script = &script; - m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(GameTime::GetGameTime() + delay), sa)); + m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(sWorld->GetGameTime() + delay), sa)); sScriptMgr->IncreaseScheduledScriptsCount(); @@ -281,7 +280,7 @@ void Map::ScriptsProcess() ///- Process overdue queued scripts ScriptScheduleMap::iterator iter = m_scriptSchedule.begin(); // ok as multimap is a *sorted* associative container - while (!m_scriptSchedule.empty() && (iter->first <= GameTime::GetGameTime())) + while (!m_scriptSchedule.empty() && (iter->first <= sWorld->GetGameTime())) { ScriptAction const& step = iter->second; diff --git a/src/server/game/Server/Protocol/PacketLog.cpp b/src/server/game/Server/Protocol/PacketLog.cpp index 4f05bff92..51df454d6 100644 --- a/src/server/game/Server/Protocol/PacketLog.cpp +++ b/src/server/game/Server/Protocol/PacketLog.cpp @@ -8,7 +8,6 @@ #include "Config.h" #include "ByteBuffer.h" #include "WorldPacket.h" -#include "GameTime.h" PacketLog::PacketLog() : _file(NULL) { @@ -41,7 +40,7 @@ void PacketLog::LogPacket(WorldPacket const& packet, Direction direction) ByteBuffer data(4+4+4+1+packet.size()); data << int32(packet.GetOpcode()); data << int32(packet.size()); - data << uint32(GameTime::GetGameTime()); + data << uint32(time(NULL)); data << uint8(direction); for (uint32 i = 0; i < packet.size(); i++) diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 21747f6dd..f209dc334 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -22,7 +22,6 @@ #include "GuildMgr.h" #include "Group.h" #include "Guild.h" -#include "GameTime.h" #include "World.h" #include "ObjectAccessor.h" #include "BattlegroundMgr.h" @@ -198,13 +197,13 @@ void WorldSession::SendPacket(WorldPacket const* packet) static uint64 sendPacketCount = 0; static uint64 sendPacketBytes = 0; - static time_t firstTime = GameTime::GetGameTime(); + static time_t firstTime = time(NULL); static time_t lastTime = firstTime; // next 60 secs start time static uint64 sendLastPacketCount = 0; static uint64 sendLastPacketBytes = 0; - time_t cur_time = GameTime::GetGameTime(); + time_t cur_time = time(NULL); if ((cur_time - lastTime) < 60) { @@ -390,7 +389,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) if (updater.ProcessLogout()) { - time_t currTime = GameTime::GetGameTime(); + time_t currTime = time(NULL); if (ShouldLogOut(currTime) && !m_playerLoading) LogoutPlayer(true); @@ -427,7 +426,7 @@ void WorldSession::HandleTeleportTimeout(bool updateInSessions) // pussywizard: handle teleport ack timeout if (m_Socket && !m_Socket->IsClosed() && GetPlayer() && GetPlayer()->IsBeingTeleported()) { - time_t currTime = GameTime::GetGameTime(); + time_t currTime = time(NULL); if (updateInSessions) // session update from World::UpdateSessions { if (GetPlayer()->IsBeingTeleportedFar() && GetPlayer()->GetSemaphoreTeleportFar()+sWorld->getIntConfig(CONFIG_TELEPORT_TIMEOUT_FAR) < currTime) @@ -770,7 +769,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 + 8 * 4); // changed in WotLK - data << uint32(GameTime::GetGameTime()); // unix time of something + data << uint32(time(NULL)); // unix time of something 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 0c3dc00ce..13a462375 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -25,7 +25,6 @@ #include "ByteBuffer.h" #include "Opcodes.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "BigNumber.h" #include "SHA1.h" #include "WorldSession.h" @@ -840,7 +839,7 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) //! Negative mutetime indicates amount of seconds to be muted effective on next login - which is now. if (mutetime < 0) { - mutetime = GameTime::GetGameTime() + llabs(mutetime); + mutetime = time(NULL) + llabs(mutetime); PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME_LOGIN); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 5898a0685..bc4fcbe4e 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -21,7 +21,6 @@ #include "Formulas.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "GameTime.h" #include "CellImpl.h" #include "ScriptMgr.h" #include "Vehicle.h" @@ -2844,7 +2843,7 @@ void AuraEffect::HandleAuraFeatherFall(AuraApplication const* aurApp, uint8 mode // start fall from current height if (!apply && target->GetTypeId() == TYPEID_PLAYER) - target->ToPlayer()->SetFallInformation(GameTime::GetGameTime(), target->GetPositionZ()); + target->ToPlayer()->SetFallInformation(time(NULL), target->GetPositionZ()); } void AuraEffect::HandleAuraHover(AuraApplication const* aurApp, uint8 mode, bool apply) const diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index b184669f1..a1a2281b1 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -19,7 +19,6 @@ #include "Util.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "GameTime.h" #include "CellImpl.h" #include "ScriptMgr.h" #include "SpellScript.h" @@ -396,7 +395,7 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne Aura::Aura(SpellInfo const* spellproto, WorldObject* owner, Unit* caster, Item* castItem, uint64 casterGUID) : m_spellInfo(spellproto), m_casterGuid(casterGUID ? casterGUID : caster->GetGUID()), -m_castItemGuid(castItem ? castItem->GetGUID() : 0),m_castItemEntry(castItem ? castItem->GetEntry() : 0), m_applyTime(GameTime::GetGameTime()), +m_castItemGuid(castItem ? castItem->GetGUID() : 0),m_castItemEntry(castItem ? castItem->GetEntry() : 0), m_applyTime(time(NULL)), 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) @@ -2016,7 +2015,7 @@ bool Aura::IsProcOnCooldown() const { /*if (m_procCooldown) { - if (m_procCooldown > GameTime::GetGameTime()) + if (m_procCooldown > time(NULL)) return true; }*/ return false; @@ -2024,7 +2023,7 @@ bool Aura::IsProcOnCooldown() const void Aura::AddProcCooldown(uint32 /*msec*/) { - //m_procCooldown = GameTime::GetGameTime() + msec; + //m_procCooldown = time(NULL) + msec; } void Aura::PrepareProcToTrigger(AuraApplication* aurApp, ProcEventInfo& eventInfo) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 9ade08991..cd286f3fb 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -23,7 +23,6 @@ #include "Spell.h" #include "DynamicObject.h" #include "Group.h" -#include "GameTime.h" #include "UpdateData.h" #include "MapManager.h" #include "ObjectAccessor.h" @@ -2577,7 +2576,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) // Xinef: absorb delayed projectiles for 500ms if (getState() == SPELL_STATE_DELAYED && !m_spellInfo->IsTargetingArea() && !m_spellInfo->IsPositive() && - (GameTime::GetGameTimeMS() - target->timeDelay) <= effectUnit->m_lastSanctuaryTime && GameTime::GetGameTimeMS() < (effectUnit->m_lastSanctuaryTime + 500) && + (World::GetGameTimeMS() - target->timeDelay) <= effectUnit->m_lastSanctuaryTime && World::GetGameTimeMS() < (effectUnit->m_lastSanctuaryTime + 500) && effectUnit->FindMap() && !effectUnit->FindMap()->IsDungeon() ) return; // No missinfo in that case @@ -4518,7 +4517,7 @@ void Spell::SendSpellGo() data << uint8(m_cast_count); // pending spell cast? data << uint32(m_spellInfo->Id); // spellId data << uint32(castFlags); // cast flags - data << uint32(GameTime::GetGameTimeMS()); // timestamp + data << uint32(World::GetGameTimeMS()); // timestamp WriteSpellGoTargets(&data); @@ -5001,7 +5000,7 @@ void Spell::TakePower() // Set the five second timer if (powerType == POWER_MANA && m_powerCost > 0) - m_caster->SetLastManaUse(GameTime::GetGameTimeMS()); + m_caster->SetLastManaUse(World::GetGameTimeMS()); } void Spell::TakeAmmo() @@ -6023,7 +6022,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_BAD_TARGETS; // Xinef: Implement summon pending error - if (target->GetSummonExpireTimer() > GameTime::GetGameTime()) + if (target->GetSummonExpireTimer() > time(NULL)) return SPELL_FAILED_SUMMON_PENDING; // check if our map is dungeon @@ -6063,7 +6062,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_BAD_TARGETS; // Xinef: Implement summon pending error - if (target->GetSummonExpireTimer() > GameTime::GetGameTime()) + if (target->GetSummonExpireTimer() > time(NULL)) return SPELL_FAILED_SUMMON_PENDING; break; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index c50a48cc2..371cfb987 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -21,7 +21,6 @@ #include "SpellAuras.h" #include "SpellAuraEffects.h" #include "Group.h" -#include "GameTime.h" #include "UpdateData.h" #include "MapManager.h" #include "ObjectAccessor.h" @@ -703,7 +702,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) case 17731: case 69294: { - if( !gameObjTarget || gameObjTarget->GetRespawnTime() > GameTime::GetGameTime() ) + if( !gameObjTarget || gameObjTarget->GetRespawnTime() > time(NULL) ) return; gameObjTarget->SetRespawnTime(10); @@ -4211,7 +4210,7 @@ void Spell::EffectSanctuary(SpellEffIndex /*effIndex*/) } // Xinef: Set last sanctuary time - unitTarget->m_lastSanctuaryTime = GameTime::GetGameTimeMS(); + unitTarget->m_lastSanctuaryTime = World::GetGameTimeMS(); // Vanish allows to remove all threat and cast regular stealth so other spells can be used if (m_caster->GetTypeId() == TYPEID_PLAYER @@ -4943,7 +4942,7 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/) // charge changes fall time if( m_caster->GetTypeId() == TYPEID_PLAYER ) - m_caster->ToPlayer()->SetFallInformation(GameTime::GetGameTime(), m_caster->GetPositionZ()); + m_caster->ToPlayer()->SetFallInformation(time(NULL), m_caster->GetPositionZ()); if (m_pathFinder) { @@ -5064,7 +5063,7 @@ void Spell::EffectLeapBack(SpellEffIndex effIndex) // xinef: changes fall time if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->SetFallInformation(GameTime::GetGameTime(), m_caster->GetPositionZ()); + m_caster->ToPlayer()->SetFallInformation(time(NULL), m_caster->GetPositionZ()); } void Spell::EffectQuestClear(SpellEffIndex effIndex) diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index 45393c772..233cc24ce 100644 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -7,7 +7,6 @@ #include "Common.h" #include "TicketMgr.h" #include "DatabaseEnv.h" -#include "GameTime.h" #include "Language.h" #include "Log.h" #include "WorldPacket.h" @@ -17,7 +16,7 @@ #include "Player.h" #include "Opcodes.h" -inline float GetAge(uint64 t) { return float(GameTime::GetGameTime() - t) / DAY; } +inline float GetAge(uint64 t) { return float(time(NULL) - t) / DAY; } /////////////////////////////////////////////////////////////////////////////////////////////////// // GM ticket @@ -25,7 +24,7 @@ GmTicket::GmTicket() : _id(0), _playerGuid(0), _type(TICKET_TYPE_OPEN), _posX(0) _closedBy(0), _resolvedBy(0), _assignedTo(0), _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needResponse(false), _needMoreHelp(false) { } -GmTicket::GmTicket(Player* player) : _type(TICKET_TYPE_OPEN), _createTime(GameTime::GetGameTime()), _lastModifiedTime(GameTime::GetGameTime()), _closedBy(0), _resolvedBy(0), _assignedTo(0), _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needMoreHelp(false) +GmTicket::GmTicket(Player* player) : _type(TICKET_TYPE_OPEN), _createTime(time(NULL)), _lastModifiedTime(time(NULL)), _closedBy(0), _resolvedBy(0), _assignedTo(0), _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), _needMoreHelp(false) { _id = sTicketMgr->GenerateTicketId(); _playerName = player->GetName(); @@ -148,7 +147,7 @@ void GmTicket::SendResponse(WorldSession* session) const std::string GmTicket::FormatMessageString(ChatHandler& handler, bool detailed) const { - time_t curTime = GameTime::GetGameTime(); + time_t curTime = time(NULL); std::stringstream ss; ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _id); @@ -187,12 +186,6 @@ std::string GmTicket::FormatMessageString(ChatHandler& handler, const char* szCl return ss.str(); } -void GmTicket::SetMessage(std::string const& message) -{ - _message = message; - _lastModifiedTime = uint64(GameTime::GetGameTime()); -} - void GmTicket::SetUnassigned() { _assignedTo = 0; @@ -242,7 +235,7 @@ void GmTicket::SetChatLog(std::list time, std::string const& log) /////////////////////////////////////////////////////////////////////////////////////////////////// // Ticket manager -TicketMgr::TicketMgr() : _status(true), _lastTicketId(0), _lastSurveyId(0), _openTicketCount(0), _lastChange(GameTime::GetGameTime()) { } +TicketMgr::TicketMgr() : _status(true), _lastTicketId(0), _lastSurveyId(0), _openTicketCount(0), _lastChange(time(NULL)) { } TicketMgr::~TicketMgr() { @@ -376,10 +369,6 @@ void TicketMgr::ResolveAndCloseTicket(uint32 ticketId, int64 source) } } -void TicketMgr::UpdateLastChange() -{ - _lastChange = uint64(GameTime::GetGameTime()); -} void TicketMgr::ShowList(ChatHandler& handler, bool onlineOnly) const { diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index ed6aba6ea..29537182d 100644 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -118,7 +118,11 @@ public: void SetClosedBy(int64 value) { _closedBy = value; _type = TICKET_TYPE_CLOSED; } void SetResolvedBy(int64 value) { _resolvedBy = value; } void SetCompleted() { _completed = true; } - void SetMessage(std::string const& message); + void SetMessage(std::string const& message) + { + _message = message; + _lastModifiedTime = uint64(time(NULL)); + } void SetComment(std::string const& comment) { _comment = comment; } void SetViewed() { _viewed = true; } void SetUnassigned(); @@ -215,7 +219,7 @@ public: void SetStatus(bool status) { _status = status; } uint64 GetLastChange() const { return _lastChange; } - void UpdateLastChange(); + void UpdateLastChange() { _lastChange = uint64(time(NULL)); } 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 deleted file mode 100644 index 6f24a356e..000000000 --- a/src/server/game/Time/GameTime.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2 - * Copyright (C) 2008-2016 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - */ - -#include "GameTime.h" -#include "Timer.h" - -namespace GameTime -{ - time_t const StartTime = time(nullptr); - - time_t GameTime = time(nullptr); - uint32 GameMSTime = 0; - - std::chrono::system_clock::time_point GameTimeSystemPoint = std::chrono::system_clock::time_point::min(); - std::chrono::steady_clock::time_point GameTimeSteadyPoint = std::chrono::steady_clock::time_point::min(); - - time_t GetStartTime() - { - return StartTime; - } - - time_t GetGameTime() - { - return GameTime; - } - - uint32 GetGameTimeMS() - { - return GameMSTime; - } - - std::chrono::system_clock::time_point GetGameTimeSystemPoint() - { - return GameTimeSystemPoint; - } - - std::chrono::steady_clock::time_point GetGameTimeSteadyPoint() - { - return GameTimeSteadyPoint; - } - - uint32 GetUptime() - { - return uint32(GameTime - StartTime); - } - - void UpdateGameTimers() - { - GameTime = time(nullptr); - GameMSTime = getMSTime(); - GameTimeSystemPoint = std::chrono::system_clock::now(); - GameTimeSteadyPoint = std::chrono::steady_clock::now(); - } -} \ No newline at end of file diff --git a/src/server/game/Time/GameTime.h b/src/server/game/Time/GameTime.h deleted file mode 100644 index 2a8995d70..000000000 --- a/src/server/game/Time/GameTime.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2 - * Copyright (C) 2008-2016 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - */ - -#ifndef __GAMETIME_H -#define __GAMETIME_H - -#include "Define.h" - -#include - -namespace GameTime -{ - // Server start time - time_t GetStartTime(); - - // Current server time (unix) in seconds - time_t GetGameTime(); - - // Milliseconds since server start - uint32 GetGameTimeMS(); - - /// Current chrono system_clock time point - std::chrono::system_clock::time_point GetGameTimeSystemPoint(); - - /// Current chrono steady_clock time point - std::chrono::steady_clock::time_point GetGameTimeSteadyPoint(); - - /// Uptime (in secs) - uint32 GetUptime(); - - void UpdateGameTimers(); -}; - -#endif \ No newline at end of file diff --git a/src/server/game/Time/UpdateTime.cpp b/src/server/game/Time/UpdateTime.cpp deleted file mode 100644 index 631ec234f..000000000 --- a/src/server/game/Time/UpdateTime.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2 - * Copyright (C) 2008-2016 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - */ - -#include "UpdateTime.h" -#include "Timer.h" -#include "Config.h" -#include "Log.h" - -// create instance -WorldUpdateTime sWorldUpdateTime; - -UpdateTime::UpdateTime() -{ - _averageUpdateTime = 0; - _totalUpdateTime = 0; - _updateTimeTableIndex = 0; - _maxUpdateTime = 0; - _maxUpdateTimeOfLastTable = 0; - _maxUpdateTimeOfCurrentTable = 0; - - _updateTimeDataTable = { }; -} - -uint32 UpdateTime::GetAverageUpdateTime() const -{ - return _averageUpdateTime; -} - -uint32 UpdateTime::GetTimeWeightedAverageUpdateTime() const -{ - uint32 sum = 0, weightsum = 0; - for (uint32 diff : _updateTimeDataTable) - { - sum += diff * diff; - weightsum += diff; - } - return sum / weightsum; -} - -uint32 UpdateTime::GetMaxUpdateTime() const -{ - return _maxUpdateTime; -} - -uint32 UpdateTime::GetMaxUpdateTimeOfCurrentTable() const -{ - return std::max(_maxUpdateTimeOfCurrentTable, _maxUpdateTimeOfLastTable); -} - -uint32 UpdateTime::GetLastUpdateTime() const -{ - return _updateTimeDataTable[_updateTimeTableIndex != 0 ? _updateTimeTableIndex - 1 : _updateTimeDataTable.size() - 1]; -} - -void UpdateTime::UpdateWithDiff(uint32 diff) -{ - _totalUpdateTime = _totalUpdateTime - _updateTimeDataTable[_updateTimeTableIndex] + diff; - _updateTimeDataTable[_updateTimeTableIndex] = diff; - - if (diff > _maxUpdateTime) - _maxUpdateTime = diff; - - if (diff > _maxUpdateTimeOfCurrentTable) - _maxUpdateTimeOfCurrentTable = diff; - - if (++_updateTimeTableIndex >= _updateTimeDataTable.size()) - { - _updateTimeTableIndex = 0; - _maxUpdateTimeOfLastTable = _maxUpdateTimeOfCurrentTable; - _maxUpdateTimeOfCurrentTable = 0; - } - - if (_updateTimeDataTable[_updateTimeDataTable.size() - 1]) - _averageUpdateTime = _totalUpdateTime / _updateTimeDataTable.size(); - else if (_updateTimeTableIndex) - _averageUpdateTime = _totalUpdateTime / _updateTimeTableIndex; -} - -void UpdateTime::RecordUpdateTimeReset() -{ - _recordedTime = getMSTime(); -} - -void UpdateTime::_RecordUpdateTimeDuration(std::string const& text, uint32 minUpdateTime) -{ - uint32 thisTime = getMSTime(); - uint32 diff = getMSTimeDiff(_recordedTime, thisTime); - - if (diff > minUpdateTime) - sLog->outError("Recored Update Time of %s: %u.", text.c_str(), diff); - - _recordedTime = thisTime; -} - -void WorldUpdateTime::LoadFromConfig() -{ - _recordUpdateTimeInverval = sConfigMgr->GetIntDefault("RecordUpdateTimeDiffInterval", 60000); - _recordUpdateTimeMin = sConfigMgr->GetIntDefault("MinRecordUpdateTimeDiff", 100); -} - -void WorldUpdateTime::SetRecordUpdateTimeInterval(uint32 t) -{ - _recordUpdateTimeInverval = t; -} - -void WorldUpdateTime::RecordUpdateTime(uint32 gameTimeMs, uint32 diff, uint32 sessionCount) -{ - if (_recordUpdateTimeInverval > 0 && diff > _recordUpdateTimeMin) - { - if (getMSTimeDiff(_lastRecordTime, gameTimeMs) > _recordUpdateTimeInverval) - { - sLog->outError("Update time diff: %u. Players online: %u.", GetAverageUpdateTime(), sessionCount); - _lastRecordTime = gameTimeMs; - } - } -} - -void WorldUpdateTime::RecordUpdateTimeDuration(std::string const& text) -{ - _RecordUpdateTimeDuration(text, _recordUpdateTimeMin); -} \ No newline at end of file diff --git a/src/server/game/Time/UpdateTime.h b/src/server/game/Time/UpdateTime.h deleted file mode 100644 index f2ebdb6e6..000000000 --- a/src/server/game/Time/UpdateTime.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2 - * Copyright (C) 2008-2016 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - */ - -#ifndef __UPDATETIME_H -#define __UPDATETIME_H - -#include - -#include "Define.h" - -#define AVG_DIFF_COUNT 500 - -class UpdateTime -{ - using DiffTableArray = std::array; - - public: - uint32 GetAverageUpdateTime() const; - uint32 GetTimeWeightedAverageUpdateTime() const; - uint32 GetMaxUpdateTime() const; - uint32 GetMaxUpdateTimeOfCurrentTable() const; - uint32 GetLastUpdateTime() const; - - void UpdateWithDiff(uint32 diff); - - void RecordUpdateTimeReset(); - - protected: - UpdateTime(); - - void _RecordUpdateTimeDuration(std::string const& text, uint32 minUpdateTime); - - private: - DiffTableArray _updateTimeDataTable; - uint32 _averageUpdateTime; - uint32 _totalUpdateTime; - uint32 _updateTimeTableIndex; - uint32 _maxUpdateTime; - uint32 _maxUpdateTimeOfLastTable; - uint32 _maxUpdateTimeOfCurrentTable; - - uint32 _recordedTime; -}; - -class WorldUpdateTime : public UpdateTime -{ - public: - WorldUpdateTime() : UpdateTime(), _recordUpdateTimeInverval(0), _recordUpdateTimeMin(0), _lastRecordTime(0) { } - void LoadFromConfig(); - void SetRecordUpdateTimeInterval(uint32 t); - void RecordUpdateTime(uint32 gameTimeMs, uint32 diff, uint32 sessionCount); - void RecordUpdateTimeDuration(std::string const& text); - - private: - uint32 _recordUpdateTimeInverval; - uint32 _recordUpdateTimeMin; - uint32 _lastRecordTime; -}; - -extern WorldUpdateTime sWorldUpdateTime; - -#endif \ No newline at end of file diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index 1d9ce00fb..84ca06f74 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -13,7 +13,6 @@ #include #include #include "World.h" -#include "GameTime.h" #include "Player.h" #include "Util.h" #include "Warden.h" @@ -89,7 +88,7 @@ void Warden::Update() { if (_initialized) { - uint32 currentTimestamp = GameTime::GetGameTimeMS(); + uint32 currentTimestamp = World::GetGameTimeMS(); uint32 diff = getMSTimeDiff(_previousTimestamp, currentTimestamp); _previousTimestamp = currentTimestamp; diff --git a/src/server/game/Warden/WardenMac.cpp b/src/server/game/Warden/WardenMac.cpp index c61b33c85..4684cd048 100644 --- a/src/server/game/Warden/WardenMac.cpp +++ b/src/server/game/Warden/WardenMac.cpp @@ -13,7 +13,6 @@ #include "ByteBuffer.h" #include #include "World.h" -#include "GameTime.h" #include "Player.h" #include "Util.h" #include "WardenMac.h" @@ -190,7 +189,7 @@ void WardenMac::HandleHashResult(ByteBuffer &buff) _initialized = true; - _previousTimestamp = GameTime::GetGameTimeMS(); + _previousTimestamp = World::GetGameTimeMS(); } void WardenMac::RequestData() diff --git a/src/server/game/Warden/WardenWin.cpp b/src/server/game/Warden/WardenWin.cpp index a6ed0562f..4bf09d262 100644 --- a/src/server/game/Warden/WardenWin.cpp +++ b/src/server/game/Warden/WardenWin.cpp @@ -15,7 +15,6 @@ #include #include "Database/DatabaseEnv.h" #include "World.h" -#include "GameTime.h" #include "Player.h" #include "Util.h" #include "WardenWin.h" @@ -184,7 +183,7 @@ void WardenWin::HandleHashResult(ByteBuffer &buff) _initialized = true; - _previousTimestamp = GameTime::GetGameTimeMS(); + _previousTimestamp = World::GetGameTimeMS(); } void WardenWin::RequestData() @@ -200,7 +199,7 @@ void WardenWin::RequestData() if (_otherChecksTodo.empty()) _otherChecksTodo.assign(sWardenCheckMgr->OtherChecksIdPool.begin(), sWardenCheckMgr->OtherChecksIdPool.end()); - _serverTicks = GameTime::GetGameTimeMS(); + _serverTicks = World::GetGameTimeMS(); uint16 id; uint8 type; @@ -388,7 +387,7 @@ void WardenWin::HandleData(ByteBuffer &buff) buff >> newClientTicks; #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) - uint32 ticksNow = GameTime::GetGameTimeMS(); + uint32 ticksNow = World::GetGameTimeMS(); uint32 ourTicks = newClientTicks + (ticksNow - _serverTicks); sLog->outDebug(LOG_FILTER_WARDEN, "ServerTicks %u", ticksNow); // Now diff --git a/src/server/game/Weather/Weather.cpp b/src/server/game/Weather/Weather.cpp index 98f121e5c..a989a1661 100644 --- a/src/server/game/Weather/Weather.cpp +++ b/src/server/game/Weather/Weather.cpp @@ -12,7 +12,6 @@ #include "WorldPacket.h" #include "Player.h" #include "World.h" -#include "GameTime.h" #include "Log.h" #include "ObjectMgr.h" #include "Util.h" @@ -83,7 +82,7 @@ bool Weather::ReGenerate() //78 days between January 1st and March 20nd; 365/4=91 days by season // season source http://aa.usno.navy.mil/data/docs/EarthSeasons.html - time_t gtime = GameTime::GetGameTime(); + time_t gtime = sWorld->GetGameTime(); struct tm ltime; ACE_OS::localtime_r(>ime, <ime); uint32 season = ((ltime.tm_yday - 78 + 365)/91)%4; diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 2f836f1ea..d1a82ee70 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -78,8 +78,6 @@ #include "ServerMotd.h" #include "GameGraveyard.h" #include -#include "GameTime.h" -#include "UpdateTime.h" #ifdef ELUNA #include "LuaEngine.h" #endif @@ -87,6 +85,7 @@ ACE_Atomic_Op World::m_stopEvent = false; uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; uint32 World::m_worldLoopCounter = 0; +uint32 World::m_gameMSTime = 0; float World::m_MaxVisibleDistanceOnContinents = DEFAULT_VISIBILITY_DISTANCE; float World::m_MaxVisibleDistanceInInstances = DEFAULT_VISIBILITY_INSTANCE; @@ -100,6 +99,9 @@ World::World() m_allowMovement = true; m_ShutdownMask = 0; m_ShutdownTimer = 0; + m_gameTime = time(NULL); + m_gameMSTime = getMSTime(); + m_startTime = m_gameTime; m_maxActiveSessionCount = 0; m_maxQueuedSessionCount = 0; m_PlayerCount = 0; @@ -113,6 +115,8 @@ World::World() m_defaultDbcLocale = LOCALE_enUS; mail_expire_check_timer = 0; + m_updateTime = 0; + m_updateTimeSum = 0; m_isClosed = false; @@ -257,7 +261,7 @@ void World::AddSession_(WorldSession* s) WorldSession* oldSession = old->second; if (!RemoveQueuedPlayer(oldSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) - m_disconnects[s->GetAccountId()] = GameTime::GetGameTime(); + m_disconnects[s->GetAccountId()] = time(NULL); // pussywizard: if (oldSession->HandleSocketClosed()) @@ -271,7 +275,7 @@ void World::AddSession_(WorldSession* s) tmp->SetShouldSetOfflineInDB(false); delete tmp; } - oldSession->SetOfflineTime(GameTime::GetGameTime()); + oldSession->SetOfflineTime(time(NULL)); m_offlineSessions[oldSession->GetAccountId()] = oldSession; } else @@ -313,7 +317,7 @@ bool World::HasRecentlyDisconnected(WorldSession* session) { for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end();) { - if ((GameTime::GetGameTime() - i->second) < tolerance) + if ((time(NULL) - i->second) < tolerance) { if (i->first == session->GetAccountId()) return true; @@ -459,9 +463,6 @@ void World::LoadConfigSettings(bool reload) // to change log confs at start sLog->ReloadConfig(); - // load update time related configs - sWorldUpdateTime.LoadFromConfig(); - ///- Read the player limit and the Message of the day from the config file if (!reload) SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100)); @@ -1230,6 +1231,8 @@ void World::LoadConfigSettings(bool reload) m_bool_configs[CONFIG_NO_RESET_TALENT_COST] = sConfigMgr->GetBoolDefault("NoResetTalentsCost", false); m_bool_configs[CONFIG_SHOW_KICK_IN_WORLD] = sConfigMgr->GetBoolDefault("ShowKickInWorld", false); + m_int_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfigMgr->GetIntDefault("RecordUpdateTimeDiffInterval", 60000); + m_int_configs[CONFIG_MIN_LOG_UPDATE] = sConfigMgr->GetIntDefault("MinRecordUpdateTimeDiff", 100); m_int_configs[CONFIG_NUMTHREADS] = sConfigMgr->GetIntDefault("MapUpdate.Threads", 1); m_int_configs[CONFIG_MAX_RESULTS_LOOKUP_COMMANDS] = sConfigMgr->GetIntDefault("Command.LookupMaxResults", 0); @@ -1314,7 +1317,7 @@ void World::SetInitialWorldSettings() uint32 startupBegin = getMSTime(); ///- Initialize the random number generator - srand((unsigned int)GameTime::GetGameTime()); + srand((unsigned int)time(NULL)); ///- Initialize detour memory management dtAllocSetCustom(dtCustomAlloc, dtCustomFree); @@ -1831,10 +1834,11 @@ void World::SetInitialWorldSettings() ///- Initialize game time and timers sLog->outString("Initialize game time and timers"); - GameTime::UpdateGameTimers(); + m_gameTime = time(NULL); + m_startTime = m_gameTime; LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES(%u, %u, 0, '%s')", - realmID, uint32(GameTime::GetStartTime()), GitRevision::GetFullVersion()); // One-time query + realmID, uint32(m_startTime), GitRevision::GetFullVersion()); // One-time query @@ -1855,7 +1859,7 @@ void World::SetInitialWorldSettings() // our speed up m_timers[WUPDATE_5_SECS].SetInterval(5*IN_MILLISECONDS); - mail_expire_check_timer = GameTime::GetGameTime() + 6*3600; + mail_expire_check_timer = time(NULL) + 6*3600; ///- Initilize static helper structures AIRegistry::Initialize(); @@ -2043,14 +2047,18 @@ void World::LoadAutobroadcasts() /// Update the World ! void World::Update(uint32 diff) { - ///- Update the game time and check for shutdown time - _UpdateGameTime(); - time_t currentGameTime = GameTime::GetGameTime(); + m_updateTime = diff; - sWorldUpdateTime.UpdateWithDiff(diff); + if (m_int_configs[CONFIG_INTERVAL_LOG_UPDATE]) + { + m_updateTimeSum += diff; + if (m_updateTimeSum > m_int_configs[CONFIG_INTERVAL_LOG_UPDATE]) + { + sLog->outBasic("Average update time diff: %u. Players online: %u.", avgDiffTracker.getAverage(), (uint32)GetActiveSessionCount()); + m_updateTimeSum = 0; + } + } - // Record update if recording set in log and diff is greater then minimum set in log - sWorldUpdateTime.RecordUpdateTime(GameTime::GetGameTimeMS(), diff, GetActiveSessionCount()); DynamicVisibilityMgr::Update(GetActiveSessionCount()); ///- Update the different timers @@ -2075,22 +2083,25 @@ void World::Update(uint32 diff) WhoListCacheMgr::Update(); } + ///- Update the game time and check for shutdown time + _UpdateGameTime(); + /// Handle daily quests reset time - if (currentGameTime > m_NextDailyQuestReset) + if (m_gameTime > m_NextDailyQuestReset) ResetDailyQuests(); /// Handle weekly quests reset time - if (currentGameTime > m_NextWeeklyQuestReset) + if (m_gameTime > m_NextWeeklyQuestReset) ResetWeeklyQuests(); /// Handle monthly quests reset time - if (currentGameTime > m_NextMonthlyQuestReset) + if (m_gameTime > m_NextMonthlyQuestReset) ResetMonthlyQuests(); - if (currentGameTime > m_NextRandomBGReset) + if (m_gameTime > m_NextRandomBGReset) ResetRandomBG(); - if (currentGameTime > m_NextGuildReset) + if (m_gameTime > m_NextGuildReset) ResetGuildCap(); // pussywizard: @@ -2111,15 +2122,13 @@ void World::Update(uint32 diff) AsyncAuctionListingMgr::Update(diff); - if (currentGameTime > mail_expire_check_timer) + if (m_gameTime > mail_expire_check_timer) { sObjectMgr->ReturnOrDeleteOldMails(true); - mail_expire_check_timer = currentGameTime + 6*3600; + mail_expire_check_timer = m_gameTime + 6*3600; } - sWorldUpdateTime.RecordUpdateTimeReset(); UpdateSessions(diff); - sWorldUpdateTime.RecordUpdateTimeDuration("UpdateSessions"); } // end of section with mutex AsyncAuctionListingMgr::SetAuctionListingAllowed(true); @@ -2147,12 +2156,9 @@ void World::Update(uint32 diff) } } - sWorldUpdateTime.RecordUpdateTimeReset(); sLFGMgr->Update(diff, 0); // pussywizard: remove obsolete stuff before finding compatibility during map update - sWorldUpdateTime.RecordUpdateTimeDuration("UpdateLFGMgr"); sMapMgr->Update(diff); - sWorldUpdateTime.RecordUpdateTimeDuration("UpdateMapMgr"); if (sWorld->getBoolConfig(CONFIG_AUTOBROADCAST)) { @@ -2164,25 +2170,20 @@ void World::Update(uint32 diff) } sBattlegroundMgr->Update(diff); - sWorldUpdateTime.RecordUpdateTimeDuration("UpdateBattlegroundMgr"); sOutdoorPvPMgr->Update(diff); - sWorldUpdateTime.RecordUpdateTimeDuration("UpdateOutdoorPvPMgr"); sBattlefieldMgr->Update(diff); - sWorldUpdateTime.RecordUpdateTimeDuration("BattlefieldMgr"); sLFGMgr->Update(diff, 2); // pussywizard: handle created proposals - sWorldUpdateTime.RecordUpdateTimeDuration("UpdateLFGMgr2"); // execute callbacks from sql queries that were queued recently ProcessQueryCallbacks(); - sWorldUpdateTime.RecordUpdateTimeDuration("ProcessQueryCallbacks"); ///
  • Update uptime table if (m_timers[WUPDATE_UPTIME].Passed()) { - uint32 tmpDiff = GameTime::GetUptime(); + uint32 tmpDiff = uint32(m_gameTime - m_startTime); uint32 maxOnlinePlayers = GetMaxPlayerCount(); m_timers[WUPDATE_UPTIME].Reset(); @@ -2192,7 +2193,7 @@ void World::Update(uint32 diff) stmt->setUInt32(0, tmpDiff); stmt->setUInt16(1, uint16(maxOnlinePlayers)); stmt->setUInt32(2, realmID); - stmt->setUInt32(3, uint32(GameTime::GetStartTime())); + stmt->setUInt32(3, uint32(m_startTime)); LoginDatabase.Execute(stmt); } @@ -2496,7 +2497,7 @@ BanReturn World::BanAccount(BanMode mode, std::string const& nameOrIP, std::stri PreparedStatement* stmtx = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED); stmtx->setUInt32(0, account); PreparedQueryResult banresultx = LoginDatabase.Query(stmtx); - if (banresultx && ((*banresultx)[0].GetUInt32() == (*banresultx)[1].GetUInt32() || ((*banresultx)[1].GetUInt32() > GameTime::GetGameTime()+duration_secs && duration_secs))) + if (banresultx && ((*banresultx)[0].GetUInt32() == (*banresultx)[1].GetUInt32() || ((*banresultx)[1].GetUInt32() > time(NULL)+duration_secs && duration_secs))) return BAN_LONGER_EXISTS; // make sure there is only one active ban @@ -2615,10 +2616,10 @@ bool World::RemoveBanCharacter(std::string const& name) void World::_UpdateGameTime() { ///- update the time - time_t lastGameTime = GameTime::GetGameTime(); - GameTime::UpdateGameTimers(); - - uint32 elapsed = uint32(GameTime::GetGameTime() - lastGameTime); + time_t thisTime = time(NULL); + uint32 elapsed = uint32(thisTime - m_gameTime); + m_gameTime = thisTime; + m_gameMSTime = getMSTime(); ///- if there is a shutdown timer if (!IsStopped() && m_ShutdownTimer > 0 && elapsed > 0) @@ -2751,7 +2752,7 @@ void World::UpdateSessions(uint32 diff) if (pSession->HandleSocketClosed()) { if (!RemoveQueuedPlayer(pSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) - m_disconnects[pSession->GetAccountId()] = GameTime::GetGameTime(); + m_disconnects[pSession->GetAccountId()] = time(NULL); m_sessions.erase(itr); // there should be no offline session if current one is logged onto a character SessionMap::iterator iter; @@ -2762,7 +2763,7 @@ void World::UpdateSessions(uint32 diff) tmp->SetShouldSetOfflineInDB(false); delete tmp; } - pSession->SetOfflineTime(GameTime::GetGameTime()); + pSession->SetOfflineTime(time(NULL)); m_offlineSessions[pSession->GetAccountId()] = pSession; continue; } @@ -2770,7 +2771,7 @@ void World::UpdateSessions(uint32 diff) if (!pSession->Update(diff, updater)) { if (!RemoveQueuedPlayer(pSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) - m_disconnects[pSession->GetAccountId()] = GameTime::GetGameTime(); + m_disconnects[pSession->GetAccountId()] = time(NULL); m_sessions.erase(itr); if (m_offlineSessions.find(pSession->GetAccountId()) != m_offlineSessions.end()) // pussywizard: don't set offline in db because offline session for that acc is present (character is in world) pSession->SetShouldSetOfflineInDB(false); @@ -2781,7 +2782,7 @@ void World::UpdateSessions(uint32 diff) // pussywizard: if (m_offlineSessions.empty()) return; - uint32 currTime = GameTime::GetGameTime(); + uint32 currTime = time(NULL); for (SessionMap::iterator itr = m_offlineSessions.begin(), next; itr != m_offlineSessions.end(); itr = next) { next = itr; @@ -2919,7 +2920,7 @@ time_t World::GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour) { if (hour < 0 || hour > 23) hour = 0; - time_t curr = GameTime::GetGameTime(); + time_t curr = time(NULL); tm localTm; ACE_OS::localtime_r(&curr, &localTm); localTm.tm_hour = hour; @@ -2940,7 +2941,7 @@ time_t World::GetNextTimeWithMonthAndHour(int8 month, int8 hour) { if (hour < 0 || hour > 23) hour = 0; - time_t curr = GameTime::GetGameTime(); + time_t curr = time(NULL); tm localTm; ACE_OS::localtime_r(&curr, &localTm); localTm.tm_mday = 1; diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index ad5129d87..a6d37e25f 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -292,6 +292,8 @@ enum WorldIntConfigs CONFIG_PVP_TOKEN_MAP_TYPE, CONFIG_PVP_TOKEN_ID, CONFIG_PVP_TOKEN_COUNT, + CONFIG_INTERVAL_LOG_UPDATE, + CONFIG_MIN_LOG_UPDATE, CONFIG_ENABLE_SINFO_LOGIN, CONFIG_PLAYER_ALLOW_COMMANDS, CONFIG_NUMTHREADS, @@ -618,6 +620,18 @@ class World /// Get the path where data (dbc, maps) are stored on disk std::string const& GetDataPath() const { return m_dataPath; } + /// When server started? + time_t const& GetStartTime() const { return m_startTime; } + /// What time is it? + time_t const& GetGameTime() const { return m_gameTime; } + /// What time is it? in ms + static uint32 GetGameTimeMS() { return m_gameMSTime; } + /// Uptime (in secs) + uint32 GetUptime() const { return uint32(m_gameTime - m_startTime); } + /// Update time + uint32 GetUpdateTime() const { return m_updateTime; } + void SetRecordDiffInterval(int32 t) { if (t >= 0) m_int_configs[CONFIG_INTERVAL_LOG_UPDATE] = (uint32)t; } + /// Next daily quests and random bg reset time time_t GetNextDailyQuestsResetTime() const { return m_NextDailyQuestReset; } time_t GetNextWeeklyQuestsResetTime() const { return m_NextWeeklyQuestReset; } @@ -798,8 +812,12 @@ class World bool m_isClosed; + time_t m_startTime; + time_t m_gameTime; IntervalTimer m_timers[WUPDATE_COUNT]; time_t mail_expire_check_timer; + uint32 m_updateTime, m_updateTimeSum; + static uint32 m_gameMSTime; SessionMap m_sessions; SessionMap m_offlineSessions; diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index 78796a7c0..9748bab2b 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -168,7 +168,6 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/Spells/Auras ${CMAKE_SOURCE_DIR}/src/server/game/Texts ${CMAKE_SOURCE_DIR}/src/server/game/Tickets - ${CMAKE_SOURCE_DIR}/src/server/game/Time ${CMAKE_SOURCE_DIR}/src/server/game/Tools ${CMAKE_SOURCE_DIR}/src/server/game/Warden ${CMAKE_SOURCE_DIR}/src/server/game/Warden/Modules diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index b0644b57e..585e58ae6 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -17,7 +17,6 @@ EndScriptData */ #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" -#include "GameTime.h" #include "ScriptMgr.h" class ban_commandscript : public CommandScript @@ -246,7 +245,7 @@ public: time_t unbanDate = time_t(fields[3].GetUInt32()); bool active = false; - if (fields[2].GetBool() && (fields[1].GetUInt64() == uint64(0) || unbanDate >= GameTime::GetGameTime())) + if (fields[2].GetBool() && (fields[1].GetUInt64() == uint64(0) || unbanDate >= time(nullptr))) active = true; bool permanent = (fields[1].GetUInt64() == uint64(0)); std::string banTime = permanent ? handler->GetTrinityString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt64(), true); @@ -294,7 +293,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 >= GameTime::GetGameTime())) + if (fields[2].GetUInt8() && (!fields[1].GetUInt32() || unbanDate >= time(nullptr))) active = true; bool permanent = (fields[1].GetUInt32() == uint32(0)); std::string banTime = permanent ? handler->GetTrinityString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt64(), true); diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index acff1b1d4..d80d3b878 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -15,7 +15,6 @@ EndScriptData */ #include "GameEventMgr.h" #include "Language.h" #include "Player.h" -#include "GameTime.h" #include "ScriptMgr.h" class event_commandscript : public CommandScript @@ -105,8 +104,8 @@ public: std::string endTimeStr = TimeToTimestampStr(eventData.end); uint32 delay = sGameEventMgr->NextCheck(eventId); - time_t nextTime = GameTime::GetGameTime() + delay; - std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(GameTime::GetGameTime() + delay) : "-"; + time_t nextTime = time(nullptr) + delay; + std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(nullptr) + delay) : "-"; std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE, true); std::string lengthStr = secsToTimeString(eventData.length * MINUTE, true); diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index c6e7db2af..85a91794d 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -19,7 +19,6 @@ EndScriptData */ #include "Chat.h" #include "Language.h" #include "Player.h" -#include "GameTime.h" #include "Opcodes.h" #include "Transport.h" #include "GameObject.h" @@ -311,7 +310,7 @@ public: if (target) { - int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - GameTime::GetGameTime()); + int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - time(nullptr)); if (curRespawnDelay < 0) curRespawnDelay = 0; diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp index aa20c177e..f5fddb549 100644 --- a/src/server/scripts/Commands/cs_instance.cpp +++ b/src/server/scripts/Commands/cs_instance.cpp @@ -18,7 +18,6 @@ EndScriptData */ #include "InstanceScript.h" #include "MapManager.h" #include "Player.h" -#include "GameTime.h" #include "Language.h" class instance_commandscript : public CommandScript @@ -72,7 +71,7 @@ public: { InstanceSave* save = itr->second.save; uint32 resetTime = itr->second.extended ? save->GetExtendedResetTime() : save->GetResetTime(); - uint32 ttr = (resetTime >= GameTime::GetGameTime() ? resetTime - GameTime::GetGameTime() : 0); + uint32 ttr = (resetTime >= time(nullptr) ? resetTime - time(nullptr) : 0); std::string timeleft = GetTimeString(ttr); handler->PSendSysMessage("map: %d, inst: %d, perm: %s, diff: %d, canReset: %s, TTR: %s%s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str(), (itr->second.extended ? " (extended)" : "")); counter++; @@ -116,7 +115,7 @@ public: if (itr->first != player->GetMapId() && (!MapId || MapId == itr->first) && (diff == -1 || diff == save->GetDifficulty())) { uint32 resetTime = itr->second.extended ? save->GetExtendedResetTime() : save->GetResetTime(); - uint32 ttr = (resetTime >= GameTime::GetGameTime() ? resetTime - GameTime::GetGameTime() : 0); + uint32 ttr = (resetTime >= time(nullptr) ? resetTime - time(nullptr) : 0); std::string timeleft = GetTimeString(ttr); handler->PSendSysMessage("unbinding map: %d, inst: %d, perm: %s, diff: %d, canReset: %s, TTR: %s%s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str(), (itr->second.extended ? " (extended)" : "")); sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUIDLow(), itr->first, Difficulty(i), true, player); diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 8d0dc8615..6fb08f45a 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -22,7 +22,6 @@ #include "WeatherMgr.h" #include "ace/INET_Addr.h" #include "Player.h" -#include "GameTime.h" #include "Pet.h" #include "LFG.h" #include "GroupMgr.h" @@ -1998,11 +1997,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 - GameTime::GetGameTime(), 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 - time(nullptr), 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 - GameTime::GetGameTime(), true).c_str(), muteBy.c_str()); + handler->PSendSysMessage(LANG_PINFO_MUTED, muteReason.c_str(), secsToTimeString(muteTime - time(nullptr), true).c_str(), muteBy.c_str()); // Output V. LANG_PINFO_ACC_ACCOUNT handler->PSendSysMessage(LANG_PINFO_ACC_ACCOUNT, userName.c_str(), accId, security); @@ -2241,7 +2240,7 @@ public: if (target) { // Target is online, mute will be in effect right away. - int64 muteTime = GameTime::GetGameTime() + notSpeakTime * MINUTE; + int64 muteTime = time(nullptr) + notSpeakTime * MINUTE; target->GetSession()->m_muteTime = muteTime; stmt->setInt64(0, muteTime); ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str()); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index c3a00cd8c..49b3db28a 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -20,7 +20,6 @@ EndScriptData */ #include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand #include "CreatureAI.h" #include "Player.h" -#include "GameTime.h" #include "Pet.h" struct NpcFlagText @@ -720,7 +719,7 @@ public: uint32 nativeid = target->GetNativeDisplayId(); uint32 Entry = target->GetEntry(); - int64 curRespawnDelay = target->GetRespawnTimeEx()-GameTime::GetGameTime(); + int64 curRespawnDelay = target->GetRespawnTimeEx()-time(nullptr); if (curRespawnDelay < 0) curRespawnDelay = 0; std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true); diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 0869e7171..7796c7a68 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -15,8 +15,6 @@ EndScriptData */ #include "Config.h" #include "Language.h" #include "ObjectAccessor.h" -#include "GameTime.h" -#include "UpdateTime.h" #include "Player.h" #include "ScriptMgr.h" #include "GitRevision.h" @@ -98,8 +96,8 @@ public: uint32 activeSessionCount = sWorld->GetActiveSessionCount(); uint32 queuedSessionCount = sWorld->GetQueuedSessionCount(); uint32 connPeak = sWorld->GetMaxActiveSessionCount(); - std::string uptime = secsToTimeString(GameTime::GetUptime()); - uint32 updateTime = sWorldUpdateTime.GetLastUpdateTime(); + std::string uptime = secsToTimeString(sWorld->GetUptime()).append("."); + uint32 updateTime = sWorld->GetUpdateTime(); uint32 avgUpdateTime = avgDiffTracker.getAverage(); handler->PSendSysMessage("%s", GitRevision::GetFullVersion()); @@ -357,7 +355,7 @@ public: if (newTime < 0) return false; - sWorldUpdateTime.SetRecordUpdateTimeInterval(newTime); + sWorld->SetRecordDiffInterval(newTime); printf("Record diff every %u ms\n", newTime); return true; diff --git a/src/server/scripts/Events/brewfest.cpp b/src/server/scripts/Events/brewfest.cpp index 8fbf1ad04..1ac19d4f2 100644 --- a/src/server/scripts/Events/brewfest.cpp +++ b/src/server/scripts/Events/brewfest.cpp @@ -9,7 +9,6 @@ #include "SpellScript.h" #include "GameEventMgr.h" #include "Group.h" -#include "GameTime.h" #include "LFGMgr.h" #include "PassiveAI.h" #include "CellImpl.h" @@ -436,7 +435,7 @@ class npc_brewfest_keg_reciver : public CreatureScript { if (Aura* aur = player->GetAura(SPELL_RAM_AURA)) { - int32 diff = aur->GetApplyTime() - (GameTime::GetGameTime()-(HOUR*18)+spellCooldown); + int32 diff = aur->GetApplyTime() - (time(NULL)-(HOUR*18)+spellCooldown); if (diff > 10) // aura applied later return; @@ -844,7 +843,7 @@ class npc_dark_iron_attack_generator : public CreatureScript bool AllowStart() { - time_t curtime = GameTime::GetGameTime(); + time_t curtime = time(NULL); tm strDate; ACE_OS::localtime_r(&curtime, &strDate); diff --git a/src/server/scripts/Events/midsummer.cpp b/src/server/scripts/Events/midsummer.cpp index 1d5b94081..6f7fcec5d 100644 --- a/src/server/scripts/Events/midsummer.cpp +++ b/src/server/scripts/Events/midsummer.cpp @@ -1,7 +1,6 @@ // Scripted by Xinef #include "ScriptMgr.h" -#include "GameTime.h" #include "ScriptedCreature.h" #include "ScriptedGossip.h" #include "Spell.h" @@ -185,7 +184,7 @@ class npc_midsummer_torch_target : public CreatureScript Position pos; pos.Relocate(posVec.at(num)); me->m_last_notify_position.Relocate(0.0f, 0.0f, 0.0f); - me->m_last_notify_mstime = GameTime::GetGameTimeMS() + 10000; + me->m_last_notify_mstime = World::GetGameTimeMS() + 10000; me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); } @@ -301,7 +300,7 @@ public: } // Achievement - if ((GameTime::GetGameTime() - GetApplyTime()) > 60 && target->GetTypeId() == TYPEID_PLAYER) + if ((time(NULL) - GetApplyTime()) > 60 && target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 58934, 0, target); } } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp index 549ef86bc..beb13db48 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/instance_trial_of_the_crusader.cpp @@ -6,7 +6,6 @@ #include "ScriptedCreature.h" #include "trial_of_the_crusader.h" #include "Group.h" -#include "GameTime.h" #include "Player.h" #define CLEANUP_CHECK_INTERVAL 5000 @@ -323,7 +322,7 @@ public: c->DespawnOrUnsummon(10000); if( Creature* c = instance->GetCreature(NPC_DreadscaleGUID) ) c->DespawnOrUnsummon(10000); - if( AchievementTimer+10 >= GameTime::GetGameTime() ) + if( AchievementTimer+10 >= time(NULL) ) DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_JORMUNGAR_ACHIEV); AchievementTimer = 0; @@ -340,7 +339,7 @@ public: } else // first one died, start timer for achievement { - AchievementTimer = GameTime::GetGameTime(); + AchievementTimer = time(NULL); } } else @@ -429,14 +428,14 @@ public: HandleGameObject(GO_EnterGateGUID, true); - if( AchievementTimer+60 >= GameTime::GetGameTime() ) + if( AchievementTimer+60 >= time(NULL) ) DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_RESILIENCE_WILL_FIX_IT_CREDIT); AchievementTimer = 0; SaveToDB(); } else if( Counter == 1 ) - AchievementTimer = GameTime::GetGameTime(); + AchievementTimer = time(NULL); } break; case TYPE_FACTION_CHAMPIONS_START: diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp index 574f18569..0b0d02dc2 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp @@ -7,7 +7,6 @@ #include "ScriptedGossip.h" #include "trial_of_the_crusader.h" #include "Player.h" -#include "GameTime.h" enum MenuTexts { 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 7aaa56607..8f68fe45d 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -11,7 +11,6 @@ #include "TransportMgr.h" #include "Vehicle.h" #include "icecrown_citadel.h" -#include "GameTime.h" enum Texts { @@ -407,7 +406,7 @@ public: return false; bool summoned = false; - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); for (int32 i = first; i <= last; ++i) { if (_respawnCooldowns[i] > now) @@ -443,7 +442,7 @@ public: void ClearSlot(PassengerSlots slot) { _controlledSlots[slot] = 0; - _respawnCooldowns[slot] = GameTime::GetGameTime() + _slotInfo[slot].Cooldown; + _respawnCooldowns[slot] = time(NULL) + _slotInfo[slot].Cooldown; } private: @@ -732,7 +731,7 @@ class npc_high_overlord_saurfang_igb : public CreatureScript _controller.ResetSlots(TEAM_HORDE, creature->GetTransport()->ToMotionTransport()); me->SetRegeneratingHealth(false); me->m_CombatDistance = 70.0f; - _firstMageCooldown = GameTime::GetGameTime() + 45; + _firstMageCooldown = time(NULL) + 45; _axethrowersYellCooldown = time_t(0); _rocketeersYellCooldown = time_t(0); checkTimer = 1000; @@ -797,7 +796,7 @@ class npc_high_overlord_saurfang_igb : public CreatureScript } else if (action == ACTION_SPAWN_MAGE) { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (_firstMageCooldown > now) _events.ScheduleEvent(EVENT_SUMMON_MAGE, (_firstMageCooldown - now) * IN_MILLISECONDS); else @@ -972,10 +971,10 @@ class npc_high_overlord_saurfang_igb : public CreatureScript case EVENT_CHECK_RIFLEMAN: if (_controller.SummonCreatures(me, SLOT_RIFLEMAN_1, Is25ManRaid() ? SLOT_RIFLEMAN_8 : SLOT_RIFLEMAN_4)) { - if (_axethrowersYellCooldown < GameTime::GetGameTime()) + if (_axethrowersYellCooldown < time(NULL)) { Talk(SAY_SAURFANG_AXETHROWERS); - _axethrowersYellCooldown = GameTime::GetGameTime() + 5; + _axethrowersYellCooldown = time(NULL) + 5; } } _events.ScheduleEvent(EVENT_CHECK_RIFLEMAN, 1500); @@ -983,10 +982,10 @@ class npc_high_overlord_saurfang_igb : public CreatureScript case EVENT_CHECK_MORTAR: if (_controller.SummonCreatures(me, SLOT_MORTAR_1, Is25ManRaid() ? SLOT_MORTAR_4 : SLOT_MORTAR_2)) { - if (_rocketeersYellCooldown < GameTime::GetGameTime()) + if (_rocketeersYellCooldown < time(NULL)) { Talk(SAY_SAURFANG_ROCKETEERS); - _rocketeersYellCooldown = GameTime::GetGameTime() + 5; + _rocketeersYellCooldown = time(NULL) + 5; } } _events.ScheduleEvent(EVENT_CHECK_MORTAR, 1500); @@ -1067,7 +1066,7 @@ class npc_muradin_bronzebeard_igb : public CreatureScript _controller.ResetSlots(TEAM_ALLIANCE, creature->GetTransport()->ToMotionTransport()); me->SetRegeneratingHealth(false); me->m_CombatDistance = 70.0f; - _firstMageCooldown = GameTime::GetGameTime() + 45; + _firstMageCooldown = time(NULL) + 45; _riflemanYellCooldown = time_t(0); _mortarYellCooldown = time_t(0); checkTimer = 1000; @@ -1133,7 +1132,7 @@ class npc_muradin_bronzebeard_igb : public CreatureScript } else if (action == ACTION_SPAWN_MAGE) { - time_t now = GameTime::GetGameTime(); + time_t now = time(NULL); if (_firstMageCooldown > now) _events.ScheduleEvent(EVENT_SUMMON_MAGE, (_firstMageCooldown - now) * IN_MILLISECONDS); else @@ -1311,10 +1310,10 @@ class npc_muradin_bronzebeard_igb : public CreatureScript case EVENT_CHECK_RIFLEMAN: if (_controller.SummonCreatures(me, SLOT_RIFLEMAN_1, Is25ManRaid() ? SLOT_RIFLEMAN_8 : SLOT_RIFLEMAN_4)) { - if (_riflemanYellCooldown < GameTime::GetGameTime()) + if (_riflemanYellCooldown < time(NULL)) { Talk(SAY_MURADIN_RIFLEMAN); - _riflemanYellCooldown = GameTime::GetGameTime() + 5; + _riflemanYellCooldown = time(NULL) + 5; } } _events.ScheduleEvent(EVENT_CHECK_RIFLEMAN, 1500); @@ -1322,10 +1321,10 @@ class npc_muradin_bronzebeard_igb : public CreatureScript case EVENT_CHECK_MORTAR: if (_controller.SummonCreatures(me, SLOT_MORTAR_1, Is25ManRaid() ? SLOT_MORTAR_4 : SLOT_MORTAR_2)) { - if (_mortarYellCooldown < GameTime::GetGameTime()) + if (_mortarYellCooldown < time(NULL)) { Talk(SAY_MURADIN_MORTAR); - _mortarYellCooldown = GameTime::GetGameTime() + 5; + _mortarYellCooldown = time(NULL) + 5; } } _events.ScheduleEvent(EVENT_CHECK_MORTAR, 1500); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 888aa5d95..1e9c426e0 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -5,7 +5,6 @@ #include "ObjectMgr.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" -#include "GameTime.h" #include "GridNotifiers.h" #include "icecrown_citadel.h" #include "Player.h" @@ -949,7 +948,7 @@ class spell_sindragosa_unchained_magic : public SpellScriptLoader if (!spellInfo) return false; - uint32 currMSTime = GameTime::GetGameTimeMS(); + uint32 currMSTime = World::GetGameTimeMS(); std::map::iterator itr = _lastMSTimeForSpell.find(spellInfo->Id); if (itr != _lastMSTimeForSpell.end()) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index ef64ec8f2..27cbb5a54 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -8,7 +8,6 @@ #include "SpellScript.h" #include "SpellAuraEffects.h" #include "Spell.h" -#include "GameTime.h" #include "Vehicle.h" #include "Unit.h" #include "Cell.h" @@ -687,9 +686,9 @@ class boss_the_lich_king : public CreatureScript void KilledUnit(Unit* victim) { - if (victim->GetTypeId() == TYPEID_PLAYER && !me->IsInEvadeMode() && _phase != PHASE_OUTRO && _lastTalkTimeKill+5 < GameTime::GetGameTime()) + if (victim->GetTypeId() == TYPEID_PLAYER && !me->IsInEvadeMode() && _phase != PHASE_OUTRO && _lastTalkTimeKill+5 < time(NULL)) { - _lastTalkTimeKill = GameTime::GetGameTime(); + _lastTalkTimeKill = time(NULL); Talk(SAY_LK_KILL); } } @@ -718,7 +717,7 @@ class boss_the_lich_king : public CreatureScript events.RescheduleEvent(EVENT_START_ATTACK, 1000); EntryCheckPredicate pred(NPC_STRANGULATE_VEHICLE); summons.DoAction(ACTION_TELEPORT_BACK, pred); - if (!IsHeroic() && _phase != PHASE_OUTRO && me->IsInCombat() && _lastTalkTimeBuff+5 <= GameTime::GetGameTime()) + if (!IsHeroic() && _phase != PHASE_OUTRO && me->IsInCombat() && _lastTalkTimeBuff+5 <= time(NULL)) Talk(SAY_LK_FROSTMOURNE_ESCAPE); } break; @@ -875,9 +874,9 @@ class boss_the_lich_king : public CreatureScript void SpellHit(Unit* /*caster*/, SpellInfo const* spell) { - if (spell->Id == HARVESTED_SOUL_BUFF && me->IsInCombat() && !IsHeroic() && _phase != PHASE_OUTRO && _lastTalkTimeBuff+5 <= GameTime::GetGameTime()) + if (spell->Id == HARVESTED_SOUL_BUFF && me->IsInCombat() && !IsHeroic() && _phase != PHASE_OUTRO && _lastTalkTimeBuff+5 <= time(NULL)) { - _lastTalkTimeBuff = GameTime::GetGameTime(); + _lastTalkTimeBuff = time(NULL); Talk(SAY_LK_FROSTMOURNE_KILL); } } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp index f305c1e85..739236580 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp @@ -5,7 +5,6 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" -#include "GameTime.h" #include "ulduar.h" #include "Vehicle.h" #include "SpellAuras.h" @@ -262,10 +261,10 @@ public: if (id == 1337) { if (lastShatterMSTime) - if (getMSTimeDiff(lastShatterMSTime, GameTime::GetGameTimeMS()) <= 5000) + if (getMSTimeDiff(lastShatterMSTime, World::GetGameTimeMS()) <= 5000) bShattered = true; - lastShatterMSTime = GameTime::GetGameTimeMS(); + lastShatterMSTime = World::GetGameTimeMS(); } } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index a0043221f..6ee534bd0 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -5,7 +5,6 @@ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SpellScript.h" -#include "GameTime.h" #include "ulduar.h" #include "Vehicle.h" #include "Spell.h" @@ -453,7 +452,7 @@ public: case EVENT_SPAWN_FLAMES_INITIAL: { if (changeAllowedFlameSpreadTime) - allowedFlameSpreadTime = GameTime::GetGameTime(); + allowedFlameSpreadTime = time(NULL); std::vector pg; Map::PlayerList const &pl = me->GetMap()->GetPlayers(); @@ -2237,7 +2236,7 @@ public: bool Load() { - lastMSTime = GameTime::GetGameTimeMS(); + lastMSTime = World::GetGameTimeMS(); lastOrientation = -1.0f; return true; } @@ -2248,14 +2247,14 @@ public: { if (c->GetTypeId() != TYPEID_UNIT) return; - uint32 diff = getMSTimeDiff(lastMSTime, GameTime::GetGameTimeMS()); + uint32 diff = getMSTimeDiff(lastMSTime, World::GetGameTimeMS()); if (lastOrientation == -1.0f) { lastOrientation = (c->ToCreature()->AI()->GetData(0)*2*M_PI)/100.0f; diff = 0; } float new_o = Position::NormalizeOrientation(lastOrientation-(M_PI/60)*(diff/250.0f)); - lastMSTime = GameTime::GetGameTimeMS(); + lastMSTime = World::GetGameTimeMS(); lastOrientation = new_o; c->SetOrientation(new_o); c->SetFacingTo(new_o); @@ -2317,7 +2316,7 @@ public: { npc_ulduar_flames_initialAI(Creature *pCreature) : NullCreatureAI(pCreature) { - CreateTime = GameTime::GetGameTime(); + CreateTime = time(NULL); events.Reset(); events.ScheduleEvent(EVENT_FLAMES_SPREAD, 5750); if( Creature* flame = me->SummonCreature(NPC_FLAMES_SPREAD, me->GetPositionX(), me->GetPositionY(), 364.32f, 0.0f) ) diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index 9ff1e599f..a7312583b 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp @@ -7,7 +7,6 @@ #include "ulduar.h" #include "Vehicle.h" #include "Player.h" -#include "GameTime.h" #include "WorldPacket.h" #include "WorldSession.h" #include "Transport.h" @@ -888,10 +887,10 @@ public: } else if (unit->GetTypeId() == TYPEID_UNIT && unit->GetAreaId() == 4656 /*Conservatory of Life*/) { - if (GameTime::GetGameTime() > (m_conspeedatoryAttempt + DAY)) + if (time(NULL) > (m_conspeedatoryAttempt + DAY)) { DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, 21597 /*CON-SPEED-ATORY_TIMED_CRITERIA*/); - m_conspeedatoryAttempt = GameTime::GetGameTime(); + m_conspeedatoryAttempt = time(NULL); SaveToDB(); } } 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 236a87391..d6dbc63a2 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp @@ -11,7 +11,6 @@ #include "BattlefieldMgr.h" #include "SpellAuras.h" #include "Player.h" -#include "GameTime.h" /* Vault of Archavon encounters: 1 - Archavon the Stone Watcher event @@ -180,13 +179,13 @@ class instance_vault_of_archavon : public InstanceMapScript switch (type) { case EVENT_ARCHAVON: - ArchavonDeath = GameTime::GetGameTime(); + ArchavonDeath = time(NULL); break; case EVENT_EMALON: - EmalonDeath = GameTime::GetGameTime(); + EmalonDeath = time(NULL); break; case EVENT_KORALON: - KoralonDeath = GameTime::GetGameTime(); + KoralonDeath = time(NULL); break; default: return; diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index 3573fda3d..00647069c 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -29,7 +29,6 @@ #include "Player.h" #include "PoolMgr.h" #include "GameGraveyard.h" -#include "GameTime.h" #include "World.h" #define GOSSIP_HELLO_DEMO1 "Build catapult." @@ -295,7 +294,7 @@ class npc_wg_queue : public CreatureScript else { uint32 timer = wintergrasp->GetTimer() / 1000; - player->SendUpdateWorldState(4354, GameTime::GetGameTime() + timer); + player->SendUpdateWorldState(4354, time(NULL) + timer); if (timer < 15 * MINUTE) { player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Queue for Wintergrasp.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); diff --git a/src/server/scripts/Outland/TempestKeep/botanica/instance_the_botanica.cpp b/src/server/scripts/Outland/TempestKeep/botanica/instance_the_botanica.cpp index 3e78cbabf..b6b3e445f 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/instance_the_botanica.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/instance_the_botanica.cpp @@ -3,7 +3,6 @@ */ #include "ScriptMgr.h" -#include "GameTime.h" #include "InstanceScript.h" #include "the_botanica.h" @@ -151,7 +150,7 @@ class spell_botanica_shift_form : public SpellScriptLoader { if (SpellInfo const* spellInfo = eventInfo.GetDamageInfo()->GetSpellInfo()) { - if ((spellInfo->GetSchoolMask() & _lastSchool) && _swapTime > GameTime::GetGameTime()) + if ((spellInfo->GetSchoolMask() & _lastSchool) && _swapTime > time(NULL)) return false; uint32 form = 0; @@ -167,7 +166,7 @@ class spell_botanica_shift_form : public SpellScriptLoader if (form) { - _swapTime = GameTime::GetGameTime() + 6; + _swapTime = time(NULL) + 6; _lastSchool = spellInfo->GetSchoolMask(); GetUnitOwner()->RemoveAurasDueToSpell(_lastForm); _lastForm = form; diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 657f6a7bd..bdf7c471e 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -22,7 +22,6 @@ #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "Group.h" -#include "GameTime.h" #include "InstanceScript.h" #include "LFGMgr.h" #include "Pet.h" @@ -2651,12 +2650,12 @@ class spell_gen_turkey_marker : public SpellScriptLoader { if (GetStackAmount() > stackAmount) { - _applyTimes.push_back(GameTime::GetGameTimeMS()); + _applyTimes.push_back(World::GetGameTimeMS()); stackAmount++; } // pop stack if it expired for us - if (_applyTimes.front() + GetMaxDuration() < GameTime::GetGameTimeMS()) + if (_applyTimes.front() + GetMaxDuration() < World::GetGameTimeMS()) { stackAmount--; ModStackAmount(-1, AURA_REMOVE_BY_EXPIRE); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index ef0854837..3d5b2c787 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -17,7 +17,6 @@ #include "SpellAuraEffects.h" #include "SkillDiscovery.h" #include "Battleground.h" -#include "GameTime.h" class spell_item_massive_seaforium_charge : public SpellScriptLoader { @@ -3093,7 +3092,7 @@ class spell_item_crystal_prison_dummy_dnd : public SpellScriptLoader if (Creature* target = GetHitCreature()) if (target->isDead() && !target->IsPet()) { - GetCaster()->SummonGameObject(OBJECT_IMPRISONED_DOOMGUARD, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), 0, 0, 0, 0, uint32(target->GetRespawnTime()-GameTime::GetGameTime())); + GetCaster()->SummonGameObject(OBJECT_IMPRISONED_DOOMGUARD, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), 0, 0, 0, 0, uint32(target->GetRespawnTime()-time(NULL))); target->DespawnOrUnsummon(); } } diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index 7ea7ac32f..8a736d40c 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -26,7 +26,6 @@ EndContentData */ #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "Player.h" -#include "GameTime.h" #include "SpellMgr.h" // Ours @@ -383,7 +382,7 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript { uint32 triggerId = trigger->entry; // Second trigger happened too early after first, skip for now - if (GameTime::GetGameTime() - _triggerTimes[triggerId] < AREATRIGGER_TALK_COOLDOWN) + if (sWorld->GetGameTime() - _triggerTimes[triggerId] < AREATRIGGER_TALK_COOLDOWN) return false; switch (triggerId) @@ -400,7 +399,7 @@ class AreaTrigger_at_brewfest : public AreaTriggerScript break; } - _triggerTimes[triggerId] = GameTime::GetGameTime(); + _triggerTimes[triggerId] = sWorld->GetGameTime(); return false; } @@ -440,7 +439,7 @@ class AreaTrigger_at_area_52_entrance : public AreaTriggerScript return false; uint32 triggerId = trigger->entry; - if (GameTime::GetGameTime() - _triggerTimes[trigger->entry] < SUMMON_COOLDOWN) + if (sWorld->GetGameTime() - _triggerTimes[trigger->entry] < SUMMON_COOLDOWN) return false; switch (triggerId) @@ -469,7 +468,7 @@ class AreaTrigger_at_area_52_entrance : public AreaTriggerScript player->SummonCreature(NPC_SPOTLIGHT, x, y, z, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 5000); player->AddAura(SPELL_A52_NEURALYZER, player); - _triggerTimes[trigger->entry] = GameTime::GetGameTime(); + _triggerTimes[trigger->entry] = sWorld->GetGameTime(); return false; } diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 390530dab..6811ef861 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -36,7 +36,6 @@ EndContentData */ #include "GameObjectAI.h" #include "Spell.h" #include "Player.h" -#include "GameTime.h" #include "WorldSession.h" // Ours @@ -837,7 +836,7 @@ class go_inconspicuous_landmark : public GameObjectScript public: go_inconspicuous_landmark() : GameObjectScript("go_inconspicuous_landmark") { - _lastUsedTime = GameTime::GetGameTime(); + _lastUsedTime = time(NULL); } bool OnGossipHello(Player* player, GameObject* /*go*/) @@ -845,10 +844,10 @@ class go_inconspicuous_landmark : public GameObjectScript if (player->HasItemCount(ITEM_CUERGOS_KEY)) return true; - if (_lastUsedTime > GameTime::GetGameTime()) + if (_lastUsedTime > time(NULL)) return true; - _lastUsedTime = GameTime::GetGameTime() + MINUTE; + _lastUsedTime = time(NULL) + MINUTE; player->CastSpell(player, SPELL_SUMMON_PIRATES_TREASURE_AND_TRIGGER_MOB, true); return true; } diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 6f2dd651a..f6310333c 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -33,7 +33,6 @@ EndContentData */ #include "ObjectMgr.h" #include "ScriptMgr.h" #include "World.h" -#include "GameTime.h" #include "CreatureTextMgr.h" #include "PassiveAI.h" #include "GameEventMgr.h" @@ -109,7 +108,7 @@ public: { case EVENT_CLEARWATER_ANNOUNCE: { - time_t curtime = GameTime::GetGameTime(); + time_t curtime = time(NULL); tm strdate; ACE_OS::localtime_r(&curtime, &strdate); @@ -254,7 +253,7 @@ public: { case EVENT_RIGGLE_ANNOUNCE: { - time_t curtime = GameTime::GetGameTime(); + time_t curtime = time(NULL); tm strdate; ACE_OS::localtime_r(&curtime, &strdate); if (!startWarning && strdate.tm_hour == 14 && strdate.tm_min == 0)