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

View File

@ -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;
}