Only archive used variables on the local VM stack

This commit is contained in:
smallmodel 2023-11-28 19:14:09 +01:00
parent e59200a7de
commit 2ac2800ecb
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -235,24 +235,27 @@ void ScriptVMStack::Archive(Archiver& arc)
{
unsigned int size;
unsigned int offset;
unsigned int numVars;
unsigned int i;
if (arc.Saving()) {
size = stackBottom - localStack;
offset = pTop - localStack;
numVars = offset + 1;
arc.ArchiveUnsigned(&size);
arc.ArchiveUnsigned(&offset);
} else {
arc.ArchiveUnsigned(&size);
arc.ArchiveUnsigned(&offset);
numVars = offset + 1;
Allocate(size);
pTop = localStack + offset;
}
if (localStack) {
for (i = 0; i < size; i++) {
for (i = 0; i < numVars; i++) {
localStack[i].ArchiveInternal(arc);
}
}