fix(Core/Movement): Removed some leftover after c8f43d8584. (#13524)

Closes #2623
This commit is contained in:
UltraNix
2022-10-29 12:11:36 +02:00
committed by GitHub
parent 420aee4b25
commit ab9c648504
7 changed files with 17 additions and 29 deletions

View File

@@ -370,11 +370,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
// 0x08000000 // 0x08000000
if (unit->m_movementInfo.GetMovementFlags() & MOVEMENTFLAG_SPLINE_ENABLED) if (unit->m_movementInfo.GetMovementFlags() & MOVEMENTFLAG_SPLINE_ENABLED)
{ {
const G3D::Vector3* p = &unit->movespline->_Spline().getPoints(true)[0]; Movement::PacketBuilder::WriteCreate(*unit->movespline, *data);
if (unit->movespline->_Spline().getPoints(true).empty() || (!unit->movespline->_Spline().getPoints(true).empty() && !p))
const_cast<Unit*>(unit)->DisableSpline();
else
Movement::PacketBuilder::WriteCreate(*unit->movespline, *data);
} }
} }
else else

View File

@@ -80,7 +80,7 @@ namespace Movement
void MoveSpline::computeFallElevation(float& el) const void MoveSpline::computeFallElevation(float& el) const
{ {
float z_now = spline.getPoint(spline.first(), false).z - Movement::computeFallElevation(MSToSec(time_passed), false); float z_now = spline.getPoint(spline.first()).z - Movement::computeFallElevation(MSToSec(time_passed), false);
float final_z = FinalDestination().z; float final_z = FinalDestination().z;
el = std::max(z_now, final_z); el = std::max(z_now, final_z);
} }
@@ -96,7 +96,7 @@ namespace Movement
float start_elevation; float start_elevation;
inline int32 operator()(Spline<int32>& s, int32 i) inline int32 operator()(Spline<int32>& s, int32 i)
{ {
return Movement::computeFallTime(start_elevation - s.getPoint(i + 1, false).z, false) * 1000.f; return Movement::computeFallTime(start_elevation - s.getPoint(i + 1).z, false) * 1000.f;
} }
}; };
@@ -138,7 +138,7 @@ namespace Movement
// init spline timestamps // init spline timestamps
if (splineflags.falling) if (splineflags.falling)
{ {
FallInitializer init(spline.getPoint(spline.first(), false).z); FallInitializer init(spline.getPoint(spline.first()).z);
spline.initLengths(init); spline.initLengths(init);
} }
else else

View File

@@ -71,7 +71,7 @@ namespace Movement
void init_spline(const MoveSplineInitArgs& args); void init_spline(const MoveSplineInitArgs& args);
protected: protected:
[[nodiscard]] const MySpline::ControlArray& getPath(bool visual) const { return spline.getPoints(visual); } [[nodiscard]] const MySpline::ControlArray& getPath() const { return spline.getPoints(); }
void computeParabolicElevation(float& el) const; void computeParabolicElevation(float& el) const;
void computeFallElevation(float& el) const; void computeFallElevation(float& el) const;
@@ -117,8 +117,8 @@ namespace Movement
[[nodiscard]] bool isCyclic() const { return splineflags.cyclic; } [[nodiscard]] bool isCyclic() const { return splineflags.cyclic; }
[[nodiscard]] bool isFalling() const { return splineflags.falling; } [[nodiscard]] bool isFalling() const { return splineflags.falling; }
[[nodiscard]] bool isWalking() const { return splineflags.walkmode; } [[nodiscard]] bool isWalking() const { return splineflags.walkmode; }
[[nodiscard]] Vector3 FinalDestination() const { return Initialized() ? spline.getPoint(spline.last(), false) : Vector3(); } [[nodiscard]] Vector3 FinalDestination() const { return Initialized() ? spline.getPoint(spline.last()) : Vector3(); }
[[nodiscard]] Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx + 1, false) : Vector3(); } [[nodiscard]] Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx + 1) : Vector3(); }
[[nodiscard]] int32 currentPathIdx() const; [[nodiscard]] int32 currentPathIdx() const;
[[nodiscard]] bool HasAnimation() const { return splineflags.animation; } [[nodiscard]] bool HasAnimation() const { return splineflags.animation; }

View File

@@ -135,11 +135,6 @@ namespace Movement
data << int8(unit->GetTransSeat()); data << int8(unit->GetTransSeat());
} }
Movement::SplineBase::ControlArray* visualPoints = const_cast<Movement::SplineBase::ControlArray*>(move_spline._Spline().allocateVisualPoints());
visualPoints->resize(move_spline._Spline().getPointCount());
// Xinef: Apply hover in creature movement packet
std::copy(move_spline._Spline().getPoints(false).begin(), move_spline._Spline().getPoints(false).end(), visualPoints->begin());
PacketBuilder::WriteMonsterMove(move_spline, data); PacketBuilder::WriteMonsterMove(move_spline, data);
unit->SendMessageToSet(&data, true); unit->SendMessageToSet(&data, true);

View File

@@ -45,7 +45,7 @@ namespace Movement
MoveSplineFlag splineflags = move_spline.splineflags; MoveSplineFlag splineflags = move_spline.splineflags;
data << uint8(0); // sets/unsets MOVEMENTFLAG2_UNK7 (0x40) data << uint8(0); // sets/unsets MOVEMENTFLAG2_UNK7 (0x40)
data << move_spline.spline.getPoint(move_spline.spline.first(), true); data << move_spline.spline.getPoint(move_spline.spline.first());
data << move_spline.GetId(); data << move_spline.GetId();
switch (splineflags & MoveSplineFlag::Mask_Final_Facing) switch (splineflags & MoveSplineFlag::Mask_Final_Facing)
@@ -99,7 +99,7 @@ namespace Movement
void WriteLinearPath(const Spline<int32>& spline, ByteBuffer& data) void WriteLinearPath(const Spline<int32>& spline, ByteBuffer& data)
{ {
uint32 last_idx = spline.getPointCount() - 3; uint32 last_idx = spline.getPointCount() - 3;
const Vector3* real_path = &spline.getPoint(1, true); const Vector3* real_path = &spline.getPoint(1);
data << last_idx; data << last_idx;
data << real_path[last_idx]; // destination data << real_path[last_idx]; // destination
@@ -120,7 +120,7 @@ namespace Movement
{ {
uint32 count = spline.getPointCount() - 3; uint32 count = spline.getPointCount() - 3;
data << count; data << count;
data.append<Vector3>(&spline.getPoint(2, true), count); data.append<Vector3>(&spline.getPoint(2), count);
} }
void WriteCatmullRomCyclicPath(const Spline<int32>& spline, ByteBuffer& data, bool flying) void WriteCatmullRomCyclicPath(const Spline<int32>& spline, ByteBuffer& data, bool flying)
@@ -129,12 +129,12 @@ namespace Movement
data << uint32(count + 1); data << uint32(count + 1);
if (flying) if (flying)
{ {
data << spline.getPoint(1, true); // fake point, client will erase it from the spline after first cycle done data << spline.getPoint(1); // fake point, client will erase it from the spline after first cycle done
data.append<Vector3>(&spline.getPoint(2, true), count); data.append<Vector3>(&spline.getPoint(2), count);
} }
else else
{ {
data.append<Vector3>(&spline.getPoint(2, true), count); data.append<Vector3>(&spline.getPoint(2), count);
data << Vector3::zero(); //Xinef: fake point data << Vector3::zero(); //Xinef: fake point
} }
} }
@@ -189,9 +189,9 @@ namespace Movement
data << move_spline.vertical_acceleration; // added in 3.1 data << move_spline.vertical_acceleration; // added in 3.1
data << move_spline.effect_start_time; // added in 3.1 data << move_spline.effect_start_time; // added in 3.1
uint32 nodes = move_spline.getPath(true).size(); uint32 nodes = move_spline.getPath().size();
data << nodes; data << nodes;
data.append<Vector3>(&move_spline.getPath(true)[0], nodes); data.append<Vector3>(&move_spline.getPath()[0], nodes);
data << uint8(move_spline.spline.mode()); // added in 3.1 data << uint8(move_spline.spline.mode()); // added in 3.1
data << (move_spline.isCyclic() ? Vector3::zero() : move_spline.FinalDestination()); data << (move_spline.isCyclic() ? Vector3::zero() : move_spline.FinalDestination());
} }

View File

@@ -286,7 +286,6 @@ namespace Movement
index_lo = 0; index_lo = 0;
index_hi = 0; index_hi = 0;
points.clear(); points.clear();
pointsVisual.clear();
} }
std::string SplineBase::ToString() const std::string SplineBase::ToString() const

View File

@@ -42,7 +42,6 @@ namespace Movement
protected: protected:
ControlArray points; ControlArray points;
ControlArray pointsVisual;
index_type index_lo{0}; index_type index_lo{0};
index_type index_hi{0}; index_type index_hi{0};
@@ -112,10 +111,9 @@ namespace Movement
[[nodiscard]] bool isCyclic() const { return cyclic;} [[nodiscard]] bool isCyclic() const { return cyclic;}
// Xinef: DO NOT USE EXCEPT FOR SPLINE INITIALIZATION!!!!!! // Xinef: DO NOT USE EXCEPT FOR SPLINE INITIALIZATION!!!!!!
[[nodiscard]] const ControlArray* allocateVisualPoints() const { return &pointsVisual; } [[nodiscard]] const ControlArray& getPoints() const { return points;}
[[nodiscard]] const ControlArray& getPoints(bool visual) const { return visual ? pointsVisual : points;}
[[nodiscard]] index_type getPointCount() const { return points.size();} [[nodiscard]] index_type getPointCount() const { return points.size();}
[[nodiscard]] const Vector3& getPoint(index_type i, bool visual) const { return visual ? pointsVisual[i] : points[i];} [[nodiscard]] const Vector3& getPoint(index_type i) const { return points[i];}
/** Initializes spline. Don't call other methods while spline not initialized. */ /** Initializes spline. Don't call other methods while spline not initialized. */
void init_spline(const Vector3* controls, index_type count, EvaluationMode m); void init_spline(const Vector3* controls, index_type count, EvaluationMode m);