From 0740ccbef1631b68a8f6baeea37cba4fb1ed3064 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Sep 2022 16:42:23 +0200 Subject: [PATCH] - use PlayerIndex where appropriate. --- source/games/duke/src/animatesprites_r.cpp | 2 +- source/games/duke/src/gameexec.cpp | 4 ++-- source/games/duke/src/player.cpp | 20 ++++++++++---------- source/games/duke/src/spawn.cpp | 2 +- source/games/duke/src/spawn_d.cpp | 2 +- source/games/duke/src/spawn_r.cpp | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 527b98408..da25d5cba 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -210,7 +210,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat case BURNING: if (OwnerAc && OwnerAc->spr.statnum == STAT_PLAYER) { - if (display_mirror == 0 && OwnerAc->spr.yvel == screenpeek && ps[OwnerAc->spr.yvel].over_shoulder_on == 0) + if (display_mirror == 0 && OwnerAc->PlayerIndex() == screenpeek && ps[OwnerAc->PlayerIndex()].over_shoulder_on == 0) t->xrepeat = 0; else { diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index b7f6bc561..1c3fb50e1 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1685,7 +1685,7 @@ int ParseState::parse(void) case concmd_getlastpal: insptr++; if (g_ac->isPlayer()) - g_ac->spr.pal = ps[g_ac->spr.yvel].palookup; + g_ac->spr.pal = ps[g_ac->PlayerIndex()].palookup; else { // Copied from DukeGDX. @@ -1700,7 +1700,7 @@ int ParseState::parse(void) break; case concmd_tossweapon: insptr++; - fi.checkweapons(&ps[g_ac->spr.yvel]); + fi.checkweapons(&ps[g_ac->PlayerIndex()]); break; case concmd_nullop: insptr++; diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 88daeaae0..f10462743 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -241,7 +241,7 @@ DDukeActor* aim(DDukeActor* actor, int aang) // Autoaim from DukeGDX. if (actor->isPlayer()) { - auto* plr = &ps[actor->spr.yvel]; + auto* plr = &ps[actor->PlayerIndex()]; int autoaim = Autoaim(actor->spr.yvel); if (!autoaim) { @@ -273,7 +273,7 @@ DDukeActor* aim(DDukeActor* actor, int aang) } else { - weap = aplWeaponWorksLike(plr->curr_weapon, actor->spr.yvel); + weap = aplWeaponWorksLike(plr->curr_weapon, actor->PlayerIndex()); } // The chickens in RRRA are homing and must always autoaim. if (!isRRRA() || plr->curr_weapon != CHICKEN_WEAPON) @@ -287,7 +287,7 @@ DDukeActor* aim(DDukeActor* actor, int aang) } } DDukeActor* aimed = nullptr; - // if(actor->isPlayer() && ps[actor->spr.yvel].aim_mode) return -1; + // if(actor->isPlayer() && ps[actor->PlayerIndex()].aim_mode) return -1; if (isRR()) { @@ -296,13 +296,13 @@ DDukeActor* aim(DDukeActor* actor, int aang) } else if (isWW2GI()) { - gotshrinker = actor->isPlayer() && aplWeaponWorksLike(ps[actor->spr.yvel].curr_weapon, actor->spr.yvel) == SHRINKER_WEAPON; - gotfreezer = actor->isPlayer() && aplWeaponWorksLike(ps[actor->spr.yvel].curr_weapon, actor->spr.yvel) == FREEZE_WEAPON; + gotshrinker = actor->isPlayer() && aplWeaponWorksLike(ps[actor->PlayerIndex()].curr_weapon, actor->PlayerIndex()) == SHRINKER_WEAPON; + gotfreezer = actor->isPlayer() && aplWeaponWorksLike(ps[actor->PlayerIndex()].curr_weapon, actor->PlayerIndex()) == FREEZE_WEAPON; } else { - gotshrinker = actor->isPlayer() && ps[actor->spr.yvel].curr_weapon == SHRINKER_WEAPON; - gotfreezer = actor->isPlayer() && ps[actor->spr.yvel].curr_weapon == FREEZE_WEAPON; + gotshrinker = actor->isPlayer() && ps[actor->PlayerIndex()].curr_weapon == SHRINKER_WEAPON; + gotfreezer = actor->isPlayer() && ps[actor->PlayerIndex()].curr_weapon == FREEZE_WEAPON; } smax = 0x7fffffff; @@ -349,7 +349,7 @@ DDukeActor* aim(DDukeActor* actor, int aang) if (sdist > 512 && sdist < smax) { if (actor->isPlayer()) - a = (abs(Scale(act->int_pos().Z - actor->int_pos().Z, 10, sdist) - ps[actor->spr.yvel].horizon.sum().asbuild()) < 100); + a = (abs(Scale(act->int_pos().Z - actor->int_pos().Z, 10, sdist) - ps[actor->PlayerIndex()].horizon.sum().asbuild()) < 100); else a = 1; cans = cansee(act->spr.pos.plusZ(-32 + gs.actorinfo[act->spr.picnum].aimoffset), act->sector(), actor->spr.pos.plusZ(-32), actor->sector()); @@ -403,8 +403,8 @@ void dokneeattack(int snum, const std::initializer_list & respawnlist) if (p->actorsqu->isPlayer()) { - quickkill(&ps[p->actorsqu->spr.yvel]); - ps[p->actorsqu->spr.yvel].frag_ps = snum; + quickkill(&ps[p->actorsqu->PlayerIndex()]); + ps[p->actorsqu->PlayerIndex()].frag_ps = snum; } else if (badguy(p->actorsqu)) { diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 14794d7a9..50d0d4fb8 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -408,7 +408,7 @@ void initfootprint(DDukeActor* actj, DDukeActor* act) else { act->spr.xrepeat = act->spr.yrepeat = 0; return; } act->spr.cstat = CSTAT_SPRITE_ALIGNMENT_FLOOR; - if ((ps[actj->spr.yvel].footprintcount & 1)) act->spr.cstat |= CSTAT_SPRITE_XFLIP; + if ((ps[actj->PlayerIndex()].footprintcount & 1)) act->spr.cstat |= CSTAT_SPRITE_XFLIP; act->spr.angle = actj->spr.angle; } diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 19902d958..cfa8d1bce 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -510,7 +510,7 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* act->spr.xrepeat = actj->spr.xrepeat; act->spr.yrepeat = actj->spr.yrepeat; act->spr.shade = actj->spr.shade; - act->spr.pal = ps[actj->spr.yvel].palookup; + act->spr.pal = ps[actj->PlayerIndex()].palookup; } [[fallthrough]]; case DUKECAR: diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 440617432..de4184eac 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -543,7 +543,7 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* act->spr.xrepeat = actj->spr.xrepeat; act->spr.yrepeat = actj->spr.yrepeat; act->spr.shade = actj->spr.shade; - act->spr.pal = ps[actj->spr.yvel].palookup; + act->spr.pal = ps[actj->PlayerIndex()].palookup; } act->spr.cstat = 0; act->spr.extra = 1;