aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/common/c_content.cpp11
-rw-r--r--src/script/common/c_content.h2
-rw-r--r--src/script/cpp_api/s_env.cpp3
-rw-r--r--src/script/lua_api/l_mapgen.cpp21
4 files changed, 23 insertions, 14 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 0d1f7aa03..d1e182f9f 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -839,12 +839,11 @@ void push_hit_params(lua_State *L,const HitParams &params)
}
/******************************************************************************/
-u32 getflagsfield(lua_State *L, int table,
- const char *fieldname, FlagDesc *flagdesc) {
- std::string flagstring;
-
- flagstring = getstringfield_default(L, table, fieldname, "");
- return readFlagString(flagstring, flagdesc);
+u32 getflagsfield(lua_State *L, int table, const char *fieldname,
+ FlagDesc *flagdesc, u32 *flagmask)
+{
+ std::string flagstring = getstringfield_default(L, table, fieldname, "");
+ return readFlagString(flagstring, flagdesc, flagmask);
}
/******************************************************************************/
diff --git a/src/script/common/c_content.h b/src/script/common/c_content.h
index 163e803db..a89de1aad 100644
--- a/src/script/common/c_content.h
+++ b/src/script/common/c_content.h
@@ -121,7 +121,7 @@ int getenumfield (lua_State *L,
u32 getflagsfield (lua_State *L, int table,
const char *fieldname,
- FlagDesc *flagdesc);
+ FlagDesc *flagdesc, u32 *flagmask);
void push_items (lua_State *L,
const std::vector<ItemStack> &items);
diff --git a/src/script/cpp_api/s_env.cpp b/src/script/cpp_api/s_env.cpp
index 2c2198edf..b0de675ec 100644
--- a/src/script/cpp_api/s_env.cpp
+++ b/src/script/cpp_api/s_env.cpp
@@ -78,7 +78,8 @@ void ScriptApiEnv::environment_OnMapgenInit(MapgenParams *mgparams)
lua_pushinteger(L, mgparams->water_level);
lua_setfield(L, -2, "water_level");
- std::string flagstr = writeFlagString(mgparams->flags, flagdesc_mapgen);
+ std::string flagstr = writeFlagString(mgparams->flags,
+ flagdesc_mapgen, (u32)-1);
lua_pushstring(L, flagstr.c_str());
lua_setfield(L, -2, "flags");
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index 709c7de35..4c6bca74e 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -210,13 +210,20 @@ int ModApiMapgen::l_set_mapgen_params(lua_State *L)
lua_getfield(L, 1, "flagmask");
if (lua_isstring(L, -1)) {
flagstr = lua_tostring(L, -1);
- emerge->params.flags &= ~readFlagString(flagstr, flagdesc_mapgen);
+ emerge->params.flags &= ~readFlagString(flagstr, flagdesc_mapgen, NULL);
+ errorstream << "set_mapgen_params(): flagmask field is deprecated, "
+ "see lua_api.txt" << std::endl;
}
lua_getfield(L, 1, "flags");
if (lua_isstring(L, -1)) {
+ u32 flags, flagmask;
+
flagstr = lua_tostring(L, -1);
- emerge->params.flags |= readFlagString(flagstr, flagdesc_mapgen);
+ flags = readFlagString(flagstr, flagdesc_mapgen, &flagmask);
+
+ emerge->params.flags &= ~flagmask;
+ emerge->params.flags |= flags;
}
return 0;
@@ -227,7 +234,8 @@ int ModApiMapgen::l_set_gen_notify(lua_State *L)
{
if (lua_isstring(L, 1)) {
EmergeManager *emerge = getServer(L)->getEmergeManager();
- emerge->gennotify = readFlagString(lua_tostring(L, 1), flagdesc_gennotify);
+ emerge->gennotify = readFlagString(lua_tostring(L, 1),
+ flagdesc_gennotify, NULL);
}
return 0;
}
@@ -371,9 +379,10 @@ int ModApiMapgen::l_register_decoration(lua_State *L)
break; }
case DECO_SCHEMATIC: {
DecoSchematic *dschem = (DecoSchematic *)deco;
- dschem->flags = getflagsfield(L, index, "flags", flagdesc_deco_schematic);
+ dschem->flags = getflagsfield(L, index, "flags",
+ flagdesc_deco_schematic, NULL);
dschem->rotation = (Rotation)getenumfield(L, index,
- "rotation", es_Rotation, ROTATE_0);
+ "rotation", es_Rotation, ROTATE_0);
lua_getfield(L, index, "replacements");
if (lua_istable(L, -1)) {
@@ -445,7 +454,7 @@ int ModApiMapgen::l_register_ore(lua_State *L)
ore->clust_size = getintfield_default(L, index, "clust_size", 0);
ore->height_min = getintfield_default(L, index, "height_min", 0);
ore->height_max = getintfield_default(L, index, "height_max", 0);
- ore->flags = getflagsfield(L, index, "flags", flagdesc_ore);
+ ore->flags = getflagsfield(L, index, "flags", flagdesc_ore, NULL);
ore->nthresh = getfloatfield_default(L, index, "noise_threshhold", 0.);
lua_getfield(L, index, "wherein");