aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mg_decoration.cpp5
-rw-r--r--src/mg_decoration.h1
-rw-r--r--src/script/lua_api/l_mapgen.cpp10
3 files changed, 13 insertions, 3 deletions
diff --git a/src/mg_decoration.cpp b/src/mg_decoration.cpp
index 094694e44..cb4705177 100644
--- a/src/mg_decoration.cpp
+++ b/src/mg_decoration.cpp
@@ -227,6 +227,9 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
s16 height = (deco_height_max > 0) ?
pr->range(deco_height, deco_height_max) : deco_height;
+ u8 param2 = (deco_param2_max > 0) ?
+ pr->range(deco_param2, deco_param2_max) : deco_param2;
+
bool force_placement = (flags & DECO_FORCE_PLACEMENT);
const v3s16 &em = vm->m_area.getExtent();
@@ -239,7 +242,7 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
!force_placement)
break;
- vm->m_data[vi] = MapNode(c_place, 0, deco_param2);
+ vm->m_data[vi] = MapNode(c_place, 0, param2);
}
return 1;
diff --git a/src/mg_decoration.h b/src/mg_decoration.h
index 31f6871d9..b63e62eff 100644
--- a/src/mg_decoration.h
+++ b/src/mg_decoration.h
@@ -84,6 +84,7 @@ public:
s16 deco_height;
s16 deco_height_max;
u8 deco_param2;
+ u8 deco_param2_max;
};
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index b179ac407..f475a8f7f 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -981,6 +981,7 @@ bool read_deco_simple(lua_State *L, DecoSimple *deco)
{
int index = 1;
int param2;
+ int param2_max;
deco->deco_height = getintfield_default(L, index, "height", 1);
deco->deco_height_max = getintfield_default(L, index, "height_max", 0);
@@ -993,6 +994,7 @@ bool read_deco_simple(lua_State *L, DecoSimple *deco)
size_t nnames = getstringlistfield(L, index, "decoration", &deco->m_nodenames);
deco->m_nnlistsizes.push_back(nnames);
+
if (nnames == 0) {
errorstream << "register_decoration: no decoration nodes "
"defined" << std::endl;
@@ -1000,12 +1002,16 @@ bool read_deco_simple(lua_State *L, DecoSimple *deco)
}
param2 = getintfield_default(L, index, "param2", 0);
- if ((param2 < 0) || (param2 > 255)) {
- errorstream << "register_decoration: param2 out of bounds (0-255)"
+ param2_max = getintfield_default(L, index, "param2_max", 0);
+
+ if (param2 < 0 || param2 > 255 || param2_max < 0 || param2_max > 255) {
+ errorstream << "register_decoration: param2 or param2_max out of bounds (0-255)"
<< std::endl;
return false;
}
+
deco->deco_param2 = (u8)param2;
+ deco->deco_param2_max = (u8)param2_max;
return true;
}