snapshot: minor changes

This commit is contained in:
Michele Caini
2023-05-22 19:03:11 +02:00
parent f4b26756c5
commit d903e268f0

View File

@@ -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);
}