From 61d46a790cfde35bedf4283cbbcce06639cce1ec Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Mar 2023 10:42:54 +0100 Subject: src/entity: move type data member to vtable --- serialize/world-writer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'serialize') diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp index 99ae0b61..043e015a 100644 --- a/serialize/world-writer.cpp +++ b/serialize/world-writer.cpp @@ -184,8 +184,8 @@ void write_entity_flags(binary_writer& s, const U& e) fm_assert((pass & pass_mask) == pass); flags |= pass; constexpr auto tag = entity_type_::value; - if (e.type != tag) - fm_abort("invalid entity type '%d'", (int)e.type); + if (e.type_of() != tag) + fm_abort("invalid entity type '%d'", (int)e.type_of()); if constexpr(tag == entity_type::scenery) { flags |= (1 << 2) * e.active; @@ -327,8 +327,9 @@ void writer_state::serialize_new_scenery(const chunk& c, writer_t& s) object_id oid = e.id; fm_assert((oid & ((object_id)1 << 60)-1) == oid); static_assert(entity_type_BITS == 3); - fm_assert(((entity_type_i)e.type & (1 << entity_type_BITS)-1) == (entity_type_i)e.type); - oid |= (object_id)e.type << 64 - entity_type_BITS; + const auto type = e.type(); + fm_assert(((entity_type_i)type & (1 << entity_type_BITS)-1) == (entity_type_i)type); + oid |= (object_id)type << 64 - entity_type_BITS; s << oid; const auto local = e.coord.local(); s << local.to_index(); @@ -340,10 +341,10 @@ void writer_state::serialize_new_scenery(const chunk& c, writer_t& s) s << e.bbox_size[0]; s << e.bbox_size[1]; }; - switch (e.type) + switch (type) { default: - fm_abort("invalid entity type '%d'", (int)e.type); + fm_abort("invalid entity type '%d'", (int)type); case entity_type::character: { const auto& C = static_cast(e); uint8_t id = 0; @@ -477,7 +478,7 @@ ArrayView writer_state::serialize_world() for (const auto& e_ : c.entities()) { const auto& e = *e_; - switch (e.type) + switch (e.type()) { case entity_type::scenery: intern_scenery(static_cast(e), false); @@ -485,7 +486,7 @@ ArrayView writer_state::serialize_world() case entity_type::character: break; default: - fm_abort("invalid scenery type '%d'", (int)e.type); + fm_abort("invalid scenery type '%d'", (int)e.type()); } } } -- cgit v1.2.3