diff options
author | kwolekr <kwolekr@minetest.net> | 2013-06-17 18:23:31 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2013-06-17 18:23:31 -0400 |
commit | 56093b6614a47b181bbce6d4e35d213a4e04120c (patch) | |
tree | cd5ac885638f130f90034de6752e23c06c9bc81c | |
parent | 0a8519a26fc7c10b4e7415746e9045caa3ae978f (diff) | |
download | minetest-56093b6614a47b181bbce6d4e35d213a4e04120c.tar.gz minetest-56093b6614a47b181bbce6d4e35d213a4e04120c.tar.bz2 minetest-56093b6614a47b181bbce6d4e35d213a4e04120c.zip |
Decoration: Change divlen to sidelen
-rw-r--r-- | doc/lua_api.txt | 5 | ||||
-rw-r--r-- | src/mapgen.cpp | 10 | ||||
-rw-r--r-- | src/mapgen.h | 2 | ||||
-rw-r--r-- | src/script/lua_api/luaapi.cpp | 6 |
4 files changed, 15 insertions, 8 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt index b6981582e..85f6ca5a6 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1875,8 +1875,9 @@ Decoration definition (register_decoration) deco_type = "simple", -- See "Decoration types" place_on = "default:dirt_with_grass", ^ Node that decoration can be placed on - divlen = 8, - ^ Number of divisions made in the chunk being generated + sidelen = 8, + ^ 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, ^ Ratio of the area to be uniformly filled by the decoration. ^ Used only if noise_params is not specified. diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 49ac827e1..17afcf350 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -232,8 +232,14 @@ void Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { int carea_size = nmax.X - nmin.X + 1; // Divide area into parts - s16 sidelen = carea_size / divlen; - float area = sidelen * sidelen; + if (carea_size % 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 x0 = 0; x0 < divlen; x0++) { diff --git a/src/mapgen.h b/src/mapgen.h index e8252cbbf..f3d90a14e 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -199,7 +199,7 @@ public: int mapseed; std::string place_on_name; content_t c_place_on; - s16 divlen; + s16 sidelen; float fill_ratio; NoiseParams *np; diff --git a/src/script/lua_api/luaapi.cpp b/src/script/lua_api/luaapi.cpp index 75139861b..667a3afcf 100644 --- a/src/script/lua_api/luaapi.cpp +++ b/src/script/lua_api/luaapi.cpp @@ -683,7 +683,7 @@ int ModApiBasic::l_register_decoration(lua_State *L) deco->c_place_on = CONTENT_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); lua_getfield(L, index, "noise_params"); @@ -749,8 +749,8 @@ int ModApiBasic::l_register_decoration(lua_State *L) break; } } - if (deco->divlen <= 0) { - errorstream << "register_decoration: divlen must be " + if (deco->sidelen <= 0) { + errorstream << "register_decoration: sidelen must be " "greater than 0" << std::endl; delete deco; return 0; |