From 1237206d4bdf840ae89018d14a0510035d54d0d3 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Sun, 25 Jun 2017 23:08:31 +0200 Subject: [PATCH] Revert "Ores: Make 'absheight' flag non-functional" This reverts commit 90ed6fc732ca667ca970b7c38d39c809e5c3553e. --- doc/lua_api.txt | 7 ++++++- src/mg_ore.cpp | 19 +++++++++++++++---- src/mg_ore.h | 5 ++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 63d090ebe..540bbe118 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1076,7 +1076,12 @@ Ore attributes See section "Flag Specifier Format". Currently supported flags: -`puff_cliffs`, `puff_additive_composition`. +`absheight`, `puff_cliffs`, `puff_additive_composition`. + +### `absheight` +Also produce this same ore between the height range of `-y_max` and `-y_min`. + +Useful for having ore in sky realms without having to duplicate ore entries. ### `puff_cliffs` If set, puff ore generation will not taper down large differences in displacement diff --git a/src/mg_ore.cpp b/src/mg_ore.cpp index 73af2e2e6..f959ca9e6 100644 --- a/src/mg_ore.cpp +++ b/src/mg_ore.cpp @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., FlagDesc flagdesc_ore[] = { - {"absheight", OREFLAG_ABSHEIGHT}, // Non-functional + {"absheight", OREFLAG_ABSHEIGHT}, {"puff_cliffs", OREFLAG_PUFF_CLIFFS}, {"puff_additive_composition", OREFLAG_PUFF_ADDITIVE}, {NULL, 0} @@ -87,11 +87,22 @@ void Ore::resolveNodeNames() size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { - if (!(nmin.Y <= y_max && nmax.Y >= y_min)) + int in_range = 0; + + in_range |= (nmin.Y <= y_max && nmax.Y >= y_min); + if (flags & OREFLAG_ABSHEIGHT) + in_range |= (nmin.Y >= -y_max && nmax.Y <= -y_min) << 1; + if (!in_range) return 0; - int actual_ymin = MYMAX(nmin.Y, y_min); - int actual_ymax = MYMIN(nmax.Y, y_max); + int actual_ymin, actual_ymax; + if (in_range & ORE_RANGE_MIRROR) { + actual_ymin = MYMAX(nmin.Y, -y_max); + actual_ymax = MYMIN(nmax.Y, -y_min); + } else { + actual_ymin = MYMAX(nmin.Y, y_min); + actual_ymax = MYMIN(nmax.Y, y_max); + } if (clust_size >= actual_ymax - actual_ymin + 1) return 0; diff --git a/src/mg_ore.h b/src/mg_ore.h index 5aeb3631c..4b052e07a 100644 --- a/src/mg_ore.h +++ b/src/mg_ore.h @@ -32,11 +32,14 @@ class MMVManip; /////////////////// Ore generation flags -#define OREFLAG_ABSHEIGHT 0x01 // Non-functional but kept to not break flags +#define OREFLAG_ABSHEIGHT 0x01 #define OREFLAG_PUFF_CLIFFS 0x02 #define OREFLAG_PUFF_ADDITIVE 0x04 #define OREFLAG_USE_NOISE 0x08 +#define ORE_RANGE_ACTUAL 1 +#define ORE_RANGE_MIRROR 2 + enum OreType { ORE_SCATTER, ORE_SHEET, -- 2.25.1