Reconcile script fixes from reference edition

This commit is contained in:
Alexander Batalov 2022-06-08 20:35:51 +03:00
parent 5a0d5d2538
commit 9cad93c764
1 changed files with 6 additions and 8 deletions

View File

@ -1778,18 +1778,16 @@ int scriptSaveAll(File* stream)
for (int index = 0; index < scriptExtent->length; index++) { for (int index = 0; index < scriptExtent->length; index++) {
Script* script = &(scriptExtent->scripts[index]); Script* script = &(scriptExtent->scripts[index]);
lastScriptExtent = scriptList->tail;
if ((script->flags & SCRIPT_FLAG_0x08) != 0) { if ((script->flags & SCRIPT_FLAG_0x08) != 0) {
scriptCount--; scriptCount--;
lastScriptExtent = scriptList->tail;
int backwardsIndex = lastScriptExtent->length - 1; int backwardsIndex = lastScriptExtent->length - 1;
while (lastScriptExtent != scriptExtent || backwardsIndex > index) { if (lastScriptExtent == scriptExtent && backwardsIndex <= index) {
if (lastScriptExtent == scriptExtent) { break;
if (backwardsIndex >= index) { }
break;
}
}
while (lastScriptExtent != scriptExtent || backwardsIndex > index) {
Script* backwardsScript = &(lastScriptExtent->scripts[backwardsIndex]); Script* backwardsScript = &(lastScriptExtent->scripts[backwardsIndex]);
if ((backwardsScript->flags & SCRIPT_FLAG_0x08) == 0) { if ((backwardsScript->flags & SCRIPT_FLAG_0x08) == 0) {
break; break;
@ -2685,7 +2683,7 @@ int scriptGetLocalVar(int sid, int variable, int* value)
} }
Script* script; Script* script;
if (scriptGetScript(sid, &script) == 1) { if (scriptGetScript(sid, &script) == -1) {
*value = -1; *value = -1;
return -1; return -1;
} }