- SW: Wrap calls to PLAYER::PlayerNowPosition.XY().

This commit is contained in:
Mitchell Richters 2022-11-16 13:23:55 +11:00 committed by Christoph Oelckers
parent f0074a913e
commit 7d0b2fba69
10 changed files with 55 additions and 49 deletions

View file

@ -713,6 +713,12 @@ struct PLAYER
int cookieTime;
uint8_t WpnReloadState;
DVector2& posXY()
{
return PlayerNowPosition.XY();
}
};
extern PLAYER Player[MAX_SW_PLAYERS_REG+1];

View file

@ -571,7 +571,7 @@ int DoCheckSwarm(DSWActor* actor)
if (actor->user.targetActor->user.PlayerP)
{
pp = actor->user.targetActor->user.PlayerP;
pdist = (actor->spr.pos.XY() - pp->PlayerNowPosition.XY()).LengthSquared();
pdist = (actor->spr.pos.XY() - pp->posXY()).LengthSquared();
}
else
return 0;

View file

@ -424,7 +424,7 @@ void JS_ProcessEchoSpot()
while (auto actor = it.Next())
{
double maxdist = SP_TAG4(actor) * maptoworld;
auto v = actor->spr.pos.XY() - pp->PlayerNowPosition.XY();
auto v = actor->spr.pos.XY() - pp->posXY();
double dist = abs(v.X) + abs(v.Y);
if (dist <= maxdist) // tag4 = ang

View file

@ -111,7 +111,7 @@ Collision MultiClipMove(PLAYER* pp, double zz, double floordist)
}
// put posx and y off from offset
pp->PlayerNowPosition.XY() += pos[min_ndx].XY() - opos[min_ndx].XY();
pp->posXY() += pos[min_ndx].XY() - opos[min_ndx].XY();
return min_ret;
}
@ -223,7 +223,7 @@ int RectClipMove(PLAYER* pp, DVector2* qpos)
}
if (testquadinsect(&point_num, xy, pp->cursector))
{
pp->PlayerNowPosition.XY() += { -pvect.X * 0.5, pvect.X * 0.5 };
pp->posXY() += { -pvect.X * 0.5, pvect.X * 0.5 };
}
return false;
@ -238,7 +238,7 @@ int RectClipMove(PLAYER* pp, DVector2* qpos)
}
if (testquadinsect(&point_num, xy, pp->cursector))
{
pp->PlayerNowPosition.XY() += { pvect.X * 0.5, -pvect.X * 0.5 };
pp->posXY() += { pvect.X * 0.5, -pvect.X * 0.5 };
}
return false;
@ -264,7 +264,7 @@ short RectClipTurn(PLAYER* pp, DAngle new_angl, DVector2* qpos, DVector2* opos)
rot_angl = new_angl + sop->spin_ang - sop->ang_orig;
for (i = 0; i < 4; i++)
{
xy[i] = rotatepoint(pp->PlayerNowPosition.XY(), opos[i], rot_angl);
xy[i] = rotatepoint(pp->posXY(), opos[i], rot_angl);
// cannot use sop->xmid and ymid because the SO is off the map at this point
}

View file

@ -1313,7 +1313,7 @@ void DoPlayerTeleportToSprite(PLAYER* pp, DVector3& pos, DAngle ang)
{
pp->angle.ang = pp->angle.oang = ang;
pp->PlayerPrevPosition = pp->PlayerNowPosition= pos.plusZ(-PLAYER_HEIGHTF);
pp->PlayerOldPosition.XY() = pp->PlayerNowPosition.XY();
pp->PlayerOldPosition.XY() = pp->posXY();
updatesector(pp->PlayerNowPosition, &pp->cursector);
pp->Flags2 |= (PF2_TELEPORTED);
@ -1327,7 +1327,7 @@ void DoPlayerTeleportToSprite(PLAYER* pp, DVector3& pos, DAngle ang)
void DoPlayerTeleportToOffset(PLAYER* pp)
{
pp->PlayerOldPosition.XY() = pp->PlayerPrevPosition.XY() = pp->PlayerNowPosition.XY();
pp->PlayerOldPosition.XY() = pp->PlayerPrevPosition.XY() = pp->posXY();
updatesector(pp->PlayerNowPosition, &pp->cursector);
pp->Flags2 |= (PF2_TELEPORTED);
@ -1684,7 +1684,7 @@ void SlipSlope(PLAYER* pp)
void DoPlayerHorizon(PLAYER* pp, float const horz, double const scaleAdjust)
{
bool const canslopetilt = !(pp->Flags & (PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING)) && pp->cursector && (pp->cursector->floorstat & CSTAT_SECTOR_SLOPE);
pp->horizon.calcviewpitch(pp->PlayerNowPosition.XY(), pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, scaleAdjust, (pp->Flags & PF_CLIMBING));
pp->horizon.calcviewpitch(pp->posXY(), pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, scaleAdjust, (pp->Flags & PF_CLIMBING));
pp->horizon.applyinput(horz, &pp->input.actions, scaleAdjust);
}
@ -1698,7 +1698,7 @@ void DoPlayerBob(PLAYER* pp)
{
double amt;
double dist = (pp->PlayerNowPosition.XY() - pp->PlayerOldPosition.XY()).Length();
double dist = (pp->posXY() - pp->PlayerOldPosition.XY()).Length();
if (dist > 32)
dist = 0;
@ -1856,7 +1856,7 @@ void UpdatePlayerSprite(PLAYER* pp)
// Update sprite representation of player
actor->spr.pos.XY() = pp->PlayerNowPosition.XY();
actor->spr.pos.XY() = pp->posXY();
// there are multiple death functions
if (pp->Flags & (PF_DEAD))
@ -2163,7 +2163,7 @@ void DoPlayerMove(PLAYER* pp)
auto sect = pp->cursector;
if (interpolate_ride)
{
pp->PlayerPrevPosition.XY() = pp->PlayerNowPosition.XY();
pp->PlayerPrevPosition.XY() = pp->posXY();
}
pp->PlayerNowPosition += pp->vect;
updatesector(pp->PlayerNowPosition, &sect);
@ -2188,7 +2188,7 @@ void DoPlayerMove(PLAYER* pp)
if (interpolate_ride)
{
pp->PlayerPrevPosition.XY() = pp->PlayerNowPosition.XY();
pp->PlayerPrevPosition.XY() = pp->posXY();
}
auto save_cstat = actor->spr.cstat;
@ -2813,7 +2813,7 @@ void DoPlayerMoveVehicle(PLAYER* pp)
}
}
OperateSectorObject(pp->sop, pp->angle.ang, pp->PlayerNowPosition.XY());
OperateSectorObject(pp->sop, pp->angle.ang, pp->posXY());
pp->cursector = save_sect; // for speed
if (!SyncInput())
@ -3359,7 +3359,7 @@ void DoPlayerClimb(PLAYER* pp)
{
const double ADJ_AMT = 0.5;
auto ppos = pp->PlayerNowPosition.XY();
auto ppos = pp->posXY();
// player
if (ppos.X != pp->LadderPosition.X)
{
@ -3382,7 +3382,7 @@ void DoPlayerClimb(PLAYER* pp)
if (fabs(ppos.Y - pp->LadderPosition.Y) <= ADJ_AMT)
ppos.Y = pp->LadderPosition.Y;
}
pp->PlayerNowPosition.XY() = ppos;
pp->posXY() = ppos;
// sprite
ppos = plActor->spr.pos.XY();
@ -3550,7 +3550,7 @@ int DoPlayerWadeSuperJump(PLAYER* pp)
//for (i = 0; i < SIZ(angs); i++)
{
FAFhitscan(DVector3(pp->PlayerNowPosition.XY(), zh), pp->cursector, DVector3(pp->angle.ang.ToVector() * 1024, 0), hit, CLIPMASK_MISSILE);
FAFhitscan(DVector3(pp->posXY(), zh), pp->cursector, DVector3(pp->angle.ang.ToVector() * 1024, 0), hit, CLIPMASK_MISSILE);
if (hit.hitWall != nullptr && hit.hitSector != nullptr)
{
@ -3558,7 +3558,7 @@ int DoPlayerWadeSuperJump(PLAYER* pp)
if (hit.hitSector != nullptr && abs(hit.hitSector->floorz - pp->PlayerNowPosition.Z) < 50)
{
double dist = (pp->PlayerNowPosition.XY() - hit.hitpos.XY()).Length();
double dist = (pp->posXY() - hit.hitpos.XY()).Length();
double comp = (pp->actor->clipdist + 16);
if (dist < comp)
return true;
@ -4266,10 +4266,10 @@ void DoPlayerWarpToUnderwater(PLAYER* pp)
PRODUCTION_ASSERT(Found == true);
// get the offset from the sprite
plActor->user.pos.XY() = over_act->spr.pos.XY() - pp->PlayerNowPosition.XY();
plActor->user.pos.XY() = over_act->spr.pos.XY() - pp->posXY();
// update to the new x y position
pp->PlayerNowPosition.XY() = under_act->spr.pos.XY() - plActor->user.pos.XY();
pp->posXY() = under_act->spr.pos.XY() - plActor->user.pos.XY();
auto over = over_act->sector();
auto under = under_act->sector();
@ -4338,10 +4338,10 @@ void DoPlayerWarpToSurface(PLAYER* pp)
PRODUCTION_ASSERT(Found == true);
// get the offset from the under sprite
plActor->user.pos.XY() = under_act->spr.pos.XY() - pp->PlayerNowPosition.XY();
plActor->user.pos.XY() = under_act->spr.pos.XY() - pp->posXY();
// update to the new x y position
pp->PlayerNowPosition.XY() = over_act->spr.pos.XY() - plActor->user.pos.XY();
pp->posXY() = over_act->spr.pos.XY() - plActor->user.pos.XY();
auto over = over_act->sector();
auto under = under_act->sector();
@ -5244,7 +5244,7 @@ void DoPlayerBeginOperate(PLAYER* pp)
sop->controller = pp->actor;
pp->angle.oang = pp->angle.ang = sop->ang;
pp->PlayerNowPosition.XY() = sop->pmid.XY();
pp->posXY() = sop->pmid.XY();
updatesector(pp->PlayerNowPosition, &pp->cursector);
calcSlope(pp->cursector, pp->PlayerNowPosition, &cz, &fz);
pp->PlayerNowPosition.Z = fz - PLAYER_HEIGHTF;
@ -5334,7 +5334,7 @@ void DoPlayerBeginRemoteOperate(PLAYER* pp, SECTOR_OBJECT* sop)
auto save_sect = pp->cursector;
pp->angle.oang = pp->angle.ang = sop->ang;
pp->PlayerNowPosition.XY() = sop->pmid.XY();
pp->posXY() = sop->pmid.XY();
updatesector(pp->PlayerNowPosition, &pp->cursector);
calcSlope(pp->cursector, pp->PlayerNowPosition, &cz, &fz);
pp->PlayerNowPosition.Z = fz - PLAYER_HEIGHTF;
@ -5420,7 +5420,7 @@ void PlayerRemoteReset(PLAYER* pp, sectortype* sect)
pp->lastcursector = pp->cursector;
auto rsp = pp->remoteActor;
pp->PlayerNowPosition.XY() = rsp->spr.pos.XY();
pp->posXY() = rsp->spr.pos.XY();
pp->PlayerNowPosition.Z = sect->floorz - PLAYER_HEIGHTF;
pp->vect.Zero();
@ -5457,7 +5457,7 @@ void DoPlayerStopOperate(PLAYER* pp)
if (TEST_BOOL1(rsp))
pp->angle.ang = pp->angle.oang = rsp->spr.angle;
else
pp->angle.ang = pp->angle.oang = (pp->sop_remote->pmid.XY() - pp->PlayerNowPosition.XY()).Angle();
pp->angle.ang = pp->angle.oang = (pp->sop_remote->pmid.XY() - pp->posXY()).Angle();
}
if (pp->sop_control)
@ -6093,7 +6093,7 @@ void DoPlayerDeathFollowKiller(PLAYER* pp)
{
if (FAFcansee(ActorVectOfTop(killer), killer->sector(), pp->PlayerNowPosition, pp->cursector))
{
pp->angle.addadjustment(deltaangle(pp->angle.ang, (killer->spr.pos.XY() - pp->PlayerNowPosition.XY()).Angle()) * (1. / 16.));
pp->angle.addadjustment(deltaangle(pp->angle.ang, (killer->spr.pos.XY() - pp->posXY()).Angle()) * (1. / 16.));
}
}
}
@ -6302,7 +6302,7 @@ void DoPlayerDeathMoveHead(PLAYER* pp)
}
}
pp->PlayerNowPosition.XY() = plActor->spr.pos.XY();
pp->posXY() = plActor->spr.pos.XY();
pp->setcursector(plActor->sector());
// try to stay in valid area - death sometimes throws you out of the map
@ -6312,13 +6312,13 @@ void DoPlayerDeathMoveHead(PLAYER* pp)
{
pp->cursector = pp->lv_sector;
ChangeActorSect(pp->actor, pp->lv_sector);
pp->PlayerNowPosition.XY() = pp->lv.XY();
plActor->spr.pos.XY() = pp->PlayerNowPosition.XY();
pp->posXY() = pp->lv.XY();
plActor->spr.pos.XY() = pp->posXY();
}
else
{
pp->lv_sector = sect;
pp->lv.XY() = pp->PlayerNowPosition.XY();
pp->lv.XY() = pp->posXY();
}
}
@ -7250,7 +7250,7 @@ int SearchSpawnPosition(PLAYER* pp)
if (opp != pp) // don't test for yourself
{
if ((spawn_sprite->spr.pos.XY() - opp->PlayerNowPosition.XY()).Length() < 62.25)
if ((spawn_sprite->spr.pos.XY() - opp->posXY()).Length() < 62.25)
{
blocked = true;
break;

View file

@ -2027,7 +2027,7 @@ void OperateTripTrigger(PLAYER* pp)
{
if (actor->user.Flags & (SPR_WAIT_FOR_TRIGGER))
{
if ((actor->spr.pos.XY() - pp->PlayerNowPosition.XY()).Length() < dist)
if ((actor->spr.pos.XY() - pp->posXY()).Length() < dist)
{
actor->user.targetActor = pp->actor;
actor->user.Flags &= ~(SPR_WAIT_FOR_TRIGGER);
@ -2178,7 +2178,7 @@ bool NearThings(PLAYER* pp)
if (hit.hitSector == nullptr)
return false;
if ((hit.hitpos.XY() - pp->PlayerNowPosition.XY()).Length() > 93.75)
if ((hit.hitpos.XY() - pp->posXY()).Length() > 93.75)
return false;
// hit a sprite?
@ -2221,7 +2221,7 @@ void NearTagList(NEAR_TAG_INFO* ntip, PLAYER* pp, double z, double dist, int typ
HitInfo near;
neartag(DVector3(pp->PlayerNowPosition.XY(), z), pp->cursector, pp->angle.ang, near, dist, type);
neartag(DVector3(pp->posXY(), z), pp->cursector, pp->angle.ang, near, dist, type);
if (near.hitSector != nullptr)
{
@ -2935,7 +2935,7 @@ void DoSector(void)
}
else
{
double dist = (pp->PlayerNowPosition.XY() - sop->pmid.XY()).Length();
double dist = (pp->posXY() - sop->pmid.XY()).Length();
if (dist < min_dist)
min_dist = dist;
}

View file

@ -599,7 +599,7 @@ void GameInterface::UpdateSounds(void)
if (TEST_BOOL1(rsp))
tang = rsp->spr.angle;
else
tang = (pp->sop_remote->pmid.XY() - pp->PlayerNowPosition.XY()).Angle();
tang = (pp->sop_remote->pmid.XY() - pp->posXY()).Angle();
}
else tang = pp->angle.ang;

View file

@ -1544,7 +1544,7 @@ void PreMapCombineFloors(void)
if (itsect == dasect)
{
pp->PlayerNowPosition += dv;
pp->PlayerPrevPosition.XY() = pp->PlayerOldPosition.XY() = pp->PlayerNowPosition.XY();
pp->PlayerPrevPosition.XY() = pp->PlayerOldPosition.XY() = pp->posXY();
break;
}
}
@ -5134,7 +5134,7 @@ int DoGet(DSWActor* actor)
if (pp->Flags & (PF_DEAD))
continue;
double dist = (pp->PlayerNowPosition.XY() - actor->spr.pos).Length();
double dist = (pp->posXY() - actor->spr.pos).Length();
if ((unsigned)dist > (plActor->user.fRadius() + actor->user.fRadius()))
{
continue;
@ -6181,7 +6181,7 @@ void SpriteControl(void)
pp = &Player[pnum];
// Only update the ones closest
double dist = (pp->PlayerNowPosition.XY() - actor->spr.pos.XY()).Length();
double dist = (pp->posXY() - actor->spr.pos.XY()).Length();
AdjustActiveRange(pp, actor, dist);

View file

@ -1481,7 +1481,7 @@ void MovePlayer(PLAYER* pp, SECTOR_OBJECT* sop, const DVector2& move)
pp->Flags |= (PF_PLAYER_RIDING);
pp->RevolveAng = pp->angle.ang;
pp->Revolve.XY() = pp->PlayerNowPosition.XY();
pp->Revolve.XY() = pp->posXY();
// set the delta angle to 0 when moving
pp->RevolveDeltaAng = nullAngle;
@ -1503,7 +1503,7 @@ void MovePlayer(PLAYER* pp, SECTOR_OBJECT* sop, const DVector2& move)
// moving then you
// know where he was last
pp->RevolveAng = pp->angle.ang;
pp->Revolve.XY() = pp->PlayerNowPosition.XY();
pp->Revolve.XY() = pp->posXY();
// set the delta angle to 0 when moving
pp->RevolveDeltaAng = nullAngle;
@ -1522,7 +1522,7 @@ void MovePlayer(PLAYER* pp, SECTOR_OBJECT* sop, const DVector2& move)
// increment Players delta angle
pp->RevolveDeltaAng += GlobSpeedSO;
pp->PlayerNowPosition.XY() = rotatepoint(sop->pmid.XY(), pp->Revolve.XY(), pp->RevolveDeltaAng);
pp->posXY() = rotatepoint(sop->pmid.XY(), pp->Revolve.XY(), pp->RevolveDeltaAng);
// THIS WAS CAUSING PROLEMS!!!!
// Sectors are still being manipulated so you can end up in a void (-1) sector
@ -3338,7 +3338,7 @@ int ActorFollowTrack(DSWActor* actor, short locktics)
{
pp = &Player[pnum];
if ((actor->spr.pos.XY() - pp->PlayerNowPosition.XY()).Length() < actor->user.Dist)
if ((actor->spr.pos.XY() - pp->posXY()).Length() < actor->user.Dist)
{
actor->user.targetActor = pp->actor;
actor->user.Flags &= ~(SPR_WAIT_FOR_PLAYER);

View file

@ -12228,7 +12228,7 @@ int InitSwordAttack(PLAYER* pp)
if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY))
continue;
double dist = (pp->PlayerNowPosition.XY() - itActor->spr.pos.XY()).Length();
double dist = (pp->posXY() - itActor->spr.pos.XY()).Length();
face = mapangle(200);
@ -12393,7 +12393,7 @@ int InitFistAttack(PLAYER* pp)
if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY))
continue;
double dist = (pp->PlayerNowPosition.XY() - itActor->spr.pos.XY()).Length();
double dist = (pp->posXY() - itActor->spr.pos.XY()).Length();
bool iactive = pp->InventoryActive[2];
if (iactive) // Shadow Bombs give you demon fist
{
@ -14024,7 +14024,7 @@ int InitMicro(PLAYER* pp)
{
picked = ts->actor;
angle = (picked->spr.pos.XY() - pp->PlayerNowPosition.XY()).Angle();
angle = (picked->spr.pos.XY() - pp->posXY()).Angle();
ts++;
}
@ -15530,7 +15530,7 @@ int InitUzi(PLAYER* pp)
DVector3 vect(daang.ToVector() * dax, daz);
FAFhitscan(DVector3(pp->PlayerNowPosition.XY(), nz), pp->cursector, vect, hit, CLIPMASK_MISSILE);
FAFhitscan(DVector3(pp->posXY(), nz), pp->cursector, vect, hit, CLIPMASK_MISSILE);
if (hit.hitSector == nullptr)
{
@ -18234,7 +18234,7 @@ int DoFloorBlood(DSWActor* actor)
{
pp = &Player[pnum];
double dist = (actor->spr.pos.XY() - pp->PlayerNowPosition.XY()).Length();
double dist = (actor->spr.pos.XY() - pp->posXY()).Length();
if (dist < FEET_IN_BLOOD_DIST)
{