- Duke/RR: do not spawn sprites with invalid picnums.

RRRA E1L7 has a respawner that will spawn an invalid sprite crashing the game.
This commit is contained in:
Christoph Oelckers 2022-08-26 20:05:28 +02:00
parent 07656251d9
commit b1cbecf268

View file

@ -53,6 +53,8 @@ DDukeActor* EGS(sectortype* whatsectp, int s_x, int s_y, int s_z, int s_pn, int8
{
// sector pointer must be strictly validated here or the engine will crash.
if (whatsectp == nullptr || !validSectorIndex(sectnum(whatsectp))) return nullptr;
// spawning out of range sprites will also crash.
if (s_pn < 0 || s_pn >= MAXTILES) return nullptr;
auto act = static_cast<DDukeActor*>(::InsertActor(RUNTIME_CLASS(DDukeActor), whatsectp, s_ss));
if (act == nullptr) return nullptr;