From 2197128dc4338d37cb18e0b91de0aea125685519 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 3 Oct 2023 22:36:13 +1100 Subject: [PATCH] - Duke: Clean up player/actor accesses in `timedexit()`. --- source/games/duke/src/funct.h | 2 +- source/games/duke/src/player.cpp | 3 +-- source/games/duke/src/player_d.cpp | 2 +- source/games/duke/src/player_r.cpp | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index d04f90098..fdc7d31b9 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -97,7 +97,7 @@ int madenoise(DDukePlayer* const p); int wakeup(DDukeActor* sn, DDukePlayer* const p); -int timedexit(int snum); +int timedexit(DDukePlayer* const p); void dokneeattack(DDukePlayer* const p); int endoflevel(DDukePlayer* const p); void playerisdead(DDukePlayer* const p, int psectlotag, double fz, double cz); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 4d1b380f7..bfe44f139 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -647,9 +647,8 @@ int endoflevel(DDukePlayer* const p) // //--------------------------------------------------------------------------- -int timedexit(int snum) +int timedexit(DDukePlayer* const p) { - auto p = getPlayer(snum); p->timebeforeexit--; if (p->timebeforeexit == 26 * 5) { diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 331d57fb7..ed98e8595 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1631,7 +1631,7 @@ void processinput_d(int snum) if (p->timebeforeexit > 1 && p->last_extra > 0) { - if (timedexit(snum)) + if (timedexit(p)) return; } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index bcc8e79f5..dfdd9dfce 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2443,7 +2443,7 @@ void processinput_r(int snum) if (p->timebeforeexit > 1 && p->last_extra > 0) { - if (timedexit(snum)) + if (timedexit(p)) return; }