mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Improve some deprecation warnings
This commit is contained in:
parent
8e03e94ea9
commit
37f922b500
3 changed files with 52 additions and 52 deletions
|
@ -637,9 +637,10 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype, bool special)
|
|||
// name="default_lava.png"
|
||||
tiledef.name.clear();
|
||||
getstringfield(L, index, "name", tiledef.name);
|
||||
warn_if_field_exists(L, index, "image", "TileDef",
|
||||
"Deprecated: new name is \"name\".");
|
||||
getstringfield(L, index, "image", tiledef.name);
|
||||
if (getstringfield(L, index, "image", tiledef.name)) {
|
||||
log_deprecated(L, "Field \"image\" on TileDef is deprecated, "
|
||||
"use \"name\" instead.", 2);
|
||||
}
|
||||
|
||||
tiledef.backface_culling = getboolfield_default(
|
||||
L, index, "backface_culling", default_culling);
|
||||
|
@ -797,16 +798,21 @@ void read_content_features(lua_State *L, ContentFeatures &f, int index)
|
|||
|
||||
f.setDefaultAlphaMode();
|
||||
|
||||
warn_if_field_exists(L, index, "alpha", "node " + f.name,
|
||||
"Obsolete, only limited compatibility provided; "
|
||||
"replaced by \"use_texture_alpha\"");
|
||||
if (getintfield_default(L, index, "alpha", 255) != 255)
|
||||
f.alpha = ALPHAMODE_BLEND;
|
||||
{
|
||||
int alpha;
|
||||
if (getintfield(L, index, "alpha", alpha)) {
|
||||
log_deprecated(L, "Field \"alpha\" on node " + f.name + " is obsolete, "
|
||||
"only limited compatibility provided; "
|
||||
"replaced by \"use_texture_alpha\".", 2);
|
||||
if (alpha != 255)
|
||||
f.alpha = ALPHAMODE_BLEND;
|
||||
}
|
||||
}
|
||||
|
||||
lua_getfield(L, index, "use_texture_alpha");
|
||||
if (lua_isboolean(L, -1)) {
|
||||
warn_if_field_exists(L, index, "use_texture_alpha", "node " + f.name,
|
||||
"Boolean values are deprecated; use the new choices");
|
||||
log_deprecated(L, "Field \"use_texture_alpha\" on node " + f.name + ": "
|
||||
"Boolean values are deprecated; use the new choices instead.", 2);
|
||||
if (lua_toboolean(L, -1))
|
||||
f.alpha = (f.drawtype == NDT_NORMAL) ? ALPHAMODE_CLIP : ALPHAMODE_BLEND;
|
||||
} else if (check_field_or_nil(L, -1, LUA_TSTRING, "use_texture_alpha")) {
|
||||
|
@ -1360,22 +1366,6 @@ void pushnode(lua_State *L, const MapNode &n)
|
|||
lua_call(L, 3, 1);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void warn_if_field_exists(lua_State *L, int table, const char *fieldname,
|
||||
std::string_view name, std::string_view message)
|
||||
{
|
||||
lua_getfield(L, table, fieldname);
|
||||
if (!lua_isnil(L, -1)) {
|
||||
warningstream << "Field \"" << fieldname << "\"";
|
||||
if (!name.empty()) {
|
||||
warningstream << " on " << name;
|
||||
}
|
||||
warningstream << ": " << message << std::endl;
|
||||
infostream << script_get_backtrace(L) << std::endl;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int getenumfield(lua_State *L, int table,
|
||||
const char *fieldname, const EnumString *spec, int default_)
|
||||
|
|
|
@ -121,9 +121,6 @@ void push_v2f(lua_State *L, v2f p);
|
|||
void push_aabb3f_vector(lua_State *L, const std::vector<aabb3f> &boxes,
|
||||
f32 divisor = 1.0f);
|
||||
|
||||
void warn_if_field_exists(lua_State *L, int table, const char *fieldname,
|
||||
std::string_view name, std::string_view message);
|
||||
|
||||
size_t write_array_slice_float(lua_State *L, int table_index, float *data,
|
||||
v3u16 data_size, v3u16 slice_offset, v3u16 slice_size);
|
||||
|
||||
|
|
|
@ -1365,30 +1365,43 @@ int ModApiMapgen::l_register_ore(lua_State *L)
|
|||
ore->flags = 0;
|
||||
|
||||
//// Get noise_threshold
|
||||
warn_if_field_exists(L, index, "noise_threshhold", "ore " + ore->name,
|
||||
"Deprecated: new name is \"noise_threshold\".");
|
||||
|
||||
float nthresh;
|
||||
if (!getfloatfield(L, index, "noise_threshold", nthresh) &&
|
||||
!getfloatfield(L, index, "noise_threshhold", nthresh))
|
||||
nthresh = 0;
|
||||
ore->nthresh = nthresh;
|
||||
{
|
||||
float nthresh;
|
||||
if (getfloatfield(L, index, "noise_threshold", nthresh)) {
|
||||
} else if (getfloatfield(L, index, "noise_threshhold", nthresh)) {
|
||||
log_deprecated(L, "Field \"noise_threshhold\" on ore " + ore->name +
|
||||
" is deprecated, use \"noise_threshold\" instead.", 2);
|
||||
} else {
|
||||
nthresh = 0;
|
||||
}
|
||||
ore->nthresh = nthresh;
|
||||
}
|
||||
|
||||
//// Get y_min/y_max
|
||||
warn_if_field_exists(L, index, "height_min", "ore " + ore->name,
|
||||
"Deprecated: new name is \"y_min\".");
|
||||
warn_if_field_exists(L, index, "height_max", "ore " + ore->name,
|
||||
"Deprecated: new name is \"y_max\".");
|
||||
|
||||
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;
|
||||
{
|
||||
int ymin;
|
||||
if (getintfield(L, index, "y_min", ymin)) {
|
||||
} else if (getintfield(L, index, "height_min", ymin)) {
|
||||
log_deprecated(L, "Field \"height_min\" on ore " + ore->name +
|
||||
" is deprecated, use \"y_min\" instead.", 2);
|
||||
} else {
|
||||
ymin = -31000;
|
||||
}
|
||||
ore->y_min = ymin;
|
||||
}
|
||||
|
||||
{
|
||||
int ymax;
|
||||
if (getintfield(L, index, "y_max", ymax)) {
|
||||
} else if (getintfield(L, index, "height_max", ymax)) {
|
||||
log_deprecated(L, "Field \"height_max\" on ore " + ore->name +
|
||||
" is deprecated, use \"y_max\" instead.", 2);
|
||||
} else {
|
||||
ymax = 31000;
|
||||
}
|
||||
ore->y_max = ymax;
|
||||
}
|
||||
|
||||
if (ore->clust_scarcity <= 0 || ore->clust_num_ores <= 0) {
|
||||
errorstream << "register_ore: clust_scarcity and clust_num_ores"
|
||||
|
@ -1410,8 +1423,8 @@ int ModApiMapgen::l_register_ore(lua_State *L)
|
|||
if (read_noiseparams(L, -1, &ore->np)) {
|
||||
ore->flags |= OREFLAG_USE_NOISE;
|
||||
} else if (ore->needs_noise) {
|
||||
log_deprecated(L,
|
||||
"register_ore: ore type requires 'noise_params' but it is not specified, falling back to defaults");
|
||||
log_deprecated(L, "register_ore: ore type requires 'noise_params'"
|
||||
" but it is not specified, falling back to defaults", 2);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue