summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/fixed_point.h3
-rw-r--r--include/sim_core.h17
-rw-r--r--src/fixed_point.cpp4
-rw-r--r--src/sim_core.cpp0
4 files changed, 19 insertions, 5 deletions
diff --git a/include/fixed_point.h b/include/fixed_point.h
index 385ccc2..2a9ec8d 100644
--- a/include/fixed_point.h
+++ b/include/fixed_point.h
@@ -3,6 +3,7 @@
#include <cstdint>
#include <type_traits>
+#include <compare>
struct fp_t {
static constexpr std::int32_t Q = 16;
@@ -16,7 +17,7 @@ struct fp_t {
fp_t operator-(const fp_t& other) const;
fp_t operator*(const fp_t& other) const;
fp_t operator/(const fp_t& other) const;
- bool operator==(const fp_t& other) const;
+ auto operator<=>(const fp_t&) const = default;
};
static_assert(std::is_trivially_copyable_v<fp_t>, "fp_t must remain trivially copyable for rollback determinism");
diff --git a/include/sim_core.h b/include/sim_core.h
new file mode 100644
index 0000000..88533d0
--- /dev/null
+++ b/include/sim_core.h
@@ -0,0 +1,17 @@
+#ifndef SIM_CORE_H
+#define SIM_CORE_H
+
+#include <type_traits>
+#include "fixed_point.h"
+
+struct SimState {
+ fp_t stage_width;
+ fp_t stage_height;
+ fp_t camera_x;
+ fp_t camera_y;
+};
+
+static_assert(std::is_trivially_copyable_v<SimState>, "SimState must be trivially copyable for rollback");
+static_assert(sizeof(SimState) == 16, "SimState size changed unexpectedly");
+
+#endif // !SIM_CORE_H
diff --git a/src/fixed_point.cpp b/src/fixed_point.cpp
index a39f2bc..3a69958 100644
--- a/src/fixed_point.cpp
+++ b/src/fixed_point.cpp
@@ -39,7 +39,3 @@ fp_t fp_t::operator/(const fp_t& other) const {
}
return {static_cast<std::int32_t>(temp)};
}
-
-bool fp_t::operator==(const fp_t& other) const {
- return raw == other.raw;
-}
diff --git a/src/sim_core.cpp b/src/sim_core.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/sim_core.cpp