From 54a90fdfe41abfefca1a4e28969c6e4eff93bd83 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 Jul 2024 16:45:18 +0200 Subject: src/world: remove weak_bptr usage --- main/ctor.cpp | 2 +- src/world.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/main/ctor.cpp b/main/ctor.cpp index 3508b7cd..73658a07 100644 --- a/main/ctor.cpp +++ b/main/ctor.cpp @@ -33,7 +33,7 @@ class world& main_impl::reset_world(class world&& w) noexcept for (auto& [_, cʹ] : _world.chunks()) for (const auto& eʹ : cʹ.objects()) - fm_assert(eʹ.use_count() == 1); + fm_assert_equal(uint32_t{2}, eʹ.use_count()); _world = move(w); _first_frame = true; diff --git a/src/world.cpp b/src/world.cpp index 935ca6c4..89c127cc 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -6,7 +6,6 @@ #include "scenery-proto.hpp" #include "light.hpp" #include "compat/borrowed-ptr.inl" -#include "compat/weak-borrowed-ptr.inl" #include "compat/hash.hpp" #include "compat/exception.hpp" #include "compat/overloaded.hpp" @@ -27,9 +26,9 @@ size_t world::chunk_coords_hasher::operator()(const chunk_coords_& coord) const } namespace floormat { -struct world::robin_map_wrapper final : tsl::robin_map, object_id_hasher> +struct world::robin_map_wrapper final : tsl::robin_map, object_id_hasher> { - using tsl::robin_map, object_id_hasher>::robin_map; + using tsl::robin_map, object_id_hasher>::robin_map; }; world::world(world&& w) noexcept = default; @@ -52,8 +51,8 @@ world& world::operator=(world&& w) noexcept fm_assert(!w._teardown); fm_assert(!_teardown); _last_chunk = {}; - _chunks = move(w._chunks); _objects = move(w._objects); + _chunks = move(w._chunks); w._objects = {}; fm_assert(w._unique_id); _unique_id = move(w._unique_id); @@ -191,7 +190,7 @@ void world::erase_object(object_id id) bptr world::find_object_(object_id id) { auto it = _objects->find(id); - auto ret = it == _objects->end() ? nullptr : it->second.lock(); + auto ret = it == _objects->end() ? nullptr : it->second; fm_debug_assert(!ret || &ret->c->world() == this); return ret; } -- cgit v1.2.3