From 9621cd08d230e2bc8daedfc78363c864184b033b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Sep 2022 17:26:46 +0200 Subject: [PATCH] - use PlayerIndex plus a bit of cleanup. --- source/games/duke/src/actors.cpp | 14 +++++++------- source/games/duke/src/actors_d.cpp | 6 ++---- source/games/duke/src/actors_r.cpp | 4 ++-- source/games/duke/src/animatesprites_d.cpp | 4 ++-- source/games/duke/src/animatesprites_r.cpp | 4 ++-- source/games/duke/src/dukeactor.h | 2 +- source/games/duke/src/player.cpp | 2 +- source/games/duke/src/player_d.cpp | 6 +++--- source/games/duke/src/player_r.cpp | 4 ++-- source/games/duke/src/sectors_r.cpp | 2 +- source/games/duke/src/sounds.cpp | 4 ++-- source/games/duke/src/spawn.cpp | 2 +- source/games/exhumed/src/bullet.cpp | 4 ++-- source/games/exhumed/src/lion.cpp | 2 +- source/games/exhumed/src/move.cpp | 6 +++--- source/games/exhumed/src/object.cpp | 4 ++-- source/games/exhumed/src/rat.cpp | 4 ++-- 17 files changed, 36 insertions(+), 38 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index e227737a9..675faee63 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -3790,7 +3790,7 @@ void handle_se17(DDukeActor* actor) auto sc = actor->sector(); int sh = actor->spr.hitag; - double q = actor->temp_data[0] * actor->spr.yvel * (4 * zinttoworld); + double q = actor->temp_data[0] * actor->spr.yvel * (1 / 64.); sc->addceilingz(q); sc->addfloorz(q); @@ -3851,7 +3851,7 @@ void handle_se17(DDukeActor* actor) { if (act3->spr.statnum == STAT_PLAYER && act3->GetOwner()) { - int p = act3->spr.yvel; + int p = act3->PlayerIndex(); ps[p].pos.X += act2->spr.pos.X - actor->spr.pos.X; ps[p].pos.Y += act2->spr.pos.Y - actor->spr.pos.Y; @@ -4412,7 +4412,7 @@ void handle_se25(DDukeActor* actor, int t_index, int snd1, int snd2) if (actor->spr.shade) { - sec->add_int_ceilingz(actor->spr.yvel << 4); + sec->addceilingz(actor->spr.yvel); if (sec->ceilingz > sec->floorz) { sec->setceilingz(sec->floorz); @@ -4422,7 +4422,7 @@ void handle_se25(DDukeActor* actor, int t_index, int snd1, int snd2) } else { - sec->add_int_ceilingz(-actor->spr.yvel << 4); + sec->addceilingz(-actor->spr.yvel); if (sec->int_ceilingz() < actor->temp_data[t_index]) { sec->set_int_ceilingz(actor->temp_data[t_index]); @@ -4457,7 +4457,7 @@ void handle_se32(DDukeActor *actor) actor->temp_data[2] = 0; actor->temp_data[0] = 0; } - else sc->add_int_ceilingz(Sgn(actor->int_pos().Z - sc->int_ceilingz()) * actor->spr.yvel); + else sc->add_int_ceilingz(Sgn(actor->spr.pos.Z - sc->ceilingz) * actor->spr.yvel); } else { @@ -4482,7 +4482,7 @@ void handle_se32(DDukeActor *actor) callsound(actor->sector(), actor); sc->setceilingz(actor->spr.pos.Z); } - else sc->add_int_ceilingz(Sgn(actor->int_pos().Z - sc->int_ceilingz()) * actor->spr.yvel); + else sc->add_int_ceilingz(Sgn(actor->spr.pos.Z - sc->ceilingz) * actor->spr.yvel); } else { @@ -4648,7 +4648,7 @@ void handle_se31(DDukeActor* actor, bool choosedir) } else { - int l = Sgn(actor->int_pos().Z - sec->int_floorz()) * actor->spr.yvel; + int l = Sgn(actor->spr.pos.Z - sec->floorz) * actor->spr.yvel; sec->add_int_floorz(l); DukeSectIterator it(actor->sector()); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 3f2fdb120..c8aacef22 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -603,7 +603,7 @@ int ifhitbyweapon_d(DDukeActor *actor) { if (ud.god && actor->attackertype != SHRINKSPARK) return -1; - p = actor->spr.yvel; + p = actor->PlayerIndex(); if (hitowner && hitowner->spr.picnum == APLAYER && @@ -1314,7 +1314,6 @@ static bool movefireball(DDukeActor* actor) actor->temp_actor = ball; ball->set_int_xvel(actor->int_xvel()); - ball->spr.yvel = actor->spr.yvel; ball->set_int_zvel(actor->int_zvel()); if (actor->temp_data[0] > 1) { @@ -1323,7 +1322,6 @@ static bool movefireball(DDukeActor* actor) FireProj* proj = &trail->fproj; ball->spr.pos = trail->temp_pos; ball->set_int_xvel(proj->vel.X); - ball->spr.yvel = proj->vel.Y; ball->set_int_zvel(proj->vel.Z); } } @@ -1332,7 +1330,7 @@ static bool movefireball(DDukeActor* actor) ball->spr.extra = 0; ball->temp_pos = ball->spr.pos; - ball->fproj.vel = { ball->int_xvel(), ball->spr.yvel, ball->int_zvel()}; + ball->fproj.vel = { ball->int_xvel(), 0, ball->int_zvel()}; ChangeActorStat(ball, STAT_PROJECTILE); } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 111bde68b..480443521 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1000,7 +1000,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 & if (targ->spr.picnum == APLAYER) { - int p = targ->spr.yvel; + int p = targ->PlayerIndex(); S_PlayActorSound(PISTOL_BODYHIT, targ); if (proj->spr.picnum == SPIT) @@ -1429,7 +1429,7 @@ void movetransports_r(void) if (act2->GetOwner()) { - p = act2->spr.yvel; + p = act2->PlayerIndex(); ps[p].on_warping_sector = 1; diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index a6d5b6ff4..b7de26d28 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -297,7 +297,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat case APLAYER: - p = h->spr.yvel; + p = h->PlayerIndex(); if (t->pal == 1) t->pos.Z -= 18; @@ -694,7 +694,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat { if (OwnerAc->spr.picnum == APLAYER) if (ud.cameraactor == nullptr) - if (screenpeek == OwnerAc->spr.yvel && display_mirror == 0) + if (screenpeek == OwnerAc->PlayerIndex() && display_mirror == 0) { t->ownerActor = nullptr; break; diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index da25d5cba..f941f08c2 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -339,7 +339,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat case APLAYER: - p = h->spr.yvel; + p = h->PlayerIndex(); if (t->pal == 1) t->pos.Z -= 18; @@ -924,7 +924,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat { if (OwnerAc->spr.picnum == APLAYER) if (ud.cameraactor == nullptr) - if (screenpeek == OwnerAc->spr.yvel && display_mirror == 0) + if (screenpeek == OwnerAc->PlayerIndex() && display_mirror == 0) { t->ownerActor = nullptr; break; diff --git a/source/games/duke/src/dukeactor.h b/source/games/duke/src/dukeactor.h index f93e8d976..ac87a05ad 100644 --- a/source/games/duke/src/dukeactor.h +++ b/source/games/duke/src/dukeactor.h @@ -16,7 +16,7 @@ inline DDukeActor* player_struct::GetActor() inline int player_struct::GetPlayerNum() { - return actor->spr.yvel; + return actor->PlayerIndex(); } DDukeActor* spawn(DDukeActor* spawner, int type); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index c5f5b14e1..1b0bc4931 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -242,7 +242,7 @@ DDukeActor* aim(DDukeActor* actor, int aang) if (actor->isPlayer()) { auto* plr = &ps[actor->PlayerIndex()]; - int autoaim = Autoaim(actor->spr.yvel); + int autoaim = Autoaim(actor->PlayerIndex()); if (!autoaim) { // Some fudging to avoid aim randomization when autoaim is off. diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 3642ab5f9..d55fa69c1 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -996,7 +996,7 @@ void shoot_d(DDukeActor* actor, int atwith) int sx, sy, sz, sa, p, vel, zvel, x, dal; if (actor->isPlayer()) { - p = actor->spr.yvel; + p = actor->PlayerIndex(); } else { @@ -1435,7 +1435,7 @@ int doincrements_d(player_struct* p) int snum; auto pact = p->GetActor(); - snum = pact->spr.yvel; + snum = pact->PlayerIndex(); p->player_par++; @@ -1639,7 +1639,7 @@ void checkweapons_d(player_struct* p) if (isWW2GI()) { - int snum = p->GetActor()->spr.yvel; + int snum = p->GetActor()->PlayerIndex(); cw = aplWeaponWorksLike(p->curr_weapon, snum); } else diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 46c00d5f7..eb00229ee 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -831,7 +831,7 @@ void shoot_r(DDukeActor* actor, int atwith) if (actor->isPlayer()) { - p = actor->spr.yvel; + p = actor->PlayerIndex(); sx = ps[p].player_int_pos().X; sy = ps[p].player_int_pos().Y; @@ -1258,7 +1258,7 @@ int doincrements_r(player_struct* p) } } - snum = p->GetActor()->spr.yvel; + snum = p->GetActor()->PlayerIndex(); p->player_par++; if (p->yehaa_timer) diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 9bf1e543d..d5c6f77f8 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2370,7 +2370,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) if (targ->spr.statnum == 10) { - p = targ->spr.yvel; + p = targ->PlayerIndex(); if (ps[p].newOwner != nullptr) { ps[p].newOwner = nullptr; diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 695844bf1..f67f7dead 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -267,7 +267,7 @@ static int GetPositionInfo(DDukeActor* actor, int soundNum, sectortype* sect, FVector3 sndorg = GetSoundPos(pos); FVector3 campos = GetSoundPos(cam); - if (!actor->isPlayer() || actor->spr.yvel != screenpeek) + if (!actor->isPlayer() || actor->PlayerIndex() != screenpeek) { orgsndist = sndist = int(16 * (sndorg - campos).Length()); @@ -433,7 +433,7 @@ int S_PlaySound3D(int sndnum, DDukeActor* actor, const vec3_t& pos, int channel, if (userflags & SF_TALK) { - if (snd_speech == 0 || (ud.multimode > 1 && actor->isPlayer() && actor->spr.yvel != screenpeek && ud.coop != 1)) return -1; + if (snd_speech == 0 || (ud.multimode > 1 && actor->isPlayer() && actor->PlayerIndex() != screenpeek && ud.coop != 1)) return -1; bool foundone = soundEngine->EnumerateChannels([&](FSoundChan* chan) { auto sid = chan->OrgID; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 4cb42efb3..92aab2497 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -435,7 +435,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell) if (actj->isPlayer()) { - snum = actj->spr.yvel; + snum = actj->PlayerIndex(); ang = ps[snum].angle.ang - DAngle::fromBuild((krand() & 63) + 8); //Fine tune act->temp_data[0] = krand() & 1; diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index 84f97f838..3287f8342 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -236,7 +236,7 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo else { int xVel = pHitActor->int_xvel(); - int yVel = pHitActor->spr.yvel; + int yVel = pHitActor->int_yvel(); pHitActor->set_int_xvel(bcos(pActor->int_ang(), -2)); pHitActor->set_int_yvel(bsin(pActor->int_ang(), -2)); @@ -714,7 +714,7 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, int nZOffset, int n if (pTarget->spr.statnum != 100) { x += (pTarget->int_xvel() * 20) >> 6; - y += (pTarget->spr.yvel * 20) >> 6; + y += (pTarget->int_yvel() * 20) >> 6; } else { diff --git a/source/games/exhumed/src/lion.cpp b/source/games/exhumed/src/lion.cpp index 6144dd171..f5472298a 100644 --- a/source/games/exhumed/src/lion.cpp +++ b/source/games/exhumed/src/lion.cpp @@ -365,7 +365,7 @@ void AILion::Tick(RunListEvent* ev) if (nMov.exbits & kHitAux2) { pActor->mul_int_xvel(0.5); - pActor->spr.yvel >>= 1; + pActor->mul_int_yvel(0.5); } return; diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index ac4bcc748..5aa0e9f98 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -1321,7 +1321,7 @@ DExhumedActor* BuildCreatureChunk(DExhumedActor* pSrc, int nPic, bool bSpecial) if (bSpecial) { pActor->mul_int_xvel(4); - pActor->spr.yvel *= 4; + pActor->mul_int_yvel(4); pActor->mul_int_zvel(2); } @@ -1380,7 +1380,7 @@ void AICreatureChunk::Tick(RunListEvent* ev) if (nVal.exbits & kHitAux1) { pActor->mul_int_xvel(0.5); - pActor->spr.yvel >>= 1; + pActor->mul_int_yvel(0.5); pActor->set_int_zvel(-pActor->int_zvel()); return; } @@ -1398,7 +1398,7 @@ void AICreatureChunk::Tick(RunListEvent* ev) } // loc_16E0C - int nSqrt = lsqrt(((pActor->spr.yvel >> 10) * (pActor->spr.yvel >> 10) + int nSqrt = lsqrt(((pActor->int_yvel() >> 10) * (pActor->int_yvel() >> 10) + (pActor->int_xvel() >> 10) * (pActor->int_xvel() >> 10)) >> 8); pActor->set_int_xvel(bcos(nAngle) * (nSqrt >> 1)); diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index dc0682102..4b0a12c4f 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1897,7 +1897,7 @@ void AIObject::Tick(RunListEvent* ev) if (nMov.exbits & kHitAux2) { pActor->add_int_xvel(-pActor->int_xvel() >> 3); - pActor->spr.yvel -= pActor->spr.yvel >> 3; + pActor->add_int_yvel(-pActor->int_yvel() >> 3); } if (nMov.type == kHitSprite) @@ -2038,7 +2038,7 @@ void AIObject::RadialDamage(RunListEvent* ev) else if (pActor->spr.statnum != kStatAnubisDrum) { pActor->mul_int_xvel(0.5); - pActor->spr.yvel >>= 1; + pActor->mul_int_yvel(0.5); pActor->mul_int_zvel(0.5); } diff --git a/source/games/exhumed/src/rat.cpp b/source/games/exhumed/src/rat.cpp index 94fb71242..26c94d5dd 100644 --- a/source/games/exhumed/src/rat.cpp +++ b/source/games/exhumed/src/rat.cpp @@ -305,7 +305,7 @@ void AIRat::Tick(RunListEvent* ev) } case 2: { - if (pActor->float_xvel() != 0 || pActor->spr.yvel || pActor->float_zvel() != 0) { + if (pActor->float_xvel() != 0 || pActor->float_yvel() != 0 || pActor->float_zvel() != 0) { MoveCreature(pActor); } @@ -317,7 +317,7 @@ void AIRat::Tick(RunListEvent* ev) if (pActor->pTarget == nullptr) { pActor->nCount = RandomSize(6); - if (pActor->float_xvel() != 0 || pActor->spr.yvel) + if (pActor->float_xvel() != 0 || pActor->float_yvel() != 0) { pActor->clear_xvel(); pActor->clear_yvel();