From 6476430be6206cc2f59ae2e83b32f49206c9ce23 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 7 Oct 2020 18:08:57 +1100 Subject: [PATCH] - SW: Cut `q16horiz`/`q16horizoff` over to PlayerHorizon struct. --- source/sw/src/draw.cpp | 33 ++++++++-------- source/sw/src/game.h | 5 ++- source/sw/src/input.cpp | 7 +++- source/sw/src/jsector.cpp | 2 +- source/sw/src/jweapon.cpp | 10 ++--- source/sw/src/osdcmds.cpp | 2 +- source/sw/src/player.cpp | 41 ++++++++++---------- source/sw/src/predict.cpp | 11 +++--- source/sw/src/weapon.cpp | 81 +++++++++++++++++++-------------------- 9 files changed, 98 insertions(+), 94 deletions(-) diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 8534ef589..bb692e2ef 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1259,7 +1259,7 @@ void DrawCrosshair(PLAYERp pp) } } -void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fixed_t *tq16ang, fixed_t *tq16horiz) +void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fixed_t *tq16ang, fixedhoriz *thoriz) { int i,nexti; short ang; @@ -1326,9 +1326,9 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fixed_t zvect = 0; // new horiz to player - *tq16horiz = clamp(-(zvect << 8), gi->playerHorizMin(), gi->playerHorizMax()); + *thoriz = q16horiz(clamp(-(zvect << 8), gi->playerHorizMin(), gi->playerHorizMax())); - //DSPRINTF(ds,"xvect %d,yvect %d,zvect %d,tq16horiz %d",xvect,yvect,zvect,*tq16horiz); + //DSPRINTF(ds,"xvect %d,yvect %d,zvect %d,thoriz %d",xvect,yvect,zvect,*thoriz.asbuild()); MONO_PRINT(ds); *tq16ang = IntToFixed(ang); @@ -1602,7 +1602,8 @@ drawscreen(PLAYERp pp, double smoothratio) { extern bool CameraTestMode; int tx, ty, tz; - fixed_t tq16horiz, tq16ang, tq16rotscrnang; + fixed_t tq16ang, tq16rotscrnang; + fixedhoriz thoriz; short tsectnum; short i,j; int bob_amt = 0; @@ -1650,15 +1651,13 @@ drawscreen(PLAYERp pp, double smoothratio) fixed_t ang = camerapp->q16ang + camerapp->q16look_ang; tq16ang = oang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(ang + dang - oang) - dang, smoothratio)); - fixed_t ohoriz = camerapp->oq16horiz + camerapp->oq16horizoff; - fixed_t horiz = camerapp->q16horiz + camerapp->q16horizoff; - tq16horiz = ohoriz + xs_CRoundToInt(fmulscale16(horiz - ohoriz, smoothratio)); + thoriz = camerapp->horizon.interpolatedsum(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 + pp->q16horizoff; + thoriz = pp->horizon.sum(); tq16rotscrnang = pp->q16rotscrnang; } tsectnum = camerapp->cursectnum; @@ -1700,7 +1699,7 @@ drawscreen(PLAYERp pp, double smoothratio) tz = tz + quake_z; tx = tx + quake_x; ty = ty + quake_y; - //tq16horiz = tq16horiz + IntToFixed(quake_x); + //thoriz += buildhoriz(quake_x); tq16ang = NORM_Q16ANGLE(tq16ang + IntToFixed(quake_ang)); if (pp->sop_remote) @@ -1715,10 +1714,10 @@ drawscreen(PLAYERp pp, double smoothratio) { tz -= 8448; - if (!BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, tq16horiz)) + if (!BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, thoriz.asq16())) { tz += 8448; - BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, tq16horiz); + BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, thoriz.asq16()); } } else @@ -1727,7 +1726,7 @@ drawscreen(PLAYERp pp, double smoothratio) if (CameraTestMode) { - CameraView(camerapp, &tx, &ty, &tz, &tsectnum, &tq16ang, &tq16horiz); + CameraView(camerapp, &tx, &ty, &tz, &tsectnum, &tq16ang, &thoriz); } } @@ -1740,7 +1739,7 @@ drawscreen(PLAYERp pp, double smoothratio) } // recoil only when not in camera - tq16horiz = clamp(tq16horiz + pp->recoil_horizoff, gi->playerHorizMin(), gi->playerHorizMax()); + thoriz = q16horiz(clamp(thoriz.asq16() + pp->recoil_horizoff, gi->playerHorizMin(), gi->playerHorizMax())); } if (automapMode != am_full)// && !ScreenSavePic) @@ -1753,20 +1752,20 @@ drawscreen(PLAYERp pp, double smoothratio) videoSetCorrectedAspect(); renderSetAspect(xs_CRoundToInt(double(viewingrange)* tan(r_fov* (PI / 360.))), yxaspect); OverlapDraw = true; - DrawOverlapRoom(tx, ty, tz, tq16ang, tq16horiz, tsectnum); + DrawOverlapRoom(tx, ty, tz, tq16ang, thoriz.asq16(), tsectnum); OverlapDraw = false; if (automapMode != am_full)// && !ScreenSavePic) { // TEST this! Changed to camerapp - //JS_DrawMirrors(camerapp, tx, ty, tz, tq16ang, tq16horiz); - JS_DrawMirrors(pp, tx, ty, tz, tq16ang, tq16horiz); + //JS_DrawMirrors(camerapp, tx, ty, tz, tq16ang, thoriz.asq16()); + JS_DrawMirrors(pp, tx, ty, tz, tq16ang, thoriz.asq16()); } // TODO: This call is redundant if the tiled overhead map is shown, but the // HUD elements should be properly outputted with hardware rendering first. if (!FAF_DebugView) - FAF_DrawRooms(tx, ty, tz, tq16ang, tq16horiz, tsectnum); + FAF_DrawRooms(tx, ty, tz, tq16ang, thoriz.asq16(), tsectnum); analyzesprites(tx, ty, tz, false); post_analyzesprites(); diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 10b1d589f..79bde2fbe 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, oq16horizoff, oq16ang; + fixed_t oq16ang; fixed_t oq16look_ang, oq16rotscrnang; // holds last valid move position @@ -882,7 +882,8 @@ struct PLAYERstruct // variables that do not fit into sprite structure int hvel,tilt,tilt_dest; - fixed_t q16horiz, q16horizoff, q16ang; + PlayerHorizon horizon; + fixed_t q16ang; fixed_t q16look_ang, q16rotscrnang; short recoil_amt; short recoil_speed; diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index de3cef46a..fdff8152c 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -230,7 +230,12 @@ void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput) DoPlayerTurnTurret(pp, input.q16avel); } - playerProcessHelpers(&pp->q16ang, &pp->angAdjust, &pp->angTarget, &pp->q16horiz, &pp->horizAdjust, &pp->horizTarget, scaleAdjust); + // temporary vals to pass through to playerProcessHelpers(). + fixed_t horiz = 0; + fixed_t target = 0; + double adjust = 0; + playerProcessHelpers(&pp->q16ang, &pp->angAdjust, &pp->angTarget, &horiz, &adjust, &target, scaleAdjust); + pp->horizon.processhelpers(scaleAdjust); } if (packet) diff --git a/source/sw/src/jsector.cpp b/source/sw/src/jsector.cpp index 184e02aea..fc76c27d3 100644 --- a/source/sw/src/jsector.cpp +++ b/source/sw/src/jsector.cpp @@ -705,7 +705,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz) if (TEST_BOOL11(sp) && numplayers > 1) { - drawroomstotile(cp->posx, cp->posy, cp->posz, cp->q16ang, cp->q16horiz, cp->cursectnum, mirror[cnt].campic); + drawroomstotile(cp->posx, cp->posy, cp->posz, cp->q16ang, cp->horizon.horiz.asq16(), cp->cursectnum, mirror[cnt].campic); } else { diff --git a/source/sw/src/jweapon.cpp b/source/sw/src/jweapon.cpp index 3eb544b71..c8fa13f0b 100644 --- a/source/sw/src/jweapon.cpp +++ b/source/sw/src/jweapon.cpp @@ -1418,10 +1418,10 @@ PlayerInitChemBomb(PLAYERp pp) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) SET(wu->Flags, SPR_UNDERWATER); - wp->zvel = -pp->q16horiz >> 9; + wp->zvel = -pp->horizon.horiz.asq16() >> 9; - // //DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",FixedToInt(pp->q16horiz), FixedToInt(pp->q16horizoff), - // FixedToInt(pp->q16horizoff + pp->q16horiz)); + // //DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d", pp->horizon.horiz.asbuild(), pp->horizon.horizoff.asbuild(), + // pp->horizon.horizoff.asbuild() + pp->horizon.horiz.asbuild()); // MONO_PRINT(ds); oclipdist = pp->SpriteP->clipdist; @@ -1862,7 +1862,7 @@ PlayerInitCaltrops(PLAYERp pp) // They go out at different angles // wp->ang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(50) - 25)); - wp->zvel = -pp->q16horiz >> 9; + wp->zvel = -pp->horizon.horiz.asq16() >> 9; oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; @@ -2496,7 +2496,7 @@ InitShell(int16_t SpriteNum, int16_t ShellNum) if (u->PlayerP) { - wp->z += xs_CRoundToInt(-fmulscale16(u->PlayerP->q16horiz, HORIZ_MULT / 3.)); + wp->z += xs_CRoundToInt(-fmulscale16(u->PlayerP->horizon.horiz.asq16(), HORIZ_MULT / 3.)); } switch (wu->ID) diff --git a/source/sw/src/osdcmds.cpp b/source/sw/src/osdcmds.cpp index c83f51c97..dd673070e 100644 --- a/source/sw/src/osdcmds.cpp +++ b/source/sw/src/osdcmds.cpp @@ -64,7 +64,7 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm) if (parm->numparms == 5) { - Player->oq16horiz = Player->q16horiz = IntToFixed(atoi(parm->parms[4])); + Player->horizon.ohoriz = Player->horizon.horiz = buildhoriz(atoi(parm->parms[4])); } return CCMD_OK; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 54b19ec40..bb4f9bcf5 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1706,29 +1706,29 @@ PlayerAutoLook(PLAYERp pp, double const scaleAdjust) // accordingly if ((pp->cursectnum == tempsect) || (klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))) { - pp->q16horizoff += xs_CRoundToInt(scaleAdjust * ((j - k) * 160)); + pp->horizon.horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * 160))); } } } } - if (TEST(pp->Flags, PF_CLIMBING) && pp->q16horizoff < IntToFixed(100)) + if (TEST(pp->Flags, PF_CLIMBING) && pp->horizon.horizoff.asq16() < IntToFixed(100)) { // tilt when climbing but you can't even really tell it. - pp->q16horizoff += xs_CRoundToInt(scaleAdjust * (((IntToFixed(100) - pp->q16horizoff) >> 3) + FRACUNIT)); + pp->horizon.horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * (((IntToFixed(100) - pp->horizon.horizoff.asq16()) >> 3) + FRACUNIT))); } else { - // Make q16horizoff grow towards 0 since q16horizoff is not modified when you're not on a slope. - if (pp->q16horizoff > 0) + // Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope. + if (pp->horizon.horizoff.asq16() > 0) { - pp->q16horizoff -= xs_CRoundToInt(scaleAdjust * ((pp->q16horizoff >> 3) + FRACUNIT)); - pp->q16horizoff = max(pp->q16horizoff, 0); + pp->horizon.horizoff -= q16horiz(xs_CRoundToInt(scaleAdjust * ((pp->horizon.horizoff.asq16() >> 3) + FRACUNIT))); + pp->horizon.horizoff = q16horiz(max(pp->horizon.horizoff.asq16(), 0)); } - if (pp->q16horizoff < 0) + if (pp->horizon.horizoff.asq16() < 0) { - pp->q16horizoff += xs_CRoundToInt(scaleAdjust * ((pp->q16horizoff >> 3) + FRACUNIT)); - pp->q16horizoff = min(pp->q16horizoff, 0); + pp->horizon.horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((pp->horizon.horizoff.asq16() >> 3) + FRACUNIT))); + pp->horizon.horizoff = q16horiz(min(pp->horizon.horizoff.asq16(), 0)); } } } @@ -1741,7 +1741,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust) PlayerAutoLook(pp, scaleAdjust); // apply default horizon from backend - sethorizon2(&pp->q16horiz, q16horz, &pp->input.actions, scaleAdjust); + sethorizon(&pp->horizon.horiz, q16horz, &pp->input.actions, scaleAdjust); } void @@ -6138,14 +6138,14 @@ DoPlayerBeginDie(PLAYERp pp) void DoPlayerDeathHoriz(PLAYERp pp, short target, short speed) { - if ((pp->q16horiz - IntToFixed(target)) > FRACUNIT) + if ((pp->horizon.horiz.asq16() - IntToFixed(target)) > FRACUNIT) { - playerAddHoriz2(&pp->q16horiz, &pp->horizAdjust, -speed); + pp->horizon.addadjustment(-speed); } - if ((IntToFixed(target) - pp->q16horiz) > FRACUNIT) + if ((IntToFixed(target) - pp->horizon.horiz.asq16()) > FRACUNIT) { - playerAddHoriz2(&pp->q16horiz, &pp->horizAdjust, speed); + pp->horizon.addadjustment(speed); } } @@ -6299,7 +6299,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp) sp->yrepeat = PLAYER_NINJA_YREPEAT; //pp->tilt = 0; - pp->q16horiz = 0; + pp->horizon.horiz = q16horiz(0); DoPlayerResetMovement(pp); u->ID = NINJA_RUN_R0; PlayerDeathReset(pp); @@ -6971,11 +6971,10 @@ MoveSkipSavePos(void) pp->oposy = pp->posy; 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; + pp->horizon.backup(); } // save off stats for skip4 @@ -7352,7 +7351,7 @@ InitAllPlayers(void) //getzsofslope(pfirst->cursectnum, pfirst->posx, pfirst->posy, &cz, &fz); //pfirst->posz = fz - PLAYER_HEIGHT; - pfirst->q16horiz = 0; + pfirst->horizon.horiz = q16horiz(0); // Initialize all [MAX_SW_PLAYERS] arrays here! for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++) @@ -7361,7 +7360,7 @@ InitAllPlayers(void) pp->posy = pp->oposy = pfirst->posy; pp->posz = pp->oposz = pfirst->posz; pp->q16ang = pp->oq16ang = pfirst->q16ang; - pp->q16horiz = pp->oq16horiz = pfirst->q16horiz; + pp->horizon.horiz = pp->horizon.ohoriz = pfirst->horizon.horiz; pp->cursectnum = pfirst->cursectnum; // set like this so that player can trigger something on start of the level pp->lastcursectnum = pfirst->cursectnum+1; @@ -7398,7 +7397,7 @@ InitAllPlayers(void) pp->FadeAmt = 0; pp->FadeTics = 0; pp->StartColor = 0; - pp->q16horizoff = 0; + pp->horizon.horizoff = q16horiz(0); INITLIST(&pp->PanelSpriteList); } diff --git a/source/sw/src/predict.cpp b/source/sw/src/predict.cpp index 991918a2c..998288f44 100644 --- a/source/sw/src/predict.cpp +++ b/source/sw/src/predict.cpp @@ -45,7 +45,8 @@ PLAYERp ppp = &PredictPlayer; typedef struct { int x,y,z; - fixed_t q16horiz, q16ang; + fixed_t q16ang; + fixedhoriz horiz; short filler; } PREDICT, *PREDICTp; @@ -99,7 +100,7 @@ DoPrediction(PLAYERp ppp) ppp->oposx = ppp->posx; ppp->oposy = ppp->posy; ppp->oposz = ppp->posz; - ppp->oq16horiz = ppp->q16horiz; + ppp->horizon.backup(); // go through the player MOVEMENT code only Prediction = true; @@ -117,7 +118,7 @@ DoPrediction(PLAYERp ppp) Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].x = ppp->posx; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].y = ppp->posy; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].z = ppp->posz; - Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].q16horiz = ppp->q16horiz; + Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].horiz = ppp->horizon.horiz; predictmovefifoplc++; #endif } @@ -139,13 +140,13 @@ CorrectPrediction(int actualfifoplc) predict->x == Player[myconnectindex].posx && predict->y == Player[myconnectindex].posy && predict->z == Player[myconnectindex].posz && - predict->q16horiz == Player[myconnectindex].q16horiz + predict->horiz == Player[myconnectindex].horizon.horiz ) { return; } -// //DSPRINTF(ds,"PREDICT ERROR: %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", FixedToInt(predict->q16ang), FixedToInt(Player[myconnectindex].q16ang), predict->x, Player[myconnectindex].posx, predict->y, Player[myconnectindex].posy, predict->z, Player[myconnectindex].posz, FixedToInt(predict->q16horiz),FixedToInt(Player[myconnectindex].q16horiz)); +// //DSPRINTF(ds,"PREDICT ERROR: %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", FixedToInt(predict->q16ang), FixedToInt(Player[myconnectindex].q16ang), predict->x, Player[myconnectindex].posx, predict->y, Player[myconnectindex].posy, predict->z, Player[myconnectindex].posz, predict->horiz.asbuild(), Player[myconnectindex].horizon.horiz.asbuild())); // MONO_PRINT(ds); InitPrediction(&Player[myconnectindex]); diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index 222f32c13..5a93ff0e0 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -12826,7 +12826,7 @@ DoRing(int16_t Weapon) sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14; sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14; if (User[sp->owner]->PlayerP) - sp->z += (u->Dist * (-pp->q16horiz >> 9)) >> 9; + sp->z += (u->Dist * (-pp->horizon.horiz.asq16() >> 9)) >> 9; //sp->ang = NORM_ANGLE(sp->ang + 512); //updatesector(sp->x, sp->y); @@ -12913,7 +12913,7 @@ InitSpellRing(PLAYERp pp) // put it out there sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14; sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14; - sp->z = pp->posz + Z(20) + ((u->Dist * (-pp->q16horiz >> 9)) >> 9); + sp->z = pp->posz + Z(20) + ((u->Dist * (-pp->horizon.horiz.asq16() >> 9)) >> 9); sp->ang = NORM_ANGLE(sp->ang + 512); @@ -13452,7 +13452,7 @@ InitSpellNapalm(PLAYERp pp) sp->xrepeat = 32; sp->yrepeat = 32; sp->clipdist = 0; - sp->zvel = -pp->q16horiz >> 9; + sp->zvel = -pp->horizon.horiz.asq16() >> 9; SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); SET(u->Flags2, SPR2_BLUR_TAPER_FAST); @@ -13607,7 +13607,7 @@ InitSpellMirv(PLAYERp pp) sp->xrepeat = 72; sp->yrepeat = 72; sp->clipdist = 32L >> 2; - sp->zvel = -pp->q16horiz >> 9; + sp->zvel = -pp->horizon.horiz.asq16() >> 9; SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); @@ -13758,7 +13758,7 @@ InitSwordAttack(PLAYERp pp) int daz; daang = FixedToInt(pp->q16ang); - daz = -mulscale16(pp->q16horiz, 2000) + (RANDOM_RANGE(24000) - 12000); + daz = -mulscale16(pp->horizon.horiz.asq16(), 2000) + (RANDOM_RANGE(24000) - 12000); FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang @@ -13948,7 +13948,7 @@ InitFistAttack(PLAYERp pp) int daz; daang = FixedToInt(pp->q16ang); - daz = -mulscale16(pp->q16horiz, 2000) + (RANDOM_RANGE(24000) - 12000); + daz = -mulscale16(pp->horizon.horiz.asq16(), 2000) + (RANDOM_RANGE(24000) - 12000); FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang @@ -14621,7 +14621,7 @@ InitStar(PLAYERp pp) wp->clipdist = 32L >> 2; // wp->zvel was overflowing with this calculation - had to move to a local // long var - zvel = -mulscale16(pp->q16horiz, HORIZ_MULT+STAR_HORIZ_ADJ); + zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT+STAR_HORIZ_ADJ); wu->ceiling_dist = Z(1); wu->floor_dist = Z(1); @@ -14678,7 +14678,7 @@ InitStar(PLAYERp pp) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(np)) SET(nu->Flags, SPR_UNDERWATER); - zvel = -mulscale16(pp->q16horiz, HORIZ_MULT+STAR_HORIZ_ADJ); + zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT+STAR_HORIZ_ADJ); np->zvel = zvel >> 1; if (MissileSetPos(nw, DoStar, 1000)) @@ -14742,7 +14742,7 @@ InitHeartAttack(PLAYERp pp) sp->xrepeat = 52; sp->yrepeat = 52; sp->clipdist = 0; - sp->zvel = -pp->q16horiz >> 9; + sp->zvel = -pp->horizon.horiz.asq16() >> 9; RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); SET(u->Flags2, SPR2_DONT_TARGET_OWNER); SET(sp->cstat, CSTAT_SPRITE_INVISIBLE); @@ -14966,7 +14966,7 @@ InitShotgun(PLAYERp pp) } else { - daz = -mulscale16(pp->q16horiz, 2000); + daz = -mulscale16(pp->horizon.horiz.asq16(), 2000); daang = FixedToInt(pp->q16ang); } @@ -15142,7 +15142,7 @@ InitLaser(PLAYERp pp) wp->clipdist = 64L>>2; // the slower the missile travels the less of a zvel it needs - wp->zvel = -pp->q16horiz >> 11; + wp->zvel = -pp->horizon.horiz.asq16() >> 11; wu->WeaponNum = u->WeaponNum; wu->Radius = 200; @@ -15249,7 +15249,7 @@ InitRail(PLAYERp pp) wp->yrepeat = 52; wp->xrepeat = 52; wp->shade = -15; - zvel = -mulscale16(pp->q16horiz, HORIZ_MULT + 17); + zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT + 17); wu->RotNum = 5; NewStateGroup(w, &sg_Rail[0]); @@ -15450,7 +15450,7 @@ InitRocket(PLAYERp pp) wp->yrepeat = 90; wp->xrepeat = 90; wp->shade = -15; - zvel = -mulscale16(pp->q16horiz, HORIZ_MULT + 35); + zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT + 35); wp->clipdist = 64L>>2; @@ -15581,7 +15581,7 @@ InitBunnyRocket(PLAYERp pp) wp->yrepeat = 64; wp->xrepeat = 64; wp->shade = -15; - zvel = -mulscale16(pp->q16horiz, HORIZ_MULT + 35); + zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT + 35); wp->clipdist = 64L>>2; @@ -15695,7 +15695,7 @@ InitNuke(PLAYERp pp) wp->yrepeat = 128; wp->xrepeat = 128; wp->shade = -15; - zvel = -mulscale16(pp->q16horiz, HORIZ_MULT + 36); + zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT + 36); wp->clipdist = 64L>>2; // Set to red palette @@ -15902,7 +15902,7 @@ InitMicro(PLAYERp pp) wp->yrepeat = 24; wp->xrepeat = 24; wp->shade = -15; - wp->zvel = -pp->q16horiz >> 9; + wp->zvel = -pp->horizon.horiz.asq16() >> 9; wp->clipdist = 64L>>2; // randomize zvelocity @@ -17432,8 +17432,8 @@ InitTracerUzi(PLAYERp pp) nx = pp->posx; ny = pp->posy; //nz = pp->posz + pp->bob_z + Z(8); - //nz = pp->posz + pp->bob_z + Z(8) + -mulscale16(pp->q16horiz, 72); - nz = pp->posz + Z(8) + -mulscale16(pp->q16horiz, 72); + //nz = pp->posz + pp->bob_z + Z(8) + -mulscale16(pp->horizon.horiz.asq16(), 72); + nz = pp->posz + Z(8) + -mulscale16(pp->horizon.horiz.asq16(), 72); // Spawn a shot // Inserting and setting up variables @@ -17451,7 +17451,7 @@ InitTracerUzi(PLAYERp pp) wp->xrepeat = 10; wp->shade = -40; wp->zvel = 0; - //wp->zvel = -pp->q16horiz >> 9; + //wp->zvel = -pp->horizon.horiz.asq16() >> 9; wp->clipdist = 32 >> 2; wu->WeaponNum = u->WeaponNum; @@ -17478,7 +17478,7 @@ InitTracerUzi(PLAYERp pp) return 0; } - wp->zvel = xs_CRoundToInt(-fmulscale16(pp->q16horiz, wp->xvel / 8.)); + wp->zvel = xs_CRoundToInt(-fmulscale16(pp->horizon.horiz.asq16(), wp->xvel / 8.)); pp->SpriteP->clipdist = oclipdist; @@ -17830,7 +17830,7 @@ InitUzi(PLAYERp pp) { //daang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(50) - 25)); daang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(24) - 12)); - daz = -mulscale16(pp->q16horiz, 2000) + (RANDOM_RANGE(24000) - 12000); + daz = -mulscale16(pp->horizon.horiz.asq16(), 2000) + (RANDOM_RANGE(24000) - 12000); } @@ -18005,7 +18005,7 @@ InitEMP(PLAYERp pp) InitTracerUzi(pp); - //daz = nz = pp->posz + Z(8) + -mulscale16(pp->q16horiz, 72); + //daz = nz = pp->posz + Z(8) + -mulscale16(pp->horizon.horiz.asq16(), 72); //daang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(50) - 25)); daz = nz = pp->posz + pp->bob_z; @@ -18015,7 +18015,7 @@ InitEMP(PLAYERp pp) } else { - daz = -mulscale16(pp->q16horiz, 2000); + daz = -mulscale16(pp->horizon.horiz.asq16(), 2000); daang = FixedToInt(pp->q16ang); } @@ -18189,7 +18189,7 @@ InitTankShell(short SpriteNum, PLAYERp pp) SET(wp->cstat, CSTAT_SPRITE_YCENTER); SET(wp->cstat, CSTAT_SPRITE_INVISIBLE); - wp->zvel = xs_CRoundToInt(-fmulscale16(pp->q16horiz, wp->xvel / 8.)); + wp->zvel = xs_CRoundToInt(-fmulscale16(pp->horizon.horiz.asq16(), wp->xvel / 8.)); WeaponAutoAim(sp, w, 64, false); // a bit of randomness @@ -18268,7 +18268,7 @@ InitTurretMicro(short SpriteNum, PLAYERp pp) wp->yrepeat = 24; wp->xrepeat = 24; wp->shade = -15; - wp->zvel = -pp->q16horiz >> 9; + wp->zvel = -pp->horizon.horiz.asq16() >> 9; wp->clipdist = 64L>>2; // randomize zvelocity @@ -18349,7 +18349,7 @@ InitTurretRocket(short SpriteNum, PLAYERp pp) SET(wu->Flags2, SPR2_SO_MISSILE); SET(wp->cstat, CSTAT_SPRITE_YCENTER); - wp->zvel = xs_CRoundToInt(-fmulscale16(pp->q16horiz, wp->xvel / 8.)); + wp->zvel = xs_CRoundToInt(-fmulscale16(pp->horizon.horiz.asq16(), wp->xvel / 8.)); WeaponAutoAim(sp, w, 64, false); // a bit of randomness @@ -18396,7 +18396,7 @@ InitTurretFireball(short SpriteNum, PLAYERp pp) SET(wu->Flags2, SPR2_SO_MISSILE); SET(wp->cstat, CSTAT_SPRITE_YCENTER); - wp->zvel = xs_CRoundToInt(-fmulscale16(pp->q16horiz, wp->xvel / 8.)); + wp->zvel = xs_CRoundToInt(-fmulscale16(pp->horizon.horiz.asq16(), wp->xvel / 8.)); WeaponAutoAim(sp, w, 64, false); // a bit of randomness @@ -18445,7 +18445,7 @@ InitTurretRail(short SpriteNum, PLAYERp pp) wp->yrepeat = 52; wp->xrepeat = 52; wp->shade = -15; - wp->zvel = -pp->q16horiz >> 9; + wp->zvel = -pp->horizon.horiz.asq16() >> 9; wu->RotNum = 5; NewStateGroup(w, &sg_Rail[0]); @@ -18505,7 +18505,7 @@ InitTurretLaser(short SpriteNum, PLAYERp pp) wp->shade = -15; // the slower the missile travels the less of a zvel it needs - wp->zvel = -pp->q16horiz >> 11; + wp->zvel = -pp->horizon.horiz.asq16() >> 11; wu->Radius = 200; wu->ceiling_dist = Z(1); @@ -18551,7 +18551,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp) nsect = sp->sectnum; if (RANDOM_P2(1024) < 200) - InitTracerTurret(sp - sprite, pp->PlayerSprite, FixedToInt(pp->q16horiz)); + InitTracerTurret(sp - sprite, pp->PlayerSprite, pp->horizon.horiz.asq16()); daang = 64; if (WeaponAutoAimHitscan(sp, &daz, &daang, false) != -1) @@ -18561,12 +18561,11 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp) } else { - fixed_t q16horiz = pp->q16horiz; - fixed_t horizmin = IntToFixed(75); - if (q16horiz < horizmin) - q16horiz = horizmin; + auto horizmin = 75; + if (pp->horizon.horiz.asbuild() < horizmin) + pp->horizon.settarget(horizmin); - daz = -mulscale16(pp->q16horiz, 2000) + (RANDOM_RANGE(Z(80)) - Z(40)); + daz = -mulscale16(pp->horizon.horiz.asq16(), 2000) + (RANDOM_RANGE(Z(80)) - Z(40)); daang = sp->ang; } @@ -19304,9 +19303,9 @@ InitGrenade(PLAYERp pp) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) SET(wu->Flags, SPR_UNDERWATER); - wp->zvel = -pp->q16horiz >> 9; + wp->zvel = -pp->horizon.horiz.asq16() >> 9; - ////DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",FixedToInt(pp->q16horiz), FixedToInt(pp->q16horizoff), FixedToInt(pp->q16horizoff + pp->q16horiz)); + ////DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d", pp->horizon.horiz.asbuild()), pp->horizon.horizoff.asbuild()), pp->horizon.horizoff.asbuild() + pp->horizon.horiz.asbuild()); //MONO_PRINT(ds); oclipdist = pp->SpriteP->clipdist; @@ -19451,7 +19450,7 @@ InitMine(PLAYERp pp) wp->xrepeat = 32; wp->shade = -15; wp->clipdist = 128L>>2; - wp->zvel = -pp->q16horiz >> 9; + wp->zvel = -pp->horizon.horiz.asq16() >> 9; wu->WeaponNum = u->WeaponNum; wu->Radius = 200; wu->ceiling_dist = Z(5); @@ -19464,7 +19463,7 @@ InitMine(PLAYERp pp) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) SET(wu->Flags, SPR_UNDERWATER); - //wp->zvel = -pp->q16horiz >> 9; + //wp->zvel = -pp->horizon.horiz.asq16() >> 9; MissileSetPos(w, DoMine, 800); @@ -19617,8 +19616,8 @@ InitFireball(PLAYERp pp) wu->ceiling_dist = Z(6); wu->floor_dist = Z(6); - //zvel = -mulscale16(pp->q16horiz, 100 + ADJUST); - zvel = -mulscale16(pp->q16horiz, 240); + //zvel = -mulscale16(pp->horizon.horiz.asq16(), 100 + ADJUST); + zvel = -mulscale16(pp->horizon.horiz.asq16(), 240); //wu->RotNum = 5; //NewStateGroup(w, &sg_Fireball);