Skip to content

Commit

Permalink
Clean up warnings and debugger errors related to the Lua console
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills committed Nov 5, 2023
1 parent 4f23762 commit d0f4067
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Source/lua/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#ifdef _DEBUG
#include "lua/modules/dev.hpp"
#include "lua/repl.hpp"
#endif

namespace devilution {
Expand Down Expand Up @@ -252,6 +253,9 @@ void LuaInitialize()

void LuaShutdown()
{
#ifdef _DEBUG
LuaReplShutdown();
#endif
CurrentLuaState = std::nullopt;
}

Expand Down
1 change: 0 additions & 1 deletion Source/lua/modules/dev/quests.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#ifdef _DEBUG
#include "lua/modules/dev/quests.hpp"

Expand Down
6 changes: 5 additions & 1 deletion Source/lua/repl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 changes: 2 additions & 0 deletions Source/lua/repl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ tl::expected<std::string, std::string> RunLuaReplLine(std::string_view code);

sol::environment &GetLuaReplEnvironment();

void LuaReplShutdown();

} // namespace devilution
#endif // _DEBUG

0 comments on commit d0f4067

Please sign in to comment.