From 48d8f894bd7bfddcb49743855397e3ab622bc40f Mon Sep 17 00:00:00 2001 From: Lars Pensjö Date: Sat, 2 Mar 2013 15:26:31 +0100 Subject: Entity allocation error fixed. Need to save the id before erasing. --- entityx/Entity.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/entityx/Entity.h b/entityx/Entity.h index 6d046c3..ae28443 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -1,10 +1,10 @@ /** * Copyright (C) 2012 Alec Thomas * All rights reserved. - * + * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. - * + * * Author: Alec Thomas */ @@ -227,7 +227,7 @@ class EntityManager : boost::noncopyable { return true; } - EntityManager &manager_; + EntityManager &manager_; const std::vector predicates_; std::vector> unpackers_; Entity::Id i_; @@ -246,7 +246,7 @@ class EntityManager : boost::noncopyable { template View &unpack_to(boost::shared_ptr &a) { unpackers_.push_back(Unpacker(manager_, a)); - // This resulted in a segfault under clang 4.1 on OSX. No idea why. + // This resulted in a segfault under clang 4.1 on OSX. No idea why. /*unpackers_.push_back([&a, this](Entity::Id id) { a = manager_.component(id); });*/ @@ -299,7 +299,9 @@ class EntityManager : boost::noncopyable { id = id_counter_++; accomodate_entity(id); } else { - id = *free_list_.erase(free_list_.begin()); + auto it = free_list_.begin(); + id = *it; + free_list_.erase(it); } event_manager_.emit(*this, id); return Entity(*this, id); -- cgit v1.2.3