diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-10 00:14:47 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-10 00:16:43 +0200 |
| commit | 2b9e97e28ed0504de15d73ff5e1dd0ff9deb6d09 (patch) | |
| tree | eee807781ce6584eaa16ebe254e27016d7422fa1 /serialize/world-reader.cpp | |
| parent | 3212ca62361da55e8eec4cb97ee1698b534daad6 (diff) | |
src/world: pre-initialize entity ctr to 1024
This way, rtree object_id can only be equal to entity's id if it's an
entity and not static geometry.
Diffstat (limited to 'serialize/world-reader.cpp')
| -rw-r--r-- | serialize/world-reader.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp index b9a6a528..09566afa 100644 --- a/serialize/world-reader.cpp +++ b/serialize/world-reader.cpp @@ -382,7 +382,7 @@ void reader_state::deserialize_world(ArrayView<const char> buf) (size_t)proto, (size_t)min_proto_version, (size_t)proto_version); PROTO = proto; fm_assert(PROTO > 0); - object_id entity_counter = 0; + object_id entity_counter = world::entity_counter_init; read_atlases(s); if (PROTO >= 3) [[likely]] read_sceneries(s); @@ -393,10 +393,11 @@ void reader_state::deserialize_world(ArrayView<const char> buf) read_chunks(s); s.assert_end(); if (PROTO >= 8) [[likely]] - { - fm_assert(_world->entity_counter() == 0); + fm_assert(_world->entity_counter() == world::entity_counter_init); + if (PROTO >= 13) [[likely]] _world->set_entity_counter(entity_counter); - } + else if (PROTO >= 8) [[likely]] + _world->set_entity_counter(std::max(world::entity_counter_init, entity_counter)); _world = nullptr; } |
