diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2021-03-20 13:02:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-20 13:02:15 +0100 |
commit | 05719913aca97e53ff5b1dde49e1a033a327551f (patch) | |
tree | e775880bc19a4fd53f3b85362c6dc49edb8d4453 /src/mapgen/mg_schematic.h | |
parent | a8cc3bdb0890c89d600ef6543c5e9b1b55bcf2b6 (diff) | |
download | minetest-05719913aca97e53ff5b1dde49e1a033a327551f.tar.gz minetest-05719913aca97e53ff5b1dde49e1a033a327551f.tar.bz2 minetest-05719913aca97e53ff5b1dde49e1a033a327551f.zip |
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)
Diffstat (limited to 'src/mapgen/mg_schematic.h')
-rw-r--r-- | src/mapgen/mg_schematic.h | 16 |
1 files changed, 8 insertions, 8 deletions
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<std::string> *names); - bool serializeToMts(std::ostream *os, - const std::vector<std::string> &names) const; - bool serializeToLua(std::ostream *os, const std::vector<std::string> &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<std::string> *usednodes, const NodeDefManager *ndef); |