- SW: Cut q16horiz/q16horizoff over to PlayerHorizon struct.

This commit is contained in:
Mitchell Richters 2020-10-07 18:08:57 +11:00
parent 6da756cc9f
commit 6476430be6
9 changed files with 98 additions and 94 deletions

View file

@ -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; int i,nexti;
short ang; short ang;
@ -1326,9 +1326,9 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fixed_t
zvect = 0; zvect = 0;
// new horiz to player // 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); MONO_PRINT(ds);
*tq16ang = IntToFixed(ang); *tq16ang = IntToFixed(ang);
@ -1602,7 +1602,8 @@ drawscreen(PLAYERp pp, double smoothratio)
{ {
extern bool CameraTestMode; extern bool CameraTestMode;
int tx, ty, tz; int tx, ty, tz;
fixed_t tq16horiz, tq16ang, tq16rotscrnang; fixed_t tq16ang, tq16rotscrnang;
fixedhoriz thoriz;
short tsectnum; short tsectnum;
short i,j; short i,j;
int bob_amt = 0; int bob_amt = 0;
@ -1650,15 +1651,13 @@ drawscreen(PLAYERp pp, double smoothratio)
fixed_t ang = camerapp->q16ang + camerapp->q16look_ang; fixed_t ang = camerapp->q16ang + camerapp->q16look_ang;
tq16ang = oang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(ang + dang - oang) - dang, smoothratio)); tq16ang = oang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(ang + dang - oang) - dang, smoothratio));
fixed_t ohoriz = camerapp->oq16horiz + camerapp->oq16horizoff; thoriz = camerapp->horizon.interpolatedsum(smoothratio);
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)); tq16rotscrnang = camerapp->oq16rotscrnang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16rotscrnang + dang - camerapp->oq16rotscrnang) - dang, smoothratio));
} }
else else
{ {
tq16ang = pp->q16ang + pp->q16look_ang; tq16ang = pp->q16ang + pp->q16look_ang;
tq16horiz = pp->q16horiz + pp->q16horizoff; thoriz = pp->horizon.sum();
tq16rotscrnang = pp->q16rotscrnang; tq16rotscrnang = pp->q16rotscrnang;
} }
tsectnum = camerapp->cursectnum; tsectnum = camerapp->cursectnum;
@ -1700,7 +1699,7 @@ drawscreen(PLAYERp pp, double smoothratio)
tz = tz + quake_z; tz = tz + quake_z;
tx = tx + quake_x; tx = tx + quake_x;
ty = ty + quake_y; ty = ty + quake_y;
//tq16horiz = tq16horiz + IntToFixed(quake_x); //thoriz += buildhoriz(quake_x);
tq16ang = NORM_Q16ANGLE(tq16ang + IntToFixed(quake_ang)); tq16ang = NORM_Q16ANGLE(tq16ang + IntToFixed(quake_ang));
if (pp->sop_remote) if (pp->sop_remote)
@ -1715,10 +1714,10 @@ drawscreen(PLAYERp pp, double smoothratio)
{ {
tz -= 8448; tz -= 8448;
if (!BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, tq16horiz)) if (!BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, thoriz.asq16()))
{ {
tz += 8448; tz += 8448;
BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, tq16horiz); BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, thoriz.asq16());
} }
} }
else else
@ -1727,7 +1726,7 @@ drawscreen(PLAYERp pp, double smoothratio)
if (CameraTestMode) 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 // 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) if (automapMode != am_full)// && !ScreenSavePic)
@ -1753,20 +1752,20 @@ drawscreen(PLAYERp pp, double smoothratio)
videoSetCorrectedAspect(); videoSetCorrectedAspect();
renderSetAspect(xs_CRoundToInt(double(viewingrange)* tan(r_fov* (PI / 360.))), yxaspect); renderSetAspect(xs_CRoundToInt(double(viewingrange)* tan(r_fov* (PI / 360.))), yxaspect);
OverlapDraw = true; OverlapDraw = true;
DrawOverlapRoom(tx, ty, tz, tq16ang, tq16horiz, tsectnum); DrawOverlapRoom(tx, ty, tz, tq16ang, thoriz.asq16(), tsectnum);
OverlapDraw = false; OverlapDraw = false;
if (automapMode != am_full)// && !ScreenSavePic) if (automapMode != am_full)// && !ScreenSavePic)
{ {
// TEST this! Changed to camerapp // TEST this! Changed to camerapp
//JS_DrawMirrors(camerapp, tx, ty, tz, tq16ang, tq16horiz); //JS_DrawMirrors(camerapp, tx, ty, tz, tq16ang, thoriz.asq16());
JS_DrawMirrors(pp, tx, ty, tz, tq16ang, tq16horiz); JS_DrawMirrors(pp, tx, ty, tz, tq16ang, thoriz.asq16());
} }
// TODO: This call is redundant if the tiled overhead map is shown, but the // TODO: This call is redundant if the tiled overhead map is shown, but the
// HUD elements should be properly outputted with hardware rendering first. // HUD elements should be properly outputted with hardware rendering first.
if (!FAF_DebugView) 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); analyzesprites(tx, ty, tz, false);
post_analyzesprites(); post_analyzesprites();

View file

@ -831,7 +831,7 @@ struct PLAYERstruct
// interpolation // interpolation
int int
oposx, oposy, oposz; oposx, oposy, oposz;
fixed_t oq16horiz, oq16horizoff, oq16ang; fixed_t oq16ang;
fixed_t oq16look_ang, oq16rotscrnang; fixed_t oq16look_ang, oq16rotscrnang;
// holds last valid move position // holds last valid move position
@ -882,7 +882,8 @@ struct PLAYERstruct
// variables that do not fit into sprite structure // variables that do not fit into sprite structure
int hvel,tilt,tilt_dest; int hvel,tilt,tilt_dest;
fixed_t q16horiz, q16horizoff, q16ang; PlayerHorizon horizon;
fixed_t q16ang;
fixed_t q16look_ang, q16rotscrnang; fixed_t q16look_ang, q16rotscrnang;
short recoil_amt; short recoil_amt;
short recoil_speed; short recoil_speed;

View file

@ -230,7 +230,12 @@ void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput)
DoPlayerTurnTurret(pp, input.q16avel); 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) if (packet)

View file

@ -705,7 +705,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz)
if (TEST_BOOL11(sp) && numplayers > 1) 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 else
{ {

View file

@ -1418,10 +1418,10 @@ PlayerInitChemBomb(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER); 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), // //DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d", pp->horizon.horiz.asbuild(), pp->horizon.horizoff.asbuild(),
// FixedToInt(pp->q16horizoff + pp->q16horiz)); // pp->horizon.horizoff.asbuild() + pp->horizon.horiz.asbuild());
// MONO_PRINT(ds); // MONO_PRINT(ds);
oclipdist = pp->SpriteP->clipdist; oclipdist = pp->SpriteP->clipdist;
@ -1862,7 +1862,7 @@ PlayerInitCaltrops(PLAYERp pp)
// They go out at different angles // They go out at different angles
// wp->ang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(50) - 25)); // 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; oclipdist = pp->SpriteP->clipdist;
pp->SpriteP->clipdist = 0; pp->SpriteP->clipdist = 0;
@ -2496,7 +2496,7 @@ InitShell(int16_t SpriteNum, int16_t ShellNum)
if (u->PlayerP) 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) switch (wu->ID)

View file

@ -64,7 +64,7 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
if (parm->numparms == 5) 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; return CCMD_OK;

View file

@ -1706,29 +1706,29 @@ PlayerAutoLook(PLAYERp pp, double const scaleAdjust)
// accordingly // accordingly
if ((pp->cursectnum == tempsect) || (klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))) 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. // 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 else
{ {
// Make q16horizoff grow towards 0 since q16horizoff is not modified when you're not on a slope. // Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
if (pp->q16horizoff > 0) if (pp->horizon.horizoff.asq16() > 0)
{ {
pp->q16horizoff -= xs_CRoundToInt(scaleAdjust * ((pp->q16horizoff >> 3) + FRACUNIT)); pp->horizon.horizoff -= q16horiz(xs_CRoundToInt(scaleAdjust * ((pp->horizon.horizoff.asq16() >> 3) + FRACUNIT)));
pp->q16horizoff = max(pp->q16horizoff, 0); 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->horizon.horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((pp->horizon.horizoff.asq16() >> 3) + FRACUNIT)));
pp->q16horizoff = min(pp->q16horizoff, 0); 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); PlayerAutoLook(pp, scaleAdjust);
// apply default horizon from backend // apply default horizon from backend
sethorizon2(&pp->q16horiz, q16horz, &pp->input.actions, scaleAdjust); sethorizon(&pp->horizon.horiz, q16horz, &pp->input.actions, scaleAdjust);
} }
void void
@ -6138,14 +6138,14 @@ DoPlayerBeginDie(PLAYERp pp)
void void
DoPlayerDeathHoriz(PLAYERp pp, short target, short speed) 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; sp->yrepeat = PLAYER_NINJA_YREPEAT;
//pp->tilt = 0; //pp->tilt = 0;
pp->q16horiz = 0; pp->horizon.horiz = q16horiz(0);
DoPlayerResetMovement(pp); DoPlayerResetMovement(pp);
u->ID = NINJA_RUN_R0; u->ID = NINJA_RUN_R0;
PlayerDeathReset(pp); PlayerDeathReset(pp);
@ -6971,11 +6971,10 @@ MoveSkipSavePos(void)
pp->oposy = pp->posy; pp->oposy = pp->posy;
pp->oposz = pp->posz; pp->oposz = pp->posz;
pp->oq16ang = pp->q16ang; pp->oq16ang = pp->q16ang;
pp->oq16horiz = pp->q16horiz;
pp->oq16horizoff = pp->q16horizoff;
pp->obob_z = pp->bob_z; pp->obob_z = pp->bob_z;
pp->oq16look_ang = pp->q16look_ang; pp->oq16look_ang = pp->q16look_ang;
pp->oq16rotscrnang = pp->q16rotscrnang; pp->oq16rotscrnang = pp->q16rotscrnang;
pp->horizon.backup();
} }
// save off stats for skip4 // save off stats for skip4
@ -7352,7 +7351,7 @@ InitAllPlayers(void)
//getzsofslope(pfirst->cursectnum, pfirst->posx, pfirst->posy, &cz, &fz); //getzsofslope(pfirst->cursectnum, pfirst->posx, pfirst->posy, &cz, &fz);
//pfirst->posz = fz - PLAYER_HEIGHT; //pfirst->posz = fz - PLAYER_HEIGHT;
pfirst->q16horiz = 0; pfirst->horizon.horiz = q16horiz(0);
// Initialize all [MAX_SW_PLAYERS] arrays here! // Initialize all [MAX_SW_PLAYERS] arrays here!
for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++) for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++)
@ -7361,7 +7360,7 @@ InitAllPlayers(void)
pp->posy = pp->oposy = pfirst->posy; pp->posy = pp->oposy = pfirst->posy;
pp->posz = pp->oposz = pfirst->posz; pp->posz = pp->oposz = pfirst->posz;
pp->q16ang = pp->oq16ang = pfirst->q16ang; 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; pp->cursectnum = pfirst->cursectnum;
// set like this so that player can trigger something on start of the level // set like this so that player can trigger something on start of the level
pp->lastcursectnum = pfirst->cursectnum+1; pp->lastcursectnum = pfirst->cursectnum+1;
@ -7398,7 +7397,7 @@ InitAllPlayers(void)
pp->FadeAmt = 0; pp->FadeAmt = 0;
pp->FadeTics = 0; pp->FadeTics = 0;
pp->StartColor = 0; pp->StartColor = 0;
pp->q16horizoff = 0; pp->horizon.horizoff = q16horiz(0);
INITLIST(&pp->PanelSpriteList); INITLIST(&pp->PanelSpriteList);
} }

View file

@ -45,7 +45,8 @@ PLAYERp ppp = &PredictPlayer;
typedef struct typedef struct
{ {
int x,y,z; int x,y,z;
fixed_t q16horiz, q16ang; fixed_t q16ang;
fixedhoriz horiz;
short filler; short filler;
} PREDICT, *PREDICTp; } PREDICT, *PREDICTp;
@ -99,7 +100,7 @@ DoPrediction(PLAYERp ppp)
ppp->oposx = ppp->posx; ppp->oposx = ppp->posx;
ppp->oposy = ppp->posy; ppp->oposy = ppp->posy;
ppp->oposz = ppp->posz; ppp->oposz = ppp->posz;
ppp->oq16horiz = ppp->q16horiz; ppp->horizon.backup();
// go through the player MOVEMENT code only // go through the player MOVEMENT code only
Prediction = true; Prediction = true;
@ -117,7 +118,7 @@ DoPrediction(PLAYERp ppp)
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].x = ppp->posx; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].x = ppp->posx;
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].y = ppp->posy; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].y = ppp->posy;
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].z = ppp->posz; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].z = ppp->posz;
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].q16horiz = ppp->q16horiz; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].horiz = ppp->horizon.horiz;
predictmovefifoplc++; predictmovefifoplc++;
#endif #endif
} }
@ -139,13 +140,13 @@ CorrectPrediction(int actualfifoplc)
predict->x == Player[myconnectindex].posx && predict->x == Player[myconnectindex].posx &&
predict->y == Player[myconnectindex].posy && predict->y == Player[myconnectindex].posy &&
predict->z == Player[myconnectindex].posz && predict->z == Player[myconnectindex].posz &&
predict->q16horiz == Player[myconnectindex].q16horiz predict->horiz == Player[myconnectindex].horizon.horiz
) )
{ {
return; 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); // MONO_PRINT(ds);
InitPrediction(&Player[myconnectindex]); InitPrediction(&Player[myconnectindex]);

View file

@ -12826,7 +12826,7 @@ DoRing(int16_t Weapon)
sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14; sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14;
sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14; sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14;
if (User[sp->owner]->PlayerP) 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); //sp->ang = NORM_ANGLE(sp->ang + 512);
//updatesector(sp->x, sp->y); //updatesector(sp->x, sp->y);
@ -12913,7 +12913,7 @@ InitSpellRing(PLAYERp pp)
// put it out there // put it out there
sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14; sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14;
sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 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); sp->ang = NORM_ANGLE(sp->ang + 512);
@ -13452,7 +13452,7 @@ InitSpellNapalm(PLAYERp pp)
sp->xrepeat = 32; sp->xrepeat = 32;
sp->yrepeat = 32; sp->yrepeat = 32;
sp->clipdist = 0; sp->clipdist = 0;
sp->zvel = -pp->q16horiz >> 9; sp->zvel = -pp->horizon.horiz.asq16() >> 9;
SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER);
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
SET(u->Flags2, SPR2_BLUR_TAPER_FAST); SET(u->Flags2, SPR2_BLUR_TAPER_FAST);
@ -13607,7 +13607,7 @@ InitSpellMirv(PLAYERp pp)
sp->xrepeat = 72; sp->xrepeat = 72;
sp->yrepeat = 72; sp->yrepeat = 72;
sp->clipdist = 32L >> 2; 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); SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER);
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
@ -13758,7 +13758,7 @@ InitSwordAttack(PLAYERp pp)
int daz; int daz;
daang = FixedToInt(pp->q16ang); 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 FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
@ -13948,7 +13948,7 @@ InitFistAttack(PLAYERp pp)
int daz; int daz;
daang = FixedToInt(pp->q16ang); 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 FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
@ -14621,7 +14621,7 @@ InitStar(PLAYERp pp)
wp->clipdist = 32L >> 2; wp->clipdist = 32L >> 2;
// wp->zvel was overflowing with this calculation - had to move to a local // wp->zvel was overflowing with this calculation - had to move to a local
// long var // 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->ceiling_dist = Z(1);
wu->floor_dist = Z(1); wu->floor_dist = Z(1);
@ -14678,7 +14678,7 @@ InitStar(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(np)) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(np))
SET(nu->Flags, SPR_UNDERWATER); 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; np->zvel = zvel >> 1;
if (MissileSetPos(nw, DoStar, 1000)) if (MissileSetPos(nw, DoStar, 1000))
@ -14742,7 +14742,7 @@ InitHeartAttack(PLAYERp pp)
sp->xrepeat = 52; sp->xrepeat = 52;
sp->yrepeat = 52; sp->yrepeat = 52;
sp->clipdist = 0; 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); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
SET(u->Flags2, SPR2_DONT_TARGET_OWNER); SET(u->Flags2, SPR2_DONT_TARGET_OWNER);
SET(sp->cstat, CSTAT_SPRITE_INVISIBLE); SET(sp->cstat, CSTAT_SPRITE_INVISIBLE);
@ -14966,7 +14966,7 @@ InitShotgun(PLAYERp pp)
} }
else else
{ {
daz = -mulscale16(pp->q16horiz, 2000); daz = -mulscale16(pp->horizon.horiz.asq16(), 2000);
daang = FixedToInt(pp->q16ang); daang = FixedToInt(pp->q16ang);
} }
@ -15142,7 +15142,7 @@ InitLaser(PLAYERp pp)
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
// the slower the missile travels the less of a zvel it needs // 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->WeaponNum = u->WeaponNum;
wu->Radius = 200; wu->Radius = 200;
@ -15249,7 +15249,7 @@ InitRail(PLAYERp pp)
wp->yrepeat = 52; wp->yrepeat = 52;
wp->xrepeat = 52; wp->xrepeat = 52;
wp->shade = -15; wp->shade = -15;
zvel = -mulscale16(pp->q16horiz, HORIZ_MULT + 17); zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT + 17);
wu->RotNum = 5; wu->RotNum = 5;
NewStateGroup(w, &sg_Rail[0]); NewStateGroup(w, &sg_Rail[0]);
@ -15450,7 +15450,7 @@ InitRocket(PLAYERp pp)
wp->yrepeat = 90; wp->yrepeat = 90;
wp->xrepeat = 90; wp->xrepeat = 90;
wp->shade = -15; wp->shade = -15;
zvel = -mulscale16(pp->q16horiz, HORIZ_MULT + 35); zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT + 35);
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
@ -15581,7 +15581,7 @@ InitBunnyRocket(PLAYERp pp)
wp->yrepeat = 64; wp->yrepeat = 64;
wp->xrepeat = 64; wp->xrepeat = 64;
wp->shade = -15; wp->shade = -15;
zvel = -mulscale16(pp->q16horiz, HORIZ_MULT + 35); zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT + 35);
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
@ -15695,7 +15695,7 @@ InitNuke(PLAYERp pp)
wp->yrepeat = 128; wp->yrepeat = 128;
wp->xrepeat = 128; wp->xrepeat = 128;
wp->shade = -15; wp->shade = -15;
zvel = -mulscale16(pp->q16horiz, HORIZ_MULT + 36); zvel = -mulscale16(pp->horizon.horiz.asq16(), HORIZ_MULT + 36);
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
// Set to red palette // Set to red palette
@ -15902,7 +15902,7 @@ InitMicro(PLAYERp pp)
wp->yrepeat = 24; wp->yrepeat = 24;
wp->xrepeat = 24; wp->xrepeat = 24;
wp->shade = -15; wp->shade = -15;
wp->zvel = -pp->q16horiz >> 9; wp->zvel = -pp->horizon.horiz.asq16() >> 9;
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
// randomize zvelocity // randomize zvelocity
@ -17432,8 +17432,8 @@ InitTracerUzi(PLAYERp pp)
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
//nz = pp->posz + pp->bob_z + Z(8); //nz = pp->posz + pp->bob_z + Z(8);
//nz = pp->posz + pp->bob_z + 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->q16horiz, 72); nz = pp->posz + Z(8) + -mulscale16(pp->horizon.horiz.asq16(), 72);
// Spawn a shot // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables
@ -17451,7 +17451,7 @@ InitTracerUzi(PLAYERp pp)
wp->xrepeat = 10; wp->xrepeat = 10;
wp->shade = -40; wp->shade = -40;
wp->zvel = 0; wp->zvel = 0;
//wp->zvel = -pp->q16horiz >> 9; //wp->zvel = -pp->horizon.horiz.asq16() >> 9;
wp->clipdist = 32 >> 2; wp->clipdist = 32 >> 2;
wu->WeaponNum = u->WeaponNum; wu->WeaponNum = u->WeaponNum;
@ -17478,7 +17478,7 @@ InitTracerUzi(PLAYERp pp)
return 0; 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; 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(50) - 25));
daang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(24) - 12)); 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); 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)); //daang = NORM_ANGLE(FixedToInt(pp->q16ang) + (RANDOM_RANGE(50) - 25));
daz = nz = pp->posz + pp->bob_z; daz = nz = pp->posz + pp->bob_z;
@ -18015,7 +18015,7 @@ InitEMP(PLAYERp pp)
} }
else else
{ {
daz = -mulscale16(pp->q16horiz, 2000); daz = -mulscale16(pp->horizon.horiz.asq16(), 2000);
daang = FixedToInt(pp->q16ang); daang = FixedToInt(pp->q16ang);
} }
@ -18189,7 +18189,7 @@ InitTankShell(short SpriteNum, PLAYERp pp)
SET(wp->cstat, CSTAT_SPRITE_YCENTER); SET(wp->cstat, CSTAT_SPRITE_YCENTER);
SET(wp->cstat, CSTAT_SPRITE_INVISIBLE); 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); WeaponAutoAim(sp, w, 64, false);
// a bit of randomness // a bit of randomness
@ -18268,7 +18268,7 @@ InitTurretMicro(short SpriteNum, PLAYERp pp)
wp->yrepeat = 24; wp->yrepeat = 24;
wp->xrepeat = 24; wp->xrepeat = 24;
wp->shade = -15; wp->shade = -15;
wp->zvel = -pp->q16horiz >> 9; wp->zvel = -pp->horizon.horiz.asq16() >> 9;
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
// randomize zvelocity // randomize zvelocity
@ -18349,7 +18349,7 @@ InitTurretRocket(short SpriteNum, PLAYERp pp)
SET(wu->Flags2, SPR2_SO_MISSILE); SET(wu->Flags2, SPR2_SO_MISSILE);
SET(wp->cstat, CSTAT_SPRITE_YCENTER); 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); WeaponAutoAim(sp, w, 64, false);
// a bit of randomness // a bit of randomness
@ -18396,7 +18396,7 @@ InitTurretFireball(short SpriteNum, PLAYERp pp)
SET(wu->Flags2, SPR2_SO_MISSILE); SET(wu->Flags2, SPR2_SO_MISSILE);
SET(wp->cstat, CSTAT_SPRITE_YCENTER); 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); WeaponAutoAim(sp, w, 64, false);
// a bit of randomness // a bit of randomness
@ -18445,7 +18445,7 @@ InitTurretRail(short SpriteNum, PLAYERp pp)
wp->yrepeat = 52; wp->yrepeat = 52;
wp->xrepeat = 52; wp->xrepeat = 52;
wp->shade = -15; wp->shade = -15;
wp->zvel = -pp->q16horiz >> 9; wp->zvel = -pp->horizon.horiz.asq16() >> 9;
wu->RotNum = 5; wu->RotNum = 5;
NewStateGroup(w, &sg_Rail[0]); NewStateGroup(w, &sg_Rail[0]);
@ -18505,7 +18505,7 @@ InitTurretLaser(short SpriteNum, PLAYERp pp)
wp->shade = -15; wp->shade = -15;
// the slower the missile travels the less of a zvel it needs // 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->Radius = 200;
wu->ceiling_dist = Z(1); wu->ceiling_dist = Z(1);
@ -18551,7 +18551,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp)
nsect = sp->sectnum; nsect = sp->sectnum;
if (RANDOM_P2(1024) < 200) if (RANDOM_P2(1024) < 200)
InitTracerTurret(sp - sprite, pp->PlayerSprite, FixedToInt(pp->q16horiz)); InitTracerTurret(sp - sprite, pp->PlayerSprite, pp->horizon.horiz.asq16());
daang = 64; daang = 64;
if (WeaponAutoAimHitscan(sp, &daz, &daang, false) != -1) if (WeaponAutoAimHitscan(sp, &daz, &daang, false) != -1)
@ -18561,12 +18561,11 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp)
} }
else else
{ {
fixed_t q16horiz = pp->q16horiz; auto horizmin = 75;
fixed_t horizmin = IntToFixed(75); if (pp->horizon.horiz.asbuild() < horizmin)
if (q16horiz < horizmin) pp->horizon.settarget(horizmin);
q16horiz = 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; daang = sp->ang;
} }
@ -19304,9 +19303,9 @@ InitGrenade(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER); 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); //MONO_PRINT(ds);
oclipdist = pp->SpriteP->clipdist; oclipdist = pp->SpriteP->clipdist;
@ -19451,7 +19450,7 @@ InitMine(PLAYERp pp)
wp->xrepeat = 32; wp->xrepeat = 32;
wp->shade = -15; wp->shade = -15;
wp->clipdist = 128L>>2; wp->clipdist = 128L>>2;
wp->zvel = -pp->q16horiz >> 9; wp->zvel = -pp->horizon.horiz.asq16() >> 9;
wu->WeaponNum = u->WeaponNum; wu->WeaponNum = u->WeaponNum;
wu->Radius = 200; wu->Radius = 200;
wu->ceiling_dist = Z(5); wu->ceiling_dist = Z(5);
@ -19464,7 +19463,7 @@ InitMine(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER); SET(wu->Flags, SPR_UNDERWATER);
//wp->zvel = -pp->q16horiz >> 9; //wp->zvel = -pp->horizon.horiz.asq16() >> 9;
MissileSetPos(w, DoMine, 800); MissileSetPos(w, DoMine, 800);
@ -19617,8 +19616,8 @@ InitFireball(PLAYERp pp)
wu->ceiling_dist = Z(6); wu->ceiling_dist = Z(6);
wu->floor_dist = Z(6); wu->floor_dist = Z(6);
//zvel = -mulscale16(pp->q16horiz, 100 + ADJUST); //zvel = -mulscale16(pp->horizon.horiz.asq16(), 100 + ADJUST);
zvel = -mulscale16(pp->q16horiz, 240); zvel = -mulscale16(pp->horizon.horiz.asq16(), 240);
//wu->RotNum = 5; //wu->RotNum = 5;
//NewStateGroup(w, &sg_Fireball); //NewStateGroup(w, &sg_Fireball);