From 8912d7d6cc010faf90f8f92767b4604109fdcdc3 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sat, 27 Aug 2022 20:51:50 +1000 Subject: [PATCH] - SW: Change `RevolveAng`, `RevolveDeltaAng` and `GlobSpeedSO` to `DAngle` objects. * For now, SW is as `binangle` free as it can be until other backend parts are changed. --- source/games/sw/src/copysect.cpp | 4 +-- source/games/sw/src/game.h | 4 +-- source/games/sw/src/track.cpp | 36 +++++++++++------------- wadsrc/static/zscript/games/sw/swgame.zs | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/source/games/sw/src/copysect.cpp b/source/games/sw/src/copysect.cpp index a287807ff..28a4057b2 100644 --- a/source/games/sw/src/copysect.cpp +++ b/source/games/sw/src/copysect.cpp @@ -38,7 +38,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -extern int GlobSpeedSO; +extern DAngle GlobSpeedSO; void CopySectorWalls(sectortype* dest_sect, sectortype* src_sect) { @@ -189,7 +189,7 @@ void CopySectorMatch(int match) // update sprites postions so they aren't in the // wrong place for one frame - GlobSpeedSO = 0; + GlobSpeedSO = DAngle::fromDeg(0.); RefreshPoints(sop, 0, 0, true); } } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index ed677d4a1..9854a4e01 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -633,8 +633,8 @@ struct PLAYER fixed_t recoil_ohorizoff, recoil_horizoff; vec3_t Revolve; - int16_t RevolveDeltaAng; - binangle RevolveAng; + DAngle RevolveDeltaAng; + DAngle RevolveAng; int16_t pnum; // carry along the player number diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 2e6af6e97..4cff9d3f4 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -49,7 +49,7 @@ DSWActor* FindNearSprite(DSWActor, short); ANIMATOR NinjaJumpActionFunc; #define ACTOR_STD_JUMP (-384) -int GlobSpeedSO; +DAngle GlobSpeedSO; // determine if moving down the track will get you closer to the player short TrackTowardPlayer(DSWActor* actor, TRACK* t, TRACK_POINT* start_point) @@ -723,10 +723,10 @@ void SectorObjectSetupBounds(SECTOR_OBJECT* sop) if (pp->posx > xlow && pp->posx < xhigh && pp->posy > ylow && pp->posy < yhigh) { - pp->RevolveAng = pp->angle.ang; + pp->RevolveAng = DAngle::fromBam(pp->angle.ang.asbam()); pp->Revolve.X = pp->pos.X; pp->Revolve.Y = pp->pos.Y; - pp->RevolveDeltaAng = 0; + pp->RevolveDeltaAng = DAngle::fromDeg(0.); pp->Flags |= (PF_PLAYER_RIDING); pp->sop_riding = sop; @@ -1514,12 +1514,12 @@ void MovePlayer(PLAYER* pp, SECTOR_OBJECT* sop, int nx, int ny) { pp->Flags |= (PF_PLAYER_RIDING); - pp->RevolveAng = pp->angle.ang; + pp->RevolveAng = DAngle::fromBam(pp->angle.ang.asbam()); pp->Revolve.X = pp->pos.X; pp->Revolve.Y = pp->pos.Y; // set the delta angle to 0 when moving - pp->RevolveDeltaAng = 0; + pp->RevolveDeltaAng = DAngle::fromDeg(0.); } pp->pos.X += nx; @@ -1538,12 +1538,12 @@ void MovePlayer(PLAYER* pp, SECTOR_OBJECT* sop, int nx, int ny) // save the current information so when Player stops // moving then you // know where he was last - pp->RevolveAng = pp->angle.ang; + pp->RevolveAng = DAngle::fromBam(pp->angle.ang.asbam()); pp->Revolve.X = pp->pos.X; pp->Revolve.Y = pp->pos.Y; // set the delta angle to 0 when moving - pp->RevolveDeltaAng = 0; + pp->RevolveDeltaAng = DAngle::fromDeg(0.); } else { @@ -1554,20 +1554,20 @@ void MovePlayer(PLAYER* pp, SECTOR_OBJECT* sop, int nx, int ny) pp->Revolve.Y += ny; // Last known angle is now adjusted by the delta angle - pp->RevolveAng = pp->angle.ang - buildang(pp->RevolveDeltaAng); + pp->RevolveAng = DAngle::fromBam(pp->angle.ang.asbam()) - pp->RevolveDeltaAng; } // increment Players delta angle - pp->RevolveDeltaAng = NORM_ANGLE(pp->RevolveDeltaAng + GlobSpeedSO); + pp->RevolveDeltaAng = (pp->RevolveDeltaAng + GlobSpeedSO).Normalized360(); - rotatepoint(sop->pmid.vec2, *(vec2_t *)&pp->Revolve.X, pp->RevolveDeltaAng, &pp->pos.vec2); + rotatepoint(sop->pmid.vec2, *(vec2_t *)&pp->Revolve.X, pp->RevolveDeltaAng.Buildang(), &pp->pos.vec2); // THIS WAS CAUSING PROLEMS!!!! // Sectors are still being manipulated so you can end up in a void (-1) sector // New angle is formed by taking last known angle and // adjusting by the delta angle - pp->angle.addadjustment(pp->angle.ang - (pp->RevolveAng + buildang(pp->RevolveDeltaAng))); + pp->angle.addadjustment(pp->angle.ang - bamang((pp->RevolveAng + pp->RevolveDeltaAng).BAMs())); UpdatePlayerSprite(pp); } @@ -2204,13 +2204,12 @@ void MoveSectorObjects(SECTOR_OBJECT* sop, short locktics) if (sop->spin_speed) { // ignore delta angle if spinning - GlobSpeedSO = speed; + GlobSpeedSO = DAngle::fromBuild(speed); } else { // The actual delta from the last frame - GlobSpeedSO = speed; - GlobSpeedSO += delta_ang; + GlobSpeedSO = DAngle::fromBuild(speed + delta_ang); } if ((sop->flags & SOBJ_DYNAMIC)) @@ -2224,7 +2223,7 @@ void MoveSectorObjects(SECTOR_OBJECT* sop, short locktics) if ((sop->flags & (SOBJ_UPDATE|SOBJ_UPDATE_ONCE)) || sop->vel || (sop->ang != sop->ang_tgt) || - GlobSpeedSO) + GlobSpeedSO.Degrees()) { sop->flags &= ~(SOBJ_UPDATE_ONCE); RefreshPoints(sop, nx, ny, false); @@ -2600,7 +2599,7 @@ void OperateSectorObjectForTics(SECTOR_OBJECT* sop, short newang, int newx, int } } - GlobSpeedSO = 0; + GlobSpeedSO = DAngle::fromDeg(0.); //sop->ang_tgt = newang; sop->ang_moving = newang; @@ -2683,13 +2682,12 @@ void TornadoSpin(SECTOR_OBJECT* sop) if (sop->spin_speed) { // ignore delta angle if spinning - GlobSpeedSO = speed; + GlobSpeedSO = DAngle::fromBuild(speed); } else { // The actual delta from the last frame - GlobSpeedSO = speed; - GlobSpeedSO += delta_ang; + GlobSpeedSO = DAngle::fromBuild(speed + delta_ang); } } diff --git a/wadsrc/static/zscript/games/sw/swgame.zs b/wadsrc/static/zscript/games/sw/swgame.zs index d5136b3f9..ec0cd6572 100644 --- a/wadsrc/static/zscript/games/sw/swgame.zs +++ b/wadsrc/static/zscript/games/sw/swgame.zs @@ -213,7 +213,7 @@ struct SWPlayer native native int16 recoil_ndx; native int recoil_horizoff; - native int16 RevolveDeltaAng; + native double RevolveDeltaAng; native int16 pnum; // carry along the player number