Skip to content

Commit

Permalink
ChaosMod: Only increase refcount if ScriptHookV.dev file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pongo1231 committed Feb 6, 2025
1 parent 1bfdc81 commit 56a1c34
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ChaosMod/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,12 @@ namespace Main
{
LOG("Running mod init");

WCHAR fileName[MAX_PATH] = {};
GetModuleFileName(reinterpret_cast<HINSTANCE>(&__ImageBase), fileName, MAX_PATH);

ms_ModuleHandle = LoadLibrary(fileName);
if (DoesFileExist("ScriptHookV.dev"))
{
WCHAR fileName[MAX_PATH] = {};
GetModuleFileName(reinterpret_cast<HINSTANCE>(&__ImageBase), fileName, MAX_PATH);
ms_ModuleHandle = LoadLibrary(fileName);
}
}

void OnRun()
Expand Down Expand Up @@ -417,7 +419,7 @@ namespace Main
if (ms_Flags.ToggleModShortcutEnabled)
ms_Flags.ToggleModState = true;
}
else if (key == 0x52 && DoesFileExist("ScriptHookV.dev")) // R
else if (key == 0x52 && ms_ModuleHandle) // R
{
OnCleanup();
FreeModule(ms_ModuleHandle);
Expand Down

0 comments on commit 56a1c34

Please sign in to comment.