From 162ab3c4ec9bc906a626ad2b10bcb5d3ffc2aa89 Mon Sep 17 00:00:00 2001 From: Adam Kaminski Date: Fri, 24 Jan 2025 10:33:56 -0500 Subject: [PATCH] Fixed ACS scripts executing a function from another library that cause a division/modulus of zero from aborting the game. --- src/playsim/p_acs.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index 89aee643d2d..652dd61412f 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -10337,6 +10337,11 @@ int DLevelScript::RunScript() } } + // There are several or more p-codes that can trigger a division or modulus of zero. + // Reset the active behavior back to the original if this happens. + if (state == SCRIPT_DivideBy0 || state == SCRIPT_ModulusBy0) + activeBehavior = savedActiveBehavior; + if (runaway != 0 && InModuleScriptNumber >= 0) { auto scriptptr = activeBehavior->GetScriptPtr(InModuleScriptNumber);