Core/Objects: ported Heartbeat implementation fron master branch

This commit is contained in:
Ovahlord committed 2025-03-09 02:40:05 +01:00
1 parent 352ce7e1b3
commit e8588fd5ba
30 files changed
+257 -184

No files matched your search

+31 -16
View File
@@ -413,7 +413,7 @@ void Unit::Update(uint32 p_time)
// WARNING! Order of execution here is important, do not change.
// Spells must be processed with event system BEFORE they go to _UpdateSpells.
// Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
m_Events.Update(p_time);
WorldObject::Update(p_time);
CheckPendingMovementAcks();
@@ -503,6 +503,25 @@ void Unit::Update(uint32 p_time)
RefreshAI();
}
void Unit::Heartbeat()
{
WorldObject::Heartbeat();
// SMSG_FLIGHT_SPLINE_SYNC for cyclic splines
SendFlightSplineSyncUpdate();
// Trigger heartbeat procs and generic aura behavior such as food emotes and invoking aura script hooks
TriggerAuraHeartbeat();
}
void Unit::TriggerAuraHeartbeat()
{
for (auto const& [_, auraApplication] : m_appliedAuras)
auraApplication->GetBase()->Heartbeat();
Unit::ProcSkillsAndAuras(this, nullptr, PROC_FLAG_HEARTBEAT, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_NONE, PROC_HIT_NONE, nullptr, nullptr, nullptr);
}
bool Unit::haveOffhandWeapon() const
{
if (Player const* player = ToPlayer())
@@ -527,20 +546,6 @@ void Unit::UpdateSplineMovement(uint32 t_diff)
movespline->updateState(t_diff);
bool arrived = movespline->Finalized();
if (movespline->isCyclic())
{
m_splineSyncTimer.Update(t_diff);
if (m_splineSyncTimer.Passed())
{
m_splineSyncTimer.Reset(5000); // Retail value, do not change
WorldPackets::Movement::FlightSplineSync packet;
packet.Guid = GetGUID();
packet.SplineDist = Movement::PacketBuilder::GetFlightSplineSyncDist(*movespline);
SendMessageToSet(packet.Write(), IsPlayer());
}
}
if (arrived)
{
DisableSpline();
@@ -575,6 +580,17 @@ void Unit::UpdateSplinePosition()
UpdatePosition(loc.x, loc.y, loc.z, loc.orientation);
}
void Unit::SendFlightSplineSyncUpdate()
{
if (!movespline->isCyclic() || movespline->Finalized())
return;
WorldPackets::Movement::FlightSplineSync flightSplineSync;
flightSplineSync.Guid = GetGUID();
flightSplineSync.SplineDist = float(movespline->timePassed()) / movespline->Duration();
SendMessageToSet(flightSplineSync.Write(), true);
}
void Unit::InterruptMovementBasedAuras()
{
// TODO: Check if orientation transport offset changed instead of only global orientation
@@ -9625,7 +9641,6 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup)
if (finalCleanup)
m_cleanupDone = true;
m_Events.KillAllEvents(false); // non-delatable (currently cast spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
CombatStop();
ClearComboPointHolders();
}