From 0e3604ac9e485e4f26e3ad52399e7dcd7db8e1e3 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 7 Oct 2020 13:32:24 +1100 Subject: [PATCH] - SW: Remove `q16horizbase` and apply `q16horizoff` in draw code like Duke & Blood. * Standardisation is needed here for upcoming horizon changes. --- source/sw/src/draw.cpp | 7 +++++-- source/sw/src/game.h | 4 ++-- source/sw/src/player.cpp | 17 ++++------------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 310d3f475..8534ef589 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1649,13 +1649,16 @@ drawscreen(PLAYERp pp, double smoothratio) fixed_t oang = camerapp->oq16ang + camerapp->oq16look_ang; fixed_t ang = camerapp->q16ang + camerapp->q16look_ang; tq16ang = oang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(ang + dang - oang) - dang, smoothratio)); - tq16horiz = camerapp->oq16horiz + xs_CRoundToInt(fmulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio)); + + fixed_t ohoriz = camerapp->oq16horiz + camerapp->oq16horizoff; + fixed_t horiz = camerapp->q16horiz + camerapp->q16horizoff; + tq16horiz = ohoriz + xs_CRoundToInt(fmulscale16(horiz - ohoriz, smoothratio)); tq16rotscrnang = camerapp->oq16rotscrnang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16rotscrnang + dang - camerapp->oq16rotscrnang) - dang, smoothratio)); } else { tq16ang = pp->q16ang + pp->q16look_ang; - tq16horiz = pp->q16horiz; + tq16horiz = pp->q16horiz + pp->q16horizoff; tq16rotscrnang = pp->q16rotscrnang; } tsectnum = camerapp->cursectnum; diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 7638daa19..10b1d589f 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -831,7 +831,7 @@ struct PLAYERstruct // interpolation int oposx, oposy, oposz; - fixed_t oq16horiz, oq16ang; + fixed_t oq16horiz, oq16horizoff, oq16ang; fixed_t oq16look_ang, oq16rotscrnang; // holds last valid move position @@ -882,7 +882,7 @@ struct PLAYERstruct // variables that do not fit into sprite structure int hvel,tilt,tilt_dest; - fixed_t q16horiz, q16horizbase, q16horizoff, q16ang; + fixed_t q16horiz, q16horizoff, q16ang; fixed_t q16look_ang, q16rotscrnang; short recoil_amt; short recoil_speed; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index eb9c7d7fa..41f34b2c5 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1741,16 +1741,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust) PlayerAutoLook(pp, scaleAdjust); // apply default horizon from backend - sethorizon(&pp->q16horizbase, q16horz, &pp->input.actions, scaleAdjust); - - // bound adjust q16horizoff - if (pp->q16horizbase + pp->q16horizoff < gi->playerHorizMin()) - pp->q16horizoff = gi->playerHorizMin() - pp->q16horizbase; - else if (pp->q16horizbase + pp->q16horizoff > gi->playerHorizMax()) - pp->q16horizoff = gi->playerHorizMax() - pp->q16horizbase; - - // add base and offsets - pp->q16horiz = pp->q16horizbase + pp->q16horizoff; + sethorizon(&pp->q16horiz, q16horz, &pp->input.actions, scaleAdjust); } void @@ -6308,7 +6299,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp) sp->yrepeat = PLAYER_NINJA_YREPEAT; //pp->tilt = 0; - pp->q16horiz = pp->q16horizbase = 0; + pp->q16horiz = 0; DoPlayerResetMovement(pp); u->ID = NINJA_RUN_R0; PlayerDeathReset(pp); @@ -6981,6 +6972,7 @@ MoveSkipSavePos(void) pp->oposz = pp->posz; pp->oq16ang = pp->q16ang; pp->oq16horiz = pp->q16horiz; + pp->oq16horizoff = pp->q16horizoff; pp->obob_z = pp->bob_z; pp->oq16look_ang = pp->q16look_ang; pp->oq16rotscrnang = pp->q16rotscrnang; @@ -7360,7 +7352,7 @@ InitAllPlayers(void) //getzsofslope(pfirst->cursectnum, pfirst->posx, pfirst->posy, &cz, &fz); //pfirst->posz = fz - PLAYER_HEIGHT; - pfirst->q16horiz = pfirst->q16horizbase = 0; + pfirst->q16horiz = 0; // Initialize all [MAX_SW_PLAYERS] arrays here! for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++) @@ -7376,7 +7368,6 @@ InitAllPlayers(void) //pp->MaxHealth = 100; - pp->q16horizbase = pfirst->q16horizbase; pp->oldposx = 0; pp->oldposy = 0; pp->climb_ndx = 10;