Skip to content

Commit

Permalink
Fix scripts leaking on reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Sirius902 committed Oct 25, 2023
1 parent 91ea7ea commit b89cb52
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/lua_exec.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "lua_exec.h"

#include <memory>
#include <utility>

#include "ConsoleLib.h"
Expand All @@ -17,16 +18,16 @@ static std::vector<fs::path> _scriptPaths;
static bool _showConsole = false;
static bool _requestedReset = false;

static LuaBackend* _backend = nullptr;
static std::unique_ptr<LuaBackend> _backend;

static std::chrono::high_resolution_clock::time_point _sClock;
static std::chrono::high_resolution_clock::time_point _msClock;

void ResetLUA() {
std::printf("\n");
ConsoleLib::MessageOutput("Reloading...\n\n", 0);
_backend = new LuaBackend(_scriptPaths,
MemoryLib::ExecAddress + MemoryLib::BaseAddress);
_backend = std::make_unique<LuaBackend>(
_scriptPaths, MemoryLib::ExecAddress + MemoryLib::BaseAddress);

if (_backend->loadedScripts.size() == 0)
ConsoleLib::MessageOutput("No scripts found! Reload halted!\n\n", 3);
Expand Down Expand Up @@ -64,8 +65,8 @@ int EntryLUA(int ProcessID, HANDLE ProcessH, std::uint64_t TargetAddress,

MemoryLib::ExternProcess(ProcessID, ProcessH, TargetAddress);

_backend =
new LuaBackend(_scriptPaths, MemoryLib::ExecAddress + TargetAddress);
_backend = std::make_unique<LuaBackend>(_scriptPaths, MemoryLib::ExecAddress +
TargetAddress);
_backend->frameLimit = 16;

if (_backend->loadedScripts.size() == 0) {
Expand Down

0 comments on commit b89cb52

Please sign in to comment.