Skip to content

Commit

Permalink
Core/AreaTriggers: Don't suppress TimeToTarget changes in values upda…
Browse files Browse the repository at this point in the history
…te on movement start
  • Loading branch information
Shauren committed Jan 7, 2025
1 parent b32ba71 commit debbed0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
13 changes: 4 additions & 9 deletions src/server/game/Entities/AreaTrigger/AreaTrigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1086,26 +1086,21 @@ void AreaTrigger::InitSplineOffsets(std::vector<Position> const& offsets, uint32
rotatedPoints.emplace_back(x, y, z);
}

InitSplines(std::move(rotatedPoints), timeToTarget);
InitSplines(rotatedPoints, timeToTarget);
}

void AreaTrigger::InitSplines(std::vector<G3D::Vector3> splinePoints, uint32 timeToTarget)
void AreaTrigger::InitSplines(std::vector<G3D::Vector3> const& splinePoints, uint32 timeToTarget)
{
if (splinePoints.size() < 2)
return;

_movementTime = 0;

_spline = std::make_unique<::Movement::Spline<int32>>();
_spline->init_spline(&splinePoints[0], splinePoints.size(), ::Movement::SplineBase::ModeLinear);
_spline->init_spline(splinePoints.data(), splinePoints.size(), ::Movement::SplineBase::ModeLinear);
_spline->initLengths();

// should be sent in object create packets only
DoWithSuppressingObjectUpdates([&]()
{
SetUpdateFieldValue(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::TimeToTarget), timeToTarget);
const_cast<UF::AreaTriggerData&>(*m_areaTriggerData).ClearChanged(&UF::AreaTriggerData::TimeToTarget);
});
SetUpdateFieldValue(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::TimeToTarget), timeToTarget);

if (IsInWorld())
{
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/AreaTrigger/AreaTrigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class TC_GAME_API AreaTrigger final : public WorldObject, public GridObject<Area
Position const& GetRollPitchYaw() const { return _rollPitchYaw; }
Position const& GetTargetRollPitchYaw() const { return _targetRollPitchYaw; }
void InitSplineOffsets(std::vector<Position> const& offsets, uint32 timeToTarget);
void InitSplines(std::vector<G3D::Vector3> splinePoints, uint32 timeToTarget);
void InitSplines(std::vector<G3D::Vector3> const& splinePoints, uint32 timeToTarget);
bool HasSplines() const;
::Movement::Spline<int32> const& GetSpline() const { return *_spline; }
uint32 GetElapsedTimeForMovement() const { return GetTimeSinceCreated(); } /// @todo: research the right value, in sniffs both timers are nearly identical
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2957,7 +2957,7 @@ struct at_anduin_wrynn_wicked_star : AreaTriggerAI
splinePoints.push_back(PositionToVector3(at->GetPosition()));

float timeToTarget = at->GetDistance(destPos.GetPositionX(), destPos.GetPositionY(), destPos.GetPositionZ()) * 2 / GetWickedStarSpeed(at->GetMap()->GetDifficultyID()) * 1000;
at->InitSplines(std::move(splinePoints), timeToTarget);
at->InitSplines(splinePoints, timeToTarget);
}
}

Expand Down Expand Up @@ -3021,7 +3021,7 @@ struct at_anduin_wrynn_empowered_wicked_star : public at_anduin_wrynn_wicked_sta
splinePoints.push_back(PositionToVector3(destPos));

float timeToTarget = at->GetDistance(destPos.GetPositionX(), destPos.GetPositionY(), destPos.GetPositionZ()) / EMPOWERED_WICKED_STAR_SPEED * 1000;
at->InitSplines(std::move(splinePoints), timeToTarget);
at->InitSplines(splinePoints, timeToTarget);
}

void OnInitialize() override
Expand Down

0 comments on commit debbed0

Please sign in to comment.