From 05719913aca97e53ff5b1dde49e1a033a327551f Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 20 Mar 2021 13:02:15 +0100 Subject: Schematic: Properly deal with before/after node resolving and document (#11011) This fixes an out-of-bounds index access when the node resolver was already applied to the schematic (i.e. biome decoration). Also improves the handling of the two cases: prior node resolving (m_nodenames), and after node resolving (manual lookup) --- src/mapgen/mg_schematic.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/mapgen/mg_schematic.h') diff --git a/src/mapgen/mg_schematic.h b/src/mapgen/mg_schematic.h index 6b31251b6..5f64ea280 100644 --- a/src/mapgen/mg_schematic.h +++ b/src/mapgen/mg_schematic.h @@ -92,7 +92,7 @@ enum SchematicFormatType { class Schematic : public ObjDef, public NodeResolver { public: - Schematic(); + Schematic() = default; virtual ~Schematic(); ObjDef *clone() const; @@ -105,11 +105,9 @@ public: const NodeDefManager *ndef); bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2); - bool deserializeFromMts(std::istream *is, std::vector *names); - bool serializeToMts(std::ostream *os, - const std::vector &names) const; - bool serializeToLua(std::ostream *os, const std::vector &names, - bool use_comments, u32 indent_spaces) const; + bool deserializeFromMts(std::istream *is); + bool serializeToMts(std::ostream *os) const; + bool serializeToLua(std::ostream *os, bool use_comments, u32 indent_spaces) const; void blitToVManip(MMVManip *vm, v3s16 p, Rotation rot, bool force_place); bool placeOnVManip(MMVManip *vm, v3s16 p, u32 flags, Rotation rot, bool force_place); @@ -124,6 +122,10 @@ public: v3s16 size; MapNode *schemdata = nullptr; u8 *slice_probs = nullptr; + +private: + // Counterpart to the node resolver: Condense content_t to a sequential "m_nodenames" list + void condenseContentIds(); }; class SchematicManager : public ObjDefManager { @@ -151,5 +153,3 @@ private: Server *m_server; }; -void generate_nodelist_and_update_ids(MapNode *nodes, size_t nodecount, - std::vector *usednodes, const NodeDefManager *ndef); -- cgit v1.2.3