From 497d2d26dd77747a4d1a10714b99372f9cda370c Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 3 Oct 2023 22:33:54 +1100 Subject: [PATCH] - Duke: Clean up player/actor accesses in `playerisdead()`. --- source/games/duke/src/funct.h | 2 +- source/games/duke/src/player.cpp | 16 ++++++++-------- source/games/duke/src/player_d.cpp | 2 +- source/games/duke/src/player_r.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 7e93186b8..7137acbd5 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -100,7 +100,7 @@ int wakeup(DDukeActor* sn, DDukePlayer* const p); int timedexit(int snum); void dokneeattack(DDukePlayer* const p); int endoflevel(int snum); -void playerisdead(int snum, int psectlotag, double fz, double cz); +void playerisdead(DDukePlayer* const p, int psectlotag, double fz, double cz); void footprints(DDukePlayer* const p); int makepainsounds(DDukePlayer* const p, int type); void playerCrouch(int snum); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 259e7c7db..da85aa9f7 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -526,13 +526,12 @@ void footprints(DDukePlayer* const p) // //--------------------------------------------------------------------------- -void playerisdead(int snum, int psectlotag, double floorz, double ceilingz) +void playerisdead(DDukePlayer* const p, int psectlotag, double floorz, double ceilingz) { - auto p = getPlayer(snum); auto actor = p->GetActor(); // lock input when dead. - setForcedSyncInput(snum); + setForcedSyncInput(p->pnum); if (p->dead_flag == 0) { @@ -560,13 +559,14 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz) if (ud.multimode > 1 && (actor->spr.pal != 1 || (actor->spr.cstat & CSTAT_SPRITE_INVISIBLE))) { - if (p->frag_ps != snum) + if (p->frag_ps != p->pnum) { - getPlayer(p->frag_ps)->frag++; - getPlayer(p->frag_ps)->frags[snum]++; + const auto fragp = getPlayer(p->frag_ps); + fragp->frag++; + fragp->frags[p->pnum]++; auto pname = PlayerName(p->frag_ps); - if (snum == screenpeek) + if (p->pnum == screenpeek) { Printf(PRINT_NOTIFY, "Killed by %s", pname); } @@ -578,7 +578,7 @@ void playerisdead(int snum, int psectlotag, double floorz, double ceilingz) } else p->fraggedself++; - p->frag_ps = snum; + p->frag_ps = p->pnum; } } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 3b073f2fb..1a51c6fec 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1637,7 +1637,7 @@ void processinput_d(int snum) if (pact->spr.extra <= 0 && !ud.god) { - playerisdead(snum, psectlotag, floorz, ceilingz); + playerisdead(p, psectlotag, floorz, ceilingz); return; } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 2b045fc9f..aef767379 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2449,7 +2449,7 @@ void processinput_r(int snum) if (pact->spr.extra <= 0 && !ud.god) { - playerisdead(snum, psectlotag, floorz, ceilingz); + playerisdead(p, psectlotag, floorz, ceilingz); return; }