Browse Source

minor changes

Michele Caini 7 years ago
parent
commit
d8a9f0ca12

+ 1 - 0
TODO

@@ -2,6 +2,7 @@
 * scene management (I prefer the concept of spaces, that is a kind of scene anyway)
 * review doc: separate it in multiple md/dox files, reduce the readme to a minimum and provide users with links to the online documentation on gh-pages
 * debugging tools (#60): the issue online already contains interesting tips on this, look at it
+* dynamic view, useful for runtime ecs, can be filled with the desired pool at runtime and are not constrained to a compile-time list of components
 * define basic reactive systems (track entities to which component is attached, track entities from which component is removed, and so on)
 * define systems as composable mixins (initializazion, reactive, update, whatever) with flexible auto-detected arguments (registry, views, etc)
 * create dedicated flat map based on types implementation (sort of "type map") for types to use within the registry and so on...

+ 3 - 3
src/entt/entity/prototype.hpp

@@ -122,8 +122,8 @@ public:
             }) != handlers.cend();
         };
 
-        using accumulator_type = bool[];
         bool all = true;
+        using accumulator_type = bool[];
         accumulator_type accumulator = { all, (all = all && found(registry_type::template type<Component>()))... };
         (void)accumulator;
         return all;
@@ -246,7 +246,7 @@ public:
      * @param entity A valid entity identifier.
      */
     void assign(registry_type &registry, entity_type entity) {
-        std::for_each(handlers.begin(), handlers.end(), [&registry, entity, this](auto &&handler) {
+        std::for_each(handlers.begin(), handlers.end(), [&registry, entity](auto &&handler) {
             handler.assign(handler.component.get(), registry, entity);
         });
     }
@@ -266,7 +266,7 @@ public:
      * @param entity A valid entity identifier.
      */
     void accommodate(registry_type &registry, entity_type entity) {
-        std::for_each(handlers.begin(), handlers.end(), [&registry, entity, this](auto &&handler) {
+        std::for_each(handlers.begin(), handlers.end(), [&registry, entity](auto &&handler) {
             handler.accommodate(handler.component.get(), registry, entity);
         });
     }

+ 3 - 3
src/entt/entity/registry.hpp

@@ -605,8 +605,8 @@ public:
     template<typename... Component>
     bool has(entity_type entity) const ENTT_NOEXCEPT {
         assert(valid(entity));
-        using accumulator_type = bool[];
         bool all = true;
+        using accumulator_type = bool[];
         accumulator_type accumulator = { all, (all = all && managed<Component>() && pool<Component>().has(entity))... };
         (void)accumulator;
         return all;
@@ -1269,7 +1269,6 @@ public:
         }
 
         if(!handlers[htype]) {
-            using accumulator_type = int[];
             handlers[htype] = std::make_unique<SparseSet<entity_type>>();
             auto &handler = handlers[htype];
 
@@ -1283,6 +1282,7 @@ public:
                 std::get<2>(cpool).sink().template connect<&Registry::destroying<Component...>>();
             };
 
+            using accumulator_type = int[];
             accumulator_type accumulator = { (assure<Component>(), connect(component_family::type<Component>()), 0)... };
             (void)accumulator;
         }
@@ -1306,7 +1306,6 @@ public:
     template<typename... Component>
     void discard() {
         if(contains<Component...>()) {
-            using accumulator_type = int[];
             const auto htype = handler_family::type<Component...>();
 
             auto disconnect = [this](auto ctype) {
@@ -1316,6 +1315,7 @@ public:
             };
 
             // if a set exists, pools have already been created for it
+            using accumulator_type = int[];
             accumulator_type accumulator = { (disconnect(component_family::type<Component>()), 0)... };
             handlers[htype].reset();
             (void)accumulator;

+ 1 - 1
src/entt/entity/snapshot.hpp

@@ -99,7 +99,7 @@ public:
     template<typename Archive>
     Snapshot & entities(Archive &archive) {
         archive(static_cast<Entity>(registry.size()));
-        registry.each([&archive, this](auto entity) { archive(entity); });
+        registry.each([&archive](auto entity) { archive(entity); });
         return *this;
     }
 

+ 2 - 2
test/entt/core/algorithm.cpp

@@ -4,7 +4,7 @@
 
 TEST(Algorithm, StdSort) {
     // well, I'm pretty sure it works, it's std::sort!!
-    std::array<int, 5> arr = { 4, 1, 3, 2, 0 };
+    std::array<int, 5> arr{{4, 1, 3, 2, 0}};
     entt::StdSort sort;
 
     sort(arr.begin(), arr.end());
@@ -15,7 +15,7 @@ TEST(Algorithm, StdSort) {
 }
 
 TEST(Algorithm, InsertionSort) {
-    std::array<int, 5> arr = { 4, 1, 3, 2, 0 };
+    std::array<int, 5> arr{{4, 1, 3, 2, 0}};
     entt::InsertionSort sort;
 
     sort(arr.begin(), arr.end());

+ 1 - 1
test/entt/entity/snapshot.cpp

@@ -406,7 +406,7 @@ TEST(Snapshot, Continuous) {
             .orphans()
             .shrink();
 
-    dst.view<WhatAComponent>().each([&dst, &loader, entity](auto, auto &component) {
+    dst.view<WhatAComponent>().each([&dst](auto, auto &component) {
         ASSERT_FALSE(dst.valid(component.bar));
     });