aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Thomas <alec@swapoff.org>2014-08-05 13:57:58 +1000
committerAlec Thomas <alec@swapoff.org>2014-08-05 13:57:58 +1000
commitaed41e4311e6e0080ef55b673500c0facfee90c2 (patch)
tree7fabe5c26cc172dabb5ec5b66613878534dc874e
parente53e3dae11a5904194941cfb436b2430673740d1 (diff)
parent84a899775b86a1e44b2327cb35ef45a393f161d6 (diff)
Merge pull request #45 from isra17/master
Fix components mask bitset operations
-rw-r--r--entityx/Entity.h10
-rw-r--r--entityx/Event.h2
-rw-r--r--entityx/System.h2
-rw-r--r--entityx/config.h.in5
4 files changed, 10 insertions, 9 deletions
diff --git a/entityx/Entity.h b/entityx/Entity.h
index e36d761..7312e25 100644
--- a/entityx/Entity.h
+++ b/entityx/Entity.h
@@ -212,7 +212,7 @@ private:
*/
struct BaseComponent {
public:
- typedef uint64_t Family;
+ typedef size_t Family;
// NOTE: Component memory is *always* managed by the EntityManager.
// Use Entity::destroy() instead.
@@ -506,7 +506,7 @@ class EntityManager : entityx::help::NonCopyable {
Pool<C> *pool = accomodate_component<C>();
new(pool->get(id.index())) C(std::forward<Args>(args) ...);
ComponentHandle<C> component(this, id);
- entity_component_mask_[id.index()] |= uint64_t(1) << family;
+ entity_component_mask_[id.index()].set(family);
event_manager_.emit<ComponentAddedEvent<C>>(Entity(this, id), component);
return component;
}
@@ -519,12 +519,12 @@ class EntityManager : entityx::help::NonCopyable {
template <typename C>
void remove(Entity::Id id) {
assert_valid(id);
- const int family = C::family();
- const int index = id.index();
+ const BaseComponent::Family family = C::family();
+ const uint32_t index = id.index();
ComponentHandle<C> component(this, id);
BasePool *pool = component_pools_[family];
event_manager_.emit<ComponentRemovedEvent<C>>(Entity(this, id), component);
- entity_component_mask_[id.index()] &= ~(uint64_t(1) << family);
+ entity_component_mask_[id.index()].reset(family);
pool->destroy(index);
}
diff --git a/entityx/Event.h b/entityx/Event.h
index f830be0..f238497 100644
--- a/entityx/Event.h
+++ b/entityx/Event.h
@@ -26,7 +26,7 @@ namespace entityx {
/// Used internally by the EventManager.
class BaseEvent {
public:
- typedef uint64_t Family;
+ typedef size_t Family;
virtual ~BaseEvent() {}
diff --git a/entityx/System.h b/entityx/System.h
index d94c91a..4854b8d 100644
--- a/entityx/System.h
+++ b/entityx/System.h
@@ -32,7 +32,7 @@ class SystemManager;
*/
class BaseSystem : entityx::help::NonCopyable {
public:
- typedef uint64_t Family;
+ typedef size_t Family;
virtual ~BaseSystem() {}
diff --git a/entityx/config.h.in b/entityx/config.h.in
index 575b34f..e76e4df 100644
--- a/entityx/config.h.in
+++ b/entityx/config.h.in
@@ -2,10 +2,11 @@
#cmakedefine ENTITYX_MAX_COMPONENTS @ENTITYX_MAX_COMPONENTS@
-#include <stdint.h>
+#include <cstdint>
+#include <cstddef>
namespace entityx {
-static const uint64_t MAX_COMPONENTS = ENTITYX_MAX_COMPONENTS;
+static const size_t MAX_COMPONENTS = ENTITYX_MAX_COMPONENTS;
} // namespace entityx