1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-09 11:35:21 +01:00

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)
This commit is contained in:
SmallJoker
2021-03-20 13:02:15 +01:00
committed by GitHub
parent a8cc3bdb08
commit 05719913ac
7 changed files with 154 additions and 87 deletions

View File

@@ -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);