- SW: clear some pointers before killing actors in TerminateLevel.

KillActor is an in-game function which may produce undefined behavior if being run on a partially deinitialized level.
All actor pointers it may operate upon should be cleared before taking down the actors.cpp
This commit is contained in:
Christoph Oelckers 2022-01-02 15:06:57 +01:00
parent 3b833029b0
commit 2ac83b733c
2 changed files with 7 additions and 1 deletions

View file

@ -6,7 +6,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,

View file

@ -533,6 +533,12 @@ void TerminateLevel(void)
// Kill User memory and delete sprites
SWSpriteIterator it;
while (auto actor = it.Next())
{
actor->user.targetActor = nullptr;
actor->user.flameActor = nullptr;
}
it.Reset();
while (auto actor = it.Next())
{
KillActor(actor);
}