diff options
Diffstat (limited to 'src/mapgen/mg_ore.cpp')
-rw-r--r-- | src/mapgen/mg_ore.cpp | 125 |
1 files changed, 111 insertions, 14 deletions
diff --git a/src/mapgen/mg_ore.cpp b/src/mapgen/mg_ore.cpp index c36249cb9..b50ed6a32 100644 --- a/src/mapgen/mg_ore.cpp +++ b/src/mapgen/mg_ore.cpp @@ -1,7 +1,7 @@ /* Minetest -Copyright (C) 2014-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net> -Copyright (C) 2015-2018 paramat +Copyright (C) 2015-2020 paramat +Copyright (C) 2014-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -72,6 +72,14 @@ void OreManager::clear() } +OreManager *OreManager::clone() const +{ + auto mgr = new OreManager(); + ObjDefManager::cloneTo(mgr); + return mgr; +} + + /////////////////////////////////////////////////////////////////////////////// @@ -106,11 +114,39 @@ size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) } +void Ore::cloneTo(Ore *def) const +{ + ObjDef::cloneTo(def); + NodeResolver::cloneTo(def); + def->c_ore = c_ore; + def->c_wherein = c_wherein; + def->clust_scarcity = clust_scarcity; + def->clust_num_ores = clust_num_ores; + def->clust_size = clust_size; + def->y_min = y_min; + def->y_max = y_max; + def->ore_param2 = ore_param2; + def->flags = flags; + def->nthresh = nthresh; + def->np = np; + def->noise = nullptr; // cannot be shared! so created on demand + def->biomes = biomes; +} + + /////////////////////////////////////////////////////////////////////////////// +ObjDef *OreScatter::clone() const +{ + auto def = new OreScatter(); + Ore::cloneTo(def); + return def; +} + + void OreScatter::generate(MMVManip *vm, int mapseed, u32 blockseed, - v3s16 nmin, v3s16 nmax, u8 *biomemap) + v3s16 nmin, v3s16 nmax, biome_t *biomemap) { PcgRandom pr(blockseed); MapNode n_ore(c_ore, 0, ore_param2); @@ -134,7 +170,7 @@ void OreScatter::generate(MMVManip *vm, int mapseed, u32 blockseed, if (biomemap && !biomes.empty()) { u32 index = sizex * (z0 - nmin.Z) + (x0 - nmin.X); - std::unordered_set<u8>::const_iterator it = biomes.find(biomemap[index]); + auto it = biomes.find(biomemap[index]); if (it == biomes.end()) continue; } @@ -158,8 +194,21 @@ void OreScatter::generate(MMVManip *vm, int mapseed, u32 blockseed, /////////////////////////////////////////////////////////////////////////////// +ObjDef *OreSheet::clone() const +{ + auto def = new OreSheet(); + Ore::cloneTo(def); + + def->column_height_max = column_height_max; + def->column_height_min = column_height_min; + def->column_midpoint_factor = column_midpoint_factor; + + return def; +} + + void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed, - v3s16 nmin, v3s16 nmax, u8 *biomemap) + v3s16 nmin, v3s16 nmax, biome_t *biomemap) { PcgRandom pr(blockseed + 4234); MapNode n_ore(c_ore, 0, ore_param2); @@ -188,7 +237,7 @@ void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed, continue; if (biomemap && !biomes.empty()) { - std::unordered_set<u8>::const_iterator it = biomes.find(biomemap[index]); + auto it = biomes.find(biomemap[index]); if (it == biomes.end()) continue; } @@ -221,8 +270,22 @@ OrePuff::~OrePuff() } +ObjDef *OrePuff::clone() const +{ + auto def = new OrePuff(); + Ore::cloneTo(def); + + def->np_puff_top = np_puff_top; + def->np_puff_bottom = np_puff_bottom; + def->noise_puff_top = nullptr; // cannot be shared, on-demand + def->noise_puff_bottom = nullptr; + + return def; +} + + void OrePuff::generate(MMVManip *vm, int mapseed, u32 blockseed, - v3s16 nmin, v3s16 nmax, u8 *biomemap) + v3s16 nmin, v3s16 nmax, biome_t *biomemap) { PcgRandom pr(blockseed + 4234); MapNode n_ore(c_ore, 0, ore_param2); @@ -249,7 +312,7 @@ void OrePuff::generate(MMVManip *vm, int mapseed, u32 blockseed, continue; if (biomemap && !biomes.empty()) { - std::unordered_set<u8>::const_iterator it = biomes.find(biomemap[index]); + auto it = biomes.find(biomemap[index]); if (it == biomes.end()) continue; } @@ -294,8 +357,16 @@ void OrePuff::generate(MMVManip *vm, int mapseed, u32 blockseed, /////////////////////////////////////////////////////////////////////////////// +ObjDef *OreBlob::clone() const +{ + auto def = new OreBlob(); + Ore::cloneTo(def); + return def; +} + + void OreBlob::generate(MMVManip *vm, int mapseed, u32 blockseed, - v3s16 nmin, v3s16 nmax, u8 *biomemap) + v3s16 nmin, v3s16 nmax, biome_t *biomemap) { PcgRandom pr(blockseed + 2404); MapNode n_ore(c_ore, 0, ore_param2); @@ -317,7 +388,7 @@ void OreBlob::generate(MMVManip *vm, int mapseed, u32 blockseed, if (biomemap && !biomes.empty()) { u32 bmapidx = sizex * (z0 - nmin.Z) + (x0 - nmin.X); - std::unordered_set<u8>::const_iterator it = biomes.find(biomemap[bmapidx]); + auto it = biomes.find(biomemap[bmapidx]); if (it == biomes.end()) continue; } @@ -366,8 +437,21 @@ OreVein::~OreVein() } +ObjDef *OreVein::clone() const +{ + auto def = new OreVein(); + Ore::cloneTo(def); + + def->random_factor = random_factor; + def->noise2 = nullptr; // cannot be shared, on-demand + def->sizey_prev = sizey_prev; + + return def; +} + + void OreVein::generate(MMVManip *vm, int mapseed, u32 blockseed, - v3s16 nmin, v3s16 nmax, u8 *biomemap) + v3s16 nmin, v3s16 nmax, biome_t *biomemap) { PcgRandom pr(blockseed + 520); MapNode n_ore(c_ore, 0, ore_param2); @@ -401,7 +485,7 @@ void OreVein::generate(MMVManip *vm, int mapseed, u32 blockseed, if (biomemap && !biomes.empty()) { u32 bmapidx = sizex * (z - nmin.Z) + (x - nmin.X); - std::unordered_set<u8>::const_iterator it = biomes.find(biomemap[bmapidx]); + auto it = biomes.find(biomemap[bmapidx]); if (it == biomes.end()) continue; } @@ -434,8 +518,21 @@ OreStratum::~OreStratum() } +ObjDef *OreStratum::clone() const +{ + auto def = new OreStratum(); + Ore::cloneTo(def); + + def->np_stratum_thickness = np_stratum_thickness; + def->noise_stratum_thickness = nullptr; // cannot be shared, on-demand + def->stratum_thickness = stratum_thickness; + + return def; +} + + void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed, - v3s16 nmin, v3s16 nmax, u8 *biomemap) + v3s16 nmin, v3s16 nmax, biome_t *biomemap) { PcgRandom pr(blockseed + 4234); MapNode n_ore(c_ore, 0, ore_param2); @@ -463,7 +560,7 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed, for (int z = nmin.Z; z <= nmax.Z; z++) for (int x = nmin.X; x <= nmax.X; x++, index++) { if (biomemap && !biomes.empty()) { - std::unordered_set<u8>::const_iterator it = biomes.find(biomemap[index]); + auto it = biomes.find(biomemap[index]); if (it == biomes.end()) continue; } |