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

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