summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-05-28 04:48:05 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-05-28 04:58:10 +0200
commitccbf628602e1093bd4d29312113b7dc18ec918b0 (patch)
treebeb3507d4831a5b50b43ccbc73c416ae360cd10a /src
parent6f4e493d7cbe514527e2b2d942040609ef930da9 (diff)
also fix broken protos for {critter,light}_proto
Diffstat (limited to 'src')
-rw-r--r--src/critter.cpp2
-rw-r--r--src/light.cpp16
-rw-r--r--src/light.hpp2
3 files changed, 17 insertions, 3 deletions
diff --git a/src/critter.cpp b/src/critter.cpp
index 4c04022c..7b337953 100644
--- a/src/critter.cpp
+++ b/src/critter.cpp
@@ -346,7 +346,7 @@ bool critter_proto::operator==(const object_proto& e0) const
return false;
const auto& s0 = static_cast<const critter_proto&>(e0);
- return name == s0.name && playable == s0.playable;
+ return name == s0.name && Math::abs(speed - s0.speed) < 1e-8f && playable == s0.playable;
}
void critter::set_keys(bool L, bool R, bool U, bool D) { moves = { L, R, U, D, moves.AUTO, }; }
diff --git a/src/light.cpp b/src/light.cpp
index e6de08a6..647368ec 100644
--- a/src/light.cpp
+++ b/src/light.cpp
@@ -21,7 +21,21 @@ light_proto& light_proto::operator=(const light_proto&) = default;
light_proto::light_proto(light_proto&&) noexcept = default;
light_proto& light_proto::operator=(light_proto&&) noexcept = default;
-bool light_proto::operator==(const light_proto&) const = default;
+bool light_proto::operator==(const object_proto& oʹ) const
+{
+ if (type != oʹ.type)
+ return false;
+
+ if (!object_proto::operator==(oʹ))
+ return false;
+
+ const auto& o = static_cast<const light_proto&>(oʹ);
+
+ return Math::abs(max_distance - o.max_distance) < 1e-8f &&
+ color == o.color &&
+ falloff == o.falloff &&
+ enabled == o.enabled;
+}
light::light(object_id id, class chunk& c, const light_proto& proto) :
object{id, c, proto},
diff --git a/src/light.hpp b/src/light.hpp
index aeee5d88..a6a22fdb 100644
--- a/src/light.hpp
+++ b/src/light.hpp
@@ -15,7 +15,7 @@ struct light_proto : object_proto
light_proto& operator=(const light_proto&);
light_proto(light_proto&&) noexcept;
light_proto& operator=(light_proto&&) noexcept;
- bool operator==(const light_proto&) const;
+ bool operator==(const object_proto&) const override;
float max_distance = 0;
Color4ub color{255, 255, 255, 255};