Hint at problematic code when logging deprecated calls

master
sfan5 2017-11-23 23:35:52 +01:00 committed by paramat
parent 03c11a73d8
commit 813d819d15
1 changed files with 9 additions and 3 deletions

View File

@ -150,9 +150,15 @@ void log_deprecated(lua_State *L, const std::string &message)
} }
if (do_log) { if (do_log) {
warningstream << message << std::endl; warningstream << message;
// L can be NULL if we get called by log_deprecated(const std::string &msg) if (L) { // L can be NULL if we get called from scripting_game.cpp
// from scripting_game.cpp. lua_Debug ar;
FATAL_ERROR_IF(!lua_getstack(L, 2, &ar), "lua_getstack() failed");
FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
warningstream << " (at " << ar.short_src << ":" << ar.currentline << ")";
}
warningstream << std::endl;
if (L) { if (L) {
if (do_error) if (do_error)
script_error(L, LUA_ERRRUN, NULL, NULL); script_error(L, LUA_ERRRUN, NULL, NULL);