end
function minetest.get_node_group(name, group)
+ minetest.log("deprecated", "Deprecated usage of get_node_group, use get_item_group instead")
return minetest.get_item_group(name, group)
end
#disable_anticheat = false
# If true, actions are recorded for rollback
#enable_rollback_recording = false
+# handling for deprecated lua api calls
+# "legacy" = (try to) mimic old behaviour (default for release)
+# "log" = mimic and log backtrace of deprecated call (default for debug)
+# "error" = abort on usage of deprecated call (suggested for mod developers)
+#deprecated_lua_api_handling = legacy
# Profiler data print interval. #0 = disable.
#profiler_print_interval = 0
settings->setDefault("disallow_empty_password", "false");
settings->setDefault("disable_anticheat", "false");
settings->setDefault("enable_rollback_recording", "false");
+#ifdef NDEBUG
+ settings->setDefault("deprecated_lua_api_handling", "legacy");
+#else
+ settings->setDefault("deprecated_lua_api_handling", "log");
+#endif
settings->setDefault("profiler_print_interval", "0");
settings->setDefault("enable_mapgen_debug_info", "false");
#include "filesys.h"
#include "gettime.h"
#include "gettext.h"
+#include "scripting_game.h"
#define MY_CHECKPOS(a,b) \
if (v_pos.size() != 2) { \
std::string type = trim(parts[0]);
std::string description = trim(parts[1]);
- if ((type == "size") || (type == "invsize")){
+ if (type == "size") {
+ parseSize(data,description);
+ return;
+ }
+
+ if (type == "invsize") {
+ log_deprecated("Deprecated formspec element \"invsize\" is used");
parseSize(data,description);
return;
}
#include "common/c_internal.h"
#include "debug.h"
+#include "log.h"
+#include "main.h"
+#include "settings.h"
std::string script_get_backtrace(lua_State *L)
{
lua_remove(L, -2); // Remove error handler
}
+void log_deprecated(lua_State *L, std::string message)
+{
+ static bool configured = false;
+ static bool dolog = false;
+ static bool doerror = false;
+
+ // performance optimization to not have to read and compare setting for every logline
+ if (!configured) {
+ std::string value = g_settings->get("deprecated_lua_api_handling");
+ if (value == "log") {
+ dolog = true;
+ }
+ if (value == "error") {
+ dolog = true;
+ doerror = true;
+ }
+ }
+
+ if (doerror) {
+ if (L != NULL) {
+ script_error(L);
+ } else {
+ /* As of april 2014 assert is not optimized to nop in release builds
+ * therefore this is correct. */
+ assert("Can't do a scripterror for this deprecated message, so exit completely!");
+ }
+ }
+
+ if (dolog) {
+ /* abusing actionstream because of lack of file-only-logged loglevel */
+ actionstream << message << std::endl;
+ if (L != NULL) {
+ actionstream << script_get_backtrace(L) << std::endl;
+ }
+ }
+}
int script_error_handler(lua_State *L);
int script_exception_wrapper(lua_State *L, lua_CFunction f);
void script_error(lua_State *L);
-void script_run_callbacks(lua_State *L, int nargs,
- RunCallbacksMode mode);
+void script_run_callbacks(lua_State *L, int nargs, RunCallbacksMode mode);
+void log_deprecated(lua_State *L, std::string message);
#endif /* C_INTERNAL_H_ */
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
LuaEntitySAO *co = getluaobject(ref);
+ log_deprecated(L,"Deprecated call to \"get_entity_name");
if(co == NULL) return 0;
// Do it
std::string name = co->getName();
if (lua_gettop(L) > 1) // deprecated
{
+ log_deprecated(L,"Deprecated add_particle call with individual parameters instead of definition");
pos = check_v3f(L, 1);
vel = check_v3f(L, 2);
acc = check_v3f(L, 3);
if (lua_gettop(L) > 1) //deprecated
{
+ log_deprecated(L,"Deprecated add_particlespawner call with individual parameters instead of definition");
amount = luaL_checknumber(L, 1);
time = luaL_checknumber(L, 2);
minpos = check_v3f(L, 3);
level = LMT_ACTION;
else if(levelname == "verbose")
level = LMT_VERBOSE;
+ else if (levelname == "deprecated") {
+ log_deprecated(L,text);
+ return 0;
+ }
+
}
log_printline(level, text);
return 0;
ObjectRef::Register(L);
LuaSettings::Register(L);
}
+
+void log_deprecated(std::string message)
+{
+ log_deprecated(NULL,message);
+}
void InitializeModApi(lua_State *L, int top);
};
+void log_deprecated(std::string message);
+
#endif /* SCRIPTING_GAME_H_ */