- use PlayerIndex plus a bit of cleanup.

This commit is contained in:
Christoph Oelckers 2022-09-01 17:26:46 +02:00
parent 45d95ec053
commit 9621cd08d2
17 changed files with 36 additions and 38 deletions

View file

@ -3790,7 +3790,7 @@ void handle_se17(DDukeActor* actor)
auto sc = actor->sector(); auto sc = actor->sector();
int sh = actor->spr.hitag; 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->addceilingz(q);
sc->addfloorz(q); sc->addfloorz(q);
@ -3851,7 +3851,7 @@ void handle_se17(DDukeActor* actor)
{ {
if (act3->spr.statnum == STAT_PLAYER && act3->GetOwner()) 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.X += act2->spr.pos.X - actor->spr.pos.X;
ps[p].pos.Y += act2->spr.pos.Y - actor->spr.pos.Y; 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) if (actor->spr.shade)
{ {
sec->add_int_ceilingz(actor->spr.yvel << 4); sec->addceilingz(actor->spr.yvel);
if (sec->ceilingz > sec->floorz) if (sec->ceilingz > sec->floorz)
{ {
sec->setceilingz(sec->floorz); sec->setceilingz(sec->floorz);
@ -4422,7 +4422,7 @@ void handle_se25(DDukeActor* actor, int t_index, int snd1, int snd2)
} }
else else
{ {
sec->add_int_ceilingz(-actor->spr.yvel << 4); sec->addceilingz(-actor->spr.yvel);
if (sec->int_ceilingz() < actor->temp_data[t_index]) if (sec->int_ceilingz() < actor->temp_data[t_index])
{ {
sec->set_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[2] = 0;
actor->temp_data[0] = 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 else
{ {
@ -4482,7 +4482,7 @@ void handle_se32(DDukeActor *actor)
callsound(actor->sector(), actor); callsound(actor->sector(), actor);
sc->setceilingz(actor->spr.pos.Z); 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 else
{ {
@ -4648,7 +4648,7 @@ void handle_se31(DDukeActor* actor, bool choosedir)
} }
else 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); sec->add_int_floorz(l);
DukeSectIterator it(actor->sector()); DukeSectIterator it(actor->sector());

View file

@ -603,7 +603,7 @@ int ifhitbyweapon_d(DDukeActor *actor)
{ {
if (ud.god && actor->attackertype != SHRINKSPARK) return -1; if (ud.god && actor->attackertype != SHRINKSPARK) return -1;
p = actor->spr.yvel; p = actor->PlayerIndex();
if (hitowner && if (hitowner &&
hitowner->spr.picnum == APLAYER && hitowner->spr.picnum == APLAYER &&
@ -1314,7 +1314,6 @@ static bool movefireball(DDukeActor* actor)
actor->temp_actor = ball; actor->temp_actor = ball;
ball->set_int_xvel(actor->int_xvel()); ball->set_int_xvel(actor->int_xvel());
ball->spr.yvel = actor->spr.yvel;
ball->set_int_zvel(actor->int_zvel()); ball->set_int_zvel(actor->int_zvel());
if (actor->temp_data[0] > 1) if (actor->temp_data[0] > 1)
{ {
@ -1323,7 +1322,6 @@ static bool movefireball(DDukeActor* actor)
FireProj* proj = &trail->fproj; FireProj* proj = &trail->fproj;
ball->spr.pos = trail->temp_pos; ball->spr.pos = trail->temp_pos;
ball->set_int_xvel(proj->vel.X); ball->set_int_xvel(proj->vel.X);
ball->spr.yvel = proj->vel.Y;
ball->set_int_zvel(proj->vel.Z); ball->set_int_zvel(proj->vel.Z);
} }
} }
@ -1332,7 +1330,7 @@ static bool movefireball(DDukeActor* actor)
ball->spr.extra = 0; ball->spr.extra = 0;
ball->temp_pos = ball->spr.pos; 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); ChangeActorStat(ball, STAT_PROJECTILE);
} }

View file

@ -1000,7 +1000,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 &
if (targ->spr.picnum == APLAYER) if (targ->spr.picnum == APLAYER)
{ {
int p = targ->spr.yvel; int p = targ->PlayerIndex();
S_PlayActorSound(PISTOL_BODYHIT, targ); S_PlayActorSound(PISTOL_BODYHIT, targ);
if (proj->spr.picnum == SPIT) if (proj->spr.picnum == SPIT)
@ -1429,7 +1429,7 @@ void movetransports_r(void)
if (act2->GetOwner()) if (act2->GetOwner())
{ {
p = act2->spr.yvel; p = act2->PlayerIndex();
ps[p].on_warping_sector = 1; ps[p].on_warping_sector = 1;

View file

@ -297,7 +297,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat
case APLAYER: case APLAYER:
p = h->spr.yvel; p = h->PlayerIndex();
if (t->pal == 1) t->pos.Z -= 18; 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 (OwnerAc->spr.picnum == APLAYER)
if (ud.cameraactor == nullptr) if (ud.cameraactor == nullptr)
if (screenpeek == OwnerAc->spr.yvel && display_mirror == 0) if (screenpeek == OwnerAc->PlayerIndex() && display_mirror == 0)
{ {
t->ownerActor = nullptr; t->ownerActor = nullptr;
break; break;

View file

@ -339,7 +339,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat
case APLAYER: case APLAYER:
p = h->spr.yvel; p = h->PlayerIndex();
if (t->pal == 1) t->pos.Z -= 18; 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 (OwnerAc->spr.picnum == APLAYER)
if (ud.cameraactor == nullptr) if (ud.cameraactor == nullptr)
if (screenpeek == OwnerAc->spr.yvel && display_mirror == 0) if (screenpeek == OwnerAc->PlayerIndex() && display_mirror == 0)
{ {
t->ownerActor = nullptr; t->ownerActor = nullptr;
break; break;

View file

@ -16,7 +16,7 @@ inline DDukeActor* player_struct::GetActor()
inline int player_struct::GetPlayerNum() inline int player_struct::GetPlayerNum()
{ {
return actor->spr.yvel; return actor->PlayerIndex();
} }
DDukeActor* spawn(DDukeActor* spawner, int type); DDukeActor* spawn(DDukeActor* spawner, int type);

View file

@ -242,7 +242,7 @@ DDukeActor* aim(DDukeActor* actor, int aang)
if (actor->isPlayer()) if (actor->isPlayer())
{ {
auto* plr = &ps[actor->PlayerIndex()]; auto* plr = &ps[actor->PlayerIndex()];
int autoaim = Autoaim(actor->spr.yvel); int autoaim = Autoaim(actor->PlayerIndex());
if (!autoaim) if (!autoaim)
{ {
// Some fudging to avoid aim randomization when autoaim is off. // Some fudging to avoid aim randomization when autoaim is off.

View file

@ -996,7 +996,7 @@ void shoot_d(DDukeActor* actor, int atwith)
int sx, sy, sz, sa, p, vel, zvel, x, dal; int sx, sy, sz, sa, p, vel, zvel, x, dal;
if (actor->isPlayer()) if (actor->isPlayer())
{ {
p = actor->spr.yvel; p = actor->PlayerIndex();
} }
else else
{ {
@ -1435,7 +1435,7 @@ int doincrements_d(player_struct* p)
int snum; int snum;
auto pact = p->GetActor(); auto pact = p->GetActor();
snum = pact->spr.yvel; snum = pact->PlayerIndex();
p->player_par++; p->player_par++;
@ -1639,7 +1639,7 @@ void checkweapons_d(player_struct* p)
if (isWW2GI()) if (isWW2GI())
{ {
int snum = p->GetActor()->spr.yvel; int snum = p->GetActor()->PlayerIndex();
cw = aplWeaponWorksLike(p->curr_weapon, snum); cw = aplWeaponWorksLike(p->curr_weapon, snum);
} }
else else

View file

@ -831,7 +831,7 @@ void shoot_r(DDukeActor* actor, int atwith)
if (actor->isPlayer()) if (actor->isPlayer())
{ {
p = actor->spr.yvel; p = actor->PlayerIndex();
sx = ps[p].player_int_pos().X; sx = ps[p].player_int_pos().X;
sy = ps[p].player_int_pos().Y; 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++; p->player_par++;
if (p->yehaa_timer) if (p->yehaa_timer)

View file

@ -2370,7 +2370,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
if (targ->spr.statnum == 10) if (targ->spr.statnum == 10)
{ {
p = targ->spr.yvel; p = targ->PlayerIndex();
if (ps[p].newOwner != nullptr) if (ps[p].newOwner != nullptr)
{ {
ps[p].newOwner = nullptr; ps[p].newOwner = nullptr;

View file

@ -267,7 +267,7 @@ static int GetPositionInfo(DDukeActor* actor, int soundNum, sectortype* sect,
FVector3 sndorg = GetSoundPos(pos); FVector3 sndorg = GetSoundPos(pos);
FVector3 campos = GetSoundPos(cam); FVector3 campos = GetSoundPos(cam);
if (!actor->isPlayer() || actor->spr.yvel != screenpeek) if (!actor->isPlayer() || actor->PlayerIndex() != screenpeek)
{ {
orgsndist = sndist = int(16 * (sndorg - campos).Length()); 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 (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) bool foundone = soundEngine->EnumerateChannels([&](FSoundChan* chan)
{ {
auto sid = chan->OrgID; auto sid = chan->OrgID;

View file

@ -435,7 +435,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell)
if (actj->isPlayer()) if (actj->isPlayer())
{ {
snum = actj->spr.yvel; snum = actj->PlayerIndex();
ang = ps[snum].angle.ang - DAngle::fromBuild((krand() & 63) + 8); //Fine tune ang = ps[snum].angle.ang - DAngle::fromBuild((krand() & 63) + 8); //Fine tune
act->temp_data[0] = krand() & 1; act->temp_data[0] = krand() & 1;

View file

@ -236,7 +236,7 @@ void BulletHitsSprite(Bullet *pBullet, DExhumedActor* pBulletActor, DExhumedActo
else else
{ {
int xVel = pHitActor->int_xvel(); 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_xvel(bcos(pActor->int_ang(), -2));
pHitActor->set_int_yvel(bsin(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) if (pTarget->spr.statnum != 100)
{ {
x += (pTarget->int_xvel() * 20) >> 6; x += (pTarget->int_xvel() * 20) >> 6;
y += (pTarget->spr.yvel * 20) >> 6; y += (pTarget->int_yvel() * 20) >> 6;
} }
else else
{ {

View file

@ -365,7 +365,7 @@ void AILion::Tick(RunListEvent* ev)
if (nMov.exbits & kHitAux2) if (nMov.exbits & kHitAux2)
{ {
pActor->mul_int_xvel(0.5); pActor->mul_int_xvel(0.5);
pActor->spr.yvel >>= 1; pActor->mul_int_yvel(0.5);
} }
return; return;

View file

@ -1321,7 +1321,7 @@ DExhumedActor* BuildCreatureChunk(DExhumedActor* pSrc, int nPic, bool bSpecial)
if (bSpecial) if (bSpecial)
{ {
pActor->mul_int_xvel(4); pActor->mul_int_xvel(4);
pActor->spr.yvel *= 4; pActor->mul_int_yvel(4);
pActor->mul_int_zvel(2); pActor->mul_int_zvel(2);
} }
@ -1380,7 +1380,7 @@ void AICreatureChunk::Tick(RunListEvent* ev)
if (nVal.exbits & kHitAux1) if (nVal.exbits & kHitAux1)
{ {
pActor->mul_int_xvel(0.5); pActor->mul_int_xvel(0.5);
pActor->spr.yvel >>= 1; pActor->mul_int_yvel(0.5);
pActor->set_int_zvel(-pActor->int_zvel()); pActor->set_int_zvel(-pActor->int_zvel());
return; return;
} }
@ -1398,7 +1398,7 @@ void AICreatureChunk::Tick(RunListEvent* ev)
} }
// loc_16E0C // 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->int_xvel() >> 10) * (pActor->int_xvel() >> 10)) >> 8);
pActor->set_int_xvel(bcos(nAngle) * (nSqrt >> 1)); pActor->set_int_xvel(bcos(nAngle) * (nSqrt >> 1));

View file

@ -1897,7 +1897,7 @@ void AIObject::Tick(RunListEvent* ev)
if (nMov.exbits & kHitAux2) if (nMov.exbits & kHitAux2)
{ {
pActor->add_int_xvel(-pActor->int_xvel() >> 3); 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) if (nMov.type == kHitSprite)
@ -2038,7 +2038,7 @@ void AIObject::RadialDamage(RunListEvent* ev)
else if (pActor->spr.statnum != kStatAnubisDrum) else if (pActor->spr.statnum != kStatAnubisDrum)
{ {
pActor->mul_int_xvel(0.5); pActor->mul_int_xvel(0.5);
pActor->spr.yvel >>= 1; pActor->mul_int_yvel(0.5);
pActor->mul_int_zvel(0.5); pActor->mul_int_zvel(0.5);
} }

View file

@ -305,7 +305,7 @@ void AIRat::Tick(RunListEvent* ev)
} }
case 2: 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); MoveCreature(pActor);
} }
@ -317,7 +317,7 @@ void AIRat::Tick(RunListEvent* ev)
if (pActor->pTarget == nullptr) if (pActor->pTarget == nullptr)
{ {
pActor->nCount = RandomSize(6); 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_xvel();
pActor->clear_yvel(); pActor->clear_yvel();