diff options
author | sfan5 <sfan5@live.de> | 2020-04-10 02:05:20 +0200 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2020-05-05 19:26:59 +0200 |
commit | 3c65d1acec27366d88fc3686d3f820175673e203 (patch) | |
tree | f0de47610f7d5d2fe26862226cd63ddee5f5b309 /src/mapgen/mg_decoration.cpp | |
parent | 2062c80e21b657fed8e68aa48523fa12ad5ef095 (diff) | |
download | minetest-3c65d1acec27366d88fc3686d3f820175673e203.tar.gz minetest-3c65d1acec27366d88fc3686d3f820175673e203.tar.bz2 minetest-3c65d1acec27366d88fc3686d3f820175673e203.zip |
Give the Mapgen on each EmergeThread its own Biome/Ore/Deco/SchemManager copy
Diffstat (limited to 'src/mapgen/mg_decoration.cpp')
-rw-r--r-- | src/mapgen/mg_decoration.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mapgen/mg_decoration.cpp b/src/mapgen/mg_decoration.cpp index db9c696ed..a9b67d239 100644 --- a/src/mapgen/mg_decoration.cpp +++ b/src/mapgen/mg_decoration.cpp @@ -391,6 +391,13 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling) /////////////////////////////////////////////////////////////////////////////// +DecoSchematic::~DecoSchematic() +{ + if (was_cloned) + delete schematic; +} + + ObjDef *DecoSchematic::clone() const { auto def = new DecoSchematic(); @@ -398,9 +405,12 @@ ObjDef *DecoSchematic::clone() const NodeResolver::cloneTo(def); def->rotation = rotation; - /* FIXME: This is not ideal, we only have a pointer to the schematic despite - * not owning it. Optimally this would be a handle. */ - def->schematic = schematic; // not cloned + /* FIXME: We do not own this schematic, yet we only have a pointer to it + * and not a handle. We are left with no option but to clone it ourselves. + * This is a waste of memory and should be replaced with an alternative + * approach sometime. */ + def->schematic = dynamic_cast<Schematic*>(schematic->clone()); + def->was_cloned = true; return def; } |