diff options
author | Emma Miler <emma.pi@protonmail.com> | 2022-12-09 01:03:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-08 19:03:57 -0500 |
commit | 778c93587a9551debcc62ee1be9ef49f78295b49 (patch) | |
tree | 45bc274895a455c1442ceca43f5988756a66a66e /NorthstarDLL/squirrel.cpp | |
parent | 2d59006262d6e45f41ee325af78433475884dca4 (diff) | |
download | NorthstarLauncher-778c93587a9551debcc62ee1be9ef49f78295b49.tar.gz NorthstarLauncher-778c93587a9551debcc62ee1be9ef49f78295b49.zip |
Fix UI VM Destruction (#349)
The functions in question take a CSquirrelVM* instead of an HSquirrelVM*, which
causes IsUIVM() always returns false.
Diffstat (limited to 'NorthstarDLL/squirrel.cpp')
-rw-r--r-- | NorthstarDLL/squirrel.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/NorthstarDLL/squirrel.cpp b/NorthstarDLL/squirrel.cpp index 02ca651e..a5733784 100644 --- a/NorthstarDLL/squirrel.cpp +++ b/NorthstarDLL/squirrel.cpp @@ -317,18 +317,20 @@ template <ScriptContext context> CSquirrelVM* __fastcall CreateNewVMHook(void* a return sqvm; } -template <ScriptContext context> void (*__fastcall DestroyVM)(void* a1, HSquirrelVM* sqvm); -template <ScriptContext context> void __fastcall DestroyVMHook(void* a1, HSquirrelVM* sqvm) +template <ScriptContext context> void (*__fastcall DestroyVM)(void* a1, CSquirrelVM* sqvm); +template <ScriptContext context> void __fastcall DestroyVMHook(void* a1, CSquirrelVM* sqvm) { ScriptContext realContext = context; // ui and client use the same function so we use this for prints - if (IsUIVM(context, sqvm)) + if (IsUIVM(context, sqvm->sqvm)) { realContext = ScriptContext::UI; g_pSquirrel<ScriptContext::UI>->VMDestroyed(); + // Don't call DestroyVM here because it crashes. + // Respawn Code :tm: } else { - g_pSquirrel<context>->m_pSQVM = nullptr; // Fixes a race-like bug + g_pSquirrel<context>->VMDestroyed(); DestroyVM<context>(a1, sqvm); } |