]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
add cereal and entityx submodules; fix compile errors
authorClyne Sullivan <clyne@bitgloo.com>
Sat, 20 Aug 2022 00:52:59 +0000 (20:52 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Sat, 20 Aug 2022 00:52:59 +0000 (20:52 -0400)
17 files changed:
.gitmodules
Makefile
lib/cereal [new submodule]
lib/entityx [new submodule]
lib/libentityx.a
src/components/Audio.hpp
src/components/Component.hpp
src/components/EventListener.hpp
src/components/Light.hpp
src/components/Name.hpp
src/components/Physics.hpp
src/components/Player.hpp
src/components/Position.hpp
src/components/Render.hpp
src/components/Script.hpp
src/components/Velocity.hpp
src/gamestate.hpp

index 340f9cda66fa0f07d24a4fd64f8af7e8b1304cfd..e2f5cf760f819368ef6a0648c3f47df92ea5d942 100644 (file)
@@ -1,3 +1,10 @@
 [submodule "lib/sol2"]
        path = lib/sol2
        url = https://github.com/ThePhD/sol2
+[submodule "lib/entityx"]
+       path = lib/entityx
+       url = https://github.com/tcsullivan/entityx
+       branch = remove-std-iterator
+[submodule "lib/cereal"]
+       path = lib/cereal
+       url = https://github.com/USCiLab/cereal
index 357d7ff031756130386fa992dab1af920a5d4c81..23f522edbc4a0745a835550788b2aac8632e8396 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -40,11 +40,16 @@ LIBS   = -L$(LIBDIR) -lSDL2 -lpthread -lentityx -lluajit -ldl -lGLEW -lGL \
                 -lSDL2_image -lSOIL -lfreetype -lopenal -lalut
 
 CXXFLAGS = -ggdb -std=c++17 -Wall -Wextra -Werror -pedantic \
-                  -Wno-class-memaccess -Wno-implicit-fallthrough -m64
-
-CXXINCS = -Isrc -I$(LIBDIR)/LuaJIT/src -I$(LIBDIR)/entityx \
-                 -I$(LIBDIR)/LuaBridge/Source -I$(LIBDIR)/sol2/include \
-                 -I$(LIBDIR)/soil -I$(LIBDIR)/cereal/include -I$(LIBDIR)/freetype
+                  -Wno-class-memaccess -Wno-implicit-fallthrough -Wno-unused-parameter
+
+CXXINCS = -I$(SRCDIR) \
+          -I$(LIBDIR)/entityx \
+          -I$(LIBDIR)/LuaJIT/src \
+          -I$(LIBDIR)/LuaBridge/Source \
+          -I$(LIBDIR)/sol2/include \
+          -I$(LIBDIR)/soil \
+          -I$(LIBDIR)/cereal/include \
+         -I$(LIBDIR)/freetype
 
 CXXSRC := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
 CXXOBJ := $(patsubst $(SRCDIR)/%,$(OUTDIR)/%,$(CXXSRC:.$(SRCEXT)=.$(OBJEXT)))
diff --git a/lib/cereal b/lib/cereal
new file mode 160000 (submodule)
index 0000000..ddd4672
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit ddd467244713ea4fe63733628992efcdd6a9187d
diff --git a/lib/entityx b/lib/entityx
new file mode 160000 (submodule)
index 0000000..39e0709
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 39e07099da7227d7d7baec072411ddc0abfd8be4
index c1b2a0d4fb70bdea6f039851a1fe12ae1f6cc9ec..b0042ebac14f9c8db8e52914bcce6f7fdb3faa15 100644 (file)
Binary files a/lib/libentityx.a and b/lib/libentityx.a differ
index a97b2352ba371dd46e27d6515ae5fc63a2fddfe8..2bb63eb0bb38d332991f33f9c8de2f6a88c77f93 100644 (file)
@@ -47,7 +47,7 @@ public:
     void serialize([[maybe_unused]] cereal::JSONOutputArchive& ar) final {}
     void serialize([[maybe_unused]] cereal::JSONInputArchive& ar) final {}
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "Audio";
     }
 };
index 2928366af1aff1407e7610f62374b00722f25fad..576a05902efee58f6a0ad01765e1f469dee6897e 100644 (file)
@@ -33,7 +33,7 @@ public:
     virtual void serialize(cereal::JSONOutputArchive& ar) = 0;
     virtual void serialize(cereal::JSONInputArchive& ar) = 0;
 
-    void internal_serialize(bool save, void *ar) final {
+    virtual void internal_serialize(bool save, void *ar) final {
         if (save)
             serialize(*reinterpret_cast<cereal::JSONOutputArchive*>(ar));
         else
index c39b6adb795725c96d109f2265f0d3773ee6b9a6..fb55d9583637ee015d4d753267643abf1d35e900 100644 (file)
@@ -52,7 +52,7 @@ public:
     void serialize([[maybe_unused]] cereal::JSONOutputArchive& ar) final {}
     void serialize([[maybe_unused]] cereal::JSONInputArchive& ar) final {}
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "EventListener";
     }
 };
index 6849d7cbd8bd960df56f4896e4c2a02e6ce5e252..c63b6cc68708579ecd3e6a15d766beab4e22ce67 100644 (file)
@@ -58,7 +58,7 @@ public:
         ar(CEREAL_NVP(r), CEREAL_NVP(g), CEREAL_NVP(b), CEREAL_NVP(strength));
     }
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "Light";
     }
 };
index a6a6d8ad0f44977dee45514dd7bd0da3807ed41f..6390d5eae81a4a496ad909773c2bc2f1d1bbcae9 100644 (file)
@@ -47,7 +47,7 @@ public:
         ar(CEREAL_NVP(name));
     }
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "Name";
     }
 };
index 378e87f0a136b061babf5e78e74864972eb1d865..edf5ac541f2c3e4b73e7ff6181f86acca93af730 100644 (file)
@@ -33,7 +33,7 @@ public:
     void serialize([[maybe_unused]] cereal::JSONOutputArchive& ar) final {}
     void serialize([[maybe_unused]] cereal::JSONInputArchive& ar) final {}
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "Physics";
     }
 };
index a550c4fabfdfd3fad45d4d6e2193b907174b2f49..43d083eabbc4231f3c02ee878b431ce77da2da89 100644 (file)
@@ -36,7 +36,7 @@ public:
     void serialize([[maybe_unused]] cereal::JSONOutputArchive& ar) final {}
     void serialize([[maybe_unused]] cereal::JSONInputArchive& ar) final {}
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "Player";
     }
 };
index 56e8707653bc8210a3db5c5ac1b62279286f71af..fcd62f85d075d1a91426125dca34b05a6dc13799 100644 (file)
@@ -51,7 +51,7 @@ public:
         ar(CEREAL_NVP(x), CEREAL_NVP(y));
     }
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "Position";
     }
 };
index 81ca591c011ef37e5837944cf82c782eaf3c98cb..93be5d8b38965c52686270c212b922deaeffd088 100644 (file)
@@ -62,7 +62,7 @@ public:
         ar(CEREAL_NVP(visible), CEREAL_NVP(flipX));
     }
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "Render";
     }
 };
index 3f96be5ef8198ab6e30398d63e1c9f30962ac171..d7bc1470bff8dd69e7a71d6c8df85807a3c41d22 100644 (file)
@@ -119,7 +119,7 @@ public:
 
     }
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "Scripted";
     }
 };
index 776c1ddcac7196348792cd82a33d22f5b9355b7e..f48a9f3550635129dbd8d717efbd7969feb6a521 100644 (file)
@@ -52,7 +52,7 @@ public:
         ar(CEREAL_NVP(x), CEREAL_NVP(y));
     }
 
-    std::string serializeName(void) const final {
+    virtual std::string serializeName(void) const final {
         return "Velocity";
     }
 };
index 55f4e474ea6dc0178fcd73f6280485545886347a..86a419800e28f5e8796a9da6b9c701e39ec3ff07 100644 (file)
 
 #include <fstream>
 
+struct EntitySerializer
+{
+    template<class Archive>
+    static void serialize(entityx::EntityManager& entities, entityx::Entity entity, bool save, Archive& ar)
+    {
+        // TODO try and reimplement without modifying entityx?
+        // Or, make a new branch...
+
+        //const auto mask = entity.component_mask();
+
+        //for (size_t i = 0; i < entities.component_helpers_.size(); i++) {
+        //    auto helper = entities.component_helpers_[i];
+        //    if (helper && mask.test(i)) {
+        //        auto* c = helper->get_component(entity);
+        //        ar.setNextName(c->serializeName().c_str());
+        //        ar.startNode();
+        //        c->internal_serialize(save, static_cast<void*>(&ar));
+        //        ar.finishNode();
+        //    }
+        //}
+    }
+};
+
+
 /**
  * @class GameState
  * Manages save files that contain entity data.
@@ -98,7 +122,7 @@ private:
         for (auto entity : entities.entities_for_debugging()) {
             archive.setNextName((name + std::to_string(i++)).c_str());
             archive.startNode();
-            entities.entity_serialize(entity, save, archive);
+            EntitySerializer::serialize(entities, entity, save, archive);
             archive.finishNode();
         }
     }