From 9cad93c7644de83ba1470c97457ba902e2b32a69 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Wed, 8 Jun 2022 20:35:51 +0300 Subject: [PATCH] Reconcile script fixes from reference edition --- src/scripts.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/scripts.cc b/src/scripts.cc index c4d0169..3131a37 100644 --- a/src/scripts.cc +++ b/src/scripts.cc @@ -1778,18 +1778,16 @@ int scriptSaveAll(File* stream) for (int index = 0; index < scriptExtent->length; index++) { Script* script = &(scriptExtent->scripts[index]); + lastScriptExtent = scriptList->tail; if ((script->flags & SCRIPT_FLAG_0x08) != 0) { scriptCount--; - lastScriptExtent = scriptList->tail; int backwardsIndex = lastScriptExtent->length - 1; - while (lastScriptExtent != scriptExtent || backwardsIndex > index) { - if (lastScriptExtent == scriptExtent) { - if (backwardsIndex >= index) { - break; - } - } + if (lastScriptExtent == scriptExtent && backwardsIndex <= index) { + break; + } + while (lastScriptExtent != scriptExtent || backwardsIndex > index) { Script* backwardsScript = &(lastScriptExtent->scripts[backwardsIndex]); if ((backwardsScript->flags & SCRIPT_FLAG_0x08) == 0) { break; @@ -2685,7 +2683,7 @@ int scriptGetLocalVar(int sid, int variable, int* value) } Script* script; - if (scriptGetScript(sid, &script) == 1) { + if (scriptGetScript(sid, &script) == -1) { *value = -1; return -1; }