feat(core): Ensure that all actions are compared to fixed point in time (#1236) (#1458)

i.e. world update start
This commit is contained in:
Viste(Кирилл)
2019-02-14 21:22:17 +03:00
committed by Francesco Borzì
parent 1b7522ff0e
commit 51b8773528
108 changed files with 933 additions and 509 deletions
+7 -1
View File
@@ -6,6 +6,7 @@
#include "Common.h"
#include "Corpse.h"
#include "GameTime.h"
#include "Player.h"
#include "UpdateMask.h"
#include "ObjectAccessor.h"
@@ -23,7 +24,7 @@ Corpse::Corpse(CorpseType type) : WorldObject(type != CORPSE_BONES), m_type(type
m_valuesCount = CORPSE_END;
m_time = time(NULL);
m_time = GameTime::GetGameTime();
lootRecipient = NULL;
}
@@ -132,6 +133,11 @@ 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();
+1 -1
View File
@@ -54,7 +54,7 @@ class Corpse : public WorldObject, public GridObject<Corpse>
uint64 GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); }
time_t const& GetGhostTime() const { return m_time; }
void ResetGhostTime() { m_time = time(NULL); }
void ResetGhostTime();
CorpseType GetType() const { return m_type; }
GridCoord const& GetGridCoord() const { return _gridCoord; }
+37 -18
View File
@@ -14,6 +14,7 @@
#include "DatabaseEnv.h"
#include "Formulas.h"
#include "GameEventMgr.h"
#include "GameTime.h"
#include "GossipDef.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
@@ -46,6 +47,9 @@
#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);
@@ -268,7 +272,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool skipVisibility)
if (getDeathState() != CORPSE)
return;
m_corpseRemoveTime = time(NULL);
m_corpseRemoveTime = GameTime::GetGameTime();
setDeathState(DEAD);
RemoveAllAuras();
if (!skipVisibility) // pussywizard
@@ -281,7 +285,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool skipVisibility)
// Should get removed later, just keep "compatibility" with scripts
if (setSpawnTime)
{
m_respawnTime = time(NULL) + respawnDelay;
m_respawnTime = GameTime::GetGameTime() + respawnDelay;
//SaveRespawnTime();
}
@@ -506,7 +510,7 @@ void Creature::Update(uint32 diff)
break;
case DEAD:
{
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
if (m_respawnTime <= now)
{
bool allowed = IsAIEnabled ? AI()->CanRespawn() : true; // First check if there are any scripts that object to us respawning
@@ -548,7 +552,7 @@ void Creature::Update(uint32 diff)
}
else m_groupLootTimer -= diff;
}
else if (m_corpseRemoveTime <= time(NULL))
else if (m_corpseRemoveTime <= GameTime::GetGameTime())
{
RemoveCorpse(false);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
@@ -1477,7 +1481,7 @@ bool Creature::IsInvisibleDueToDespawn() const
if (Unit::IsInvisibleDueToDespawn())
return true;
if (IsAlive() || m_corpseRemoveTime > time(NULL))
if (IsAlive() || m_corpseRemoveTime > GameTime::GetGameTime())
return false;
return true;
@@ -1542,8 +1546,8 @@ void Creature::setDeathState(DeathState s, bool despawn)
if (s == JUST_DIED)
{
m_corpseRemoveTime = time(NULL) + m_corpseDelay;
m_respawnTime = time(NULL) + m_respawnDelay + m_corpseDelay;
m_corpseRemoveTime = GameTime::GetGameTime() + m_corpseDelay;
m_respawnTime = GameTime::GetGameTime() + m_respawnDelay + m_corpseDelay;
// always save boss respawn time at death to prevent crash cheating
if (GetMap()->IsDungeon() || isWorldBoss() || GetCreatureTemplate()->rank >= CREATURE_ELITE_ELITE)
@@ -2126,7 +2130,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() > sWorld->GetGameTime() || HasAuraType(SPELL_AURA_MOD_TAUNT)))
if (!isWorldBoss() && (GetLastDamagedTime() > GameTime::GetGameTime() || HasAuraType(SPELL_AURA_MOD_TAUNT)))
return true;
}
@@ -2294,7 +2298,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] = World::GetGameTimeMS() + unTimeMs;
m_ProhibitSchoolTime[i] = GameTime::GetGameTimeMS() + unTimeMs;
}
bool Creature::IsSpellProhibited(SpellSchoolMask idSchoolMask) const
@@ -2305,7 +2309,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] >= World::GetGameTimeMS())
if (m_ProhibitSchoolTime[i] >= GameTime::GetGameTimeMS())
return true;
return false;
@@ -2313,7 +2317,7 @@ bool Creature::IsSpellProhibited(SpellSchoolMask idSchoolMask) const
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, uint32 end_time)
{
m_CreatureSpellCooldowns[spell_id] = World::GetGameTimeMS()+end_time;
m_CreatureSpellCooldowns[spell_id] = GameTime::GetGameTimeMS()+end_time;
}
void Creature::AddSpellCooldown(uint32 spell_id, uint32 /*itemid*/, uint32 end_time, bool /*needSendToClient*/, bool /*forceSendToSpectator*/)
@@ -2360,13 +2364,13 @@ uint32 Creature::GetSpellCooldown(uint32 spell_id) const
if (itr == m_CreatureSpellCooldowns.end())
return 0;
return itr->second > World::GetGameTimeMS() ? itr->second - World::GetGameTimeMS() : 0;
return itr->second > GameTime::GetGameTimeMS() ? itr->second - GameTime::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 > World::GetGameTimeMS());
return (itr != m_CreatureSpellCooldowns.end() && itr->second > GameTime::GetGameTimeMS());
}
bool Creature::HasSpell(uint32 spellID) const
@@ -2380,13 +2384,18 @@ bool Creature::HasSpell(uint32 spellID) const
time_t Creature::GetRespawnTimeEx() const
{
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
if (m_respawnTime > now)
return m_respawnTime;
else
return now;
}
void Creature::SetRespawnTime(uint32 respawn)
{
m_respawnTime = respawn ? GameTime::GetGameTime() + respawn : 0;
}
void Creature::GetRespawnPosition(float &x, float &y, float &z, float* ori, float* dist) const
{
if (m_DBTableGuid)
@@ -2431,7 +2440,7 @@ void Creature::AllLootRemovedFromCorpse()
{
if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE))
{
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
if (m_corpseRemoveTime <= now)
return;
@@ -2445,7 +2454,7 @@ void Creature::AllLootRemovedFromCorpse()
// corpse skinnable, but without skinning flag, and then skinned, corpse will despawn next update
if (cinfo && cinfo->SkinLootId)
m_corpseRemoveTime = time(NULL);
m_corpseRemoveTime = GameTime::GetGameTime();
else
m_corpseRemoveTime -= diff;
}
@@ -2499,7 +2508,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
VendorItemCount* vCount = &*itr;
time_t ptime = time(NULL);
time_t ptime = GameTime::GetGameTime();
if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime)
{
@@ -2538,7 +2547,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
VendorItemCount* vCount = &*itr;
time_t ptime = time(NULL);
time_t ptime = GameTime::GetGameTime();
if (time_t(vCount->lastIncrementTime + vItem->incrtime) <= ptime)
{
@@ -2857,3 +2866,13 @@ 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());
}
+4 -5
View File
@@ -370,8 +370,7 @@ struct VendorItemData
struct VendorItemCount
{
explicit VendorItemCount(uint32 _item, uint32 _count)
: itemId(_item), count(_count), lastIncrementTime(time(NULL)) {}
VendorItemCount(uint32 _item, uint32 _count);
uint32 itemId;
uint32 count;
@@ -573,8 +572,8 @@ class Creature : public Unit, public GridObject<Creature>, 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 { return lootPickPocketRestoreTime == 0 || lootPickPocketRestoreTime < time(NULL); }
void SetPickPocketLootTime() { lootPickPocketRestoreTime = time(NULL) + MINUTE + GetCorpseDelay() + GetRespawnTime(); }
bool CanGeneratePickPocketLoot() const;
void SetPickPocketLootTime();
void ResetPickPocketLootTime() { lootPickPocketRestoreTime = 0; }
void SetLootRecipient (Unit* unit, bool withGroup = true);
@@ -627,7 +626,7 @@ class Creature : public Unit, public GridObject<Creature>, public MovableMapObje
time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const;
void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; }
void SetRespawnTime(uint32 respawn);
void Respawn(bool force = false);
void SaveRespawnTime();
@@ -10,6 +10,7 @@
#include "World.h"
#include "ObjectAccessor.h"
#include "DatabaseEnv.h"
#include "GameTime.h"
#include "GridNotifiers.h"
#include "CellImpl.h"
#include "GridNotifiersImpl.h"
@@ -107,7 +108,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, World::GetGameTimeMS());
SetUInt32Value(DYNAMICOBJECT_CASTTIME, GameTime::GetGameTimeMS());
if (IsWorldObject())
setActive(true); //must before add to map to be put in world container
@@ -6,6 +6,7 @@
#include <G3D/Quat.h>
#include "GameObjectAI.h"
#include "GameTime.h"
#include "BattlegroundAV.h"
#include "CellImpl.h"
#include "CreatureAISelector.h"
@@ -376,9 +377,9 @@ void GameObject::Update(uint32 diff)
GameObjectTemplate const* goInfo = GetGOInfo();
// Bombs
if (goInfo->trap.type == 2)
m_cooldownTime = World::GetGameTimeMS()+10*IN_MILLISECONDS; // Hardcoded tooltip value
m_cooldownTime = GameTime::GetGameTimeMS()+10*IN_MILLISECONDS; // Hardcoded tooltip value
else if (GetOwner())
m_cooldownTime = World::GetGameTimeMS()+goInfo->trap.startDelay*IN_MILLISECONDS;
m_cooldownTime = GameTime::GetGameTimeMS()+goInfo->trap.startDelay*IN_MILLISECONDS;
m_lootState = GO_READY;
break;
@@ -386,7 +387,7 @@ void GameObject::Update(uint32 diff)
case GAMEOBJECT_TYPE_FISHINGNODE:
{
// fishing code (bobber ready)
if (time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME)
if (GameTime::GetGameTime() > m_respawnTime - FISHING_BOBBER_READY_TIME)
{
// splash bobber (bobber ready now)
Unit* caster = GetOwner();
@@ -410,7 +411,7 @@ void GameObject::Update(uint32 diff)
}
case GAMEOBJECT_TYPE_SUMMONING_RITUAL:
{
if (World::GetGameTimeMS() < m_cooldownTime)
if (GameTime::GetGameTimeMS() < m_cooldownTime)
return;
GameObjectTemplate const* info = GetGOInfo();
if (info->summoningRitual.animSpell)
@@ -484,7 +485,7 @@ void GameObject::Update(uint32 diff)
{
if (m_respawnTime > 0) // timer on
{
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
if (m_respawnTime <= now) // timer expired
{
uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_GAMEOBJECT);
@@ -560,7 +561,7 @@ void GameObject::Update(uint32 diff)
GameObjectTemplate const* goInfo = GetGOInfo();
if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
{
if (World::GetGameTimeMS() < m_cooldownTime)
if (GameTime::GetGameTimeMS() < m_cooldownTime)
break;
// Type 2 - Bomb (will go away after casting it's spell)
@@ -620,7 +621,7 @@ void GameObject::Update(uint32 diff)
if (goInfo->trap.spellId)
CastSpell(target, goInfo->trap.spellId);
m_cooldownTime = World::GetGameTimeMS()+(goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4))*IN_MILLISECONDS; // template or 4 seconds
m_cooldownTime = GameTime::GetGameTimeMS()+(goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4))*IN_MILLISECONDS; // template or 4 seconds
if (goInfo->trap.type == 1)
SetLootState(GO_JUST_DEACTIVATED);
@@ -652,11 +653,11 @@ void GameObject::Update(uint32 diff)
{
case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON:
if (GetGOInfo()->GetAutoCloseTime() && World::GetGameTimeMS() >= m_cooldownTime)
if (GetGOInfo()->GetAutoCloseTime() && GameTime::GetGameTimeMS() >= m_cooldownTime)
ResetDoorOrButton();
break;
case GAMEOBJECT_TYPE_GOOBER:
if (World::GetGameTimeMS() >= m_cooldownTime)
if (GameTime::GetGameTimeMS() >= m_cooldownTime)
{
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
@@ -728,7 +729,7 @@ void GameObject::Update(uint32 diff)
return;
}
m_respawnTime = time(NULL) + m_respawnDelayTime;
m_respawnTime = GameTime::GetGameTime() + m_respawnDelayTime;
// if option not set then object will be saved at grid unload
if (GetMap()->IsDungeon())
@@ -941,7 +942,7 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
m_respawnTime = GetMap()->GetGORespawnTime(m_DBTableGuid);
// ready to respawn
if (m_respawnTime && m_respawnTime <= time(NULL))
if (m_respawnTime && m_respawnTime <= GameTime::GetGameTime())
{
m_respawnTime = 0;
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
@@ -1025,7 +1026,7 @@ Unit* GameObject::GetOwner() const
void GameObject::SaveRespawnTime()
{
if (m_goData && m_goData->dbData && m_respawnTime > time(NULL) && m_spawnedByDefault)
if (m_goData && m_goData->dbData && m_respawnTime > GameTime::GetGameTime() && m_spawnedByDefault)
GetMap()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime);
}
@@ -1080,11 +1081,26 @@ 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 = time(NULL);
m_respawnTime = GameTime::GetGameTime();
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
}
}
@@ -1212,7 +1228,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
SwitchDoorOrButton(true, alternative);
SetLootState(GO_ACTIVATED, user);
m_cooldownTime = World::GetGameTimeMS()+time_to_restore;
m_cooldownTime = GameTime::GetGameTimeMS()+time_to_restore;
}
void GameObject::SetGoArtKit(uint8 kit)
@@ -1279,10 +1295,10 @@ void GameObject::Use(Unit* user)
// If cooldown data present in template
if (uint32 cooldown = GetGOInfo()->GetCooldown())
{
if (World::GetGameTimeMS() < m_cooldownTime)
if (GameTime::GetGameTimeMS() < m_cooldownTime)
return;
m_cooldownTime = World::GetGameTimeMS()+cooldown*IN_MILLISECONDS;
m_cooldownTime = GameTime::GetGameTimeMS()+cooldown*IN_MILLISECONDS;
}
switch (GetGoType())
@@ -1316,7 +1332,7 @@ void GameObject::Use(Unit* user)
if (goInfo->trap.spellId)
CastSpell(user, goInfo->trap.spellId);
m_cooldownTime = World::GetGameTimeMS()+(goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4))*IN_MILLISECONDS; // template or 4 seconds
m_cooldownTime = GameTime::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);
@@ -1469,7 +1485,7 @@ void GameObject::Use(Unit* user)
if (info->goober.customAnim)
SendCustomAnim(GetGoAnimProgress());
m_cooldownTime = World::GetGameTimeMS()+info->GetAutoCloseTime();
m_cooldownTime = GameTime::GetGameTimeMS()+info->GetAutoCloseTime();
// cast this spell later if provided
spellId = info->goober.spellId;
@@ -1643,7 +1659,7 @@ void GameObject::Use(Unit* user)
if (!info->summoningRitual.animSpell)
m_cooldownTime = 0;
else // channel ready, maintain this
m_cooldownTime = World::GetGameTimeMS()+5*IN_MILLISECONDS;
m_cooldownTime = GameTime::GetGameTimeMS()+5*IN_MILLISECONDS;
}
return;
@@ -2196,6 +2212,11 @@ void GameObject::SetLootState(LootState state, Unit* unit)
}*/
}
void GameObject::SetLootGenerationTime()
{
m_lootGenerationTime = GameTime::GetGameTime();
}
void GameObject::SetGoState(GOState state)
{
SetByteValue(GAMEOBJECT_BYTES_1, 0, state);
@@ -700,20 +700,9 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Mov
uint32 GetSpellId() const { return m_spellId;}
time_t GetRespawnTime() const { return m_respawnTime; }
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;
}
time_t GetRespawnTimeEx() const;
void SetRespawnTime(int32 respawn);
void Respawn();
bool isSpawned() const
{
@@ -782,7 +771,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, 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() { m_lootGenerationTime = time(NULL); }
void SetLootGenerationTime();
uint32 GetLootGenerationTime() const { return m_lootGenerationTime; }
bool hasQuest(uint32 quest_id) const;
+4 -3
View File
@@ -9,6 +9,7 @@
#include "ObjectMgr.h"
#include "WorldPacket.h"
#include "DatabaseEnv.h"
#include "GameTime.h"
#include "ItemEnchantmentMgr.h"
#include "SpellMgr.h"
#include "SpellInfo.h"
@@ -236,7 +237,7 @@ Item::Item()
m_container = NULL;
m_lootGenerated = false;
mb_in_trade = false;
m_lastPlayedTimeUpdate = time(NULL);
m_lastPlayedTimeUpdate = GameTime::GetGameTime();
m_refundRecipient = 0;
m_paidMoney = 0;
@@ -1140,7 +1141,7 @@ void Item::UpdatePlayedTime(Player* owner)
// Get current played time
uint32 current_playtime = GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME);
// Calculate time elapsed since last played time update
time_t curtime = time(NULL);
time_t curtime = GameTime::GetGameTime();
uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);
uint32 new_playtime = current_playtime + elapsed;
// Check if the refund timer has expired yet
@@ -1161,7 +1162,7 @@ void Item::UpdatePlayedTime(Player* owner)
uint32 Item::GetPlayedTime()
{
time_t curtime = time(NULL);
time_t curtime = GameTime::GetGameTime();
uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);
return GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + elapsed;
}
+4 -3
View File
@@ -15,6 +15,7 @@
#include "Player.h"
#include "Vehicle.h"
#include "ObjectMgr.h"
#include "GameTime.h"
#include "UpdateData.h"
#include "UpdateMask.h"
#include "Util.h"
@@ -940,7 +941,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(::time(NULL)));
sLog->outString("time %u current time " UI64FMTD "", flags2, uint64(::GameTime::GetGameTime()));
sLog->outString("position: `%s`", pos.ToString().c_str());
if (flags & MOVEMENTFLAG_ONTRANSPORT)
{
@@ -2885,13 +2886,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, World::GetGameTimeMS());
uint32 diff = getMSTimeDiff(u->m_last_notify_mstime, GameTime::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 = World::GetGameTimeMS()+EVENT_VISIBILITY_DELAY-1;
u->m_last_notify_mstime = GameTime::GetGameTimeMS()+EVENT_VISIBILITY_DELAY-1;
}
else if (f & NOTIFY_AI_RELOCATION)
{
+9 -8
View File
@@ -9,6 +9,7 @@
#include "Log.h"
#include "WorldPacket.h"
#include "ObjectMgr.h"
#include "GameTime.h"
#include "SpellMgr.h"
#include "Pet.h"
#include "Formulas.h"
@@ -237,7 +238,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, time(NULL));
stmt->setUInt32(15, GameTime::GetGameTime());
std::ostringstream ss;
for (uint32 i = ACTION_BAR_INDEX_START; i < ACTION_BAR_INDEX_END; ++i)
@@ -321,7 +322,7 @@ void Pet::Update(uint32 diff)
{
case CORPSE:
{
if (getPetType() != HUNTER_PET || m_corpseRemoveTime <= time(NULL))
if (getPetType() != HUNTER_PET || m_corpseRemoveTime <= GameTime::GetGameTime())
{
Remove(PET_SAVE_NOT_IN_SLOT); //hunters' pets never get removed because of death, NEVER!
return;
@@ -1059,7 +1060,7 @@ void Pet::_LoadSpellCooldowns(PreparedQueryResult result)
if (result)
{
time_t curTime = time(NULL);
time_t curTime = GameTime::GetGameTime();
PacketCooldowns cooldowns;
WorldPacket data;
@@ -1105,8 +1106,8 @@ void Pet::_SaveSpellCooldowns(SQLTransaction& trans, bool logout)
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
trans->Append(stmt);
time_t curTime = time(NULL);
uint32 checkTime = World::GetGameTimeMS() + 30*IN_MILLISECONDS;
time_t curTime = GameTime::GetGameTime();
uint32 checkTime = GameTime::GetGameTimeMS() + 30*IN_MILLISECONDS;
// remove oudated and save active
CreatureSpellCooldowns::iterator itr, itr2;
@@ -1114,11 +1115,11 @@ void Pet::_SaveSpellCooldowns(SQLTransaction& trans, bool logout)
{
itr2 = itr;
++itr;
if (itr2->second <= World::GetGameTimeMS()+1000)
if (itr2->second <= GameTime::GetGameTimeMS()+1000)
m_CreatureSpellCooldowns.erase(itr2);
else if (logout || itr2->second > checkTime)
{
uint32 cooldown = ((itr2->second-World::GetGameTimeMS())/IN_MILLISECONDS) + curTime;
uint32 cooldown = ((itr2->second-GameTime::GetGameTimeMS())/IN_MILLISECONDS) + curTime;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL_COOLDOWN);
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
stmt->setUInt32(1, itr2->first);
@@ -2143,7 +2144,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(time(NULL))); // 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
}
map->AddToMap(pet->ToCreature(), true);
+91 -57
View File
@@ -27,6 +27,7 @@
#include "DisableMgr.h"
#include "Formulas.h"
#include "GameEventMgr.h"
#include "GameTime.h"
#include "GossipDef.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
@@ -774,7 +775,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(NULL);
m_logintime = GameTime::GetGameTime();
m_Last_tick = m_logintime;
m_Played_time[PLAYED_TIME_TOTAL] = 0;
m_Played_time[PLAYED_TIME_LEVEL] = 0;
@@ -847,7 +848,7 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
m_spellPenetrationItemMod = 0;
// Honor System
m_lastHonorUpdateTime = time(NULL);
m_lastHonorUpdateTime = GameTime::GetGameTime();
m_IsBGRandomWinner = false;
@@ -1101,7 +1102,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo)
}
// Played time
m_Last_tick = time(NULL);
m_Last_tick = GameTime::GetGameTime();
m_Played_time[PLAYED_TIME_TOTAL] = 0;
m_Played_time[PLAYED_TIME_LEVEL] = 0;
@@ -1544,7 +1545,7 @@ void Player::Update(uint32 p_time)
sScriptMgr->OnBeforePlayerUpdate(this, p_time);
// undelivered mail
if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL))
if (m_nextMailDelivereTime && m_nextMailDelivereTime <= GameTime::GetGameTime())
{
SendNewMail();
++unReadMails;
@@ -1558,7 +1559,7 @@ void Player::Update(uint32 p_time)
Unit::Update(p_time);
SetMustDelayTeleport(false);
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
UpdatePvPFlag(now);
@@ -1709,7 +1710,7 @@ void Player::Update(uint32 p_time)
{
if (now > m_Last_tick && _restTime > 0) // freeze update
{
time_t currTime = time(NULL);
time_t currTime = GameTime::GetGameTime();
time_t timeDiff = currTime - _restTime;
if (timeDiff >= 10) // freeze update
{
@@ -1958,7 +1959,7 @@ void Player::setDeathState(DeathState s, bool /*despawn = false*/)
void Player::SetRestState(uint32 triggerId)
{
_innTriggerId = triggerId;
_restTime = time(NULL);
_restTime = GameTime::GetGameTime();
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
}
@@ -2274,7 +2275,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (MustDelayTeleport())
{
SetHasDelayedTeleport(true);
SetSemaphoreTeleportNear(time(NULL));
SetSemaphoreTeleportNear(GameTime::GetGameTime());
//lets save teleport destination for player
teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
teleportStore_options = options;
@@ -2296,11 +2297,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(NULL), z);
SetFallInformation(GameTime::GetGameTime(), z);
// code for finish transfer called in WorldSession::HandleMovementOpcodes()
// at client packet MSG_MOVE_TELEPORT_ACK
SetSemaphoreTeleportNear(time(NULL));
SetSemaphoreTeleportNear(GameTime::GetGameTime());
// near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing
if (!GetSession()->PlayerLogout())
{
@@ -2336,7 +2337,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (MustDelayTeleport())
{
SetHasDelayedTeleport(true);
SetSemaphoreTeleportFar(time(NULL));
SetSemaphoreTeleportFar(GameTime::GetGameTime());
//lets save teleport destination for player
teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
teleportStore_options = options;
@@ -2403,7 +2404,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
}
teleportStore_dest = WorldLocation(mapid, x, y, z, orientation);
SetFallInformation(time(NULL), z);
SetFallInformation(GameTime::GetGameTime(), z);
// if the player is saved before worldportack (at logout for example)
// this will be used instead of the current location in SaveToDB
@@ -2422,7 +2423,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(NULL));
SetSemaphoreTeleportFar(GameTime::GetGameTime());
}
}
return true;
@@ -3468,8 +3469,8 @@ void Player::InitStatsForLevel(bool reapplyMods)
void Player::SendInitialSpells()
{
uint32 curTime = World::GetGameTimeMS();
uint32 infTime = World::GetGameTimeMS()+infinityCooldownDelayCheck;
uint32 curTime = GameTime::GetGameTimeMS();
uint32 infTime = GameTime::GetGameTimeMS()+infinityCooldownDelayCheck;
uint16 spellCount = 0;
@@ -3597,7 +3598,7 @@ void Player::UpdateNextMailTimeAndUnreads()
{
// calculate next delivery time (min. from non-delivered mails
// and recalculate unReadMail
time_t cTime = time(NULL);
time_t cTime = GameTime::GetGameTime();
m_nextMailDelivereTime = 0;
unReadMails = 0;
for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
@@ -3614,7 +3615,7 @@ void Player::UpdateNextMailTimeAndUnreads()
void Player::AddNewMailDeliverTime(time_t deliver_time)
{
if (deliver_time <= time(NULL)) // ready now
if (deliver_time <= GameTime::GetGameTime()) // ready now
{
++unReadMails;
SendNewMail();
@@ -4257,7 +4258,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()+infinityCooldownDelayCheck;
SpellCooldowns::iterator itr, next;
for (itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); itr = next)
{
@@ -4289,7 +4290,7 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns)
void Player::RemoveAllSpellCooldown()
{
uint32 infTime = World::GetGameTimeMS()+infinityCooldownDelayCheck;
uint32 infTime = GameTime::GetGameTimeMS()+infinityCooldownDelayCheck;
if (!m_spellCooldowns.empty())
{
for (SpellCooldowns::const_iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); ++itr)
@@ -4308,7 +4309,7 @@ void Player::_LoadSpellCooldowns(PreparedQueryResult result)
if (result)
{
time_t curTime = time(NULL);
time_t curTime = GameTime::GetGameTime();
do
{
@@ -4344,8 +4345,8 @@ void Player::_SaveSpellCooldowns(SQLTransaction& trans, bool logout)
stmt->setUInt32(0, GetGUIDLow());
trans->Append(stmt);
time_t curTime = time(NULL);
uint32 curMSTime = World::GetGameTimeMS();
time_t curTime = GameTime::GetGameTime();
uint32 curMSTime = GameTime::GetGameTimeMS();
uint32 infTime = curMSTime + infinityCooldownDelayCheck;
bool first_round = true;
@@ -4399,7 +4400,7 @@ uint32 Player::resetTalentsCost() const
return 10*GOLD;
else
{
uint64 months = (sWorld->GetGameTime() - m_resetTalentsTime)/MONTH;
uint64 months = (GameTime::GetGameTime() - m_resetTalentsTime)/MONTH;
if (months > 0)
{
// This cost will be reduced by a rate of 5 gold per month
@@ -4508,7 +4509,7 @@ bool Player::resetTalents(bool noResetCost)
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS, 1);
m_resetTalentsCost = resetCost;
m_resetTalentsTime = time(NULL);
m_resetTalentsTime = GameTime::GetGameTime();
}
return true;
@@ -5049,7 +5050,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(time(NULL) - time_t(keepDays * DAY)));
stmt->setUInt32(0, uint32(GameTime::GetGameTime() - time_t(keepDays * DAY)));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
@@ -7166,8 +7167,8 @@ void Player::RewardReputation(Quest const* quest)
void Player::UpdateHonorFields()
{
/// called when rewarding honor and at each save
time_t now = time_t(time(NULL));
time_t today = time_t(time(NULL) / DAY) * DAY;
time_t now = time_t(GameTime::GetGameTime());
time_t today = time_t(GameTime::GetGameTime() / DAY * DAY);
if (m_lastHonorUpdateTime < today)
{
@@ -8977,7 +8978,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() < time(NULL))
if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && go->GetLootGenerationTime()+go->GetRespawnDelay() < GameTime::GetGameTime())
go->SetLootState(GO_READY);
if (go->getLootState() == GO_READY)
@@ -10015,7 +10016,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(NULL) + (wg->GetTimer() / 1000)));
SendUpdateWorldState(ClockWorldState[i], uint32(GameTime::GetGameTime() + (wg->GetTimer() / 1000)));
}
}
}
@@ -13916,7 +13917,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem)
#endif
m_items[slot] = pItem;
time_t base = time(NULL);
time_t base = GameTime::GetGameTime();
uint32 etime = uint32(base - m_logintime + (30 * 3600));
uint32 eslot = slot - BUYBACK_SLOT_START;
@@ -15670,7 +15671,7 @@ void Player::AddQuest(Quest const* quest, Object* questGiver)
AddTimedQuest(quest_id);
questStatusData.Timer = timeAllowed * IN_MILLISECONDS;
qtime = static_cast<uint32>(time(NULL)) + timeAllowed;
qtime = static_cast<uint32>(GameTime::GetGameTime()) + timeAllowed;
}
else
questStatusData.Timer = 0;
@@ -18059,7 +18060,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
SaveRecallPosition();
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
time_t logoutTime = time_t(fields[27].GetUInt32());
// since last logout (in seconds)
@@ -18227,7 +18228,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
SetUInt32Value(PLAYER_CHOSEN_TITLE, curTitle);
// has to be called after last Relocate() in Player::LoadFromDB
SetFallInformation(time(NULL), GetPositionZ());
SetFallInformation(GameTime::GetGameTime(), GetPositionZ());
_LoadSpellCooldowns(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_SPELL_COOLDOWNS));
@@ -19095,10 +19096,10 @@ void Player::_LoadQuestStatus(PreparedQueryResult result)
{
AddTimedQuest(quest_id);
if (quest_time <= sWorld->GetGameTime())
if (quest_time <= GameTime::GetGameTime())
questStatusData.Timer = 1;
else
questStatusData.Timer = uint32((quest_time - sWorld->GetGameTime()) * IN_MILLISECONDS);
questStatusData.Timer = uint32((quest_time - GameTime::GetGameTime()) * IN_MILLISECONDS);
}
else
quest_time = 0;
@@ -19363,7 +19364,7 @@ void Player::SendRaidInfo()
size_t p_counter = data.wpos();
data << uint32(counter); // placeholder
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
@@ -20033,7 +20034,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+ sWorld->GetGameTime()));
stmt->setUInt32(index++, uint32(statusItr->second.Timer / IN_MILLISECONDS+ GameTime::GetGameTime()));
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
stmt->setUInt16(index++, statusItr->second.CreatureOrGOCount[i]);
@@ -20956,7 +20957,7 @@ void Player::PetSpellInitialize()
uint8 cooldownsCount = pet->m_CreatureSpellCooldowns.size();
data << uint8(cooldownsCount);
uint32 curTime = World::GetGameTimeMS();
uint32 curTime = GameTime::GetGameTimeMS();
for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr)
{
@@ -21050,7 +21051,7 @@ void Player::VehicleSpellInitialize()
// Cooldowns
data << uint8(cooldownCount);
uint32 curTime = World::GetGameTimeMS();
uint32 curTime = GameTime::GetGameTimeMS();
for (CreatureSpellCooldowns::const_iterator itr = vehicle->m_CreatureSpellCooldowns.begin(); itr != vehicle->m_CreatureSpellCooldowns.end(); ++itr)
{
@@ -22231,7 +22232,7 @@ void Player::UpdatePvPState(bool onlyFFA)
else // in friendly area
{
if (IsPvP() && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) && pvpInfo.EndTimer == 0)
pvpInfo.EndTimer = time(NULL); // start toggle-off
pvpInfo.EndTimer = GameTime::GetGameTime(); // start toggle-off
}
}
@@ -22244,7 +22245,7 @@ void Player::UpdatePvP(bool state, bool _override)
}
else
{
pvpInfo.EndTimer = time(NULL);
pvpInfo.EndTimer = GameTime::GetGameTime();
SetPvP(state);
}
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER);
@@ -22368,7 +22369,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 = World::GetGameTimeMS()+end_time;
sc.end = GameTime::GetGameTimeMS()+end_time;
sc.itemid = itemid;
sc.maxduration = end_time;
sc.sendToSpectator = false;
@@ -22651,7 +22652,7 @@ void Player::LeaveBattleground(Battleground* bg)
}
// xinef: reset corpse reclaim time
m_deathExpireTime = time(NULL);
m_deathExpireTime = GameTime::GetGameTime();
// pussywizard: clear movement, because after porting player will move to arena cords
GetMotionMaster()->MovementExpired();
@@ -23120,7 +23121,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
SendEquipmentSetList();
data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4);
data.AppendPackedTime(sWorld->GetGameTime());
data.AppendPackedTime(GameTime::GetGameTime());
data << float(0.01666667f); // game speed
data << uint32(0); // added in 3.1.2
GetSession()->SendPacket(&data);
@@ -23302,7 +23303,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 > time(NULL) + 30)
if (itr != m_spellCooldowns.end() && itr->second.itemid == pItem->GetEntry() && itr->second.end > GameTime::GetGameTime() + 30)
continue;
// xinef: dont apply eqiup cooldown for spells with this attribute
@@ -23474,7 +23475,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(NULL); // last daily quest time
m_lastDailyQuestTime = GameTime::GetGameTime(); // last daily quest time
m_DailyQuestChanged = true;
break;
}
@@ -23482,7 +23483,7 @@ void Player::SetDailyQuestStatus(uint32 quest_id)
} else
{
m_DFQuests.insert(quest_id);
m_lastDailyQuestTime = time(NULL);
m_lastDailyQuestTime = GameTime::GetGameTime();
m_DailyQuestChanged = true;
}
}
@@ -23740,7 +23741,7 @@ void Player::SummonIfPossible(bool agree, uint32 summoner_guid)
}
// expire and auto declined
if (m_summon_expire < time(NULL))
if (m_summon_expire < GameTime::GetGameTime())
return;
// drop flag at summon
@@ -24262,7 +24263,7 @@ uint32 Player::GetCorpseReclaimDelay(bool pvp) const
else if (!sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE))
return 0;
time_t now = time(NULL);
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;
@@ -24277,7 +24278,7 @@ void Player::UpdateCorpseReclaimDelay()
(!pvp && !sWorld->getBoolConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE)))
return;
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
if (now < m_deathExpireTime)
{
@@ -24321,7 +24322,7 @@ int32 Player::CalculateCorpseReclaimDelay(bool load)
}
time_t expected_time = corpse->GetGhostTime() + copseReclaimDelay[count];
time_t now = time(NULL);
time_t now = GameTime::GetGameTime();
if (now >= expected_time)
return -1;
@@ -26287,7 +26288,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(time(NULL)));
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
@@ -26419,7 +26420,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(time(NULL)));
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
@@ -26867,7 +26868,7 @@ void Player::ResetTimeSync()
m_timeSyncCounter = 0;
m_timeSyncTimer = 0;
m_timeSyncClient = 0;
m_timeSyncServer = World::GetGameTimeMS();
m_timeSyncServer = GameTime::GetGameTimeMS();
}
void Player::SendTimeSync()
@@ -26878,7 +26879,7 @@ void Player::SendTimeSync()
// Schedule next sync in 10 sec
m_timeSyncTimer = 10000;
m_timeSyncServer = World::GetGameTimeMS();
m_timeSyncServer = GameTime::GetGameTimeMS();
}
void Player::SetReputation(uint32 factionentry, uint32 value)
@@ -27330,7 +27331,7 @@ void Player::_LoadBrewOfTheMonth(PreparedQueryResult result)
lastEventId = fields[0].GetUInt32();
}
time_t curtime = time(NULL);
time_t curtime = GameTime::GetGameTime();
tm localTime;
ACE_OS::localtime_r(&curtime, &localTime);
@@ -27413,7 +27414,7 @@ bool Player::SetCanFly(bool apply, bool packetOnly /*= false*/)
return false;
if (!apply)
SetFallInformation(time(NULL), GetPositionZ());
SetFallInformation(GameTime::GetGameTime(), GetPositionZ());
WorldPacket data(apply ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY, 12);
data.append(GetPackGUID());
@@ -27497,3 +27498,36 @@ 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);
}
+5 -25
View File
@@ -1104,16 +1104,8 @@ class Player : public Unit, public GridObject<Player>
}
bool TeleportToEntryPoint();
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 SetSummonPoint(uint32 mapid, float x, float y, float z, uint32 delay = 0, bool asSpectator = false);
bool IsSummonAsSpectator() const;
void SetSummonAsSpectator(bool on) { m_summon_asSpectator = on; }
void SummonIfPossible(bool agree, uint32 summoner_guid);
time_t GetSummonExpireTimer() const { return m_summon_expire; }
@@ -1738,21 +1730,9 @@ class Player : public Unit, public GridObject<Player>
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
{
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);
}
virtual bool HasSpellCooldown(uint32 spell_id) const;
virtual bool HasSpellItemCooldown(uint32 spell_id, uint32 itemid) const;
uint32 GetSpellCooldownDelay(uint32 spell_id) const;
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);
@@ -16,6 +16,7 @@
#include "Vehicle.h"
#include "MapReference.h"
#include "Player.h"
#include "GameTime.h"
#include "Cell.h"
#include "CellImpl.h"
#include "WorldModel.h"
@@ -281,7 +282,7 @@ void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll)
if (Player* plr = passenger->ToPlayer())
{
sScriptMgr->OnRemovePassenger(ToTransport(), plr);
plr->SetFallInformation(time(NULL), plr->GetPositionZ());
plr->SetFallInformation(GameTime::GetGameTime(), plr->GetPositionZ());
}
if (withAll)
@@ -955,7 +956,7 @@ void StaticTransport::RemovePassenger(WorldObject* passenger, bool withAll)
if (Player* plr = passenger->ToPlayer())
{
sScriptMgr->OnRemovePassenger(ToTransport(), plr);
plr->SetFallInformation(time(NULL), plr->GetPositionZ());
plr->SetFallInformation(GameTime::GetGameTime(), plr->GetPositionZ());
}
if (withAll)
+18 -18
View File
@@ -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, World::GetGameTimeMS()) < itr->second.duration;
return itr != m_GlobalCooldowns.end() && itr->second.duration && getMSTimeDiff(itr->second.cast_time, GameTime::GetGameTimeMS()) < itr->second.duration;
}
void GlobalCooldownMgr::AddGlobalCooldown(SpellInfo const* spellInfo, uint32 gcd)
{
m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, World::GetGameTimeMS());
m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, GameTime::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 << World::GetGameTimeMS();
data << GameTime::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(sWorld->GetGameTime()+MAX_AGGRO_RESET_TIME);
victim->ToCreature()->SetLastDamagedTime(GameTime::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) > (time(NULL) + aura->GetDuration()/1000))
if ((aura->GetApplyTime() + aura->GetMaxDuration()/1000 + 8) > (GameTime::GetGameTime() + 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) > (time(NULL) + aur->GetDuration()/1000) )
if ((aur->GetApplyTime() + aur->GetMaxDuration()/1000 + 5) > (GameTime::GetGameTime() + 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(sWorld->GetGameTime()); // Packet counter
data << uint32(GameTime::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(sWorld->GetGameTime()); // Packet counter
data << uint32(GameTime::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(), sWorld->GetGameTime(), v))
if (isTargetNotAcceptableByMMaps(v->GetGUID(), GameTime::GetGameTime(), v))
if (_CanDetectFeignDeathOf(v) && CanCreatureAttack(v))
{
if (m_mmapNotAcceptableStartTime)
{
if (sWorld->GetGameTime() <= m_mmapNotAcceptableStartTime+4)
if (GameTime::GetGameTime() <= m_mmapNotAcceptableStartTime+4)
return NULL;
}
else
{
m_mmapNotAcceptableStartTime = sWorld->GetGameTime();
m_mmapNotAcceptableStartTime = GameTime::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, World::GetGameTimeMS()) > 15000)
if (i->stack == 0 && getMSTimeDiff(i->hitTime, GameTime::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, World::GetGameTimeMS(), DIMINISHING_LEVEL_2));
m_Diminishing.push_back(DiminishingReturn(group, GameTime::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 = World::GetGameTimeMS();
i->hitTime = GameTime::GetGameTimeMS();
}
break;
}
@@ -15919,7 +15919,7 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized)
bool Unit::IsUnderLastManaUseEffect() const
{
return getMSTimeDiff(m_lastManaUse, World::GetGameTimeMS()) < 5000;
return getMSTimeDiff(m_lastManaUse, GameTime::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(time(NULL))); // cast can't be helped
SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // 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(time(NULL), GetPositionZ());
player->SetFallInformation(GameTime::GetGameTime(), 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(World::GetGameTimeMS()); // time / counter
*data << uint32(GameTime::GetGameTimeMS()); // time / counter
*data << GetPositionX();
*data << GetPositionY();
*data << GetPositionZ() + GetHoverHeight();