diff --git a/src/entt/entity/snapshot.hpp b/src/entt/entity/snapshot.hpp index 9b7978943..319465e9d 100644 --- a/src/entt/entity/snapshot.hpp +++ b/src/entt/entity/snapshot.hpp @@ -83,6 +83,7 @@ public: template const basic_snapshot &entities(Archive &archive) const { const auto *storage = reg->template storage(); + ENTT_ASSERT(storage != nullptr, "No entity storage, no party"); archive(static_cast(storage->size())); archive(static_cast(storage->in_use())); @@ -215,16 +216,16 @@ public: template basic_snapshot_loader &entities(Archive &archive) { auto &storage = reg->template storage(); + typename traits_type::entity_type length{}; typename traits_type::entity_type in_use{}; - entity_type entity = null; archive(length); archive(in_use); storage.reserve(length); - for(std::size_t pos{}; pos < length; ++pos) { + for(entity_type entity = null; length; --length) { archive(entity); storage.emplace(entity); }