From 8398d7be17bc80f0f2125534aaa689d809ffc8ac Mon Sep 17 00:00:00 2001 From: luk3yx Date: Mon, 2 Aug 2021 08:33:44 +1200 Subject: [PATCH] Add node name to deprecation warnings --- src/script/common/c_content.cpp | 16 +++++++++------- src/script/common/c_converter.h | 4 +++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index e286857fe..40e9f44f9 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -554,7 +554,7 @@ void read_content_features(lua_State *L, ContentFeatures &f, int index) if(lua_isnil(L, -1)){ lua_pop(L, 1); warn_if_field_exists(L, index, "tile_images", - "Deprecated; new name is \"tiles\"."); + "Deprecated; new name is \"tiles\".", &f); lua_getfield(L, index, "tile_images"); } if(lua_istable(L, -1)){ @@ -617,7 +617,7 @@ void read_content_features(lua_State *L, ContentFeatures &f, int index) if(lua_isnil(L, -1)){ lua_pop(L, 1); warn_if_field_exists(L, index, "special_materials", - "Deprecated; new name is \"special_tiles\"."); + "Deprecated; new name is \"special_tiles\".", &f); lua_getfield(L, index, "special_materials"); } if(lua_istable(L, -1)){ @@ -645,14 +645,14 @@ void read_content_features(lua_State *L, ContentFeatures &f, int index) warn_if_field_exists(L, index, "alpha", "Obsolete, only limited compatibility provided; " - "replaced by \"use_texture_alpha\""); + "replaced by \"use_texture_alpha\"", &f); if (getintfield_default(L, index, "alpha", 255) != 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", - "Boolean values are deprecated; use the new choices"); + "Boolean values are deprecated; use the new choices", &f); 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")) { @@ -1180,12 +1180,14 @@ void pushnode(lua_State *L, const MapNode &n, const NodeDefManager *ndef) /******************************************************************************/ void warn_if_field_exists(lua_State *L, int table, - const char *name, const std::string &message) + const char *name, const std::string &message, ContentFeatures *f) { lua_getfield(L, table, name); if (!lua_isnil(L, -1)) { - warningstream << "Field \"" << name << "\": " - << message << std::endl; + warningstream << "Field \"" << name; + if (f != nullptr) + warningstream << "\" in node \"" << f->name; + warningstream << "\": " << message << std::endl; infostream << script_get_backtrace(L) << std::endl; } lua_pop(L, 1); diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h index d6c552fbb..4f1ed3cd2 100644 --- a/src/script/common/c_converter.h +++ b/src/script/common/c_converter.h @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include "irrlichttypes_bloated.h" +#include "common/c_content.h" #include "common/c_types.h" extern "C" { @@ -132,7 +133,8 @@ void push_v2f (lua_State *L, v2f p); void warn_if_field_exists(lua_State *L, int table, const char *fieldname, - const std::string &message); + const std::string &message, + ContentFeatures *f = nullptr); size_t write_array_slice_float(lua_State *L, int table_index, float *data, v3u16 data_size, v3u16 slice_offset, v3u16 slice_size);