From c58acff446a7eeb770710d3f68066e1f4c2143be Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Sat, 11 Jan 2025 23:44:45 +0800 Subject: [PATCH] chore: add some operators --- src/mc/common/ActorRuntimeID.h | 15 +++++++++++---- src/mc/common/ActorUniqueID.h | 7 +++++++ src/mc/world/level/BlockTickingQueue.h | 8 ++++++-- src/mc/world/level/Tick.h | 7 +++++++ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/mc/common/ActorRuntimeID.h b/src/mc/common/ActorRuntimeID.h index d7794ecbab..82ee81fe9d 100644 --- a/src/mc/common/ActorRuntimeID.h +++ b/src/mc/common/ActorRuntimeID.h @@ -4,15 +4,22 @@ class ActorRuntimeID { public: - // member variables - // NOLINTBEGIN - uint64 rawID; - // NOLINTEND + [[nodiscard]] constexpr bool operator==(ActorRuntimeID const& other) const noexcept { return rawID == other.rawID; } + + [[nodiscard]] constexpr std::strong_ordering operator<=>(ActorRuntimeID const& other) const noexcept { + return rawID <=> other.rawID; + } [[nodiscard]] constexpr ActorRuntimeID() : rawID(0) {} [[nodiscard]] constexpr ActorRuntimeID(uint64 x) : rawID(x) {} [[nodiscard]] constexpr operator uint64() const { return rawID; } + +public: + // member variables + // NOLINTBEGIN + uint64 rawID; + // NOLINTEND }; namespace std { diff --git a/src/mc/common/ActorUniqueID.h b/src/mc/common/ActorUniqueID.h index fbe0e0d92f..b1c1988f68 100644 --- a/src/mc/common/ActorUniqueID.h +++ b/src/mc/common/ActorUniqueID.h @@ -8,6 +8,13 @@ namespace mce { class UUID; } // clang-format on struct ActorUniqueID { +public: + [[nodiscard]] constexpr bool operator==(ActorUniqueID const& other) const noexcept { return rawID == other.rawID; } + + [[nodiscard]] constexpr std::strong_ordering operator<=>(ActorUniqueID const& other) const noexcept { + return rawID <=> other.rawID; + } + public: // member variables // NOLINTBEGIN diff --git a/src/mc/world/level/BlockTickingQueue.h b/src/mc/world/level/BlockTickingQueue.h index 5cd2ead322..b1ff436edb 100644 --- a/src/mc/world/level/BlockTickingQueue.h +++ b/src/mc/world/level/BlockTickingQueue.h @@ -1,6 +1,7 @@ #pragma once #include "mc/_HeaderOutputPredefine.h" +#include "mc/world/level/TickNextTickData.h" // auto generated inclusion list #include "mc/deps/core/container/MovePriorityQueue.h" @@ -33,11 +34,14 @@ class BlockTickingQueue { // BlockTickingQueue inner types define class BlockTick { + public: + [[nodiscard]] bool operator>(BlockTick const& other) const { return mData > other.mData; } + public: // member variables // NOLINTBEGIN - ::ll::TypedStorage<1, 1, bool> mIsRemoved; - ::ll::TypedStorage<8, 40, ::TickNextTickData> mData; + bool mIsRemoved; + ::TickNextTickData mData; // NOLINTEND }; diff --git a/src/mc/world/level/Tick.h b/src/mc/world/level/Tick.h index 2e5bb724ec..40eea60f7c 100644 --- a/src/mc/world/level/Tick.h +++ b/src/mc/world/level/Tick.h @@ -3,6 +3,13 @@ #include "mc/_HeaderOutputPredefine.h" struct Tick { +public: + [[nodiscard]] constexpr bool operator==(Tick const& other) const noexcept { return tickID == other.tickID; } + + [[nodiscard]] constexpr std::strong_ordering operator<=>(Tick const& other) const noexcept { + return tickID <=> other.tickID; + } + public: // member variables // NOLINTBEGIN