From 99ca3ec2ebdc2f2080c54b874b057d538eb8d81e Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 10 Jul 2024 21:21:05 +0300 Subject: [PATCH] Bugfix in ecs query caches: store the component UUIDs in vectors instead of hash sets, because the order of components matters --- .../ecs/detail/query_cache_container.hpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libs/ecs/include/psemek/ecs/detail/query_cache_container.hpp b/libs/ecs/include/psemek/ecs/detail/query_cache_container.hpp index c784767a..a5986cf4 100644 --- a/libs/ecs/include/psemek/ecs/detail/query_cache_container.hpp +++ b/libs/ecs/include/psemek/ecs/detail/query_cache_container.hpp @@ -13,8 +13,8 @@ namespace psemek::ecs::detail struct query_cache_data { std::size_t hash; - util::hash_set with_uuids; - util::hash_set without_uuids; + std::vector with_uuids; + std::vector without_uuids; std::shared_ptr cache; }; @@ -41,13 +41,11 @@ namespace psemek::ecs::detail if (uuids.second.size() != set->without_uuids.size()) return false; - for (auto const & uuid : uuids.first) - if (!set->with_uuids.contains(uuid)) - return false; + if (!std::equal(uuids.first.begin(), uuids.first.end(), set->with_uuids.begin())) + return false; - for (auto const & uuid : uuids.second) - if (!set->without_uuids.contains(uuid)) - return false; + if (!std::equal(uuids.second.begin(), uuids.second.end(), set->without_uuids.begin())) + return false; return true; } @@ -70,12 +68,12 @@ namespace psemek::ecs::detail value->cache = std::make_shared(); for (auto const & uuid : with_uuids) { - value->with_uuids.insert(uuid); + value->with_uuids.push_back(uuid); value->cache->with_uuids.push_back(uuid); } for (auto const & uuid : without_uuids) { - value->without_uuids.insert(uuid); + value->without_uuids.push_back(uuid); value->cache->without_uuids.push_back(uuid); } value->hash = component_hash(with_uuids, without_uuids);