diff --git a/methods/CMangos/GlobalMethods.h b/methods/CMangos/GlobalMethods.h index 0bcc5867fe..a6384b1229 100644 --- a/methods/CMangos/GlobalMethods.h +++ b/methods/CMangos/GlobalMethods.h @@ -2522,14 +2522,27 @@ namespace LuaGlobalFunctions static std::string GetStackAsString(Eluna* E) { - std::ostringstream oss; + std::string output; int top = lua_gettop(E->L); for (int i = 1; i <= top; ++i) { - oss << luaL_tolstring(E->L, i, NULL); - lua_pop(E->L, 1); + if (lua_isstring(E->L, i)) + { + output += lua_tostring(E->L, i); + } + else + { + lua_getglobal(E->L, "tostring"); + lua_pushvalue(E->L, i); + lua_call(E->L, 1, 1); + output += lua_tostring(E->L, -1); + lua_pop(E->L, 1); + } + + if (i < top) + output += "\t"; } - return oss.str(); + return output; } /** diff --git a/methods/Mangos/GlobalMethods.h b/methods/Mangos/GlobalMethods.h index 84c532bea7..0260a75d39 100644 --- a/methods/Mangos/GlobalMethods.h +++ b/methods/Mangos/GlobalMethods.h @@ -2279,14 +2279,27 @@ namespace LuaGlobalFunctions static std::string GetStackAsString(Eluna* E) { - std::ostringstream oss; + std::string output; int top = lua_gettop(E->L); for (int i = 1; i <= top; ++i) { - oss << luaL_tolstring(E->L, i, NULL); - lua_pop(E->L, 1); + if (lua_isstring(E->L, i)) + { + output += lua_tostring(E->L, i); + } + else + { + lua_getglobal(E->L, "tostring"); + lua_pushvalue(E->L, i); + lua_call(E->L, 1, 1); + output += lua_tostring(E->L, -1); + lua_pop(E->L, 1); + } + + if (i < top) + output += "\t"; } - return oss.str(); + return output; } /** diff --git a/methods/TrinityCore/GlobalMethods.h b/methods/TrinityCore/GlobalMethods.h index c55c02c4c1..042fa0c779 100644 --- a/methods/TrinityCore/GlobalMethods.h +++ b/methods/TrinityCore/GlobalMethods.h @@ -2404,14 +2404,27 @@ namespace LuaGlobalFunctions static std::string GetStackAsString(Eluna* E) { - std::ostringstream oss; + std::string output; int top = lua_gettop(E->L); for (int i = 1; i <= top; ++i) { - oss << luaL_tolstring(E->L, i, NULL); - lua_pop(E->L, 1); + if (lua_isstring(E->L, i)) + { + output += lua_tostring(E->L, i); + } + else + { + lua_getglobal(E->L, "tostring"); + lua_pushvalue(E->L, i); + lua_call(E->L, 1, 1); + output += lua_tostring(E->L, -1); + lua_pop(E->L, 1); + } + + if (i < top) + output += "\t"; } - return oss.str(); + return output; } /** diff --git a/methods/VMangos/GlobalMethods.h b/methods/VMangos/GlobalMethods.h index 365e7833f9..17a4920bc7 100644 --- a/methods/VMangos/GlobalMethods.h +++ b/methods/VMangos/GlobalMethods.h @@ -2222,14 +2222,27 @@ namespace LuaGlobalFunctions static std::string GetStackAsString(Eluna* E) { - std::ostringstream oss; + std::string output; int top = lua_gettop(E->L); for (int i = 1; i <= top; ++i) { - oss << luaL_tolstring(E->L, i, NULL); - lua_pop(E->L, 1); + if (lua_isstring(E->L, i)) + { + output += lua_tostring(E->L, i); + } + else + { + lua_getglobal(E->L, "tostring"); + lua_pushvalue(E->L, i); + lua_call(E->L, 1, 1); + output += lua_tostring(E->L, -1); + lua_pop(E->L, 1); + } + + if (i < top) + output += "\t"; } - return oss.str(); + return output; } /**