Skip to content

Commit d8cde00

Browse files
committed
Core/Units: moved cyclic spline synchronization mechanic heartbeat handling
(cherry picked from commit c2fedbb6cc89510002e9f56751e7f8427e306487)
1 parent 4aabcc3 commit d8cde00

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

src/server/game/Entities/Unit/Unit.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,14 @@ void Unit::Update(uint32 p_time)
499499
RefreshAI();
500500
}
501501

502+
void Unit::Heartbeat()
503+
{
504+
WorldObject::Heartbeat();
505+
506+
// SMSG_FLIGHT_SPLINE_SYNC for cyclic splines
507+
SendFlightSplineSyncUpdate();
508+
}
509+
502510
bool Unit::haveOffhandWeapon() const
503511
{
504512
if (Player const* player = ToPlayer())
@@ -525,20 +533,6 @@ void Unit::UpdateSplineMovement(uint32 t_diff)
525533
movespline->updateState(t_diff);
526534
bool arrived = movespline->Finalized();
527535

528-
if (movespline->isCyclic())
529-
{
530-
m_splineSyncTimer.Update(t_diff);
531-
if (m_splineSyncTimer.Passed())
532-
{
533-
m_splineSyncTimer.Reset(5000); // Retail value, do not change
534-
535-
WorldPacket data(SMSG_FLIGHT_SPLINE_SYNC, 4 + GetPackGUID().size());
536-
Movement::PacketBuilder::WriteSplineSync(*movespline, data);
537-
data << GetPackGUID();
538-
SendMessageToSet(&data, true);
539-
}
540-
}
541-
542536
if (arrived)
543537
{
544538
DisableSpline();
@@ -574,6 +568,17 @@ void Unit::UpdateSplinePosition()
574568
UpdatePosition(loc.x, loc.y, loc.z, loc.orientation);
575569
}
576570

571+
void Unit::SendFlightSplineSyncUpdate()
572+
{
573+
if (!movespline->isCyclic() || movespline->Finalized())
574+
return;
575+
576+
WorldPacket data(SMSG_FLIGHT_SPLINE_SYNC, 4 + GetPackGUID().size());
577+
Movement::PacketBuilder::WriteSplineSync(*movespline, data);
578+
data << GetPackGUID();
579+
SendMessageToSet(&data, true);
580+
}
581+
577582
void Unit::InterruptMovementBasedAuras()
578583
{
579584
// TODO: Check if orientation transport offset changed instead of only global orientation

src/server/game/Entities/Unit/Unit.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,8 @@ class TC_GAME_API Unit : public WorldObject
827827

828828
virtual void Update(uint32 time) override;
829829

830+
void Heartbeat() override;
831+
830832
void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; }
831833
void resetAttackTimer(WeaponAttackType type = BASE_ATTACK);
832834
uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; }
@@ -1921,6 +1923,7 @@ class TC_GAME_API Unit : public WorldObject
19211923
friend class ImmediateMovementGenerator; // for UpdateSplineMovement
19221924
void UpdateSplineMovement(uint32 t_diff);
19231925
void UpdateSplinePosition();
1926+
void SendFlightSplineSyncUpdate();
19241927
void InterruptMovementBasedAuras();
19251928
void CheckPendingMovementAcks();
19261929

@@ -1940,7 +1943,6 @@ class TC_GAME_API Unit : public WorldObject
19401943

19411944
uint32 m_state; // Even derived shouldn't modify
19421945
uint32 m_lastManaUse; // msecs
1943-
TimeTracker m_splineSyncTimer;
19441946

19451947
Diminishing m_Diminishing;
19461948

0 commit comments

Comments
 (0)