From 13e19bad36dfd2595f3ff75640126aa8deb7bc8a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Nov 2022 08:12:18 +0100 Subject: [PATCH] - fixed handling of bad class assignment to map picnums. --- source/core/actorlist.cpp | 1 + source/core/gamecontrol.h | 6 +++++- source/games/duke/src/namelist_r.h | 1 + source/games/duke/src/premap.cpp | 8 ++------ source/games/duke/src/premap_r.cpp | 2 +- source/games/duke/src/sectors_r.cpp | 2 +- source/games/duke/src/spawn.cpp | 2 +- wadsrc/static/zscript/games/duke/actors/controllers.zs | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/source/core/actorlist.cpp b/source/core/actorlist.cpp index 8a2cb5dbb..046d6c2ad 100644 --- a/source/core/actorlist.cpp +++ b/source/core/actorlist.cpp @@ -345,6 +345,7 @@ void ChangeActorSect(DCoreActor* actor, sectortype* sect, bool tail) DCoreActor* InsertActor(PClass* type, sectortype* sector, int stat, bool tail) { + if (type == nullptr) return nullptr; assert(type->IsDescendantOf(RUNTIME_CLASS(DCoreActor))); if (!type->IsDescendantOf(RUNTIME_CLASS(DCoreActor))) { diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index a60fd4cf4..fc05001ac 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -272,9 +272,13 @@ struct SpawnRec PClass* cls; int param; - PClass* Class() + PClass* Class(int pn) { if (!cls && clsname != NAME_None) cls = PClass::FindClass(clsname); + if (cls == nullptr) + { + Printf(TEXTCOLOR_RED "Bad class name %s for ID# %d\n", clsname.GetChars(), pn); + } clsname = NAME_None; return cls; } diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index 3960c7845..5c7aa5830 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -1014,6 +1014,7 @@ x(FECES, 4802) x(DRONE, 4916) x(RECON, 4989) y(RRTILE5014, 5014) +y(RRTILE5015, 5015) y(RRTILE5016, 5016) y(RRTILE5017, 5017) y(RRTILE5018, 5018) diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 3fd06606b..c05ef3512 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -937,15 +937,11 @@ static TArray spawnactors(SpawnSpriteDef& sprites) spawns.Pop(); continue; } - if (i == 210) - { - int a = 0; - } - auto sprt = &sprites.sprites[i]; auto info = spawnMap.CheckKey(sprt->picnum); - auto actor = static_cast(InsertActor(info? info->Class() : RUNTIME_CLASS(DDukeActor), sprt->sectp, sprt->statnum)); + auto cls = info ? info->Class(sprt->picnum) : nullptr;; + auto actor = static_cast(InsertActor(cls? cls : RUNTIME_CLASS(DDukeActor), sprt->sectp, sprt->statnum)); if (actor) { spawns[j++] = actor; diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 115477417..406c922ff 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -552,7 +552,7 @@ void prelevel_r(int g, TArray& actors) geosector[geocnt] = actor->sector(); for (auto actor2 : actors) { - if (actor->spr.lotag == actor2->spr.lotag && actor2 != actor && actor2->spr.picnum == RRTILE19) + if (actor && actor->spr.lotag == actor2->spr.lotag && actor2 != actor && actor2->spr.picnum == RRTILE19) { if (actor2->spr.hitag == 1) { diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 9b72fdcd7..f75dff0b9 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1064,7 +1064,7 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw } case RRTILE7555: if (!isRRRA()) break; - wal->picnum = SBMOVE; + wal->picnum = RRTILE5015; S_PlayActorSound(GLASS_HEAVYBREAK, spr); return; case RRTILE7441: diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 30c26dc61..e31f09a54 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -63,7 +63,7 @@ DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, PClassActor* auto info = spawnMap.CheckKey(s_pn); if (info) { - clstype = static_cast(info->Class()); + clstype = static_cast(info->Class(s_pn)); basepicnum = info->param; } } diff --git a/wadsrc/static/zscript/games/duke/actors/controllers.zs b/wadsrc/static/zscript/games/duke/actors/controllers.zs index 578db9606..eb236d5e9 100644 --- a/wadsrc/static/zscript/games/duke/actors/controllers.zs +++ b/wadsrc/static/zscript/games/duke/actors/controllers.zs @@ -127,7 +127,7 @@ class DukeGPSpeed : DukeActor } // the following ones are only used in RR. -class TorchCtrl : DukeActor +class DukeTorchCtrl : DukeActor { override void StaticSetup() {