diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mg_ore.h | 2 | ||||
-rw-r--r-- | src/noise.cpp | 8 | ||||
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 11 |
3 files changed, 15 insertions, 6 deletions
diff --git a/src/mg_ore.h b/src/mg_ore.h index 8ffb8fca0..2e065cee3 100644 --- a/src/mg_ore.h +++ b/src/mg_ore.h @@ -61,7 +61,7 @@ public: s16 y_max; u8 ore_param2; // to set node-specific attributes u32 flags; // attributes for this ore - float nthresh; // threshhold for noise at which an ore is placed + float nthresh; // threshold for noise at which an ore is placed NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering) Noise *noise; std::set<u8> biomes; diff --git a/src/noise.cpp b/src/noise.cpp index b1b702538..2ddc3926f 100644 --- a/src/noise.cpp +++ b/src/noise.cpp @@ -99,17 +99,17 @@ u32 PcgRandom::range(u32 bound) Using rand() % 3, the number 0 would be twice as likely to appear. With a very large RNG range, the effect becomes less prevalent but still present. This can be solved by modifying the range of the RNG - to become a multiple of bound by dropping values above the a threshhold. - In our example, threshhold == 4 - 3 = 1 % 3 == 1, so reject 0, thus + to become a multiple of bound by dropping values above the a threshold. + In our example, threshold == 4 - 3 = 1 % 3 == 1, so reject 0, thus making the range 3 with no bias. This loop looks dangerous, but will always terminate due to the RNG's property of uniformity. */ - u32 threshhold = -bound % bound; + u32 threshold = -bound % bound; u32 r; - while ((r = next()) < threshhold) + while ((r = next()) < threshold) ; return r % bound; diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index d5cf54f24..b29fd96ca 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -944,10 +944,19 @@ int ModApiMapgen::l_register_ore(lua_State *L) ore->clust_scarcity = getintfield_default(L, index, "clust_scarcity", 1); ore->clust_num_ores = getintfield_default(L, index, "clust_num_ores", 1); ore->clust_size = getintfield_default(L, index, "clust_size", 0); - ore->nthresh = getfloatfield_default(L, index, "noise_threshhold", 0); ore->noise = NULL; ore->flags = 0; + //// Get noise_threshold + warn_if_field_exists(L, index, "noise_threshhold", + "Deprecated: new name is \"noise_threshold\"."); + + int nthresh; + if (!getintfield(L, index, "noise_threshold", nthresh) && + !getintfield(L, index, "noise_threshhold", nthresh)) + nthresh = 0; + ore->nthresh = nthresh; + //// Get y_min/y_max warn_if_field_exists(L, index, "height_min", "Deprecated: new name is \"y_min\"."); |