Hint at problematic code when logging deprecated calls
authorsfan5 <sfan5@live.de>
Thu, 23 Nov 2017 22:35:52 +0000 (23:35 +0100)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:32:00 +0000 (17:32 +0200)
src/script/common/c_internal.cpp

index b349f9dd1f7d928ebc537872380e884c4248857d..3fa0441725a57e36e226330d4573b73d3ef5ef07 100644 (file)
@@ -178,9 +178,15 @@ void log_deprecated(lua_State *L, const std::string &message)
        }
 
        if (do_log) {
-               warningstream << message << std::endl;
-               // L can be NULL if we get called by log_deprecated(const std::string &msg)
-               // from scripting_game.cpp.
+               warningstream << message;
+               if (L) { // L can be NULL if we get called 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 (do_error)
                                script_error(L, LUA_ERRRUN, NULL, NULL);