diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index c87807c4e..2de2e1e04 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1891,11 +1891,6 @@ struct PLAYER } - DVector2& posXY() - { - return actor->spr.pos.XY(); - } - void posSet(const DVector3& val) { actor->spr.pos = val.plusZ(-actor->viewzoffset); @@ -1909,11 +1904,6 @@ struct PLAYER return actor->spr.pos.plusZ(actor->viewzoffset); } - DVector2& posprevXY() - { - return actor->opos.XY(); - } - void posprevSet(const DVector3& val) { actor->opos = val.plusZ(-actor->viewzoffset); diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index 1e525c05a..867f260cf 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -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->posXY()).LengthSquared(); + pdist = (actor->spr.pos.XY() - pp->actor->spr.pos.XY()).LengthSquared(); } else return 0; diff --git a/source/games/sw/src/jsector.cpp b/source/games/sw/src/jsector.cpp index 5547b6d8a..121de73e7 100644 --- a/source/games/sw/src/jsector.cpp +++ b/source/games/sw/src/jsector.cpp @@ -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->posXY(); + auto v = actor->spr.pos.XY() - pp->actor->spr.pos.XY(); double dist = abs(v.X) + abs(v.Y); if (dist <= maxdist) // tag4 = ang diff --git a/source/games/sw/src/mclip.cpp b/source/games/sw/src/mclip.cpp index 7a1b7b59c..5c70b4067 100644 --- a/source/games/sw/src/mclip.cpp +++ b/source/games/sw/src/mclip.cpp @@ -111,7 +111,7 @@ Collision MultiClipMove(PLAYER* pp, double zz, double floordist) } // put posx and y off from offset - pp->posXY() += pos[min_ndx].XY() - opos[min_ndx].XY(); + pp->actor->spr.pos.XY() += 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->posXY() += { -pvect.X * 0.5, pvect.X * 0.5 }; + pp->actor->spr.pos.XY() += { -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->posXY() += { pvect.X * 0.5, -pvect.X * 0.5 }; + pp->actor->spr.pos.XY() += { 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->posXY(), opos[i], rot_angl); + xy[i] = rotatepoint(pp->actor->spr.pos.XY(), opos[i], rot_angl); // cannot use sop->xmid and ymid because the SO is off the map at this point } diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index ff64a0e9d..ebc6a40ff 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1314,7 +1314,7 @@ void DoPlayerTeleportToSprite(PLAYER* pp, DVector3& pos, DAngle ang) pp->angle.ang = pp->angle.oang = ang; pp->posSet(pos.plusZ(-PLAYER_HEIGHTF)); pp->posprevSet(pos.plusZ(-PLAYER_HEIGHTF)); - pp->posoldXY() = pp->posXY(); + pp->posoldXY() = pp->actor->spr.pos.XY(); updatesector(pp->posGet(), &pp->cursector); pp->Flags2 |= (PF2_TELEPORTED); @@ -1328,7 +1328,8 @@ void DoPlayerTeleportToSprite(PLAYER* pp, DVector3& pos, DAngle ang) void DoPlayerTeleportToOffset(PLAYER* pp) { - pp->posoldXY() = pp->posprevXY() = pp->posXY(); + pp->posoldXY() = pp->actor->spr.pos.XY(); + pp->actor->backupvec2(); updatesector(pp->posGet(), &pp->cursector); pp->Flags2 |= (PF2_TELEPORTED); @@ -1682,7 +1683,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->posXY(), pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, scaleAdjust, (pp->Flags & PF_CLIMBING)); + pp->horizon.calcviewpitch(pp->actor->spr.pos.XY(), pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, scaleAdjust, (pp->Flags & PF_CLIMBING)); pp->horizon.applyinput(horz, &pp->input.actions, scaleAdjust); } @@ -1696,7 +1697,7 @@ void DoPlayerBob(PLAYER* pp) { double amt; - double dist = (pp->posXY() - pp->posoldXY()).Length(); + double dist = (pp->actor->spr.pos.XY() - pp->posoldXY()).Length(); if (dist > 32) dist = 0; @@ -2137,7 +2138,7 @@ void DoPlayerMove(PLAYER* pp) auto sect = pp->cursector; if (interpolate_ride) { - pp->posprevXY() = pp->posXY(); + actor->backupvec2(); } pp->posAdd(pp->vect); updatesector(pp->posGet(), §); @@ -2162,7 +2163,7 @@ void DoPlayerMove(PLAYER* pp) if (interpolate_ride) { - pp->posprevXY() = pp->posXY(); + pp->actor->backupvec2(); } auto save_cstat = actor->spr.cstat; @@ -2782,7 +2783,7 @@ void DoPlayerMoveVehicle(PLAYER* pp) } } - OperateSectorObject(pp->sop, pp->angle.ang, pp->posXY()); + OperateSectorObject(pp->sop, pp->angle.ang, pp->actor->spr.pos.XY()); pp->cursector = save_sect; // for speed if (!SyncInput()) @@ -3460,7 +3461,7 @@ int DoPlayerWadeSuperJump(PLAYER* pp) //for (i = 0; i < SIZ(angs); i++) { - FAFhitscan(DVector3(pp->posXY(), zh), pp->cursector, DVector3(pp->angle.ang.ToVector() * 1024, 0), hit, CLIPMASK_MISSILE); + FAFhitscan(DVector3(pp->actor->spr.pos.XY(), zh), pp->cursector, DVector3(pp->angle.ang.ToVector() * 1024, 0), hit, CLIPMASK_MISSILE); if (hit.hitWall != nullptr && hit.hitSector != nullptr) { @@ -3468,7 +3469,7 @@ int DoPlayerWadeSuperJump(PLAYER* pp) if (hit.hitSector != nullptr && abs(hit.hitSector->floorz - pp->actor->getOffsetZ()) < 50) { - double dist = (pp->posXY() - hit.hitpos.XY()).Length(); + double dist = (pp->actor->spr.pos.XY() - hit.hitpos.XY()).Length(); double comp = (pp->actor->clipdist + 16); if (dist < comp) return true; @@ -4168,10 +4169,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->posXY(); + plActor->user.pos.XY() = over_act->spr.pos.XY() - pp->actor->spr.pos.XY(); // update to the new x y position - pp->posXY() = under_act->spr.pos.XY() - plActor->user.pos.XY(); + pp->actor->spr.pos.XY() = under_act->spr.pos.XY() - plActor->user.pos.XY(); auto over = over_act->sector(); auto under = under_act->sector(); @@ -4240,10 +4241,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->posXY(); + plActor->user.pos.XY() = under_act->spr.pos.XY() - pp->actor->spr.pos.XY(); // update to the new x y position - pp->posXY() = over_act->spr.pos.XY() - plActor->user.pos.XY(); + pp->actor->spr.pos.XY() = over_act->spr.pos.XY() - plActor->user.pos.XY(); auto over = over_act->sector(); auto under = under_act->sector(); @@ -5140,7 +5141,7 @@ void DoPlayerBeginOperate(PLAYER* pp) sop->controller = pp->actor; pp->angle.oang = pp->angle.ang = sop->ang; - pp->posXY() = sop->pmid.XY(); + pp->actor->spr.pos.XY() = sop->pmid.XY(); updatesector(pp->posGet(), &pp->cursector); calcSlope(pp->cursector, pp->posGet(), &cz, &fz); pp->setHeightAndZ(fz, PLAYER_HEIGHTF); @@ -5230,7 +5231,7 @@ void DoPlayerBeginRemoteOperate(PLAYER* pp, SECTOR_OBJECT* sop) auto save_sect = pp->cursector; pp->angle.oang = pp->angle.ang = sop->ang; - pp->posXY() = sop->pmid.XY(); + pp->actor->spr.pos.XY() = sop->pmid.XY(); updatesector(pp->posGet(), &pp->cursector); calcSlope(pp->cursector, pp->posGet(), &cz, &fz); pp->setHeightAndZ(fz, PLAYER_HEIGHTF); @@ -5316,7 +5317,7 @@ void PlayerRemoteReset(PLAYER* pp, sectortype* sect) pp->lastcursector = pp->cursector; auto rsp = pp->remoteActor; - pp->posXY() = rsp->spr.pos.XY(); + pp->actor->spr.pos.XY() = rsp->spr.pos.XY(); pp->setHeightAndZ(sect->floorz, PLAYER_HEIGHTF); pp->vect.Zero(); @@ -5353,7 +5354,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->posXY()).Angle(); + pp->angle.ang = pp->angle.oang = (pp->sop_remote->pmid.XY() - pp->actor->spr.pos.XY()).Angle(); } if (pp->sop_control) @@ -5985,7 +5986,7 @@ void DoPlayerDeathFollowKiller(PLAYER* pp) { if (FAFcansee(ActorVectOfTop(killer), killer->sector(), pp->posGet(), pp->cursector)) { - pp->angle.addadjustment(deltaangle(pp->angle.ang, (killer->spr.pos.XY() - pp->posXY()).Angle()) * (1. / 16.)); + pp->angle.addadjustment(deltaangle(pp->angle.ang, (killer->spr.pos.XY() - pp->actor->spr.pos.XY()).Angle()) * (1. / 16.)); } } } @@ -6189,7 +6190,7 @@ void DoPlayerDeathMoveHead(PLAYER* pp) } } - pp->posXY() = plActor->spr.pos.XY(); + pp->actor->spr.pos.XY() = plActor->spr.pos.XY(); pp->setcursector(plActor->sector()); // try to stay in valid area - death sometimes throws you out of the map @@ -6199,13 +6200,13 @@ void DoPlayerDeathMoveHead(PLAYER* pp) { pp->cursector = pp->lv_sector; ChangeActorSect(pp->actor, pp->lv_sector); - pp->posXY() = pp->lv.XY(); - plActor->spr.pos.XY() = pp->posXY(); + pp->actor->spr.pos.XY() = pp->lv.XY(); + plActor->spr.pos.XY() = pp->actor->spr.pos.XY(); } else { pp->lv_sector = sect; - pp->lv.XY() = pp->posXY(); + pp->lv.XY() = pp->actor->spr.pos.XY(); } } @@ -7137,7 +7138,7 @@ int SearchSpawnPosition(PLAYER* pp) if (opp != pp) // don't test for yourself { - if ((spawn_sprite->spr.pos.XY() - opp->posXY()).Length() < 62.25) + if ((spawn_sprite->spr.pos.XY() - opp->actor->spr.pos.XY()).Length() < 62.25) { blocked = true; break; diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index c58cc51f1..689605fcf 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -2027,7 +2027,7 @@ void OperateTripTrigger(PLAYER* pp) { if (actor->user.Flags & (SPR_WAIT_FOR_TRIGGER)) { - if ((actor->spr.pos.XY() - pp->posXY()).Length() < dist) + if ((actor->spr.pos.XY() - pp->actor->spr.pos.XY()).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->posXY()).Length() > 93.75) + if ((hit.hitpos.XY() - pp->actor->spr.pos.XY()).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->posXY(), z), pp->cursector, pp->angle.ang, near, dist, type); + neartag(DVector3(pp->actor->spr.pos.XY(), z), pp->cursector, pp->angle.ang, near, dist, type); if (near.hitSector != nullptr) { @@ -2935,7 +2935,7 @@ void DoSector(void) } else { - double dist = (pp->posXY() - sop->pmid.XY()).Length(); + double dist = (pp->actor->spr.pos.XY() - sop->pmid.XY()).Length(); if (dist < min_dist) min_dist = dist; } diff --git a/source/games/sw/src/sounds.cpp b/source/games/sw/src/sounds.cpp index 5bf9d9525..9306e01b3 100644 --- a/source/games/sw/src/sounds.cpp +++ b/source/games/sw/src/sounds.cpp @@ -599,7 +599,7 @@ void GameInterface::UpdateSounds(void) if (TEST_BOOL1(rsp)) tang = rsp->spr.angle; else - tang = (pp->sop_remote->pmid.XY() - pp->posXY()).Angle(); + tang = (pp->sop_remote->pmid.XY() - pp->actor->spr.pos.XY()).Angle(); } else tang = pp->angle.ang; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index cc63c34f2..770baa1a1 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -1544,7 +1544,8 @@ void PreMapCombineFloors(void) if (itsect == dasect) { pp->posAdd(dv); - pp->posprevXY() = pp->posoldXY() = pp->posXY(); + pp->posoldXY() = pp->actor->spr.pos.XY(); + pp->actor->backupvec2(); break; } } @@ -5134,7 +5135,7 @@ int DoGet(DSWActor* actor) if (pp->Flags & (PF_DEAD)) continue; - double dist = (pp->posXY() - actor->spr.pos).Length(); + double dist = (pp->actor->spr.pos.XY() - actor->spr.pos).Length(); if ((unsigned)dist > (plActor->user.fRadius() + actor->user.fRadius())) { continue; @@ -6181,7 +6182,7 @@ void SpriteControl(void) pp = &Player[pnum]; // Only update the ones closest - double dist = (pp->posXY() - actor->spr.pos.XY()).Length(); + double dist = (pp->actor->spr.pos.XY() - actor->spr.pos.XY()).Length(); AdjustActiveRange(pp, actor, dist); diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index fce49f17f..6afd939a2 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -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->posXY(); + pp->Revolve.XY() = pp->actor->spr.pos.XY(); // 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->posXY(); + pp->Revolve.XY() = pp->actor->spr.pos.XY(); // 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->posXY() = rotatepoint(sop->pmid.XY(), pp->Revolve.XY(), pp->RevolveDeltaAng); + pp->actor->spr.pos.XY() = 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 @@ -3336,7 +3336,7 @@ int ActorFollowTrack(DSWActor* actor, short locktics) { pp = &Player[pnum]; - if ((actor->spr.pos.XY() - pp->posXY()).Length() < actor->user.Dist) + if ((actor->spr.pos.XY() - pp->actor->spr.pos.XY()).Length() < actor->user.Dist) { actor->user.targetActor = pp->actor; actor->user.Flags &= ~(SPR_WAIT_FOR_PLAYER); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index e917218c6..49938e72f 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -12228,7 +12228,7 @@ int InitSwordAttack(PLAYER* pp) if (!(itActor->spr.extra & SPRX_PLAYER_OR_ENEMY)) continue; - double dist = (pp->posXY() - itActor->spr.pos.XY()).Length(); + double dist = (pp->actor->spr.pos.XY() - 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->posXY() - itActor->spr.pos.XY()).Length(); + double dist = (pp->actor->spr.pos.XY() - 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->posXY()).Angle(); + angle = (picked->spr.pos.XY() - pp->actor->spr.pos.XY()).Angle(); ts++; } @@ -15530,7 +15530,7 @@ int InitUzi(PLAYER* pp) DVector3 vect(daang.ToVector() * dax, daz); - FAFhitscan(DVector3(pp->posXY(), nz), pp->cursector, vect, hit, CLIPMASK_MISSILE); + FAFhitscan(DVector3(pp->actor->spr.pos.XY(), 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->posXY()).Length(); + double dist = (actor->spr.pos.XY() - pp->actor->spr.pos.XY()).Length(); if (dist < FEET_IN_BLOOD_DIST) {