Skip to content

Commit

Permalink
Replace instances of height_min/height_max with y_min/y_max to remove…
Browse files Browse the repository at this point in the history
… ambiguity
  • Loading branch information
kwolekr committed Dec 30, 2014
1 parent b589353 commit 9b0d77a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 27 deletions.
6 changes: 3 additions & 3 deletions src/mg_biome.cpp
Expand Up @@ -45,8 +45,8 @@ BiomeManager::BiomeManager(IGameDef *gamedef) :
b->depth_filler = 0;
b->height_shore = 0;
b->depth_water_top = 0;
b->height_min = -MAP_GENERATION_LIMIT;
b->height_max = MAP_GENERATION_LIMIT;
b->y_min = -MAP_GENERATION_LIMIT;
b->y_max = MAP_GENERATION_LIMIT;
b->heat_point = 0.0;
b->humidity_point = 0.0;

Expand Down Expand Up @@ -91,7 +91,7 @@ Biome *BiomeManager::getBiome(float heat, float humidity, s16 y)

for (size_t i = 1; i < m_elements.size(); i++) {
b = (Biome *)m_elements[i];
if (!b || y > b->height_max || y < b->height_min)
if (!b || y > b->y_max || y < b->y_min)
continue;

float d_heat = heat - b->heat_point;
Expand Down
4 changes: 2 additions & 2 deletions src/mg_biome.h
Expand Up @@ -52,8 +52,8 @@ class Biome : public GenElement, public NodeResolver {
s16 height_shore;
s16 depth_water_top;

s16 height_min;
s16 height_max;
s16 y_min;
s16 y_max;
float heat_point;
float humidity_point;

Expand Down
4 changes: 2 additions & 2 deletions src/mg_decoration.cpp
Expand Up @@ -140,8 +140,8 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
mg->heightmap[mapindex] :
mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);

if (y < nmin.Y || y > nmax.Y ||
y < height_min || y > height_max)
if (y < nmin.Y || y > nmax.Y ||
y < y_min || y > y_max)
continue;

int height = getHeight();
Expand Down
4 changes: 2 additions & 2 deletions src/mg_decoration.h
Expand Up @@ -66,8 +66,8 @@ class Decoration : public GenElement, public NodeResolver {
int mapseed;
std::vector<content_t> c_place_on;
s16 sidelen;
s16 height_min;
s16 height_max;
s16 y_min;
s16 y_max;
float fill_ratio;
NoiseParams np;

Expand Down
20 changes: 10 additions & 10 deletions src/mg_ore.cpp
Expand Up @@ -95,25 +95,25 @@ size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
{
int in_range = 0;

in_range |= (nmin.Y <= height_max && nmax.Y >= height_min);
in_range |= (nmin.Y <= y_max && nmax.Y >= y_min);
if (flags & OREFLAG_ABSHEIGHT)
in_range |= (nmin.Y >= -height_max && nmax.Y <= -height_min) << 1;
in_range |= (nmin.Y >= -y_max && nmax.Y <= -y_min) << 1;
if (!in_range)
return 0;

int ymin, ymax;
int actual_ymin, actual_ymax;
if (in_range & ORE_RANGE_MIRROR) {
ymin = MYMAX(nmin.Y, -height_max);
ymax = MYMIN(nmax.Y, -height_min);
actual_ymin = MYMAX(nmin.Y, -y_max);
actual_ymax = MYMIN(nmax.Y, -y_min);
} else {
ymin = MYMAX(nmin.Y, height_min);
ymax = MYMIN(nmax.Y, height_max);
actual_ymin = MYMAX(nmin.Y, y_min);
actual_ymax = MYMIN(nmax.Y, y_max);
}
if (clust_size >= ymax - ymin + 1)
if (clust_size >= actual_ymax - actual_ymin + 1)
return 0;

nmin.Y = ymin;
nmax.Y = ymax;
nmin.Y = actual_ymin;
nmax.Y = actual_ymax;
generate(mg->vm, mg->seed, blockseed, nmin, nmax);

return 1;
Expand Down
4 changes: 2 additions & 2 deletions src/mg_ore.h
Expand Up @@ -56,8 +56,8 @@ class Ore : public GenElement, public NodeResolver {
u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
s16 clust_num_ores; // how many ore nodes are in a chunk
s16 clust_size; // how large (in nodes) a chunk of ore is
s16 height_min;
s16 height_max;
s16 y_min;
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
Expand Down
22 changes: 16 additions & 6 deletions src/script/lua_api/l_mapgen.cpp
Expand Up @@ -448,8 +448,8 @@ int ModApiMapgen::l_register_biome(lua_State *L)
b->depth_filler = getintfield_default(L, index, "depth_filler", 3);
b->height_shore = getintfield_default(L, index, "height_shore", 3);
b->depth_water_top = getintfield_default(L, index, "depth_water_top", 0);
b->height_min = getintfield_default(L, index, "height_min", -31000);
b->height_max = getintfield_default(L, index, "height_max", 31000);
b->y_min = getintfield_default(L, index, "y_min", -31000);
b->y_max = getintfield_default(L, index, "y_max", 31000);
b->heat_point = getfloatfield_default(L, index, "heat_point", 0.f);
b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.f);
b->flags = 0; //reserved
Expand Down Expand Up @@ -522,8 +522,8 @@ int ModApiMapgen::l_register_decoration(lua_State *L)

deco->name = getstringfield_default(L, index, "name", "");
deco->fill_ratio = getfloatfield_default(L, index, "fill_ratio", 0.02);
deco->height_min = getintfield_default(L, index, "height_min", -31000);
deco->height_max = getintfield_default(L, index, "height_max", 31000);
deco->y_min = getintfield_default(L, index, "y_min", -31000);
deco->y_max = getintfield_default(L, index, "y_max", 31000);
deco->sidelen = getintfield_default(L, index, "sidelen", 8);
if (deco->sidelen <= 0) {
errorstream << "register_decoration: sidelen must be "
Expand Down Expand Up @@ -683,12 +683,22 @@ 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->height_min = getintfield_default(L, index, "height_min", -31000);
ore->height_max = getintfield_default(L, index, "height_max", 31000);
ore->nthresh = getfloatfield_default(L, index, "noise_threshhold", 0);
ore->noise = NULL;
ore->flags = 0;

// height_min and height_max are aliases for y_min and y_max, respectively,
// for backwards compatibility
int ymin, ymax;
if (!getintfield(L, index, "y_min", ymin) &&
!getintfield(L, index, "height_min", ymin))
ymin = -31000;
if (!getintfield(L, index, "y_max", ymax) &&
!getintfield(L, index, "height_max", ymax))
ymax = 31000;
ore->y_min = ymin;
ore->y_max = ymax;

This comment has been minimized.

Copy link
@ShadowNinja

ShadowNinja Dec 30, 2014

Member

I don't think compatibility with 2-day-old code is an issue. Also, if y_* is the new version the docs should be changed.

if (ore->clust_scarcity <= 0 || ore->clust_num_ores <= 0) {
errorstream << "register_ore: clust_scarcity and clust_num_ores"
"must be greater than 0" << std::endl;
Expand Down

0 comments on commit 9b0d77a

Please sign in to comment.