mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-31 01:23:47 +00:00
feat(Core/Time): Implement saparated manager for game time (#8630)
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include "GameEventMgr.h"
|
||||
#include "GameGraveyard.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "GameTime.h"
|
||||
#include "GossipDef.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "Group.h"
|
||||
@@ -247,7 +248,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 = time(nullptr);
|
||||
m_logintime = GameTime::GetGameTime().count();
|
||||
m_Last_tick = m_logintime;
|
||||
m_Played_time[PLAYED_TIME_TOTAL] = 0;
|
||||
m_Played_time[PLAYED_TIME_LEVEL] = 0;
|
||||
@@ -318,7 +319,7 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
|
||||
m_spellPenetrationItemMod = 0;
|
||||
|
||||
// Honor System
|
||||
m_lastHonorUpdateTime = time(nullptr);
|
||||
m_lastHonorUpdateTime = GameTime::GetGameTime().count();
|
||||
|
||||
m_IsBGRandomWinner = false;
|
||||
|
||||
@@ -577,7 +578,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
|
||||
SetArenaPoints(sWorld->getIntConfig(CONFIG_START_ARENA_POINTS));
|
||||
|
||||
// Played time
|
||||
m_Last_tick = time(nullptr);
|
||||
m_Last_tick = GameTime::GetGameTime().count();
|
||||
m_Played_time[PLAYED_TIME_TOTAL] = 0;
|
||||
m_Played_time[PLAYED_TIME_LEVEL] = 0;
|
||||
|
||||
@@ -1074,7 +1075,7 @@ void Player::setDeathState(DeathState s, bool /*despawn = false*/)
|
||||
void Player::SetRestState(uint32 triggerId)
|
||||
{
|
||||
_innTriggerId = triggerId;
|
||||
_restTime = time(nullptr);
|
||||
_restTime = GameTime::GetGameTime().count();
|
||||
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
|
||||
}
|
||||
|
||||
@@ -1432,7 +1433,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
if (MustDelayTeleport())
|
||||
{
|
||||
SetHasDelayedTeleport(true);
|
||||
SetSemaphoreTeleportNear(time(nullptr));
|
||||
SetSemaphoreTeleportNear(GameTime::GetGameTime().count());
|
||||
//lets save teleport destination for player
|
||||
teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
|
||||
teleportStore_options = options;
|
||||
@@ -1454,11 +1455,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(time(nullptr), z);
|
||||
SetFallInformation(GameTime::GetGameTime().count(), z);
|
||||
|
||||
// code for finish transfer called in WorldSession::HandleMovementOpcodes()
|
||||
// at client packet MSG_MOVE_TELEPORT_ACK
|
||||
SetSemaphoreTeleportNear(time(nullptr));
|
||||
SetSemaphoreTeleportNear(GameTime::GetGameTime().count());
|
||||
// near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing
|
||||
if (!GetSession()->PlayerLogout())
|
||||
{
|
||||
@@ -1493,7 +1494,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
if (MustDelayTeleport())
|
||||
{
|
||||
SetHasDelayedTeleport(true);
|
||||
SetSemaphoreTeleportFar(time(nullptr));
|
||||
SetSemaphoreTeleportFar(GameTime::GetGameTime().count());
|
||||
//lets save teleport destination for player
|
||||
teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
|
||||
teleportStore_options = options;
|
||||
@@ -1558,7 +1559,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
}
|
||||
|
||||
teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
|
||||
SetFallInformation(time(nullptr), z);
|
||||
SetFallInformation(GameTime::GetGameTime().count(), z);
|
||||
// if the player is saved before worldportack (at logout for example)
|
||||
// this will be used instead of the current location in SaveToDB
|
||||
|
||||
@@ -1577,7 +1578,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(time(nullptr));
|
||||
SetSemaphoreTeleportFar(GameTime::GetGameTime().count());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -2683,8 +2684,8 @@ void Player::InitStatsForLevel(bool reapplyMods)
|
||||
|
||||
void Player::SendInitialSpells()
|
||||
{
|
||||
uint32 curTime = World::GetGameTimeMS();
|
||||
uint32 infTime = World::GetGameTimeMS() + infinityCooldownDelayCheck;
|
||||
uint32 curTime = GameTime::GetGameTimeMS().count();
|
||||
uint32 infTime = GameTime::GetGameTimeMS().count() + infinityCooldownDelayCheck;
|
||||
|
||||
uint16 spellCount = 0;
|
||||
|
||||
@@ -2816,7 +2817,7 @@ void Player::SendNewMail()
|
||||
|
||||
void Player::AddNewMailDeliverTime(time_t deliver_time)
|
||||
{
|
||||
if (deliver_time <= time(nullptr)) // ready now
|
||||
if (deliver_time <= GameTime::GetGameTime().count()) // ready now
|
||||
{
|
||||
++unReadMails;
|
||||
SendNewMail();
|
||||
@@ -3459,7 +3460,7 @@ void Player::RemoveCategoryCooldown(uint32 cat)
|
||||
void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns)
|
||||
{
|
||||
// remove cooldowns on spells that have < 10 min CD
|
||||
uint32 infTime = World::GetGameTimeMS() + infinityCooldownDelayCheck;
|
||||
uint32 infTime = GameTime::GetGameTimeMS().count() + infinityCooldownDelayCheck;
|
||||
SpellCooldowns::iterator itr, next;
|
||||
for (itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); itr = next)
|
||||
{
|
||||
@@ -3493,7 +3494,7 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns)
|
||||
|
||||
void Player::RemoveAllSpellCooldown()
|
||||
{
|
||||
uint32 infTime = World::GetGameTimeMS() + infinityCooldownDelayCheck;
|
||||
uint32 infTime = GameTime::GetGameTimeMS().count() + infinityCooldownDelayCheck;
|
||||
if (!m_spellCooldowns.empty())
|
||||
{
|
||||
for (SpellCooldowns::const_iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); ++itr)
|
||||
@@ -3512,7 +3513,7 @@ void Player::_LoadSpellCooldowns(PreparedQueryResult result)
|
||||
|
||||
if (result)
|
||||
{
|
||||
time_t curTime = time(nullptr);
|
||||
time_t curTime = GameTime::GetGameTime().count();
|
||||
|
||||
do
|
||||
{
|
||||
@@ -3546,8 +3547,8 @@ void Player::_SaveSpellCooldowns(CharacterDatabaseTransaction trans, bool logout
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
time_t curTime = time(nullptr);
|
||||
uint32 curMSTime = World::GetGameTimeMS();
|
||||
time_t curTime = GameTime::GetGameTime().count();
|
||||
uint32 curMSTime = GameTime::GetGameTimeMS().count();
|
||||
uint32 infTime = curMSTime + infinityCooldownDelayCheck;
|
||||
|
||||
bool first_round = true;
|
||||
@@ -3601,7 +3602,7 @@ uint32 Player::resetTalentsCost() const
|
||||
return 10 * GOLD;
|
||||
else
|
||||
{
|
||||
uint64 months = (sWorld->GetGameTime() - m_resetTalentsTime) / MONTH;
|
||||
uint64 months = (GameTime::GetGameTime().count() - m_resetTalentsTime) / MONTH;
|
||||
if (months > 0)
|
||||
{
|
||||
// This cost will be reduced by a rate of 5 gold per month
|
||||
@@ -3710,7 +3711,7 @@ bool Player::resetTalents(bool noResetCost)
|
||||
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, 1);
|
||||
|
||||
m_resetTalentsCost = resetCost;
|
||||
m_resetTalentsTime = time(nullptr);
|
||||
m_resetTalentsTime = GameTime::GetGameTime().count();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -4252,7 +4253,7 @@ void Player::DeleteOldCharacters(uint32 keepDays)
|
||||
LOG_INFO("server.loading", " ");
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_OLD_CHARS);
|
||||
stmt->setUInt32(0, uint32(time(nullptr) - time_t(keepDays * DAY)));
|
||||
stmt->setUInt32(0, uint32(GameTime::GetGameTime().count() - time_t(keepDays * DAY)));
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
@@ -7627,7 +7628,7 @@ void Player::SendLoot(ObjectGuid 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() < time(nullptr))
|
||||
if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && go->GetLootGenerationTime() + go->GetRespawnDelay() < GameTime::GetGameTime().count())
|
||||
go->SetLootState(GO_READY);
|
||||
|
||||
if (go->getLootState() == GO_READY)
|
||||
@@ -8661,7 +8662,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(time(nullptr) + (wg->GetTimer() / 1000)));
|
||||
SendUpdateWorldState(ClockWorldState[i], uint32(GameTime::GetGameTime().count() + (wg->GetTimer() / 1000)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8808,29 +8809,23 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
|
||||
|
||||
SetMinion(pet, true);
|
||||
|
||||
switch (petType)
|
||||
if (petType == SUMMON_PET)
|
||||
{
|
||||
case SUMMON_PET:
|
||||
if (pet->GetCreatureTemplate()->type == CREATURE_TYPE_DEMON || pet->GetCreatureTemplate()->type == CREATURE_TYPE_UNDEAD)
|
||||
{
|
||||
if (pet->GetCreatureTemplate()->type == CREATURE_TYPE_DEMON || pet->GetCreatureTemplate()->type == CREATURE_TYPE_UNDEAD)
|
||||
{
|
||||
pet->GetCharmInfo()->SetPetNumber(pet_number, true); // Show pet details tab (Shift+P) only for demons & undead
|
||||
}
|
||||
else
|
||||
{
|
||||
pet->GetCharmInfo()->SetPetNumber(pet_number, false);
|
||||
}
|
||||
|
||||
pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048);
|
||||
pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
|
||||
pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
|
||||
pet->SetFullHealth();
|
||||
pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA));
|
||||
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); // cast can't be helped in this case
|
||||
break;
|
||||
pet->GetCharmInfo()->SetPetNumber(pet_number, true); // Show pet details tab (Shift+P) only for demons & undead
|
||||
}
|
||||
default:
|
||||
break;
|
||||
else
|
||||
{
|
||||
pet->GetCharmInfo()->SetPetNumber(pet_number, false);
|
||||
}
|
||||
|
||||
pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048);
|
||||
pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
|
||||
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().count())); // cast can't be helped in this case
|
||||
}
|
||||
|
||||
map->AddToMap(pet->ToCreature(), true);
|
||||
@@ -9321,8 +9316,8 @@ void Player::PetSpellInitialize()
|
||||
uint8 cooldownsCount = pet->m_CreatureSpellCooldowns.size();
|
||||
data << uint8(cooldownsCount);
|
||||
|
||||
uint32 curTime = World::GetGameTimeMS();
|
||||
uint32 infTime = World::GetGameTimeMS() + infinityCooldownDelayCheck;
|
||||
uint32 curTime = GameTime::GetGameTimeMS().count();
|
||||
uint32 infTime = GameTime::GetGameTimeMS().count() + infinityCooldownDelayCheck;
|
||||
|
||||
for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr)
|
||||
{
|
||||
@@ -9424,8 +9419,8 @@ void Player::VehicleSpellInitialize()
|
||||
// Cooldowns
|
||||
data << uint8(cooldownCount);
|
||||
|
||||
uint32 curTime = World::GetGameTimeMS();
|
||||
uint32 infTime = World::GetGameTimeMS() + infinityCooldownDelayCheck;
|
||||
uint32 curTime = GameTime::GetGameTimeMS().count();
|
||||
uint32 infTime = GameTime::GetGameTimeMS().count() + infinityCooldownDelayCheck;
|
||||
|
||||
for (CreatureSpellCooldowns::const_iterator itr = vehicle->m_CreatureSpellCooldowns.begin(); itr != vehicle->m_CreatureSpellCooldowns.end(); ++itr)
|
||||
{
|
||||
@@ -10726,7 +10721,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 ite
|
||||
void Player::_AddSpellCooldown(uint32 spellid, uint16 categoryId, uint32 itemid, uint32 end_time, bool needSendToClient, bool forceSendToSpectator)
|
||||
{
|
||||
SpellCooldown sc;
|
||||
sc.end = World::GetGameTimeMS() + end_time;
|
||||
sc.end = GameTime::GetGameTimeMS().count() + end_time;
|
||||
sc.category = categoryId;
|
||||
sc.itemid = itemid;
|
||||
sc.maxduration = end_time;
|
||||
@@ -11003,7 +10998,7 @@ void Player::LeaveBattleground(Battleground* bg)
|
||||
}
|
||||
|
||||
// xinef: reset corpse reclaim time
|
||||
m_deathExpireTime = time(nullptr);
|
||||
m_deathExpireTime = GameTime::GetGameTime().count();
|
||||
|
||||
// pussywizard: clear movement, because after porting player will move to arena cords
|
||||
GetMotionMaster()->MovementExpired();
|
||||
@@ -11241,7 +11236,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
|
||||
SendEquipmentSetList();
|
||||
|
||||
data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4);
|
||||
data.AppendPackedTime(sWorld->GetGameTime());
|
||||
data.AppendPackedTime(GameTime::GetGameTime().count());
|
||||
data << float(0.01666667f); // game speed
|
||||
data << uint32(0); // added in 3.1.2
|
||||
GetSession()->SendPacket(&data);
|
||||
@@ -11426,7 +11421,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 > World::GetGameTimeMS() + 30 * IN_MILLISECONDS)
|
||||
if (itr != m_spellCooldowns.end() && itr->second.itemid == pItem->GetEntry() && itr->second.end > GameTime::GetGameTimeMS().count() + 30 * IN_MILLISECONDS)
|
||||
continue;
|
||||
|
||||
// xinef: dont apply eqiup cooldown for spells with this attribute
|
||||
@@ -11730,7 +11725,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().count(); // last daily quest time
|
||||
m_DailyQuestChanged = true;
|
||||
break;
|
||||
}
|
||||
@@ -11739,7 +11734,7 @@ void Player::SetDailyQuestStatus(uint32 quest_id)
|
||||
else
|
||||
{
|
||||
m_DFQuests.insert(quest_id);
|
||||
m_lastDailyQuestTime = time(nullptr);
|
||||
m_lastDailyQuestTime = GameTime::GetGameTime().count();
|
||||
m_DailyQuestChanged = true;
|
||||
}
|
||||
}
|
||||
@@ -11966,7 +11961,7 @@ void Player::SummonIfPossible(bool agree, ObjectGuid summoner_guid)
|
||||
}
|
||||
|
||||
// expire and auto declined
|
||||
if (m_summon_expire < time(nullptr))
|
||||
if (m_summon_expire < GameTime::GetGameTime().count())
|
||||
return;
|
||||
|
||||
// drop flag at summon
|
||||
@@ -12455,7 +12450,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().count();
|
||||
// 0..2 full period
|
||||
// should be std::ceil(x)-1 but not floor(x)
|
||||
uint64 count = (now < m_deathExpireTime - 1) ? (m_deathExpireTime - 1 - now) / DEATH_EXPIRE_STEP : 0;
|
||||
@@ -12490,7 +12485,7 @@ int32 Player::CalculateCorpseReclaimDelay(bool load)
|
||||
}
|
||||
|
||||
time_t expected_time = corpse->GetGhostTime() + copseReclaimDelay[count];
|
||||
time_t now = time(nullptr);
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
|
||||
if (now >= expected_time)
|
||||
return -1;
|
||||
@@ -14207,7 +14202,7 @@ void Player::_SaveCharacter(bool create, CharacterDatabaseTransaction 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(time(nullptr)));
|
||||
stmt->setUInt32(index++, uint32(GameTime::GetGameTime().count()));
|
||||
stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
|
||||
//save, far from tavern/city
|
||||
//save, but in tavern/city
|
||||
@@ -14346,7 +14341,7 @@ void Player::_SaveCharacter(bool create, CharacterDatabaseTransaction 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(time(nullptr)));
|
||||
stmt->setUInt32(index++, uint32(GameTime::GetGameTime().count()));
|
||||
stmt->setUInt8(index++, (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0));
|
||||
//save, far from tavern/city
|
||||
//save, but in tavern/city
|
||||
@@ -15379,7 +15374,7 @@ bool Player::SetCanFly(bool apply, bool packetOnly /*= false*/)
|
||||
return false;
|
||||
|
||||
if (!apply)
|
||||
SetFallInformation(time(nullptr), GetPositionZ());
|
||||
SetFallInformation(GameTime::GetGameTime().count(), GetPositionZ());
|
||||
|
||||
WorldPacket data(apply ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY, 12);
|
||||
data << GetPackGUID();
|
||||
@@ -15658,7 +15653,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().count();
|
||||
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
|
||||
}
|
||||
|
||||
@@ -15799,3 +15794,36 @@ std::string Player::GetPlayerName()
|
||||
|
||||
return "|Hplayer:" + name + "|h" + color + name + "|h|r";
|
||||
}
|
||||
|
||||
void Player::SetSummonPoint(uint32 mapid, float x, float y, float z, uint32 delay /*= 0*/, bool asSpectator /*= false*/)
|
||||
{
|
||||
m_summon_expire = GameTime::GetGameTime().count() + (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().count();
|
||||
}
|
||||
|
||||
bool Player::HasSpellCooldown(uint32 spell_id) const
|
||||
{
|
||||
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
|
||||
return itr != m_spellCooldowns.end() && itr->second.end > getMSTime();
|
||||
}
|
||||
|
||||
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 > getMSTime() && 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 > getMSTime() ? itr->second.end - getMSTime() : 0);
|
||||
}
|
||||
|
||||
@@ -1066,16 +1066,8 @@ public:
|
||||
}
|
||||
bool TeleportToEntryPoint();
|
||||
|
||||
void SetSummonPoint(uint32 mapid, float x, float y, float z, uint32 delay = 0, bool asSpectator = false)
|
||||
{
|
||||
m_summon_expire = time(nullptr) + (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;
|
||||
}
|
||||
[[nodiscard]] bool IsSummonAsSpectator() const { return m_summon_asSpectator && m_summon_expire >= time(nullptr); }
|
||||
void SetSummonPoint(uint32 mapid, float x, float y, float z, uint32 delay = 0, bool asSpectator = false);
|
||||
[[nodiscard]] bool IsSummonAsSpectator() const;
|
||||
void SetSummonAsSpectator(bool on) { m_summon_asSpectator = on; }
|
||||
void SummonIfPossible(bool agree, ObjectGuid summoner_guid);
|
||||
[[nodiscard]] time_t GetSummonExpireTimer() const { return m_summon_expire; }
|
||||
@@ -1726,21 +1718,9 @@ public:
|
||||
void DropModCharge(SpellModifier* mod, Spell* spell);
|
||||
void SetSpellModTakingSpell(Spell* spell, bool apply);
|
||||
|
||||
[[nodiscard]] bool HasSpellCooldown(uint32 spell_id) const override
|
||||
{
|
||||
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
|
||||
return itr != m_spellCooldowns.end() && itr->second.end > World::GetGameTimeMS();
|
||||
}
|
||||
[[nodiscard]] bool HasSpellItemCooldown(uint32 spell_id, uint32 itemid) const override
|
||||
{
|
||||
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
|
||||
return itr != m_spellCooldowns.end() && itr->second.end > World::GetGameTimeMS() && itr->second.itemid == itemid;
|
||||
}
|
||||
[[nodiscard]] 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);
|
||||
}
|
||||
[[nodiscard]] bool HasSpellCooldown(uint32 spell_id) const override;
|
||||
[[nodiscard]] bool HasSpellItemCooldown(uint32 spell_id, uint32 itemid) const override;
|
||||
[[nodiscard]] uint32 GetSpellCooldownDelay(uint32 spell_id) const;
|
||||
void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = nullptr, bool infinityCooldown = false);
|
||||
void AddSpellCooldown(uint32 spell_id, uint32 itemid, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false) override;
|
||||
void _AddSpellCooldown(uint32 spell_id, uint16 categoryId, uint32 itemid, uint32 end_time, bool needSendToClient = false, bool forceSendToSpectator = false);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "GameTime.h"
|
||||
#include "MapMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
@@ -31,7 +32,7 @@ void Player::UpdateSpeakTime(uint32 specialMessageLimit)
|
||||
if (!AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()))
|
||||
return;
|
||||
|
||||
time_t current = time (nullptr);
|
||||
time_t current = GameTime::GetGameTime().count();
|
||||
if (m_speakTime > current)
|
||||
{
|
||||
uint32 max_count = specialMessageLimit ? specialMessageLimit : sWorld->getIntConfig(CONFIG_CHATFLOOD_MESSAGE_COUNT);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "CreatureAI.h"
|
||||
#include "DisableMgr.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "GameTime.h"
|
||||
#include "GitRevision.h"
|
||||
#include "GossipDef.h"
|
||||
#include "Group.h"
|
||||
@@ -553,7 +554,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().count()) + timeAllowed;
|
||||
}
|
||||
else
|
||||
questStatusData.Timer = 0;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "GameEventMgr.h"
|
||||
#include "GameGraveyard.h"
|
||||
#include "GameObjectAI.h"
|
||||
#include "GameTime.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "Group.h"
|
||||
#include "GroupMgr.h"
|
||||
@@ -3995,7 +3996,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem)
|
||||
LOG_DEBUG("entities.player.items", "STORAGE: AddItemToBuyBackSlot item = %u, slot = %u", pItem->GetEntry(), slot);
|
||||
|
||||
m_items[slot] = pItem;
|
||||
time_t base = time(nullptr);
|
||||
time_t base = GameTime::GetGameTime().count();
|
||||
uint32 etime = uint32(base - m_logintime + (30 * 3600));
|
||||
uint32 eslot = slot - BUYBACK_SLOT_START;
|
||||
|
||||
@@ -5336,7 +5337,7 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
|
||||
|
||||
SaveRecallPosition();
|
||||
|
||||
time_t now = time(nullptr);
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
time_t logoutTime = time_t(fields[27].GetUInt32());
|
||||
|
||||
// since last logout (in seconds)
|
||||
@@ -5504,7 +5505,7 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
|
||||
SetUInt32Value(PLAYER_CHOSEN_TITLE, curTitle);
|
||||
|
||||
// has to be called after last Relocate() in Player::LoadFromDB
|
||||
SetFallInformation(time(nullptr), GetPositionZ());
|
||||
SetFallInformation(GameTime::GetGameTime().count(), GetPositionZ());
|
||||
|
||||
_LoadSpellCooldowns(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_SPELL_COOLDOWNS));
|
||||
|
||||
@@ -6218,7 +6219,7 @@ void Player::_LoadMail(PreparedQueryResult mailsResult, PreparedQueryResult mail
|
||||
m->state = MAIL_STATE_UNCHANGED;
|
||||
|
||||
// Do not load expired pending sale mail if there is already delivery auction mail
|
||||
if (m->auctionId < 0 && m->expire_time <= time(nullptr))
|
||||
if (m->auctionId < 0 && m->expire_time <= GameTime::GetGameTime().count())
|
||||
{
|
||||
uint32 auctionId = std::abs(m->auctionId);
|
||||
if (pendingAuctions.count(auctionId))
|
||||
@@ -6335,10 +6336,10 @@ void Player::_LoadQuestStatus(PreparedQueryResult result)
|
||||
{
|
||||
AddTimedQuest(quest_id);
|
||||
|
||||
if (quest_time <= sWorld->GetGameTime())
|
||||
if (quest_time <= GameTime::GetGameTime().count())
|
||||
questStatusData.Timer = 1;
|
||||
else
|
||||
questStatusData.Timer = uint32((quest_time - sWorld->GetGameTime()) * IN_MILLISECONDS);
|
||||
questStatusData.Timer = uint32((quest_time - GameTime::GetGameTime().count()) * IN_MILLISECONDS);
|
||||
}
|
||||
else
|
||||
quest_time = 0;
|
||||
@@ -6595,7 +6596,7 @@ void Player::SendRaidInfo()
|
||||
size_t p_counter = data.wpos();
|
||||
data << uint32(counter); // placeholder
|
||||
|
||||
time_t now = time(nullptr);
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
|
||||
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
|
||||
{
|
||||
@@ -7535,7 +7536,7 @@ void Player::_SaveQuestStatus(CharacterDatabaseTransaction 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 + sWorld->GetGameTime()));
|
||||
stmt->setUInt32(index++, uint32(statusItr->second.Timer / IN_MILLISECONDS + GameTime::GetGameTime().count()));
|
||||
|
||||
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
|
||||
stmt->setUInt16(index++, statusItr->second.CreatureOrGOCount[i]);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "Channel.h"
|
||||
#include "ChannelMgr.h"
|
||||
#include "Formulas.h"
|
||||
#include "GameTime.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
@@ -57,7 +58,7 @@ void Player::Update(uint32 p_time)
|
||||
sScriptMgr->OnBeforePlayerUpdate(this, p_time);
|
||||
|
||||
// undelivered mail
|
||||
if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(nullptr))
|
||||
if (m_nextMailDelivereTime && m_nextMailDelivereTime <= GameTime::GetGameTime().count())
|
||||
{
|
||||
SendNewMail();
|
||||
++unReadMails;
|
||||
@@ -82,7 +83,7 @@ void Player::Update(uint32 p_time)
|
||||
Unit::Update(p_time);
|
||||
SetMustDelayTeleport(false);
|
||||
|
||||
time_t now = time(nullptr);
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
|
||||
UpdatePvPFlag(now);
|
||||
UpdateFFAPvPFlag(now);
|
||||
@@ -239,7 +240,7 @@ void Player::Update(uint32 p_time)
|
||||
{
|
||||
if (now > lastTick && _restTime > 0) // freeze update
|
||||
{
|
||||
time_t currTime = time(nullptr);
|
||||
time_t currTime = GameTime::GetGameTime().count();
|
||||
time_t timeDiff = currTime - _restTime;
|
||||
if (timeDiff >= 10) // freeze update
|
||||
{
|
||||
@@ -434,7 +435,7 @@ void Player::UpdateMirrorTimers()
|
||||
void Player::UpdateNextMailTimeAndUnreads()
|
||||
{
|
||||
// Update the next delivery time and unread mails
|
||||
time_t cTime = time(nullptr);
|
||||
time_t cTime = GameTime::GetGameTime().count();
|
||||
// Get the next delivery time
|
||||
CharacterDatabasePreparedStatement* stmtNextDeliveryTime =
|
||||
CharacterDatabase.GetPreparedStatement(CHAR_SEL_NEXT_MAIL_DELIVERYTIME);
|
||||
@@ -1126,8 +1127,8 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation,
|
||||
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().count());
|
||||
time_t today = time_t(GameTime::GetGameTime().count() / DAY) * DAY;
|
||||
|
||||
if (m_lastHonorUpdateTime < today)
|
||||
{
|
||||
@@ -1384,7 +1385,7 @@ void Player::UpdatePvPState()
|
||||
{
|
||||
if (IsPvP() && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) &&
|
||||
pvpInfo.EndTimer == 0)
|
||||
pvpInfo.EndTimer = time(nullptr); // start toggle-off
|
||||
pvpInfo.EndTimer = GameTime::GetGameTime().count(); // start toggle-off
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1450,7 +1451,7 @@ void Player::UpdateFFAPvPState(bool reset /*= true*/)
|
||||
!pvpInfo.FFAPvPEndTimer)
|
||||
{
|
||||
pvpInfo.FFAPvPEndTimer =
|
||||
sWorld->GetGameTime() +
|
||||
GameTime::GetGameTime().count() +
|
||||
sWorld->getIntConfig(CONFIG_FFA_PVP_TIMER);
|
||||
}
|
||||
}
|
||||
@@ -1466,7 +1467,7 @@ void Player::UpdatePvP(bool state, bool _override)
|
||||
}
|
||||
else
|
||||
{
|
||||
pvpInfo.EndTimer = time(nullptr);
|
||||
pvpInfo.EndTimer = GameTime::GetGameTime().count();
|
||||
SetPvP(state);
|
||||
}
|
||||
|
||||
@@ -1958,7 +1959,7 @@ void Player::UpdateCorpseReclaimDelay()
|
||||
(!pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE)))
|
||||
return;
|
||||
|
||||
time_t now = time(nullptr);
|
||||
time_t now = GameTime::GetGameTime().count();
|
||||
|
||||
if (now < m_deathExpireTime)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user