aboutsummaryrefslogtreecommitdiff
path: root/src/script/common/c_internal.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-11-28 13:48:33 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-11-28 13:48:33 +0100
commiteb6aca8b4a67ef55108231e71ff29a18a29bf5ae (patch)
treef891914d25cae2cdaa24392381436a287340651e /src/script/common/c_internal.cpp
parent8de51dae97aa2fe6ea02e4cf437bfe2b2a38eb06 (diff)
parentf1d72d212a0661588be27003069abf4bd8092e55 (diff)
downloaddragonfireclient-eb6aca8b4a67ef55108231e71ff29a18a29bf5ae.tar.xz
Merged Minetest
Diffstat (limited to 'src/script/common/c_internal.cpp')
-rw-r--r--src/script/common/c_internal.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp
index 6df1f8b7b..ad5f836c5 100644
--- a/src/script/common/c_internal.cpp
+++ b/src/script/common/c_internal.cpp
@@ -155,24 +155,28 @@ static void script_log(lua_State *L, const std::string &message,
infostream << script_get_backtrace(L) << std::endl;
}
-void log_deprecated(lua_State *L, const std::string &message, int stack_depth)
+DeprecatedHandlingMode get_deprecated_handling_mode()
{
static thread_local bool configured = false;
- static thread_local bool do_log = false;
- static thread_local bool do_error = false;
+ static thread_local DeprecatedHandlingMode ret = DeprecatedHandlingMode::Ignore;
// Only read settings on first call
if (!configured) {
std::string value = g_settings->get("deprecated_lua_api_handling");
if (value == "log") {
- do_log = true;
+ ret = DeprecatedHandlingMode::Log;
} else if (value == "error") {
- do_log = true;
- do_error = true;
+ ret = DeprecatedHandlingMode::Error;
}
configured = true;
}
- if (do_log)
- script_log(L, message, warningstream, do_error, stack_depth);
+ return ret;
+}
+
+void log_deprecated(lua_State *L, const std::string &message, int stack_depth)
+{
+ DeprecatedHandlingMode mode = get_deprecated_handling_mode();
+ if (mode != DeprecatedHandlingMode::Ignore)
+ script_log(L, message, warningstream, mode == DeprecatedHandlingMode::Error, stack_depth);
}