- Duke: Wrap calls to player_struct::PlayerNowPosition.XY().

This commit is contained in:
Mitchell Richters 2022-11-15 17:40:04 +11:00 committed by Christoph Oelckers
parent 4b7d2fcfcc
commit 5d3878eb55
12 changed files with 53 additions and 47 deletions

View file

@ -780,7 +780,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball)
{
// if(actor->spr.pal == 12)
{
auto delta = absangle(ps[p].angle.ang, (actor->spr.pos.XY() - ps[p].PlayerNowPosition.XY()).Angle());
auto delta = absangle(ps[p].angle.ang, (actor->spr.pos.XY() - ps[p].posXY()).Angle());
if (delta < DAngle22_5 / 2 && PlayerInput(p, SB_OPEN))
if (ps[p].toggle_key_flag == 1)
{
@ -790,7 +790,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball)
{
if (act2->spr.picnum == queball || act2->spr.picnum == stripeball)
{
delta = absangle(ps[p].angle.ang, (act2->spr.pos.XY() - ps[p].PlayerNowPosition.XY()).Angle());
delta = absangle(ps[p].angle.ang, (act2->spr.pos.XY() - ps[p].posXY()).Angle());
if (delta < DAngle22_5 / 2)
{
double l;
@ -812,7 +812,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball)
}
if (x < 32 && actor->sector() == ps[p].cursector)
{
actor->spr.angle = (actor->spr.pos.XY() - ps[p].PlayerNowPosition.XY()).Angle();
actor->spr.angle = (actor->spr.pos.XY() - ps[p].posXY()).Angle();
actor->vel.X = 3;
}
}
@ -964,7 +964,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p
actor->temp_data[2] = 0;
}
else actor->temp_angle +=
deltaangle(actor->temp_angle, (ps[p].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle()) / 3;
deltaangle(actor->temp_angle, (ps[p].posXY() - actor->spr.pos.XY()).Angle()) / 3;
}
else if (actor->temp_data[0] == 2 || actor->temp_data[0] == 3)
{
@ -991,7 +991,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p
fi.shoot(actor, firelaser);
}
}
actor->spr.angle += deltaangle(actor->spr.angle, (ps[p].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle()) * 0.25;
actor->spr.angle += deltaangle(actor->spr.angle, (ps[p].posXY() - actor->spr.pos.XY()).Angle()) * 0.25;
}
if (actor->temp_data[0] != 2 && actor->temp_data[0] != 3 && Owner)
@ -1864,9 +1864,9 @@ void handle_se00(DDukeActor* actor)
ps[p].PlayerNowPosition.Z += zchange;
auto result = rotatepoint(Owner->spr.pos, ps[p].PlayerNowPosition.XY(), ang_amount * direction);
auto result = rotatepoint(Owner->spr.pos, ps[p].posXY(), ang_amount * direction);
ps[p].bobpos += (result - ps[p].PlayerNowPosition.XY());
ps[p].bobpos += (result - ps[p].posXY());
ps[p].PlayerNowPosition.X = result.X;
ps[p].PlayerNowPosition.Y = result.Y;
@ -1996,7 +1996,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
if (dist2 < 1280)//20480)
{
auto saved_angle = actor->spr.angle;
actor->spr.angle = (actor->spr.pos.XY() - ps[p].PlayerNowPosition.XY()).Angle();
actor->spr.angle = (actor->spr.pos.XY() - ps[p].posXY()).Angle();
fi.shoot(actor, RPG);
actor->spr.angle = saved_angle;
}
@ -2018,7 +2018,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
updatesector(ps[p].PlayerNowPosition, &sect);
if ((sect == nullptr && ud.clipping == 0) || (sect == actor->sector() && ps[p].cursector != actor->sector()))
{
ps[p].PlayerNowPosition.XY() = actor->spr.pos.XY();
ps[p].posXY() = actor->spr.pos.XY();
ps[p].setCursector(actor->sector());
SetActor(ps[p].GetActor(), actor->spr.pos);
@ -2042,9 +2042,9 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
if (actor->sector() == psp->sector())
{
auto result = rotatepoint(actor->spr.pos.XY(), ps[p].PlayerNowPosition.XY(), diffangle);
auto result = rotatepoint(actor->spr.pos.XY(), ps[p].posXY(), diffangle);
ps[p].PlayerNowPosition.XY() = result + vec;
ps[p].posXY() = result + vec;
ps[p].bobpos += vec;
@ -2056,7 +2056,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
}
if (psp->spr.extra <= 0)
{
psp->spr.pos.XY() = ps[p].PlayerNowPosition.XY();
psp->spr.pos.XY() = ps[p].posXY();
}
}
}
@ -2093,7 +2093,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
updatesector(ps[p].PlayerNowPosition, &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
{
ps[p].PlayerNowPosition.XY() = actor->spr.pos.XY();
ps[p].posXY() = actor->spr.pos.XY();
ps[p].backupxy();
ps[p].setCursector(actor->sector());
@ -2196,7 +2196,7 @@ void handle_se30(DDukeActor *actor, int JIBS6)
updatesector(ps[p].PlayerNowPosition, &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
{
ps[p].PlayerNowPosition.XY() = actor->spr.pos.XY();
ps[p].posXY() = actor->spr.pos.XY();
ps[p].setCursector(actor->sector());
SetActor(ps[p].GetActor(), actor->spr.pos);
@ -2252,7 +2252,7 @@ void handle_se30(DDukeActor *actor, int JIBS6)
updatesector(ps[p].PlayerNowPosition, &k);
if ((k == nullptr && ud.clipping == 0) || (k == actor->sector() && ps[p].cursector != actor->sector()))
{
ps[p].PlayerNowPosition.XY() = actor->spr.pos.XY();
ps[p].posXY() = actor->spr.pos.XY();
ps[p].backupxy();
ps[p].setCursector(actor->sector());
@ -2537,7 +2537,7 @@ void handle_se05(DDukeActor* actor, int FIRELASER)
else
{
actor->temp_angle +=
deltaangle(actor->temp_angle + DAngle90, (ps[p].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle()) * 0.25;
deltaangle(actor->temp_angle + DAngle90, (ps[p].posXY() - actor->spr.pos.XY()).Angle()) * 0.25;
sc->ceilingshade = 0;
}
j = fi.ifhitbyweapon(actor);
@ -3047,7 +3047,7 @@ void handle_se17(DDukeActor* actor)
int p = act3->PlayerIndex();
ps[p].PlayerOldPosition -= ps[p].PlayerNowPosition;
ps[p].PlayerNowPosition.XY() += act2->spr.pos.XY() - actor->spr.pos.XY();
ps[p].posXY() += act2->spr.pos.XY() - actor->spr.pos.XY();
ps[p].PlayerNowPosition.Z += act2->sector()->floorz - sc->floorz;
ps[p].PlayerOldPosition += ps[p].PlayerNowPosition;
@ -3498,7 +3498,7 @@ void handle_se27(DDukeActor* actor)
{
ud.cameraactor = actor;
actor->temp_data[0] = 999;
actor->spr.angle += deltaangle(actor->spr.angle, (ps[p].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle()) * 0.125;
actor->spr.angle += deltaangle(actor->spr.angle, (ps[p].posXY() - actor->spr.pos.XY()).Angle()) * 0.125;
actor->spr.yint = 100 + int((actor->spr.pos.Z - ps[p].PlayerNowPosition.Z) * (256. / 257.));
}
@ -3513,7 +3513,7 @@ void handle_se27(DDukeActor* actor)
}
else
{
actor->spr.angle = (ps[p].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
actor->spr.angle = (ps[p].posXY() - actor->spr.pos.XY()).Angle();
if (actor->temp_data[0] == 999)
{

View file

@ -1667,7 +1667,7 @@ static void greenslime(DDukeActor *actor)
}
else if (xx < 64 && ps[p].quick_kick == 0)
{
auto ang = absangle(ps[p].angle.ang, (actor->spr.pos.XY() - ps[p].PlayerNowPosition.XY()).Angle());
auto ang = absangle(ps[p].angle.ang, (actor->spr.pos.XY() - ps[p].posXY()).Angle());
if (ang < DAngle22_5)
ps[p].quick_kick = 14;
}
@ -1772,7 +1772,7 @@ static void greenslime(DDukeActor *actor)
double add = (BobVal(actor->temp_data[1]) * 2) * REPEAT_SCALE;
actor->spr.scale = DVector2(0.3125 + add, 0.234375 + add);
actor->spr.pos.XY() = ps[p].PlayerNowPosition.XY() + ps[p].angle.ang.ToVector() * 8;
actor->spr.pos.XY() = ps[p].posXY() + ps[p].angle.ang.ToVector() * 8;
return;
}
@ -1934,7 +1934,7 @@ static void greenslime(DDukeActor *actor)
{
if (actor->vel.X < 2) actor->vel.X += 0.25;
actor->vel.X = 4 - BobVal(512 + actor->temp_data[1]) * 2;
actor->spr.angle += deltaangle(actor->spr.angle, (ps[p].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle()) * 0.125;
actor->spr.angle += deltaangle(actor->spr.angle, (ps[p].posXY() - actor->spr.pos.XY()).Angle()) * 0.125;
// TJR
}
@ -3035,7 +3035,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
{
if (ps[playernum].newOwner != nullptr)
goalang = (ps[playernum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[playernum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[playernum].posXY() - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.angle, goalang) * 0.25;
if (angdif > -DAngle22_5 / 16 && angdif < nullAngle) angdif = nullAngle;
actor->spr.angle += angdif;
@ -3048,7 +3048,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
{
if (ps[playernum].newOwner != nullptr)
goalang = (ps[playernum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[playernum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[playernum].posXY() - actor->spr.pos.XY()).Angle();
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.angle, goalang).Degrees()); // this looks very wrong...
actor->spr.angle += angdif;
}
@ -3062,7 +3062,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
if (a & face_player_smart)
{
DVector2 newpos = ps[playernum].PlayerNowPosition.XY() + (ps[playernum].vel.XY() * (4. / 3.));
DVector2 newpos = ps[playernum].posXY() + (ps[playernum].vel.XY() * (4. / 3.));
goalang = (newpos - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.angle, goalang) * 0.25;
if (angdif > -DAngle22_5/16 && angdif < nullAngle) angdif = nullAngle;
@ -3173,7 +3173,7 @@ void move_d(DDukeActor *actor, int playernum, int xvel)
{
daxvel = -(1024 - xvel) * maptoworld;
angdif = (ps[playernum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
angdif = (ps[playernum].posXY() - actor->spr.pos.XY()).Angle();
if (xvel < 512)
{

View file

@ -3213,7 +3213,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
{
if (ps[pnum].newOwner != nullptr)
goalang = (ps[pnum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[pnum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[pnum].posXY() - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.angle, goalang) * 0.25;
if (angdif > -DAngle22_5 / 16 && angdif < nullAngle) angdif = nullAngle;
actor->spr.angle += angdif;
@ -3226,7 +3226,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
{
if (ps[pnum].newOwner != nullptr)
goalang = (ps[pnum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[pnum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
else goalang = (ps[pnum].posXY() - actor->spr.pos.XY()).Angle();
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.angle, goalang).Degrees()); // this looks very wrong...
actor->spr.angle += angdif;
}
@ -3237,7 +3237,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
{
if (ps[pnum].newOwner != nullptr)
goalang = ((ps[pnum].PlayerOldPosition.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
else goalang = ((ps[pnum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle() + DAngle180);
else goalang = ((ps[pnum].posXY() - actor->spr.pos.XY()).Angle() + DAngle180);
angdif = DAngle22_5 * 0.25 * Sgn(deltaangle(actor->spr.angle, goalang).Degrees()); // this looks very wrong...
actor->spr.angle += angdif;
}
@ -3296,7 +3296,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
if (a & face_player_smart)
{
DVector2 newpos = ps[pnum].PlayerNowPosition.XY() + (ps[pnum].vel.XY() * (4. / 3.));
DVector2 newpos = ps[pnum].posXY() + (ps[pnum].vel.XY() * (4. / 3.));
goalang = (newpos - actor->spr.pos.XY()).Angle();
angdif = deltaangle(actor->spr.angle, goalang) * 0.25;
if (angdif > -DAngle22_5 / 16 && angdif < nullAngle) angdif = nullAngle;
@ -3396,7 +3396,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
{
daxvel = -(1024 - xvel) * maptoworld;
angdif = (ps[pnum].PlayerNowPosition.XY() - actor->spr.pos.XY()).Angle();
angdif = (ps[pnum].posXY() - actor->spr.pos.XY()).Angle();
if (xvel < 512)
{

View file

@ -217,7 +217,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
case FORCESPHERE:
if (t->statnum == STAT_MISC && OwnerAc)
{
auto sqa = ( OwnerAc->spr.pos.XY() - ps[screenpeek].PlayerNowPosition.XY()).Angle();
auto sqa = ( OwnerAc->spr.pos.XY() - ps[screenpeek].posXY()).Angle();
auto sqb = (OwnerAc->spr.pos.XY() - t->pos.XY()).Angle();
if (absangle(sqa, sqb) > DAngle90)
@ -566,7 +566,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
else
{
// Alter the shadow's position so that it appears behind the sprite itself.
auto look = (shadowspr->pos.XY() - ps[screenpeek].PlayerNowPosition.XY()).Angle();
auto look = (shadowspr->pos.XY() - ps[screenpeek].posXY()).Angle();
shadowspr->pos.XY() += look.ToVector() * 2;
}
}

View file

@ -209,7 +209,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
case FORCESPHERE:
if (t->statnum == STAT_MISC && OwnerAc)
{
auto sqa = (OwnerAc->spr.pos.XY() - ps[screenpeek].PlayerNowPosition.XY()).Angle();
auto sqa = (OwnerAc->spr.pos.XY() - ps[screenpeek].posXY()).Angle();
auto sqb = (OwnerAc->spr.pos.XY() - t->pos.XY()).Angle();
if (absangle(sqa, sqb) > DAngle90)
@ -730,7 +730,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
else
{
// Alter the shadow's position so that it appears behind the sprite itself.
auto look = (shadowspr->pos.XY() - ps[screenpeek].PlayerNowPosition.XY()).Angle();
auto look = (shadowspr->pos.XY() - ps[screenpeek].posXY()).Angle();
shadowspr->pos.XY() += look.ToVector() * 2;
}
}

View file

@ -2432,9 +2432,9 @@ int ParseState::parse(void)
{
DAngle ang;
if (g_ac->isPlayer() && ud.multimode > 1)
ang = absangle(ps[otherp].angle.ang, (ps[g_p].PlayerNowPosition.XY() - ps[otherp].PlayerNowPosition.XY()).Angle());
ang = absangle(ps[otherp].angle.ang, (ps[g_p].posXY() - ps[otherp].posXY()).Angle());
else
ang = absangle(ps[g_p].angle.ang, (g_ac->spr.pos.XY() - ps[g_p].PlayerNowPosition.XY()).Angle());
ang = absangle(ps[g_p].angle.ang, (g_ac->spr.pos.XY() - ps[g_p].posXY()).Angle());
j = ang < DAngle22_5;
}

View file

@ -211,7 +211,7 @@ inline bool playrunning()
inline void doslopetilting(player_struct* p, double const scaleAdjust = 1)
{
bool const canslopetilt = p->on_ground && p->insector() && p->cursector->lotag != ST_2_UNDERWATER && (p->cursector->floorstat & CSTAT_SECTOR_SLOPE);
p->horizon.calcviewpitch(p->PlayerNowPosition.XY(), p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust);
p->horizon.calcviewpitch(p->posXY(), p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust);
}
//---------------------------------------------------------------------------

View file

@ -35,7 +35,7 @@ int madenoise(int snum)
player_struct *p;
p = &ps[snum];
p->donoise = 1;
p->noise = p->PlayerNowPosition.XY();
p->noise = p->posXY();
return 1;
}

View file

@ -214,7 +214,7 @@ double hitawall(player_struct* p, walltype** hitw)
hitscan(p->PlayerNowPosition, p->cursector, DVector3(p->angle.ang.ToVector() * 1024, 0), hit, CLIPMASK0);
if (hitw) *hitw = hit.hitWall;
return (hit.hitpos.XY() - p->PlayerNowPosition.XY()).Length();
return (hit.hitpos.XY() - p->posXY()).Length();
}
@ -775,7 +775,7 @@ void player_struct::backuppos(bool noclipping)
}
PlayerOldPosition.Z = PlayerNowPosition.Z;
bobpos = PlayerNowPosition.XY();
bobpos = posXY();
opyoff = pyoff;
}

View file

@ -178,7 +178,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, DVector3 spos, DAng
setFreeAimVelocity(vel, zvel, ps[p].horizon.sum(), 40.5);
// WTF???
DAngle myang = DAngle90 - (DAngle180 - abs(abs((spos.XY() - ps[p].PlayerNowPosition.XY()).Angle() - sang) - DAngle180));
DAngle myang = DAngle90 - (DAngle180 - abs(abs((spos.XY() - ps[p].posXY()).Angle() - sang) - DAngle180));
if (ps[p].GetActor()->vel.X != 0)
vel = ((myang / DAngle90) * ps[p].GetActor()->vel.X) + 25;
if (actor->sector()->lotag == 2 && (krand() % 5) == 0)
@ -2040,7 +2040,7 @@ int operateTripbomb(int snum)
if (act == nullptr && hit.hitWall != nullptr && (hit.hitWall->cstat & CSTAT_WALL_MASKED) == 0)
if ((hit.hitWall->twoSided() && hit.hitWall->nextSector()->lotag <= 2) || (!hit.hitWall->twoSided() && hit.hitSector->lotag <= 2))
{
auto delta = hit.hitpos.XY() - p->PlayerNowPosition.XY();
auto delta = hit.hitpos.XY() - p->posXY();
if (delta.LengthSquared() < (18.125 * 18.125))
{
p->PlayerNowPosition.Z = p->PlayerOldPosition.Z;
@ -2867,7 +2867,7 @@ void processinput_d(int snum)
p->playerweaponsway(pact->vel.X);
pact->vel.X = clamp((p->PlayerNowPosition.XY() - p->bobpos).Length(), 0., 32.);
pact->vel.X = clamp((p->posXY() - p->bobpos).Length(), 0., 32.);
if (p->on_ground) p->bobcounter += int(p->GetActor()->vel.X * 8);
p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floorpicnum == MIRROR) || !p->insector()));
@ -3033,7 +3033,7 @@ HORIZONLY:
Collision clip{};
if (ud.clipping)
{
p->PlayerNowPosition.XY() += p->vel.XY() ;
p->posXY() += p->vel.XY() ;
updatesector(p->PlayerNowPosition, &p->cursector);
ChangeActorSect(pact, p->cursector);
}

View file

@ -3532,7 +3532,7 @@ void processinput_r(int snum)
p->playerweaponsway(pact->vel.X);
pact->vel.X = clamp((p->PlayerNowPosition.XY() - p->bobpos).Length(), 0., 32.);
pact->vel.X = clamp((p->posXY() - p->bobpos).Length(), 0., 32.);
if (p->on_ground) p->bobcounter += int(p->GetActor()->vel.X * 8);
p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floorpicnum == MIRROR) || !p->insector()));
@ -3737,7 +3737,7 @@ HORIZONLY:
Collision clip{};
if (ud.clipping)
{
p->PlayerNowPosition.XY() += p->vel.XY() ;
p->posXY() += p->vel.XY() ;
updatesector(p->PlayerNowPosition, &p->cursector);
ChangeActorSect(pact, p->cursector);
}

View file

@ -356,6 +356,12 @@ struct player_struct
{
bobpos = PlayerNowPosition.XY();
}
DVector2& posXY()
{
return PlayerNowPosition.XY();
}
};
struct Cycler