mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Script: avoid fatal error in deprecated func handler
This commit is contained in:
parent
dd2e45ee82
commit
d6d045aad4
1 changed files with 9 additions and 5 deletions
|
@ -123,14 +123,18 @@ int ModApiBase::l_deprecated_function(lua_State *L, const char *good, const char
|
|||
|
||||
u64 start_time = porting::getTimeUs();
|
||||
lua_Debug ar;
|
||||
std::string backtrace;
|
||||
|
||||
// Get caller name with line and script backtrace
|
||||
FATAL_ERROR_IF(!lua_getstack(L, 1, &ar), "lua_getstack() failed");
|
||||
FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
|
||||
if (lua_getstack(L, 1, &ar) && lua_getinfo(L, "Sl", &ar)) {
|
||||
// Get backtrace and hash it to reduce the warning flood
|
||||
backtrace = ar.short_src;
|
||||
backtrace.append(":").append(std::to_string(ar.currentline));
|
||||
} else {
|
||||
backtrace = "<tail call optimized coroutine> ";
|
||||
backtrace.append(script_get_backtrace(L));
|
||||
}
|
||||
|
||||
// Get backtrace and hash it to reduce the warning flood
|
||||
std::string backtrace = ar.short_src;
|
||||
backtrace.append(":").append(std::to_string(ar.currentline));
|
||||
u64 hash = murmur_hash_64_ua(backtrace.data(), backtrace.length(), 0xBADBABE);
|
||||
|
||||
if (std::find(deprecated_logged.begin(), deprecated_logged.end(), hash)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue