1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 03:39:55 +00:00

Merge branch 'solve_6430' into 'master'

Use a setting to enable Lua Action tracebacks

See merge request OpenMW/openmw!1419
This commit is contained in:
Petr Mikheev 2021-11-22 19:39:47 +00:00
commit 6f5e0e7697
4 changed files with 27 additions and 13 deletions

View File

@ -4,6 +4,7 @@
#include <components/debug/debuglog.hpp>
#include <components/lua/luastate.hpp>
#include <components/settings/settings.hpp>
#include "../mwworld/cellstore.hpp"
#include "../mwworld/class.hpp"
@ -12,12 +13,12 @@
namespace MWLua
{
#ifdef NDEBUG
Action::Action(LuaUtil::LuaState* state) {}
#else
Action::Action(LuaUtil::LuaState* state) : mCallerTraceback(state->debugTraceback()) {}
#endif
Action::Action(LuaUtil::LuaState* state)
{
static const bool luaDebug = Settings::Manager::getBool("lua debug", "Lua");
if (luaDebug)
mCallerTraceback = state->debugTraceback();
}
void Action::safeApply(WorldView& w) const
{
@ -28,11 +29,11 @@ namespace MWLua
catch (const std::exception& e)
{
Log(Debug::Error) << "Error in " << this->toString() << ": " << e.what();
#ifdef NDEBUG
Log(Debug::Error) << "Traceback is available only in debug builds";
#else
Log(Debug::Error) << "Caller " << mCallerTraceback;
#endif
if (mCallerTraceback.empty())
Log(Debug::Error) << "Set 'lua_debug=true' in settings.cfg to enable action tracebacks";
else
Log(Debug::Error) << "Caller " << mCallerTraceback;
}
}

View File

@ -29,9 +29,7 @@ namespace MWLua
virtual std::string toString() const = 0;
private:
#ifndef NDEBUG
std::string mCallerTraceback;
#endif
};
class TeleportAction final : public Action

View File

@ -1,6 +1,18 @@
Lua Settings
############
lua debug
---------
:Type: boolean
:Range: True/False
:Default: False
Enables debug tracebacks for Lua actions.
It adds significant performance overhead, don't enable if you don't need it.
This setting can only be configured by editing the settings configuration file.
lua num threads
---------------

View File

@ -1106,6 +1106,9 @@ stomp intensity = 1
[Lua]
# Enable performance-heavy debug features
lua debug = false
# Set the maximum number of threads used for Lua scripts.
# If zero, Lua scripts are processed in the main thread.
lua num threads = 1