Browse Source

snapshot: cleanup

Michele Caini 5 years ago
parent
commit
4d73adb540
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/entt/entity/snapshot.hpp

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

@@ -210,17 +210,18 @@ class basic_snapshot_loader {
         archive(length);
         archive(length);
 
 
         while(length--) {
         while(length--) {
-            static constexpr auto discard = false;
             Entity entt{};
             Entity entt{};
 
 
             if constexpr(std::is_empty_v<Type>) {
             if constexpr(std::is_empty_v<Type>) {
                 archive(entt);
                 archive(entt);
-                force(*reg, entt, discard);
+                const auto entity = reg->valid(entt) ? entt : reg->create(entt);
+                ENTT_ASSERT(entity == entt);
                 reg->template emplace<Type>(args..., entt);
                 reg->template emplace<Type>(args..., entt);
             } else {
             } else {
                 Type instance{};
                 Type instance{};
                 archive(entt, instance);
                 archive(entt, instance);
-                force(*reg, entt, discard);
+                const auto entity = reg->valid(entt) ? entt : reg->create(entt);
+                ENTT_ASSERT(entity == entt);
                 reg->template emplace<Type>(args..., entt, std::as_const(instance));
                 reg->template emplace<Type>(args..., entt, std::as_const(instance));
             }
             }
         }
         }