diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 18:34:33 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 21:30:56 +0200 |
commit | afdb73b18329d1e135340ac4a7aab952648fada8 (patch) | |
tree | 483972316bf46ac25bbbc180825acb8a3c68ba0b | |
parent | e679da407d43b581afaf0539acea1143c022b245 (diff) |
b
-rw-r--r-- | editor/inspect-types.cpp | 6 | ||||
-rw-r--r-- | src/chunk-collision.cpp | 4 | ||||
-rw-r--r-- | src/chunk.cpp | 2 | ||||
-rw-r--r-- | src/chunk.hpp | 3 | ||||
-rw-r--r-- | src/object.cpp | 2 | ||||
-rw-r--r-- | src/scenery.cpp | 2 |
6 files changed, 10 insertions, 9 deletions
diff --git a/editor/inspect-types.cpp b/editor/inspect-types.cpp index 520f0f3c..cb85f574 100644 --- a/editor/inspect-types.cpp +++ b/editor/inspect-types.cpp @@ -298,6 +298,9 @@ bool inspect_object_subtype(object& x) const auto type = x.type(); switch (type) { + case object_type::none: + case object_type::COUNT: + break; case object_type::scenery: { auto& sc = static_cast<scenery&>(x); const auto sc_type = sc.scenery_type(); @@ -315,9 +318,6 @@ bool inspect_object_subtype(object& x) } case object_type::critter: return inspect_type(static_cast<critter&>(x), inspect_intent_t{}); case object_type::light: return inspect_type(static_cast<light&>(x), inspect_intent_t{}); - case object_type::none: - case object_type::COUNT: - break; } fm_warn_once("unknown object subtype '%d'", (int)type); return false; diff --git a/src/chunk-collision.cpp b/src/chunk-collision.cpp index ecd05eb7..196a2c12 100644 --- a/src/chunk-collision.cpp +++ b/src/chunk-collision.cpp @@ -13,8 +13,8 @@ namespace floormat { bool collision_data::operator==(const collision_data&) const noexcept = default; bool chunk::bbox::operator==(const floormat::chunk::bbox& other) const noexcept = default; - chunk::RTree* chunk::rtree() noexcept { ensure_passability(); return &*_rtree; } +world& chunk::world() noexcept { return *_world; } namespace { @@ -65,7 +65,7 @@ void chunk::ensure_passability() noexcept auto id = make_id(collision_type::geometry, atlas->info().passability, TILE_COUNT+i+1); _rtree->Insert(min.data(), max.data(), id); - if (tile.wall_west_atlas().get()) + if (tile.wall_west_atlas()) { auto [min, max] = wall_pillar(i, (float)atlas->info().depth); _rtree->Insert(min.data(), max.data(), id); diff --git a/src/chunk.cpp b/src/chunk.cpp index e0330339..57a3e62a 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -168,6 +168,8 @@ void chunk::on_teardown() fm_assert(!_teardown); // too late, some chunks were already erased } +bool chunk::is_teardown() const { return _teardown || _world->is_teardown(); } + void chunk::remove_object(size_t i) { fm_assert(_objects_sorted); diff --git a/src/chunk.hpp b/src/chunk.hpp index 133fb428..4b18ada8 100644 --- a/src/chunk.hpp +++ b/src/chunk.hpp @@ -96,7 +96,7 @@ public: void ensure_passability() noexcept; RTree* rtree() noexcept; - class world& world() noexcept { return *_world; } + class world& world() noexcept; [[nodiscard]] bool can_place_object(const object_proto& proto, local_coords pos); @@ -105,6 +105,7 @@ public: void sort_objects(); void remove_object(size_t i); void on_teardown(); + bool is_teardown() const; ArrayView<const std::shared_ptr<object>> objects() const; // for drawing only diff --git a/src/object.cpp b/src/object.cpp index 1bc6e015..72906320 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -68,7 +68,7 @@ object::object(object_id id, class chunk& c, const object_proto& proto) : object::~object() noexcept { fm_debug_assert(id); - if (c->_teardown || c->_world->_teardown) [[unlikely]] + if (c->is_teardown()) [[unlikely]] return; if (chunk::bbox bb; c->_bbox_for_scenery(*this, bb)) c->_remove_bbox(bb); diff --git a/src/scenery.cpp b/src/scenery.cpp index c7d3b51d..7e52c08e 100644 --- a/src/scenery.cpp +++ b/src/scenery.cpp @@ -11,8 +11,6 @@ namespace floormat { - - // --- scenery --- enum object_type scenery::type() const noexcept { return object_type::scenery; } // NOLINT(*-convert-*-to-static) |