Browse Source

snapshot: reject entity type in the range-get (now get instead of get_sparse)

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

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

@@ -94,7 +94,9 @@ public:
      * @return An object of this type to continue creating the snapshot.
      */
     template<typename Type, typename Archive, typename It>
-    const basic_snapshot &get_sparse(Archive &archive, It first, It last, const id_type id = type_hash<Type>::value()) const {
+    const basic_snapshot &get(Archive &archive, It first, It last, const id_type id = type_hash<Type>::value()) const {
+        static_assert(!std::is_same_v<Type, entity_type>, "Entity types not supported");
+
         if(const auto *storage = reg->template storage<Type>(id); storage && !storage->empty()) {
             archive(static_cast<typename traits_type::entity_type>(std::distance(first, last)));
 
@@ -148,8 +150,8 @@ public:
      * @return An object of this type to continue creating the snapshot.
      */
     template<typename... Component, typename Archive, typename It>
-    [[deprecated("use .get_sparse<Type>(archive, first, last) instead")]] const basic_snapshot &component(Archive &archive, It first, It last) const {
-        return (get_sparse<Component>(archive, first, last), ...);
+    [[deprecated("use .get<Type>(archive, first, last) instead")]] const basic_snapshot &component(Archive &archive, It first, It last) const {
+        return (get<Component>(archive, first, last), ...);
     }
 
 private: