- fixed issues with uninitialized RNGs and bad assumptions about corpse pointers always being fully initialized when being destroyed.

Both of these may be true when occuring during normal gameplay, but not during an exception unwind in the serializer, which caused crashes if ACS errored out due to mismatched scripts.
This commit is contained in:
Christoph Oelckers 2017-01-27 12:02:47 +01:00
parent 15b95cc023
commit 08c252274a
2 changed files with 16 additions and 10 deletions

View file

@ -142,21 +142,25 @@ void DCorpsePointer::OnDestroy ()
TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER); TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER);
DCorpsePointer *first = iterator.Next (); DCorpsePointer *first = iterator.Next ();
int prevCount = first->Count; // During a serialization unwind the thinker list won't be available.
if (first != nullptr)
if (first == this)
{ {
first = iterator.Next (); int prevCount = first->Count;
}
if (first != NULL) if (first == this)
{ {
first->Count = prevCount - 1; first = iterator.Next();
} }
if (first != NULL)
{
first->Count = prevCount - 1;
}
}
if (Corpse != NULL) if (Corpse != NULL)
{ {
Corpse->Destroy (); Corpse->Destroy();
} }
Super::OnDestroy(); Super::OnDestroy();
} }

View file

@ -156,6 +156,7 @@ FRandom::FRandom ()
#endif #endif
Next = RNGList; Next = RNGList;
RNGList = this; RNGList = this;
Init(0);
} }
//========================================================================== //==========================================================================
@ -199,6 +200,7 @@ FRandom::FRandom (const char *name)
Next = probe; Next = probe;
*prev = this; *prev = this;
Init(0);
} }
//========================================================================== //==========================================================================