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

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);