diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 3b7e8d921..426218884 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -50,7 +50,6 @@ struct DukeGameInfo extern DukeGameInfo gs; inline TObjPtr camsprite; -inline TObjPtr BellSprite; inline TObjPtr spriteq[1024]; inline TObjPtr currentCommentarySprite; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 1540cb5e5..0bd11fa7d 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -268,7 +268,7 @@ static void shootknee(DDukeActor* actor, int p, DVector3 pos, DAngle ang) if (p >= 0 && ps[p].steroids_amount > 0 && ps[p].steroids_amount < 400) knee->spr.extra += (gs.max_player_health >> 2); } - if (hit.actor() && hit.actor()->spr.picnum != DTILE_ACCESSSWITCH && hit.actor()->spr.picnum != DTILE_ACCESSSWITCH2) + if (hit.actor() && ! isaccessswitch(hit.actor()->spr.spritetexture())) { fi.checkhitsprite(hit.actor(), knee); if (p >= 0) fi.checkhitswitch(p, nullptr, hit.actor()); @@ -281,7 +281,7 @@ static void shootknee(DDukeActor* actor, int p, DVector3 pos, DAngle ang) if (hit.hitpos.Z >= hit.hitWall->nextSector()->floorz) hit.hitWall =hit.hitWall->nextWall(); - if (hit.hitWall->wallpicnum != DTILE_ACCESSSWITCH && hit.hitWall->wallpicnum != DTILE_ACCESSSWITCH2) + if (!isaccessswitch(hit.hitWall->walltexture())) { checkhitwall(knee, hit.hitWall, hit.hitpos); if (p >= 0) fi.checkhitswitch(p, hit.hitWall, nullptr); @@ -441,15 +441,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int } else spawn(spark, DTILE_SMALLSMOKE); - if (p >= 0 && ( - hit.actor()->spr.picnum == DTILE_DIPSWITCH || - hit.actor()->spr.picnum == DTILE_DIPSWITCHON || - hit.actor()->spr.picnum == DTILE_DIPSWITCH2 || - hit.actor()->spr.picnum == DTILE_DIPSWITCH2ON || - hit.actor()->spr.picnum == DTILE_DIPSWITCH3 || - hit.actor()->spr.picnum == DTILE_DIPSWITCH3ON || - hit.actor()->spr.picnum == DTILE_HANDSWITCH || - hit.actor()->spr.picnum == DTILE_HANDSWITCHON)) + if (p >= 0 && isshootableswitch(hit.actor()->spr.spritetexture())) { fi.checkhitswitch(p, nullptr, hit.actor()); return; @@ -463,15 +455,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int goto SKIPBULLETHOLE; if (isablockdoor(hit.hitWall->walltexture()) == 1) goto SKIPBULLETHOLE; - if (p >= 0 && ( - hit.hitWall->wallpicnum == DTILE_DIPSWITCH || - hit.hitWall->wallpicnum == DTILE_DIPSWITCHON || - hit.hitWall->wallpicnum == DTILE_DIPSWITCH2 || - hit.hitWall->wallpicnum == DTILE_DIPSWITCH2ON || - hit.hitWall->wallpicnum == DTILE_DIPSWITCH3 || - hit.hitWall->wallpicnum == DTILE_DIPSWITCH3ON || - hit.hitWall->wallpicnum == DTILE_HANDSWITCH || - hit.hitWall->wallpicnum == DTILE_HANDSWITCHON)) + if (p >= 0 && isshootableswitch(hit.hitWall->walltexture())) { fi.checkhitswitch(p, hit.hitWall, nullptr); return; @@ -956,7 +940,7 @@ static void shootgrowspark(DDukeActor* actor, int p, DVector3 pos, DAngle ang) else if (hit.actor() != nullptr) fi.checkhitsprite(hit.actor(), spark); else if (hit.hitWall != nullptr) { - if (hit.hitWall->wallpicnum != DTILE_ACCESSSWITCH && hit.hitWall->wallpicnum != DTILE_ACCESSSWITCH2) + if (!isaccessswitch(hit.hitWall->walltexture())) { checkhitwall(spark, hit.hitWall, hit.hitpos); } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index b5cbd4ec2..b1df7a68a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -160,7 +160,7 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a if (p >= 0 && ps[p].steroids_amount > 0 && ps[p].steroids_amount < 400) wpn->spr.extra += (gs.max_player_health >> 2); - if (hit.actor() && hit.actor()->spr.picnum != RTILE_ACCESSSWITCH && hit.actor()->spr.picnum != RTILE_ACCESSSWITCH2) + if (hit.actor() && !isaccessswitch(hit.actor()->spr.spritetexture())) { fi.checkhitsprite(hit.actor(), wpn); if (p >= 0) fi.checkhitswitch(p, nullptr, hit.actor()); @@ -172,7 +172,7 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a if (hit.hitpos.Z >= hit.hitWall->nextSector()->floorz) hit.hitWall = hit.hitWall->nextWall(); - if (hit.hitWall->wallpicnum != RTILE_ACCESSSWITCH && hit.hitWall->wallpicnum != RTILE_ACCESSSWITCH2) + if (!isaccessswitch(hit.hitWall->walltexture())) { checkhitwall(wpn, hit.hitWall, hit.hitpos); if (p >= 0) fi.checkhitswitch(p, hit.hitWall, nullptr); @@ -334,16 +334,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int } else spawn(spark, RTILE_SMALLSMOKE); - if (p >= 0 && ( - hit.actor()->spr.picnum == RTILE_DIPSWITCH || - hit.actor()->spr.picnum == RTILE_DIPSWITCHON || - hit.actor()->spr.picnum == RTILE_DIPSWITCH2 || - hit.actor()->spr.picnum == RTILE_DIPSWITCH2ON || - hit.actor()->spr.picnum == RTILE_DIPSWITCH3 || - hit.actor()->spr.picnum == RTILE_DIPSWITCH3ON || - (isRRRA() && hit.actor()->spr.picnum == RTILE_BELLSWITCH) || - hit.actor()->spr.picnum == RTILE_HANDSWITCH || - hit.actor()->spr.picnum == RTILE_HANDSWITCHON)) + if (p >= 0 && isshootableswitch(hit.actor()->spr.spritetexture())) { fi.checkhitswitch(p, nullptr, hit.actor()); return; @@ -357,16 +348,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int goto SKIPBULLETHOLE; if (isablockdoor(hit.hitWall->walltexture()) == 1) goto SKIPBULLETHOLE; - if (p >= 0 && ( - hit.hitWall->wallpicnum == RTILE_DIPSWITCH || - hit.hitWall->wallpicnum == RTILE_DIPSWITCHON || - hit.hitWall->wallpicnum == RTILE_DIPSWITCH2 || - hit.hitWall->wallpicnum == RTILE_DIPSWITCH2ON || - hit.hitWall->wallpicnum == RTILE_DIPSWITCH3 || - hit.hitWall->wallpicnum == RTILE_DIPSWITCH3ON || - (isRRRA() && hit.hitWall->wallpicnum == RTILE_BELLSWITCH) || - hit.hitWall->wallpicnum == RTILE_HANDSWITCH || - hit.hitWall->wallpicnum == RTILE_HANDSWITCHON)) + if (p >= 0 && isshootableswitch(hit.hitWall->walltexture())) { fi.checkhitswitch(p, hit.hitWall, nullptr); return; diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index 40ad6f1e4..af1dcc761 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -291,21 +291,9 @@ void prelevel_d(int g, TArray& actors) it.Reset(STAT_DEFAULT); while (auto actor = it.Next()) { - switch (actor->spr.picnum) + auto ext = GetExtInfo(actor->spr.spritetexture()); + if (ext.switchphase == 1 && switches[ext.switchindex].type == SwitchDef::Regular) { - case DTILE_DIPSWITCHON: - case DTILE_DIPSWITCH2ON: - case DTILE_PULLSWITCHON: - case DTILE_HANDSWITCHON: - case DTILE_SLOTDOORON: - case DTILE_LIGHTSWITCHON: - case DTILE_SPACELIGHTSWITCHON: - case DTILE_SPACEDOORSWITCHON: - case DTILE_FRANKENSTINESWITCHON: - case DTILE_LIGHTSWITCH2ON: - case DTILE_POWERSWITCH1ON: - case DTILE_LOCKSWITCH1ON: - case DTILE_POWERSWITCH2ON: j = lotags.Find(actor->spr.lotag); if (j == lotags.Size()) { @@ -317,7 +305,6 @@ void prelevel_d(int g, TArray& actors) ac->temp_data[0] = 1; } } - break; } } diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index d26454d8f..4261931b2 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -590,25 +590,9 @@ void prelevel_r(int g, TArray& actors) it.Reset(STAT_DEFAULT); while (auto ac = it.Next()) { - switch (ac->spr.picnum) + auto ext = GetExtInfo(ac->spr.spritetexture()); + if (ext.switchphase == 1 && switches[ext.switchindex].type == SwitchDef::Regular) { - case RTILE_IRONWHEELSWITCHON: - if (!isRRRA()) break; - [[fallthrough]]; - case RTILE_DIPSWITCHON: - case RTILE_DIPSWITCH2ON: - case RTILE_PULLSWITCHON: - case RTILE_HANDSWITCHON: - case RTILE_SLOTDOORON: - case RTILE_LIGHTSWITCHON: - case RTILE_SPACELIGHTSWITCHON: - case RTILE_SPACEDOORSWITCHON: - case RTILE_FRANKENSTINESWITCHON: - case RTILE_LIGHTSWITCH2ON: - case RTILE_POWERSWITCH1ON: - case RTILE_LOCKSWITCH1ON: - case RTILE_POWERSWITCH2ON: - j = lotags.Find(ac->spr.lotag); if (j == lotags.Size()) { @@ -620,7 +604,6 @@ void prelevel_r(int g, TArray& actors) actj->temp_data[0] = 1; } } - break; } }