Browse Source

Clean up warnings and debugger errors related to the Lua console

pull/6781/head
staphen 2 years ago committed by Gleb Mazovetskiy
parent
commit
7df7b35123
  1. 4
      Source/lua/lua.cpp
  2. 1
      Source/lua/modules/dev/quests.cpp
  3. 6
      Source/lua/repl.cpp
  4. 2
      Source/lua/repl.hpp

4
Source/lua/lua.cpp

@ -20,6 +20,7 @@
#ifdef _DEBUG
#include "lua/modules/dev.hpp"
#include "lua/repl.hpp"
#endif
namespace devilution {
@ -252,6 +253,9 @@ void LuaInitialize()
void LuaShutdown()
{
#ifdef _DEBUG
LuaReplShutdown();
#endif
CurrentLuaState = std::nullopt;
}

1
Source/lua/modules/dev/quests.cpp

@ -1,4 +1,3 @@
#pragma once
#ifdef _DEBUG
#include "lua/modules/dev/quests.hpp"

6
Source/lua/repl.cpp

@ -48,7 +48,6 @@ int LuaPrintToConsole(lua_State *state)
void CreateReplEnvironment()
{
sol::state &lua = GetLuaState();
sol::environment env = CreateLuaSandbox();
env["print"] = LuaPrintToConsole;
lua_setwarnf(env.lua_state(), LuaConsoleWarn, /*ud=*/nullptr);
@ -103,5 +102,10 @@ tl::expected<std::string, std::string> RunLuaReplLine(std::string_view code)
return sol::utility::to_string(sol::stack_object(result));
}
void LuaReplShutdown()
{
replEnv = std::nullopt;
}
} // namespace devilution
#endif // _DEBUG

2
Source/lua/repl.hpp

@ -13,5 +13,7 @@ tl::expected<std::string, std::string> RunLuaReplLine(std::string_view code);
sol::environment &GetLuaReplEnvironment();
void LuaReplShutdown();
} // namespace devilution
#endif // _DEBUG

Loading…
Cancel
Save