diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-04-08 20:58:50 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-04-08 20:58:50 +0200 |
commit | 53940c48b32cfe045bdd26df33788cc480b39d90 (patch) | |
tree | a38cb5ee448d579604fd3f1ee1ec8cb67930e2f3 /src | |
parent | 5ddebce84be0905b28ce5975762f8b144ea4cbcd (diff) |
b
Diffstat (limited to 'src')
-rw-r--r-- | src/world.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/world.cpp b/src/world.cpp index 2b6407ae..7e9ec86a 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -156,10 +156,11 @@ void world::do_make_object(const std::shared_ptr<object>& e, global_coords pos, { fm_assert(e->id > 0); fm_debug_assert(_unique_id && e->c->world()._unique_id == _unique_id); - fm_assert(!_objects->contains(e->id)); fm_assert(e->type() != object_type::none); const_cast<global_coords&>(e->coord) = pos; - (*_objects)[e->id] = e; + auto [_, fresh] = _objects->try_emplace(e->id, e); + if (!fresh) [[unlikely]] + fm_throw("object already initialized id:{}"_cf, e->id); if (sorted) e->c->add_object(e); else |