Skip to content

Commit

Permalink
Fix ResetQuestDeleteScriptEventListHook and rename to ResetQuestReall…
Browse files Browse the repository at this point in the history
…ocateEventListHook - Will now update the current ScriptRunner's event list instead of delaying the free of the old event list

Update xNVSE version
  • Loading branch information
bdemmy committed Dec 22, 2024
1 parent c494092 commit 5b8d80e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 16 additions & 10 deletions nvse/nvse/Hooks_Other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,22 @@ namespace OtherHooks
}
}

void __fastcall ResetQuestDeleteScriptEventListHook(ScriptEventList* eventList)
{
if (g_currentScriptContext.Empty() || g_currentScriptContext.Top().script != eventList->m_script)
{
DeleteEventList(eventList);
return;
// Called via ResetQuest when it is reallocating the new script event list
ScriptEventList* __fastcall ResetQuestReallocateEventListHook(const Script* script) {
const auto res = ThisStdCall<ScriptEventList*>(0x5ABF60, script);

// Not sure that this is even possible, better safe than sorry
if (!g_currentScriptContext.Empty()) {
const auto& currentContext = g_currentScriptContext.Top();

// If ResetQuest is called from within the quest's script, we need to update the
// ScriptRunner's event list otherwise it will keep using the freed one
if (script == currentContext.script) {
currentContext.scriptRunner->eventList = res;
}
}
// delay deletion of event list until after the script has finished executing
// event list is still being passed around while the script is running
g_onExitScripts.push_back([eventList]() { DeleteEventList(eventList); });

return res;
}

void __fastcall ScriptDestructorHook(Script* script)
Expand Down Expand Up @@ -468,7 +474,7 @@ namespace OtherHooks

WriteRelCall(0x5AA206, ScriptDestructorHook);

WriteRelCall(0x60D858, ResetQuestDeleteScriptEventListHook);
WriteRelCall(0x60D876, ResetQuestReallocateEventListHook);

*(UInt32*)0x0126FDF4 = 1; // locale fix

Expand Down
4 changes: 2 additions & 2 deletions nvse/nvse/nvse_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#define ALPHA_MODE 0
#define NVSE_VERSION_INTEGER 6
#define NVSE_VERSION_INTEGER_MINOR 3
#define NVSE_VERSION_INTEGER_BETA 8
#define NVSE_VERSION_VERSTRING "0, 6, 3, 8"
#define NVSE_VERSION_INTEGER_BETA 9
#define NVSE_VERSION_VERSTRING "0, 6, 3, 9"
#define NVSE_VERSION_PADDEDSTRING "0006"

// build numbers do not appear to follow the same format as with oblivion
Expand Down

0 comments on commit 5b8d80e

Please sign in to comment.