Bugfix in ecs entity creation in case a table with the same components but in a different order already exists

This commit is contained in:
Nikita Lisitsa 2023-08-23 14:47:26 +03:00
parent 72508eb445
commit c0668e2de2

View file

@ -12,7 +12,7 @@ namespace psemek::ecs::detail
struct table_container struct table_container
{ {
template <typename ... Components> template <typename ... Components>
std::pair<table_impl<Components...> *, bool> insert(component_mask const & mask, util::span<util::uuid const> component_uuids); std::pair<table *, bool> insert(component_mask const & mask, util::span<util::uuid const> component_uuids);
template <typename Function> template <typename Function>
void apply(Function && function, component_mask const & mask); void apply(Function && function, component_mask const & mask);
@ -22,7 +22,7 @@ namespace psemek::ecs::detail
}; };
template <typename ... Components> template <typename ... Components>
std::pair<table_impl<Components...> *, bool> table_container::insert(component_mask const & mask, util::span<util::uuid const> component_uuids) std::pair<table *, bool> table_container::insert(component_mask const & mask, util::span<util::uuid const> component_uuids)
{ {
auto & result = tables_[mask]; auto & result = tables_[mask];
bool created = false; bool created = false;
@ -31,7 +31,7 @@ namespace psemek::ecs::detail
result = std::make_unique<table_impl<Components...>>(component_uuids); result = std::make_unique<table_impl<Components...>>(component_uuids);
created = true; created = true;
} }
return {static_cast<table_impl<Components...> *>(result.get()), created}; return {result.get(), created};
} }
template <typename Function> template <typename Function>