Pārlūkot izejas kodu

snapshot: minor changes

Michele Caini 2 gadi atpakaļ
vecāks
revīzija
d903e268f0
1 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. 3 2
      src/entt/entity/snapshot.hpp

+ 3 - 2
src/entt/entity/snapshot.hpp

@@ -83,6 +83,7 @@ public:
     template<typename Archive>
     const basic_snapshot &entities(Archive &archive) const {
         const auto *storage = reg->template storage<entity_type>();
+        ENTT_ASSERT(storage != nullptr, "No entity storage, no party");
 
         archive(static_cast<typename traits_type::entity_type>(storage->size()));
         archive(static_cast<typename traits_type::entity_type>(storage->in_use()));
@@ -215,16 +216,16 @@ public:
     template<typename Archive>
     basic_snapshot_loader &entities(Archive &archive) {
         auto &storage = reg->template storage<entity_type>();
+
         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);
         }