summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-05-28 04:47:29 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-05-28 04:47:29 +0200
commit6f4e493d7cbe514527e2b2d942040609ef930da9 (patch)
treef8582972e1c970c884cfdea8589882c184bf1ff6 /src
parent13cf28c20f441876f9f608373788ed5104f817aa (diff)
fix hole_proto::operator==
Diffstat (limited to 'src')
-rw-r--r--src/hole.cpp13
-rw-r--r--src/hole.hpp4
2 files changed, 14 insertions, 3 deletions
diff --git a/src/hole.cpp b/src/hole.cpp
index fa4a80d6..6a48e57b 100644
--- a/src/hole.cpp
+++ b/src/hole.cpp
@@ -18,7 +18,18 @@ hole_proto::hole_proto(hole_proto&&) noexcept = default;
hole_proto& hole_proto::operator=(hole_proto&&) noexcept = default;
bool hole_proto::flags::operator==(const struct flags&) const = default;
-bool hole_proto::operator==(const hole_proto&) const = default;
+
+bool hole_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 hole_proto&>(oʹ);
+ return height == o.height && z_offset == o.z_offset && flags == o.flags;
+}
hole_proto::hole_proto()
{
diff --git a/src/hole.hpp b/src/hole.hpp
index 49d1e809..6ec1c666 100644
--- a/src/hole.hpp
+++ b/src/hole.hpp
@@ -12,7 +12,7 @@ struct hole_proto final : object_proto
hole_proto& operator=(const hole_proto&);
hole_proto(hole_proto&&) noexcept;
hole_proto& operator=(hole_proto&&) noexcept;
- bool operator==(const hole_proto&) const;
+ bool operator==(const object_proto& proto) const override;
struct flags
{
@@ -23,7 +23,7 @@ struct hole_proto final : object_proto
bool is_wall : 1 = false;
};
- uint8_t height = 0;
+ uint8_t height = 0, z_offset = tile_size_z/2;
struct flags flags;
};