- 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);
DCorpsePointer *first = iterator.Next ();
int prevCount = first->Count;
if (first == this)
// During a serialization unwind the thinker list won't be available.
if (first != nullptr)
{
first = iterator.Next ();
}
int prevCount = first->Count;
if (first != NULL)
{
first->Count = prevCount - 1;
}
if (first == this)
{
first = iterator.Next();
}
if (first != NULL)
{
first->Count = prevCount - 1;
}
}
if (Corpse != NULL)
{
Corpse->Destroy ();
Corpse->Destroy();
}
Super::OnDestroy();
}

View File

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