aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--entityx/Entity.cc1
-rw-r--r--entityx/Entity.h1
-rw-r--r--entityx/help/Pool.h4
3 files changed, 5 insertions, 1 deletions
diff --git a/entityx/Entity.cc b/entityx/Entity.cc
index e81ae80..463e6b3 100644
--- a/entityx/Entity.cc
+++ b/entityx/Entity.cc
@@ -39,6 +39,7 @@ EntityManager::~EntityManager() {
}
void EntityManager::reset() {
+ for (Entity entity : entities_for_debugging()) entity.destroy();
for (BasePool *pool : component_pools_) {
if (pool) delete pool;
}
diff --git a/entityx/Entity.h b/entityx/Entity.h
index 7032ab1..b749c4c 100644
--- a/entityx/Entity.h
+++ b/entityx/Entity.h
@@ -552,6 +552,7 @@ class EntityManager : entityx::help::NonCopyable {
ComponentHandle<C> assign(Entity::Id id, Args && ... args) {
assert_valid(id);
const BaseComponent::Family family = C::family();
+ assert(!entity_component_mask_[id.index()].test(family));
// Placement new into the component pool.
Pool<C> *pool = accomodate_component<C>();
diff --git a/entityx/help/Pool.h b/entityx/help/Pool.h
index 7b1ca19..f217ec2 100644
--- a/entityx/help/Pool.h
+++ b/entityx/help/Pool.h
@@ -81,7 +81,9 @@ template <typename T, std::size_t ChunkSize = 8192>
class Pool : public BasePool {
public:
Pool() : BasePool(sizeof(T), ChunkSize) {}
- virtual ~Pool() {}
+ virtual ~Pool() {
+ // Component destructors *must* be called by owner.
+ }
virtual void destroy(std::size_t n) override {
assert(n < size_);