From 778c93587a9551debcc62ee1be9ef49f78295b49 Mon Sep 17 00:00:00 2001 From: Emma Miler Date: Fri, 9 Dec 2022 01:03:57 +0100 Subject: Fix UI VM Destruction (#349) The functions in question take a CSquirrelVM* instead of an HSquirrelVM*, which causes IsUIVM() always returns false. --- NorthstarDLL/squirrel.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'NorthstarDLL') 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 CSquirrelVM* __fastcall CreateNewVMHook(void* a return sqvm; } -template void (*__fastcall DestroyVM)(void* a1, HSquirrelVM* sqvm); -template void __fastcall DestroyVMHook(void* a1, HSquirrelVM* sqvm) +template void (*__fastcall DestroyVM)(void* a1, CSquirrelVM* sqvm); +template 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->VMDestroyed(); + // Don't call DestroyVM here because it crashes. + // Respawn Code :tm: } else { - g_pSquirrel->m_pSQVM = nullptr; // Fixes a race-like bug + g_pSquirrel->VMDestroyed(); DestroyVM(a1, sqvm); } -- cgit v1.2.3