diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-27 16:50:12 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-27 16:50:12 +0100 |
commit | 0a7ab6ad108d4c1820975e05e1429bad708da662 (patch) | |
tree | 2daea2e35adbbe79f0f4f7783391b8869f2af9ee | |
parent | 1756ee2afde0659430f3a8f7e50a6734ce7519c7 (diff) |
add ephemeral object flag
Used to prevent objects from being stored in save files.
-rw-r--r-- | editor/inspect-types.cpp | 4 | ||||
-rw-r--r-- | serialize/savegame.cpp | 11 | ||||
-rw-r--r-- | src/object.hpp | 1 |
3 files changed, 15 insertions, 1 deletions
diff --git a/editor/inspect-types.cpp b/editor/inspect-types.cpp index 914c76a4..5668d6b2 100644 --- a/editor/inspect-types.cpp +++ b/editor/inspect-types.cpp @@ -62,6 +62,10 @@ struct entity_accessors<object, inspect_intent_t> { [](object& x, Vector2ub value) { x.set_bbox(x.offset, x.bbox_offset, value, x.pass); }, [](const object& x) { return x.pass == pass_mode::pass ? st::readonly : st::enabled; }, }, + E::type<bool>::field{"ephemeral"_s, + [](const object& x) { return x.ephemeral; }, + [](object& x, bool value) { x.ephemeral = value; }, + }, }; } }; diff --git a/serialize/savegame.cpp b/serialize/savegame.cpp index 620d7457..eea89a03 100644 --- a/serialize/savegame.cpp +++ b/serialize/savegame.cpp @@ -490,11 +490,20 @@ ok: template<typename F> void serialize_objects_(chunk& c, F&& f) { - f((uint32_t)c.objects().size()); + uint32_t count = 0; + for (const std::shared_ptr<object>& obj : c.objects()) + { + if (obj->ephemeral) + continue; + count++; + } + f((uint32_t)count); for (const std::shared_ptr<object>& obj : c.objects()) { fm_assert(obj != nullptr); + if (obj->ephemeral) + continue; do_visit(object_magic, f); // todo move before all objects visit(*obj, f, c.coord()); } diff --git a/src/object.hpp b/src/object.hpp index 10a900d1..2d33885d 100644 --- a/src/object.hpp +++ b/src/object.hpp @@ -49,6 +49,7 @@ struct object uint16_t delta = 0, frame = 0; const rotation r = rotation::N; const pass_mode pass = pass_mode::see_through; + bool ephemeral : 1 = false; //char _pad[4]; // got 4 bytes left virtual ~object() noexcept; |