- Duke: Clean up player/actor accesses in noise.cpp.

This commit is contained in:
Mitchell Richters 2023-10-03 22:19:20 +11:00
parent 20ba784ab7
commit 50acc673c9
5 changed files with 21 additions and 25 deletions

View file

@ -4285,8 +4285,7 @@ void movefta(void)
DukeStatIterator it(STAT_ZOMBIEACTOR); DukeStatIterator it(STAT_ZOMBIEACTOR);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
const auto pnum = findplayer(act, &xx); const auto p = getPlayer(findplayer(act, &xx));
const auto p = getPlayer(pnum);
const auto pact = p->GetActor(); const auto pact = p->GetActor();
canseeme = 0; canseeme = 0;
ssect = psect = act->sector(); ssect = psect = act->sector();
@ -4360,7 +4359,7 @@ void movefta(void)
// wakeup is an RR feature, this flag will allow it to use in Duke, too. // wakeup is an RR feature, this flag will allow it to use in Duke, too.
if ((act->flags1 & SFLAG_MOVEFTA_WAKEUPCHECK)) if ((act->flags1 & SFLAG_MOVEFTA_WAKEUPCHECK))
{ {
if (wakeup(act, pnum)) if (wakeup(act, p))
{ {
act->timetosleep = 0; act->timetosleep = 0;
check_fta_sounds(act); check_fta_sounds(act);

View file

@ -93,7 +93,8 @@ void addammo(int weapon, DDukePlayer* p, int amount);
int ssp(DDukeActor* i, unsigned int cliptype); //The set sprite function int ssp(DDukeActor* i, unsigned int cliptype); //The set sprite function
void insertspriteq(DDukeActor *i); void insertspriteq(DDukeActor *i);
int wakeup(DDukeActor* sn, int pn); int madenoise(DDukePlayer* const p);
int wakeup(DDukeActor* sn, DDukePlayer* const p);
int timedexit(int snum); int timedexit(int snum);
@ -118,7 +119,6 @@ void checkweapons(DDukePlayer* const p);
int findotherplayer(int p, double* d); int findotherplayer(int p, double* d);
void quickkill(DDukePlayer* p); void quickkill(DDukePlayer* p);
int setpal(DDukePlayer* p); int setpal(DDukePlayer* p);
int madenoise(int playerNum);
int haslock(sectortype* sect, int snum); int haslock(sectortype* sect, int snum);
void purplelavacheck(DDukePlayer* p); void purplelavacheck(DDukePlayer* p);
void addphealth(DDukePlayer* p, int amount, bool bigitem); void addphealth(DDukePlayer* p, int amount, bool bigitem);

View file

@ -332,7 +332,7 @@ void hud_input(DDukePlayer* const p)
p->yehaa_timer = 126; p->yehaa_timer = 126;
S_PlayActorSound(390, pact); S_PlayActorSound(390, pact);
p->noise_radius = 1024; p->noise_radius = 1024;
madenoise(p->pnum); madenoise(p);
if (p->cursector->lotag == 857) if (p->cursector->lotag == 857)
{ {
if (pact->spr.extra <= gs.max_player_health) if (pact->spr.extra <= gs.max_player_health)

View file

@ -30,18 +30,15 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
BEGIN_DUKE_NS BEGIN_DUKE_NS
int madenoise(int snum) int madenoise(DDukePlayer* const p)
{ {
DDukePlayer *p;
p = getPlayer(snum);
p->donoise = 1; p->donoise = 1;
p->noise = p->GetActor()->spr.pos.XY(); p->noise = p->GetActor()->spr.pos.XY();
return 1; return 1;
} }
int wakeup(DDukeActor* actor, int snum) int wakeup(DDukeActor* actor, DDukePlayer* const p)
{ {
auto p = getPlayer(snum);
if (!p->donoise) if (!p->donoise)
return 0; return 0;
if (actor->spr.pal == 30 || actor->spr.pal == 32 || actor->spr.pal == 33 || (isRRRA() && actor->spr.pal == 8)) if (actor->spr.pal == 30 || actor->spr.pal == 32 || actor->spr.pal == 33 || (isRRRA() && actor->spr.pal == 8))

View file

@ -427,7 +427,7 @@ int doincrements_r(DDukePlayer* p)
if (numplayers < 2) if (numplayers < 2)
{ {
p->noise_radius = 1024; p->noise_radius = 1024;
madenoise(screenpeek); madenoise(getPlayer(screenpeek));
p->vel.XY() += p->GetActor()->spr.Angles.Yaw.ToVector(); p->vel.XY() += p->GetActor()->spr.Angles.Yaw.ToVector();
} }
p->eat -= 4; p->eat -= 4;
@ -1675,7 +1675,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
{ {
p->hbomb_on = 0; p->hbomb_on = 0;
p->noise_radius = 512; p->noise_radius = 512;
madenoise(snum); madenoise(p);
} }
if (p->kickback_pic == 12) if (p->kickback_pic == 12)
{ {
@ -1743,7 +1743,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
shoot(pact, DukeShotSparkClass); shoot(pact, DukeShotSparkClass);
S_PlayActorSound(PISTOL_FIRE, pact); S_PlayActorSound(PISTOL_FIRE, pact);
p->noise_radius = 512; p->noise_radius = 512;
madenoise(snum); madenoise(p);
lastvisinc = PlayClock + 32; lastvisinc = PlayClock + 32;
p->visibility = 0; p->visibility = 0;
@ -1813,7 +1813,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
S_PlayActorSound(SHOTGUN_FIRE, pact); S_PlayActorSound(SHOTGUN_FIRE, pact);
p->noise_radius = 512; p->noise_radius = 512;
madenoise(snum); madenoise(p);
lastvisinc = PlayClock + 32; lastvisinc = PlayClock + 32;
p->visibility = 0; p->visibility = 0;
@ -1917,7 +1917,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
S_PlayActorSound(CHAINGUN_FIRE, pact); S_PlayActorSound(CHAINGUN_FIRE, pact);
shoot(pact, DukeChaingunShotClass); shoot(pact, DukeChaingunShotClass);
p->noise_radius = 512; p->noise_radius = 512;
madenoise(snum); madenoise(p);
lastvisinc = PlayClock + 32; lastvisinc = PlayClock + 32;
p->visibility = 0; p->visibility = 0;
@ -1949,7 +1949,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
p->okickback_pic = p->kickback_pic = 0; p->okickback_pic = p->kickback_pic = 0;
shoot(pact, RedneckBuzzSawClass); shoot(pact, RedneckBuzzSawClass);
p->noise_radius = 64; p->noise_radius = 64;
madenoise(snum); madenoise(p);
checkavailweapon(p); checkavailweapon(p);
} }
else p->kickback_pic++; else p->kickback_pic++;
@ -1977,7 +1977,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
S_PlayActorSound(CHAINGUN_FIRE, pact); S_PlayActorSound(CHAINGUN_FIRE, pact);
shoot(pact, DukeShotSparkClass); shoot(pact, DukeShotSparkClass);
p->noise_radius = 1024; p->noise_radius = 1024;
madenoise(snum); madenoise(p);
p->ammo_amount[TIT_WEAPON]--; p->ammo_amount[TIT_WEAPON]--;
checkavailweapon(p); checkavailweapon(p);
} }
@ -2004,7 +2004,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
S_PlayActorSound(CHAINGUN_FIRE, pact); S_PlayActorSound(CHAINGUN_FIRE, pact);
shoot(pact, DukeChaingunShotClass); shoot(pact, DukeChaingunShotClass);
p->noise_radius = 1024; p->noise_radius = 1024;
madenoise(snum); madenoise(p);
p->ammo_amount[MOTORCYCLE_WEAPON]--; p->ammo_amount[MOTORCYCLE_WEAPON]--;
if (p->ammo_amount[MOTORCYCLE_WEAPON] <= 0) if (p->ammo_amount[MOTORCYCLE_WEAPON] <= 0)
p->okickback_pic = p->kickback_pic = 0; p->okickback_pic = p->kickback_pic = 0;
@ -2052,7 +2052,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
{ {
S_PlayActorSound(CAT_FIRE, pact); S_PlayActorSound(CAT_FIRE, pact);
p->noise_radius = 128; p->noise_radius = 128;
madenoise(snum); madenoise(p);
} }
else if (p->kickback_pic == 9) else if (p->kickback_pic == 9)
{ {
@ -2106,7 +2106,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
S_PlayActorSound(354, pact); S_PlayActorSound(354, pact);
shoot(pact, RedneckBowlingBallClass); shoot(pact, RedneckBowlingBallClass);
p->noise_radius = 64; p->noise_radius = 64;
madenoise(snum); madenoise(p);
} }
if (p->kickback_pic < 30) if (p->kickback_pic < 30)
{ {
@ -2129,7 +2129,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
{ {
shoot(pact, DukeMeleeAttackClass); shoot(pact, DukeMeleeAttackClass);
p->noise_radius = 64; p->noise_radius = 64;
madenoise(snum); madenoise(p);
} }
else if (p->kickback_pic == 16) else if (p->kickback_pic == 16)
p->okickback_pic = p->kickback_pic = 0; p->okickback_pic = p->kickback_pic = 0;
@ -2147,7 +2147,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
{ {
shoot(pact, RedneckSlingbladeAttackClass); shoot(pact, RedneckSlingbladeAttackClass);
p->noise_radius = 64; p->noise_radius = 64;
madenoise(snum); madenoise(p);
} }
else if (p->kickback_pic == 16) else if (p->kickback_pic == 16)
p->okickback_pic = p->kickback_pic = 0; p->okickback_pic = p->kickback_pic = 0;
@ -2167,7 +2167,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
p->visibility = 0; p->visibility = 0;
shoot(pact, RedneckDynamiteArrowClass); shoot(pact, RedneckDynamiteArrowClass);
p->noise_radius = 2048; p->noise_radius = 2048;
madenoise(snum); madenoise(p);
checkavailweapon(p); checkavailweapon(p);
} }
else if (p->kickback_pic == 16) else if (p->kickback_pic == 16)
@ -2185,7 +2185,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
p->visibility = 0; p->visibility = 0;
shoot(pact, RedneckChickenArrowClass); shoot(pact, RedneckChickenArrowClass);
p->noise_radius = 2048; p->noise_radius = 2048;
madenoise(snum); madenoise(p);
checkavailweapon(p); checkavailweapon(p);
} }
else if (p->kickback_pic == 16) else if (p->kickback_pic == 16)