Jelajahi Sumber

storage: prevent ::next from spinning forever

Michele Caini 2 tahun lalu
induk
melakukan
f18c8f14bf
2 mengubah file dengan 1 tambahan dan 2 penghapusan
  1. 0 1
      TODO
  2. 1 1
      src/entt/entity/storage.hpp

+ 0 - 1
TODO

@@ -32,7 +32,6 @@ TODO:
 * range sparse_set::push should return a reverse iterator, it's kinda wrong now
 * range sparse_set::push should return a reverse iterator, it's kinda wrong now
 * after non-continuous generation for entity storage:
 * after non-continuous generation for entity storage:
   - get/reset placeholder to position after saving/loading (avoid long lookup)
   - get/reset placeholder to position after saving/loading (avoid long lookup)
-  - basic_storage<...>::next never stops in release when it runs out of entities (well, not an issue probably but still)
   - documentation for reserved entities
   - documentation for reserved entities
 * no-version entities always return true when compared to tombstones (fixed but test needed)
 * no-version entities always return true when compared to tombstones (fixed but test needed)
 * storage entity: no emplace/insert, rename and add a fast range-push from above
 * storage entity: no emplace/insert, rename and add a fast range-push from above

+ 1 - 1
src/entt/entity/storage.hpp

@@ -957,7 +957,7 @@ class basic_storage<Entity, Entity, Allocator>
         do {
         do {
             ENTT_ASSERT(placeholder < underlying_type::traits_type::to_entity(null), "Invalid element");
             ENTT_ASSERT(placeholder < underlying_type::traits_type::to_entity(null), "Invalid element");
             entt = underlying_type::traits_type::combine(static_cast<typename underlying_type::traits_type::entity_type>(placeholder++), {});
             entt = underlying_type::traits_type::combine(static_cast<typename underlying_type::traits_type::entity_type>(placeholder++), {});
-        } while(base_type::current(entt) != underlying_type::traits_type::to_version(tombstone));
+        } while(base_type::current(entt) != underlying_type::traits_type::to_version(tombstone) && entt != null);
 
 
         return entt;
         return entt;
     }
     }