Decoration: Change divlen to sidelen

This commit is contained in:
kwolekr 2013-06-17 18:23:31 -04:00
parent 0a8519a26f
commit 56093b6614
4 changed files with 15 additions and 8 deletions

@ -1875,8 +1875,9 @@ Decoration definition (register_decoration)
deco_type = "simple", -- See "Decoration types" deco_type = "simple", -- See "Decoration types"
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
^ Node that decoration can be placed on ^ Node that decoration can be placed on
divlen = 8, sidelen = 8,
^ Number of divisions made in the chunk being generated ^ Size of divisions made in the chunk being generated.
^ If the chunk size is not evenly divisible by sidelen, sidelen is made equal to the chunk size.
fill_ratio = 0.02, fill_ratio = 0.02,
^ Ratio of the area to be uniformly filled by the decoration. ^ Ratio of the area to be uniformly filled by the decoration.
^ Used only if noise_params is not specified. ^ Used only if noise_params is not specified.

@ -232,8 +232,14 @@ void Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) {
int carea_size = nmax.X - nmin.X + 1; int carea_size = nmax.X - nmin.X + 1;
// Divide area into parts // Divide area into parts
s16 sidelen = carea_size / divlen; if (carea_size % sidelen) {
float area = sidelen * sidelen; errorstream << "Decoration::placeDeco: chunk size is not divisible by "
"sidelen; setting sidelen to " << carea_size << std::endl;
sidelen = carea_size;
}
s16 divlen = carea_size / sidelen;
int area = sidelen * sidelen;
for (s16 z0 = 0; z0 < divlen; z0++) for (s16 z0 = 0; z0 < divlen; z0++)
for (s16 x0 = 0; x0 < divlen; x0++) { for (s16 x0 = 0; x0 < divlen; x0++) {

@ -199,7 +199,7 @@ public:
int mapseed; int mapseed;
std::string place_on_name; std::string place_on_name;
content_t c_place_on; content_t c_place_on;
s16 divlen; s16 sidelen;
float fill_ratio; float fill_ratio;
NoiseParams *np; NoiseParams *np;

@ -683,7 +683,7 @@ int ModApiBasic::l_register_decoration(lua_State *L)
deco->c_place_on = CONTENT_IGNORE; deco->c_place_on = CONTENT_IGNORE;
deco->place_on_name = getstringfield_default(L, index, "place_on", "ignore"); deco->place_on_name = getstringfield_default(L, index, "place_on", "ignore");
deco->divlen = getintfield_default(L, index, "divlen", 8); deco->sidelen = getintfield_default(L, index, "sidelen", 8);
deco->fill_ratio = getfloatfield_default(L, index, "fill_ratio", 0.02); deco->fill_ratio = getfloatfield_default(L, index, "fill_ratio", 0.02);
lua_getfield(L, index, "noise_params"); lua_getfield(L, index, "noise_params");
@ -749,8 +749,8 @@ int ModApiBasic::l_register_decoration(lua_State *L)
break; } break; }
} }
if (deco->divlen <= 0) { if (deco->sidelen <= 0) {
errorstream << "register_decoration: divlen must be " errorstream << "register_decoration: sidelen must be "
"greater than 0" << std::endl; "greater than 0" << std::endl;
delete deco; delete deco;
return 0; return 0;