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

(ported commit: 12701cb0c6c45eb105ad449eb9a56e76d84d691e)
This commit is contained in:
Ovahlord committed 2019-07-08 12:19:19 +02:00
1 parent ba38f74816
commit 5fe3a1f7f9
68 files changed
+335 -259

No files matched your search

+33 -33
View File
@@ -280,7 +280,7 @@ Player::Player(WorldSession* session): Unit(true)
m_bgBattlegroundQueueID[j].invitedToInstance = 0;
}
m_logintime = time(nullptr);
m_logintime = GameTime::GetGameTime();
m_Last_tick = m_logintime;
m_Played_time[PLAYED_TIME_TOTAL] = 0;
m_Played_time[PLAYED_TIME_LEVEL] = 0;
@@ -343,7 +343,7 @@ Player::Player(WorldSession* session): Unit(true)
m_spellPenetrationItemMod = 0;
// Honor System
m_lastHonorUpdateTime = time(nullptr);
m_lastHonorUpdateTime = GameTime::GetGameTime();
m_IsBGRandomWinner = false;
@@ -585,7 +585,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
SetCurrency(CURRENCY_TYPE_CONQUEST_POINTS, sWorld->getIntConfig(CONFIG_CURRENCY_START_CONQUEST_POINTS));
// Played time
m_Last_tick = time(nullptr);
m_Last_tick = GameTime::GetGameTime();
m_Played_time[PLAYED_TIME_TOTAL] = 0;
m_Played_time[PLAYED_TIME_LEVEL] = 0;
@@ -1039,7 +1039,7 @@ void Player::Update(uint32 p_time)
return;
// undelivered mail
if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(nullptr))
if (m_nextMailDelivereTime && m_nextMailDelivereTime <= GameTime::GetGameTime())
{
SendNewMail();
++unReadMails;
@@ -1061,7 +1061,7 @@ void Player::Update(uint32 p_time)
Unit::Update(p_time);
SetCanDelayTeleport(false);
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime();
UpdatePvPFlag(now);
@@ -1202,7 +1202,7 @@ void Player::Update(uint32 p_time)
{
if (roll_chance_i(3) && _restTime > 0) // freeze update
{
time_t currTime = time(nullptr);
time_t currTime = GameTime::GetGameTime();
time_t timeDiff = currTime - _restTime;
if (timeDiff >= 10) // freeze update
{
@@ -3126,7 +3126,7 @@ void Player::UpdateNextMailTimeAndUnreads()
{
// calculate next delivery time (min. from non-delivered mails
// and recalculate unReadMail
time_t cTime = time(nullptr);
time_t cTime = GameTime::GetGameTime();
m_nextMailDelivereTime = 0;
unReadMails = 0;
for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
@@ -3143,7 +3143,7 @@ void Player::UpdateNextMailTimeAndUnreads()
void Player::AddNewMailDeliverTime(time_t deliver_time)
{
if (deliver_time <= time(nullptr)) // ready now
if (deliver_time <= GameTime::GetGameTime()) // ready now
{
++unReadMails;
SendNewMail();
@@ -4003,7 +4003,7 @@ bool Player::ResetTalents(bool no_cost)
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, 1);
SetTalentResetCost(cost);
SetTalentResetTime(time(nullptr));
SetTalentResetTime(GameTime::GetGameTime());
}
/* when prev line will dropped use next line
@@ -4576,7 +4576,7 @@ void Player::DeleteOldCharacters(uint32 keepDays)
TC_LOG_INFO("entities.player", "Player::DeleteOldCharacters: Deleting all characters which have been deleted %u days before...", keepDays);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_OLD_CHARS);
stmt->setUInt32(0, uint32(time(nullptr) - time_t(keepDays * DAY)));
stmt->setUInt32(0, uint32(GameTime::GetGameTime() - time_t(keepDays * DAY)));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
@@ -6815,8 +6815,8 @@ void Player::RewardReputation(Quest const* quest)
void Player::UpdateHonorFields()
{
/// called when rewarding honor and at each save
time_t now = time_t(time(nullptr));
time_t today = time_t(time(nullptr) / DAY) * DAY;
time_t now = time_t(GameTime::GetGameTime());
time_t today = time_t(GameTime::GetGameTime() / DAY) * DAY;
if (m_lastHonorUpdateTime < today)
{
@@ -9757,7 +9757,7 @@ void Player::SendBattlefieldWorldStates() const
{
SendUpdateWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, wg->IsWarTime() ? 0 : 1);
uint32 timer = wg->IsWarTime() ? 0 : (wg->GetTimer() / 1000); // 0 - Time to next battle
SendUpdateWorldState(ClockWorldState[1], uint32(time(nullptr) + timer));
SendUpdateWorldState(ClockWorldState[1], uint32(GameTime::GetGameTime() + timer));
}
}
@@ -9767,8 +9767,8 @@ void Player::SendBattlefieldWorldStates() const
{
SendUpdateWorldState(TB_WS_FACTION_CONTROLLING, uint32(tb->GetDefenderTeam() + 1));
uint32 timer = tb->GetTimer() / 1000;
SendUpdateWorldState(TB_WS_TIME_BATTLE_END, uint32(tb->IsWarTime() ? uint32(time(nullptr) + timer) : 0));
SendUpdateWorldState(TB_WS_TIME_NEXT_BATTLE, uint32(!tb->IsWarTime() ? uint32(time(nullptr) + timer) : 0));
SendUpdateWorldState(TB_WS_TIME_BATTLE_END, uint32(tb->IsWarTime() ? uint32(GameTime::GetGameTime() + timer) : 0));
SendUpdateWorldState(TB_WS_TIME_NEXT_BATTLE, uint32(!tb->IsWarTime() ? uint32(GameTime::GetGameTime() + timer) : 0));
}
}
}
@@ -13208,7 +13208,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem)
GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetEntry(), slot);
m_items[slot] = pItem;
time_t base = time(nullptr);
time_t base = GameTime::GetGameTime();
uint32 etime = uint32(base - m_logintime + (30 * 3600));
uint32 eslot = slot - BUYBACK_SLOT_START;
@@ -15217,7 +15217,7 @@ void Player::AddQuest(Quest const* quest, Object* questGiver)
AddTimedQuest(quest_id);
questStatusData.Timer = timeAllowed * IN_MILLISECONDS;
qtime = static_cast<uint32>(time(nullptr)) + timeAllowed;
qtime = static_cast<uint32>(GameTime::GetGameTime()) + timeAllowed;
}
else
questStatusData.Timer = 0;
@@ -17901,7 +17901,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder* holder)
SaveRecallPosition();
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime();
time_t logoutTime = time_t(fields[27].GetUInt32());
// since last logout (in seconds)
@@ -19565,7 +19565,7 @@ void Player::SendRaidInfo()
size_t p_counter = data.wpos();
data << uint32(counter); // placeholder
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime();
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
@@ -19948,7 +19948,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]);
stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]);
stmt->setFloat(index++, finiteAlways(m_rest_bonus));
stmt->setUInt32(index++, uint32(time(nullptr)));
stmt->setUInt32(index++, uint32(GameTime::GetGameTime()));
stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
//save, far from tavern/city
//save, but in tavern/city
@@ -20088,7 +20088,7 @@ void Player::SaveToDB(bool create /*=false*/)
stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_TOTAL]);
stmt->setUInt32(index++, m_Played_time[PLAYED_TIME_LEVEL]);
stmt->setFloat(index++, finiteAlways(m_rest_bonus));
stmt->setUInt32(index++, uint32(time(nullptr)));
stmt->setUInt32(index++, uint32(GameTime::GetGameTime()));
stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
//save, far from tavern/city
//save, but in tavern/city
@@ -20996,7 +20996,7 @@ void Player::UpdateSpeakTime()
if (GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHAT_SPAM))
return;
time_t current = time(nullptr);
time_t current = GameTime::GetGameTime();
if (m_speakTime > current)
{
uint32 max_count = sWorld->getIntConfig(CONFIG_CHATFLOOD_MESSAGE_COUNT);
@@ -22995,7 +22995,7 @@ void Player::UpdatePvPState(bool onlyFFA)
else // in friendly area
{
if (IsPvP() && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) && !pvpInfo.EndTimer)
pvpInfo.EndTimer = time(nullptr); // start toggle-off
pvpInfo.EndTimer = GameTime::GetGameTime(); // start toggle-off
}
}
@@ -23015,7 +23015,7 @@ void Player::UpdatePvP(bool state, bool _override)
}
else
{
pvpInfo.EndTimer = time(nullptr);
pvpInfo.EndTimer = GameTime::GetGameTime();
SetPvP(state);
}
}
@@ -24349,7 +24349,7 @@ void Player::SetDailyQuestStatus(uint32 quest_id)
if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx))
{
SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, quest_id);
m_lastDailyQuestTime = time(nullptr); // last daily quest time
m_lastDailyQuestTime = GameTime::GetGameTime(); // last daily quest time
m_DailyQuestChanged = true;
break;
}
@@ -24727,7 +24727,7 @@ void Player::UpdateVisibleGameobjectsOrSpellClicks()
bool Player::HasSummonPending() const
{
return m_summon_expire >= time(nullptr);
return m_summon_expire >= GameTime::GetGameTime();
}
void Player::SendSummonRequestFrom(Unit* summoner)
@@ -24743,7 +24743,7 @@ void Player::SendSummonRequestFrom(Unit* summoner)
if (HasAura(23445))
return;
m_summon_expire = time(nullptr) + MAX_PLAYER_SUMMON_DELAY;
m_summon_expire = GameTime::GetGameTime() + MAX_PLAYER_SUMMON_DELAY;
m_summon_location.WorldRelocate(*summoner);
WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4);
@@ -24762,7 +24762,7 @@ void Player::SummonIfPossible(bool agree)
}
// expire and auto declined
if (m_summon_expire < time(nullptr))
if (m_summon_expire < GameTime::GetGameTime())
return;
// stop taxi flight at summon
@@ -25249,7 +25249,7 @@ uint32 Player::GetCorpseReclaimDelay(bool pvp) const
else if (!sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))
return 0;
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime();
// 0..2 full period
// should be ceil(x)-1 but not floor(x)
uint64 count = (now < m_deathExpireTime - 1) ? (m_deathExpireTime - 1 - now) / DEATH_EXPIRE_STEP : 0;
@@ -25264,7 +25264,7 @@ void Player::UpdateCorpseReclaimDelay()
(!pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE)))
return;
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime();
if (now < m_deathExpireTime)
{
@@ -25308,7 +25308,7 @@ int32 Player::CalculateCorpseReclaimDelay(bool load) const
}
time_t expected_time = corpse->GetGhostTime() + copseReclaimDelay[count];
time_t now = time(nullptr);
time_t now = GameTime::GetGameTime();
if (now >= expected_time)
return -1;
@@ -28060,7 +28060,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
pet->SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, CLASS_MAGE);
pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); // cast can't be helped in this case
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped in this case
break;
default:
break;
@@ -28519,7 +28519,7 @@ void Player::SetRestFlag(RestFlag restFlag, uint32 triggerId /*= 0*/)
if (!oldRestMask && _restFlagMask) // only set flag/time on the first rest state
{
_restTime = time(nullptr);
_restTime = GameTime::GetGameTime();
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
}