refactor(Core): apply clang-tidy modernize-use-nodiscard (#3835)
This commit is contained in:
@@ -85,7 +85,7 @@ private:
|
||||
--_top;
|
||||
}
|
||||
|
||||
bool needInitTop() const
|
||||
[[nodiscard]] bool needInitTop() const
|
||||
{
|
||||
if (empty())
|
||||
return false;
|
||||
@@ -107,20 +107,20 @@ public:
|
||||
void Initialize();
|
||||
void InitDefault();
|
||||
|
||||
bool empty() const { return (_top < 0); }
|
||||
int size() const { return _top + 1; }
|
||||
_Ty top() const
|
||||
[[nodiscard]] bool empty() const { return (_top < 0); }
|
||||
[[nodiscard]] int size() const { return _top + 1; }
|
||||
[[nodiscard]] _Ty top() const
|
||||
{
|
||||
ASSERT(!empty());
|
||||
return Impl[_top];
|
||||
}
|
||||
_Ty GetMotionSlot(int slot) const
|
||||
[[nodiscard]] _Ty GetMotionSlot(int slot) const
|
||||
{
|
||||
ASSERT(slot >= 0);
|
||||
return Impl[slot];
|
||||
}
|
||||
|
||||
uint8 GetCleanFlags() const { return _cleanFlag; }
|
||||
[[nodiscard]] uint8 GetCleanFlags() const { return _cleanFlag; }
|
||||
|
||||
void DirectDelete(_Ty curr);
|
||||
void DelayedDelete(_Ty curr);
|
||||
@@ -193,9 +193,9 @@ public:
|
||||
void MovePath(uint32 path_id, bool repeatable);
|
||||
void MoveRotate(uint32 time, RotateDirection direction);
|
||||
|
||||
MovementGeneratorType GetCurrentMovementGeneratorType() const;
|
||||
MovementGeneratorType GetMotionSlotType(int slot) const;
|
||||
uint32 GetCurrentSplineId() const; // Xinef: Escort system
|
||||
[[nodiscard]] MovementGeneratorType GetCurrentMovementGeneratorType() const;
|
||||
[[nodiscard]] MovementGeneratorType GetMotionSlotType(int slot) const;
|
||||
[[nodiscard]] uint32 GetCurrentSplineId() const; // Xinef: Escort system
|
||||
|
||||
void propagateSpeedChange();
|
||||
void ReinitializeMovement();
|
||||
|
||||
@@ -60,26 +60,26 @@ namespace Movement
|
||||
void init_spline(const MoveSplineInitArgs& args);
|
||||
|
||||
protected:
|
||||
const MySpline::ControlArray& getPath(bool visual) const { return spline.getPoints(visual); }
|
||||
[[nodiscard]] const MySpline::ControlArray& getPath(bool visual) const { return spline.getPoints(visual); }
|
||||
void computeParabolicElevation(float& el) const;
|
||||
void computeFallElevation(float& el) const;
|
||||
|
||||
UpdateResult _updateState(int32& ms_time_diff);
|
||||
int32 next_timestamp() const { return spline.length(point_Idx + 1); }
|
||||
int32 segment_time_elapsed() const { return next_timestamp() - time_passed; }
|
||||
[[nodiscard]] int32 next_timestamp() const { return spline.length(point_Idx + 1); }
|
||||
[[nodiscard]] int32 segment_time_elapsed() const { return next_timestamp() - time_passed; }
|
||||
|
||||
public:
|
||||
int32 timeElapsed() const { return Duration() - time_passed; } // xinef: moved to public for waypoint movegen
|
||||
int32 timePassed() const { return time_passed; } // xinef: moved to public for waypoint movegen
|
||||
int32 Duration() const { return spline.length(); }
|
||||
MySpline const& _Spline() const { return spline; }
|
||||
int32 _currentSplineIdx() const { return point_Idx; }
|
||||
[[nodiscard]] int32 timeElapsed() const { return Duration() - time_passed; } // xinef: moved to public for waypoint movegen
|
||||
[[nodiscard]] int32 timePassed() const { return time_passed; } // xinef: moved to public for waypoint movegen
|
||||
[[nodiscard]] int32 Duration() const { return spline.length(); }
|
||||
[[nodiscard]] MySpline const& _Spline() const { return spline; }
|
||||
[[nodiscard]] int32 _currentSplineIdx() const { return point_Idx; }
|
||||
void _Finalize();
|
||||
void _Interrupt() { splineflags.done = true; }
|
||||
|
||||
public:
|
||||
void Initialize(const MoveSplineInitArgs&);
|
||||
bool Initialized() const { return !spline.empty(); }
|
||||
[[nodiscard]] bool Initialized() const { return !spline.empty(); }
|
||||
|
||||
MoveSpline();
|
||||
|
||||
@@ -99,19 +99,19 @@ namespace Movement
|
||||
while (difftime > 0);
|
||||
}
|
||||
|
||||
Location ComputePosition() const;
|
||||
[[nodiscard]] Location ComputePosition() const;
|
||||
|
||||
uint32 GetId() const { return m_Id; }
|
||||
bool Finalized() const { return splineflags.done; }
|
||||
bool isCyclic() const { return splineflags.cyclic; }
|
||||
bool isFalling() const { return splineflags.falling; }
|
||||
bool isWalking() const { return splineflags.walkmode; }
|
||||
Vector3 FinalDestination() const { return Initialized() ? spline.getPoint(spline.last(), false) : Vector3(); }
|
||||
Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx + 1, false) : Vector3(); }
|
||||
int32 currentPathIdx() const;
|
||||
[[nodiscard]] uint32 GetId() const { return m_Id; }
|
||||
[[nodiscard]] bool Finalized() const { return splineflags.done; }
|
||||
[[nodiscard]] bool isCyclic() const { return splineflags.cyclic; }
|
||||
[[nodiscard]] bool isFalling() const { return splineflags.falling; }
|
||||
[[nodiscard]] bool isWalking() const { return splineflags.walkmode; }
|
||||
[[nodiscard]] Vector3 FinalDestination() const { return Initialized() ? spline.getPoint(spline.last(), false) : Vector3(); }
|
||||
[[nodiscard]] Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx + 1, false) : Vector3(); }
|
||||
[[nodiscard]] int32 currentPathIdx() const;
|
||||
|
||||
bool onTransport;
|
||||
std::string ToString() const;
|
||||
[[nodiscard]] std::string ToString() const;
|
||||
};
|
||||
}
|
||||
#endif // TRINITYSERVER_MOVEPLINE_H
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Movement
|
||||
};
|
||||
|
||||
inline uint32& raw() { return (uint32&) * this; }
|
||||
inline const uint32& raw() const { return (const uint32&) * this; }
|
||||
[[nodiscard]] inline const uint32& raw() const { return (const uint32&) * this; }
|
||||
|
||||
MoveSplineFlag() { raw() = 0; }
|
||||
MoveSplineFlag(uint32 f) { raw() = f; }
|
||||
@@ -77,16 +77,16 @@ namespace Movement
|
||||
|
||||
// Constant interface
|
||||
|
||||
bool isSmooth() const { return raw() & Mask_CatmullRom; }
|
||||
bool isLinear() const { return !isSmooth(); }
|
||||
bool isFacing() const { return raw() & Mask_Final_Facing; }
|
||||
[[nodiscard]] bool isSmooth() const { return raw() & Mask_CatmullRom; }
|
||||
[[nodiscard]] bool isLinear() const { return !isSmooth(); }
|
||||
[[nodiscard]] bool isFacing() const { return raw() & Mask_Final_Facing; }
|
||||
|
||||
uint8 getAnimationId() const { return animId; }
|
||||
bool hasAllFlags(uint32 f) const { return (raw() & f) == f; }
|
||||
bool hasFlag(uint32 f) const { return (raw() & f) != 0; }
|
||||
[[nodiscard]] uint8 getAnimationId() const { return animId; }
|
||||
[[nodiscard]] bool hasAllFlags(uint32 f) const { return (raw() & f) == f; }
|
||||
[[nodiscard]] bool hasFlag(uint32 f) const { return (raw() & f) != 0; }
|
||||
uint32 operator & (uint32 f) const { return (raw() & f); }
|
||||
uint32 operator | (uint32 f) const { return (raw() | f); }
|
||||
std::string ToString() const;
|
||||
[[nodiscard]] std::string ToString() const;
|
||||
|
||||
// Not constant interface
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Movement
|
||||
bool Validate(Unit* unit) const;
|
||||
|
||||
private:
|
||||
bool _checkPathBounds() const;
|
||||
[[nodiscard]] bool _checkPathBounds() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -61,9 +61,9 @@ namespace Movement
|
||||
void EvaluateDerivativeBezier3(index_type, float, Vector3&) const;
|
||||
static EvaluationMethtod derivative_evaluators[ModesEnd];
|
||||
|
||||
float SegLengthLinear(index_type) const;
|
||||
float SegLengthCatmullRom(index_type) const;
|
||||
float SegLengthBezier3(index_type) const;
|
||||
[[nodiscard]] float SegLengthLinear(index_type) const;
|
||||
[[nodiscard]] float SegLengthCatmullRom(index_type) const;
|
||||
[[nodiscard]] float SegLengthBezier3(index_type) const;
|
||||
typedef float (SplineBase::*SegLenghtMethtod)(index_type) const;
|
||||
static SegLenghtMethtod seglengths[ModesEnd];
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Movement
|
||||
static InitMethtod initializers[ModesEnd];
|
||||
|
||||
void UninitializedSplineEvaluationMethod(index_type, float, Vector3&) const { ABORT(); }
|
||||
float UninitializedSplineSegLenghtMethod(index_type) const { ABORT(); }
|
||||
[[nodiscard]] float UninitializedSplineSegLenghtMethod(index_type) const { ABORT(); }
|
||||
void UninitializedSplineInitMethod(Vector3 const*, index_type, bool, index_type) { ABORT(); }
|
||||
|
||||
public:
|
||||
@@ -94,18 +94,18 @@ namespace Movement
|
||||
void evaluate_derivative(index_type Idx, float u, Vector3& hermite) const {(this->*derivative_evaluators[m_mode])(Idx, u, hermite);}
|
||||
|
||||
/** Bounds for spline indexes. All indexes should be in range [first, last). */
|
||||
index_type first() const { return index_lo;}
|
||||
index_type last() const { return index_hi;}
|
||||
[[nodiscard]] index_type first() const { return index_lo;}
|
||||
[[nodiscard]] index_type last() const { return index_hi;}
|
||||
|
||||
bool empty() const { return index_lo == index_hi;}
|
||||
EvaluationMode mode() const { return (EvaluationMode)m_mode;}
|
||||
bool isCyclic() const { return cyclic;}
|
||||
[[nodiscard]] bool empty() const { return index_lo == index_hi;}
|
||||
[[nodiscard]] EvaluationMode mode() const { return (EvaluationMode)m_mode;}
|
||||
[[nodiscard]] bool isCyclic() const { return cyclic;}
|
||||
|
||||
// Xinef: DO NOT USE EXCEPT FOR SPLINE INITIALIZATION!!!!!!
|
||||
const ControlArray* allocateVisualPoints() const { return &pointsVisual; }
|
||||
const ControlArray& getPoints(bool visual) const { return visual ? pointsVisual : points;}
|
||||
index_type getPointCount() const { return points.size();}
|
||||
const Vector3& getPoint(index_type i, bool visual) const { return visual ? pointsVisual[i] : points[i];}
|
||||
[[nodiscard]] const ControlArray* allocateVisualPoints() const { return &pointsVisual; }
|
||||
[[nodiscard]] const ControlArray& getPoints(bool visual) const { return visual ? pointsVisual : points;}
|
||||
[[nodiscard]] index_type getPointCount() const { return points.size();}
|
||||
[[nodiscard]] const Vector3& getPoint(index_type i, bool visual) const { return visual ? pointsVisual[i] : points[i];}
|
||||
|
||||
/** Initializes spline. Don't call other methods while spline not initialized. */
|
||||
void init_spline(const Vector3* controls, index_type count, EvaluationMode m);
|
||||
@@ -121,9 +121,9 @@ namespace Movement
|
||||
void clear();
|
||||
|
||||
/** Calculates distance between [i; i+1] points, assumes that index i is in bounds. */
|
||||
float SegLength(index_type i) const { return (this->*seglengths[m_mode])(i);}
|
||||
[[nodiscard]] float SegLength(index_type i) const { return (this->*seglengths[m_mode])(i);}
|
||||
|
||||
std::string ToString() const;
|
||||
[[nodiscard]] std::string ToString() const;
|
||||
};
|
||||
|
||||
template<typename length_type>
|
||||
@@ -136,7 +136,7 @@ namespace Movement
|
||||
|
||||
LengthArray lengths;
|
||||
|
||||
index_type computeIndexInBounds(length_type length) const;
|
||||
[[nodiscard]] index_type computeIndexInBounds(length_type length) const;
|
||||
public:
|
||||
|
||||
explicit Spline() {}
|
||||
@@ -160,7 +160,7 @@ namespace Movement
|
||||
void evaluate_derivative(index_type Idx, float u, Vector3& c) const { SplineBase::evaluate_derivative(Idx, u, c);}
|
||||
|
||||
// Assumes that t in range [0, 1]
|
||||
index_type computeIndexInBounds(float t) const;
|
||||
[[nodiscard]] index_type computeIndexInBounds(float t) const;
|
||||
void computeIndex(float t, index_type& out_idx, float& out_u) const;
|
||||
|
||||
/** Initializes spline. Don't call other methods while spline not initialized. */
|
||||
@@ -191,10 +191,10 @@ namespace Movement
|
||||
}
|
||||
|
||||
/** Returns length of the whole spline. */
|
||||
length_type length() const { return lengths[index_hi];}
|
||||
[[nodiscard]] length_type length() const { return lengths[index_hi];}
|
||||
/** Returns length between given nodes. */
|
||||
length_type length(index_type first, index_type last) const { return lengths[last] - lengths[first];}
|
||||
length_type length(index_type Idx) const { return lengths[Idx];}
|
||||
[[nodiscard]] length_type length(index_type first, index_type last) const { return lengths[last] - lengths[first];}
|
||||
[[nodiscard]] length_type length(index_type Idx) const { return lengths[Idx];}
|
||||
|
||||
void set_length(index_type i, length_type length) { lengths[i] = length;}
|
||||
void clear();
|
||||
|
||||
Reference in New Issue
Block a user