aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2022-08-19 20:52:59 -0400
committerClyne Sullivan <clyne@bitgloo.com>2022-08-19 20:52:59 -0400
commitbdc0e843a4762a1abddebc53d12a351debe8d457 (patch)
treead4c2023c5c03527b628108f2c76bf42c354724c
parentd1dd9743d93009eef7d32d5403eeefbba29c2ee6 (diff)
add cereal and entityx submodules; fix compile errors
-rw-r--r--.gitmodules7
-rw-r--r--Makefile15
m---------lib/cereal0
m---------lib/entityx0
-rw-r--r--lib/libentityx.abin414808 -> 945228 bytes
-rw-r--r--src/components/Audio.hpp2
-rw-r--r--src/components/Component.hpp2
-rw-r--r--src/components/EventListener.hpp2
-rw-r--r--src/components/Light.hpp2
-rw-r--r--src/components/Name.hpp2
-rw-r--r--src/components/Physics.hpp2
-rw-r--r--src/components/Player.hpp2
-rw-r--r--src/components/Position.hpp2
-rw-r--r--src/components/Render.hpp2
-rw-r--r--src/components/Script.hpp2
-rw-r--r--src/components/Velocity.hpp2
-rw-r--r--src/gamestate.hpp26
17 files changed, 53 insertions, 17 deletions
diff --git a/.gitmodules b/.gitmodules
index 340f9cd..e2f5cf7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -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
diff --git a/Makefile b/Makefile
index 357d7ff..23f522e 100644
--- 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
+Subproject ddd467244713ea4fe63733628992efcdd6a9187
diff --git a/lib/entityx b/lib/entityx
new file mode 160000
+Subproject 39e07099da7227d7d7baec072411ddc0abfd8be
diff --git a/lib/libentityx.a b/lib/libentityx.a
index c1b2a0d..b0042eb 100644
--- a/lib/libentityx.a
+++ b/lib/libentityx.a
Binary files differ
diff --git a/src/components/Audio.hpp b/src/components/Audio.hpp
index a97b235..2bb63eb 100644
--- a/src/components/Audio.hpp
+++ b/src/components/Audio.hpp
@@ -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";
}
};
diff --git a/src/components/Component.hpp b/src/components/Component.hpp
index 2928366..576a059 100644
--- a/src/components/Component.hpp
+++ b/src/components/Component.hpp
@@ -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
diff --git a/src/components/EventListener.hpp b/src/components/EventListener.hpp
index c39b6ad..fb55d95 100644
--- a/src/components/EventListener.hpp
+++ b/src/components/EventListener.hpp
@@ -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";
}
};
diff --git a/src/components/Light.hpp b/src/components/Light.hpp
index 6849d7c..c63b6cc 100644
--- a/src/components/Light.hpp
+++ b/src/components/Light.hpp
@@ -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";
}
};
diff --git a/src/components/Name.hpp b/src/components/Name.hpp
index a6a6d8a..6390d5e 100644
--- a/src/components/Name.hpp
+++ b/src/components/Name.hpp
@@ -47,7 +47,7 @@ public:
ar(CEREAL_NVP(name));
}
- std::string serializeName(void) const final {
+ virtual std::string serializeName(void) const final {
return "Name";
}
};
diff --git a/src/components/Physics.hpp b/src/components/Physics.hpp
index 378e87f..edf5ac5 100644
--- a/src/components/Physics.hpp
+++ b/src/components/Physics.hpp
@@ -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";
}
};
diff --git a/src/components/Player.hpp b/src/components/Player.hpp
index a550c4f..43d083e 100644
--- a/src/components/Player.hpp
+++ b/src/components/Player.hpp
@@ -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";
}
};
diff --git a/src/components/Position.hpp b/src/components/Position.hpp
index 56e8707..fcd62f8 100644
--- a/src/components/Position.hpp
+++ b/src/components/Position.hpp
@@ -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";
}
};
diff --git a/src/components/Render.hpp b/src/components/Render.hpp
index 81ca591..93be5d8 100644
--- a/src/components/Render.hpp
+++ b/src/components/Render.hpp
@@ -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";
}
};
diff --git a/src/components/Script.hpp b/src/components/Script.hpp
index 3f96be5..d7bc147 100644
--- a/src/components/Script.hpp
+++ b/src/components/Script.hpp
@@ -119,7 +119,7 @@ public:
}
- std::string serializeName(void) const final {
+ virtual std::string serializeName(void) const final {
return "Scripted";
}
};
diff --git a/src/components/Velocity.hpp b/src/components/Velocity.hpp
index 776c1dd..f48a9f3 100644
--- a/src/components/Velocity.hpp
+++ b/src/components/Velocity.hpp
@@ -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";
}
};
diff --git a/src/gamestate.hpp b/src/gamestate.hpp
index 55f4e47..86a4198 100644
--- a/src/gamestate.hpp
+++ b/src/gamestate.hpp
@@ -27,6 +27,30 @@
#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();
}
}