diff --git a/source/egg/math/Quat.hh b/source/egg/math/Quat.hh index f4a22a83..4052cb92 100644 --- a/source/egg/math/Quat.hh +++ b/source/egg/math/Quat.hh @@ -63,16 +63,16 @@ struct Quatf { return *this = *this * q; } - bool operator==(const Quatf &rhs) const { + [[nodiscard]] bool operator==(const Quatf &rhs) const { return w == rhs.w && v == rhs.v; } - bool operator!=(const Quatf &rhs) const { + [[nodiscard]] bool operator!=(const Quatf &rhs) const { return !(*this == rhs); } /// @brief A conversion function that allows for string representation of a quaternion. - explicit operator std::string() const { + [[nodiscard]] explicit operator std::string() const { return std::format("[0x{:08X}, 0x{:08X}, 0x{:08X}, 0x{:08X}] | [{}, {}, {}, {}]", f2u(v.x), f2u(v.y), f2u(v.z), f2u(w), v.x, v.y, v.z, w); } @@ -82,33 +82,33 @@ struct Quatf { void makeVectorRotation(const Vector3f &from, const Vector3f &to); /// @brief Computes \f$conj(a+bi+cj+dk) = a-bi-cj-dk\f$ - Quatf conjugate() const { + [[nodiscard]] Quatf conjugate() const { return Quatf(w, -v); } - Vector3f rotateVector(const Vector3f &vec) const; - Vector3f rotateVectorInv(const Vector3f &vec) const; - Quatf slerpTo(const Quatf &q2, f32 t) const; + [[nodiscard]] Vector3f rotateVector(const Vector3f &vec) const; + [[nodiscard]] Vector3f rotateVectorInv(const Vector3f &vec) const; + [[nodiscard]] Quatf slerpTo(const Quatf &q2, f32 t) const; /// @addr{0x8023A138} /// @brief Computes \f$this \cdot this = w^2 + x^2 + y^2 + z^2\f$ - f32 squaredNorm() const { + [[nodiscard]] f32 squaredNorm() const { return w * w + v.squaredLength(); } - f32 norm() const { + [[nodiscard]] f32 norm() const { return Mathf::sqrt(squaredNorm()); } /// @brief Computes \f$this \cdot rhs = w \times rhs.w + x \times rhs.x + y \times rhs.y + z /// \times rhs.z\f$ - f32 dot(const Quatf &q) const { + [[nodiscard]] f32 dot(const Quatf &q) const { return w * q.w + v.dot(q.v); } void setAxisRotation(f32 angle, const Vector3f &axis); - Quatf multSwap(const Vector3f &v) const; - Quatf multSwap(const Quatf &q) const; + [[nodiscard]] Quatf multSwap(const Vector3f &v) const; + [[nodiscard]] Quatf multSwap(const Quatf &q) const; void read(Stream &stream); diff --git a/source/egg/math/Vector.hh b/source/egg/math/Vector.hh index 197e8205..b0cabd36 100644 --- a/source/egg/math/Vector.hh +++ b/source/egg/math/Vector.hh @@ -154,11 +154,11 @@ struct Vector3f { return *this = *this / scalar; } - bool operator==(const Vector3f &rhs) const { + [[nodiscard]] bool operator==(const Vector3f &rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; } - bool operator!=(const Vector3f &rhs) const { + [[nodiscard]] bool operator!=(const Vector3f &rhs) const { return !(*this == rhs); } diff --git a/source/game/field/CourseColMgr.hh b/source/game/field/CourseColMgr.hh index 320fab2c..f08bec6f 100644 --- a/source/game/field/CourseColMgr.hh +++ b/source/game/field/CourseColMgr.hh @@ -92,7 +92,7 @@ public: } /// @endGetters - static void *LoadFile(const char *filename); + [[nodiscard]] static void *LoadFile(const char *filename); static CourseColMgr *CreateInstance(); static void DestroyInstance(); diff --git a/source/game/field/ObjectCollisionBase.hh b/source/game/field/ObjectCollisionBase.hh index 97224514..6dd7df42 100644 --- a/source/game/field/ObjectCollisionBase.hh +++ b/source/game/field/ObjectCollisionBase.hh @@ -28,8 +28,8 @@ public: virtual void transform(const EGG::Matrix34f &mat, const EGG::Vector3f &scale, const EGG::Vector3f &speed) = 0; - virtual const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const = 0; - virtual f32 getBoundingRadius() const = 0; + [[nodiscard]] virtual const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const = 0; + [[nodiscard]] virtual f32 getBoundingRadius() const = 0; bool check(ObjectCollisionBase &rhs, EGG::Vector3f &distance); @@ -37,12 +37,12 @@ protected: EGG::Vector3f m_translation; private: - bool enclosesOrigin(const GJKState &state, u32 idx) const; + [[nodiscard]] bool enclosesOrigin(const GJKState &state, u32 idx) const; void FUN_808350e4(GJKState &state, EGG::Vector3f &v) const; bool getNearestSimplex(GJKState &state, EGG::Vector3f &v) const; void getNearestPoint(GJKState &state, u32 idx, EGG::Vector3f &v0, EGG::Vector3f &v1) const; - bool FUN_808357e4(const GJKState &state, u32 idx) const; - bool inSimplex(const GJKState &state, const EGG::Vector3f &v) const; + [[nodiscard]] bool FUN_808357e4(const GJKState &state, u32 idx) const; + [[nodiscard]] bool inSimplex(const GJKState &state, const EGG::Vector3f &v) const; void getNearestPoint(const GJKState &state, u32 idx, EGG::Vector3f &v) const; void calcSimplex(GJKState &state) const; diff --git a/source/game/field/ObjectCollisionConvexHull.hh b/source/game/field/ObjectCollisionConvexHull.hh index fc3482d6..fcad0421 100644 --- a/source/game/field/ObjectCollisionConvexHull.hh +++ b/source/game/field/ObjectCollisionConvexHull.hh @@ -12,7 +12,7 @@ public: void transform(const EGG::Matrix34f &mat, const EGG::Vector3f &scale, const EGG::Vector3f &speed) override; - const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const override; + [[nodiscard]] const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const override; /// @addr{0x807F957C} f32 getBoundingRadius() const override { diff --git a/source/game/field/ObjectCollisionCylinder.hh b/source/game/field/ObjectCollisionCylinder.hh index b25dc7e6..bc882315 100644 --- a/source/game/field/ObjectCollisionCylinder.hh +++ b/source/game/field/ObjectCollisionCylinder.hh @@ -13,12 +13,12 @@ public: const EGG::Vector3f &speed) override; /// @addr{0x8083618C} - const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const override { + [[nodiscard]] const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const override { return m_top.dot(v) > m_bottom.dot(v) ? m_top : m_bottom; } /// @addr{0x80836498} - f32 getBoundingRadius() const override { + [[nodiscard]] f32 getBoundingRadius() const override { return m_worldRadius; } diff --git a/source/game/field/ObjectCollisionKart.hh b/source/game/field/ObjectCollisionKart.hh index 7a9049bd..a67b0d32 100644 --- a/source/game/field/ObjectCollisionKart.hh +++ b/source/game/field/ObjectCollisionKart.hh @@ -20,8 +20,8 @@ public: size_t checkCollision(const EGG::Matrix34f &mat, const EGG::Vector3f &v); - static EGG::Vector3f GetHitDirection(u16 objKartHit); - static constexpr std::span GetVehicleVertices(Vehicle vehicle); + [[nodiscard]] static EGG::Vector3f GetHitDirection(u16 objKartHit); + [[nodiscard]] static constexpr std::span GetVehicleVertices(Vehicle vehicle); private: ObjectCollisionConvexHull *m_hull; diff --git a/source/game/field/ObjectCollisionSphere.hh b/source/game/field/ObjectCollisionSphere.hh index 0e5fe7f9..9d946307 100644 --- a/source/game/field/ObjectCollisionSphere.hh +++ b/source/game/field/ObjectCollisionSphere.hh @@ -11,10 +11,10 @@ public: void transform(const EGG::Matrix34f &mat, const EGG::Vector3f &scale, const EGG::Vector3f &speed) override; - const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const override; + [[nodiscard]] const EGG::Vector3f &getSupport(const EGG::Vector3f &v) const override; /// @addr{0x80836B54} - f32 getBoundingRadius() const override { + [[nodiscard]] f32 getBoundingRadius() const override { return m_scaledRadius; } diff --git a/source/game/field/ObjectFlowTable.hh b/source/game/field/ObjectFlowTable.hh index 97c5f832..e4ab8eed 100644 --- a/source/game/field/ObjectFlowTable.hh +++ b/source/game/field/ObjectFlowTable.hh @@ -46,7 +46,7 @@ public: ObjectFlowTable(const char *filename); ~ObjectFlowTable(); - const SObjectCollisionSet *set(s16 slot) const { + [[nodiscard]] const SObjectCollisionSet *set(s16 slot) const { return slot == -1 ? nullptr : slot < m_count ? &m_sets[slot] : nullptr; } diff --git a/source/game/field/ObjectHitTable.hh b/source/game/field/ObjectHitTable.hh index 6fb509c9..389f681f 100644 --- a/source/game/field/ObjectHitTable.hh +++ b/source/game/field/ObjectHitTable.hh @@ -13,8 +13,8 @@ public: ObjectHitTable(const char *filename); ~ObjectHitTable(); - Kart::Reaction reaction(s16 i) const; - s16 slot(ObjectId id) const; + [[nodiscard]] Kart::Reaction reaction(s16 i) const; + [[nodiscard]] s16 slot(ObjectId id) const; private: s16 m_count; diff --git a/source/game/kart/KartHalfPipe.hh b/source/game/kart/KartHalfPipe.hh index d11244c9..205698b5 100644 --- a/source/game/kart/KartHalfPipe.hh +++ b/source/game/kart/KartHalfPipe.hh @@ -22,7 +22,7 @@ public: void end(bool boost); /// @addr{0x80574108} - static consteval f32 TerminalVelocity() { + [[nodiscard]] static consteval f32 TerminalVelocity() { return 65.0f; } diff --git a/source/game/kart/KartMove.hh b/source/game/kart/KartMove.hh index 3e09767b..03f326fe 100644 --- a/source/game/kart/KartMove.hh +++ b/source/game/kart/KartMove.hh @@ -86,7 +86,7 @@ public: bool calcZipperCollision(f32 radius, f32 scale, EGG::Vector3f &pos, EGG::Vector3f &upLocal, const EGG::Vector3f &prevPos, Field::CourseColMgr::CollisionInfo *colInfo, Field::KCLTypeMask *maskOut, Field::KCLTypeMask flags) const; - f32 calcSlerpRate(f32 scale, const EGG::Quatf &from, const EGG::Quatf &to) const; + [[nodiscard]] f32 calcSlerpRate(f32 scale, const EGG::Quatf &from, const EGG::Quatf &to) const; virtual void calcVehicleRotation(f32 turn); virtual void hop(); virtual void onHop() {} @@ -102,12 +102,12 @@ public: } /// @addr{0x8058758C} - virtual bool canWheelie() const { + [[nodiscard]] virtual bool canWheelie() const { return false; } /// @addr{0x8057DA18} - virtual bool canHop() const { + [[nodiscard]] virtual bool canHop() const { if (!state()->isHopStart() || !state()->isTouchingGround()) { return false; } @@ -120,7 +120,7 @@ public: } /// @addr{0x8057EA94} - bool canStartDrift() const { + [[nodiscard]] bool canStartDrift() const { constexpr f32 MINIMUM_DRIFT_THRESOLD = 0.55f; return m_speed > MINIMUM_DRIFT_THRESOLD * m_baseSpeed; diff --git a/source/game/kart/KartReject.hh b/source/game/kart/KartReject.hh index 98b82ed8..5a7fc35b 100644 --- a/source/game/kart/KartReject.hh +++ b/source/game/kart/KartReject.hh @@ -13,7 +13,7 @@ public: void reset(); void calcRejectRoad(); - bool calcRejection(); + [[nodiscard]] bool calcRejection(); private: f32 m_rejectSign; diff --git a/source/game/system/TimerManager.hh b/source/game/system/TimerManager.hh index 9f820da3..6c037895 100644 --- a/source/game/system/TimerManager.hh +++ b/source/game/system/TimerManager.hh @@ -11,7 +11,7 @@ struct Timer { Timer(u32 data); ~Timer(); - std::strong_ordering operator<=>(const Timer &rhs) const { + [[nodiscard]] std::strong_ordering operator<=>(const Timer &rhs) const { if (auto cmp = min <=> rhs.min; cmp != 0) { return cmp; } @@ -27,11 +27,11 @@ struct Timer { return valid <=> rhs.valid; } - bool operator==(const Timer &rhs) const = default; - bool operator!=(const Timer &rhs) const = default; + [[nodiscard]] bool operator==(const Timer &rhs) const = default; + [[nodiscard]] bool operator!=(const Timer &rhs) const = default; /// @addr{0x807EE860} - Timer operator-(const Timer &rhs) const { + [[nodiscard]] Timer operator-(const Timer &rhs) const { s16 addMin = 0; s16 addSec = 0; @@ -57,7 +57,7 @@ struct Timer { return Timer(newMin, newSec, newMs); } - Timer operator+(f32 ms) const { + [[nodiscard]] Timer operator+(f32 ms) const { s16 addMin = 0; s16 addSec = 0; diff --git a/source/game/system/map/MapdataCannonPoint.hh b/source/game/system/map/MapdataCannonPoint.hh index 41ebeb2c..924efba1 100644 --- a/source/game/system/map/MapdataCannonPoint.hh +++ b/source/game/system/map/MapdataCannonPoint.hh @@ -21,19 +21,19 @@ public: void read(EGG::Stream &stream); /// @beginGetters - const EGG::Vector3f &pos() const { + [[nodiscard]] const EGG::Vector3f &pos() const { return m_pos; } - const EGG::Vector3f &rot() const { + [[nodiscard]] const EGG::Vector3f &rot() const { return m_rot; } - u16 id() const { + [[nodiscard]] u16 id() const { return m_id; } - s16 parameterIdx() const { + [[nodiscard]] s16 parameterIdx() const { return m_parameterIdx; } /// @endGetters diff --git a/source/game/system/map/MapdataGeoObj.hh b/source/game/system/map/MapdataGeoObj.hh index 98010fdf..d6ec14cc 100644 --- a/source/game/system/map/MapdataGeoObj.hh +++ b/source/game/system/map/MapdataGeoObj.hh @@ -22,23 +22,23 @@ public: void read(EGG::Stream &stream); /// @beginGetters - u16 id() const { + [[nodiscard]] u16 id() const { return m_id; } - const EGG::Vector3f &pos() const { + [[nodiscard]] const EGG::Vector3f &pos() const { return m_pos; } - const EGG::Vector3f &rot() const { + [[nodiscard]] const EGG::Vector3f &rot() const { return m_rot; } - const EGG::Vector3f &scale() const { + [[nodiscard]] const EGG::Vector3f &scale() const { return m_scale; } - u16 presenceFlag() const { + [[nodiscard]] u16 presenceFlag() const { return m_presenceFlag; } /// @endGetters diff --git a/source/host/KReplaySystem.hh b/source/host/KReplaySystem.hh index 29a4fadf..6afc74e2 100644 --- a/source/host/KReplaySystem.hh +++ b/source/host/KReplaySystem.hh @@ -15,7 +15,7 @@ public: static KReplaySystem *CreateInstance(); static void DestroyInstance(); - static KReplaySystem *Instance() { + [[nodiscard]] static KReplaySystem *Instance() { return static_cast(s_instance); } @@ -27,12 +27,12 @@ private: KReplaySystem(KReplaySystem &&) = delete; ~KReplaySystem() override; - bool calcEnd() const; + [[nodiscard]] bool calcEnd() const; void reportFail(const std::string &msg) const; - bool success() const; - s32 getDesyncingTimerIdx() const; - DesyncingTimerPair getDesyncingTimer(s32 i) const; + [[nodiscard]] bool success() const; + [[nodiscard]] s32 getDesyncingTimerIdx() const; + [[nodiscard]] DesyncingTimerPair getDesyncingTimer(s32 i) const; static void OnInit(System::RaceConfig *config, void *arg); diff --git a/source/host/KTestSystem.hh b/source/host/KTestSystem.hh index f7ad9a8d..a215a34f 100644 --- a/source/host/KTestSystem.hh +++ b/source/host/KTestSystem.hh @@ -20,7 +20,7 @@ public: static KTestSystem *CreateInstance(); static void DestroyInstance(); - static KTestSystem *Instance() { + [[nodiscard]] static KTestSystem *Instance() { return static_cast(s_instance); } @@ -118,13 +118,13 @@ private: bool popTestCase(); bool calcTest(); - TestData findCurrentFrameEntry(); + [[nodiscard]] TestData findCurrentFrameEntry(); void testFrame(const TestData &data); bool runTest(); void writeTestOutput() const; - const TestCase &getCurrentTestCase() const; + [[nodiscard]] const TestCase &getCurrentTestCase() const; static void OnInit(System::RaceConfig *config, void *arg); diff --git a/source/host/Option.hh b/source/host/Option.hh index f3f6dd65..923dc3fe 100644 --- a/source/host/Option.hh +++ b/source/host/Option.hh @@ -15,7 +15,7 @@ enum class EOption { namespace Option { -std::optional CheckFlag(const char *arg); +[[nodiscard]] std::optional CheckFlag(const char *arg); } // namespace Option } // namespace Host