- SW: fixed some savegame issues:

* the saveable tables were initialized too late when reading in the actors.
* the abort messages for the saveables did not show. We need to use I_FatalError here, plus some actor list modifications to make this work.
This commit is contained in:
Christoph Oelckers 2021-12-13 22:37:49 +01:00
parent ae622274bd
commit 6db1ba47c2
4 changed files with 11 additions and 2 deletions

View file

@ -664,6 +664,7 @@ void FSerializer::ReadObjects(bool hubtravel)
if (!founderrors) if (!founderrors)
{ {
// Reset to start; // Reset to start;
unsigned size = r->mObjects.Size();
r->mObjects.Last().mIndex = 0; r->mObjects.Last().mIndex = 0;
for (unsigned i = 0; i < r->mDObjects.Size(); i++) for (unsigned i = 0; i < r->mDObjects.Size(); i++)
@ -680,6 +681,7 @@ void FSerializer::ReadObjects(bool hubtravel)
} }
catch (CRecoverableError &err) catch (CRecoverableError &err)
{ {
r->mObjects.Clamp(size); // close all inner objects.
// In case something in here throws an error, let's continue and deal with it later. // In case something in here throws an error, let's continue and deal with it later.
Printf(TEXTCOLOR_RED "'%s'\n while restoring %s\n", err.GetMessage(), obj ? obj->GetClass()->TypeName.GetChars() : "invalid object"); Printf(TEXTCOLOR_RED "'%s'\n while restoring %s\n", err.GetMessage(), obj ? obj->GetClass()->TypeName.GetChars() : "invalid object");
mErrors++; mErrors++;

View file

@ -142,6 +142,7 @@ static void RemoveActorStat(DCoreActor* actor)
auto prevp = prev ? &prev->nextStat : &firstEntry; auto prevp = prev ? &prev->nextStat : &firstEntry;
auto nextp = next ? &next->prevStat : &lastEntry; auto nextp = next ? &next->prevStat : &lastEntry;
if (*prevp == nullptr && *nextp == nullptr) return; // can happen during an aborted savegame load.
assert(*prevp == actor); assert(*prevp == actor);
assert(*nextp == actor); assert(*nextp == actor);
@ -285,6 +286,7 @@ static void RemoveActorSect(DCoreActor* actor)
auto prevp = prev ? &prev->nextSect : &firstEntry; auto prevp = prev ? &prev->nextSect : &firstEntry;
auto nextp = next ? &next->prevSect : &lastEntry; auto nextp = next ? &next->prevSect : &lastEntry;
if (*prevp == nullptr && *nextp == nullptr) return; // can happen during an aborted savegame load.
assert(*prevp == actor); assert(*prevp == actor);
assert(*nextp == actor); assert(*nextp == actor);

View file

@ -1113,6 +1113,7 @@ void DSWActor::Serialize(FSerializer& arc)
{ {
Super::Serialize(arc); Super::Serialize(arc);
arc("hasuser", hasUser) arc("hasuser", hasUser)
("tempwall", tempwall)
("owner", ownerActor); ("owner", ownerActor);
if (hasUser) arc("user", user); // only write if defined. if (hasUser) arc("user", user); // only write if defined.
} }

View file

@ -140,6 +140,7 @@ int Saveable_RestoreCodeSym(savedcodesym *sym, void **ptr)
return 0; return 0;
} }
Saveable_Init();
for (auto module : saveablemodules) for (auto module : saveablemodules)
{ {
for (unsigned i = 0; i < module->numcode; i++) for (unsigned i = 0; i < module->numcode; i++)
@ -151,7 +152,8 @@ int Saveable_RestoreCodeSym(savedcodesym *sym, void **ptr)
} }
} }
} }
I_Error("Unknown code reference '%s' in savegame\n", sym->name.GetChars()); // No way to recover. I_FatalError is the only chance to get an error message shown. :(
I_FatalError("Unknown code reference '%s' in savegame\n", sym->name.GetChars());
return -1; return -1;
} }
@ -163,6 +165,7 @@ int Saveable_RestoreDataSym(saveddatasym *sym, void **ptr)
return 0; return 0;
} }
Saveable_Init();
for (auto module : saveablemodules) for (auto module : saveablemodules)
{ {
for (unsigned i = 0; i < module->numdata; i++) for (unsigned i = 0; i < module->numdata; i++)
@ -174,7 +177,8 @@ int Saveable_RestoreDataSym(saveddatasym *sym, void **ptr)
} }
} }
} }
I_Error("Unknown data reference '%s' in savegame\n", sym->name.GetChars()); // No way to recover. I_FatalError is the only chance to get an error message shown. :(
I_FatalError("Unknown data reference '%s' in savegame\n", sym->name.GetChars());
return -1; return -1;
} }