mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- SW: Get synchronised input going in a testable way. This is not a complete re-factor, just enough to get it going.
* Remove bool `PedanticMode`. * Transition appropriate lines to `cl_syncinput`. * Remove inlines added purely only to maintain DOS demo compatibility. * Fix a few pedantic Q16.16 >> Int >> Q16.16 conversions.
This commit is contained in:
parent
1354d52c05
commit
17da849add
5 changed files with 31 additions and 56 deletions
|
@ -792,7 +792,7 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror)
|
|||
//SET(tsp->cstat, CSTAT_SPRITE_INVISIBLE);
|
||||
}
|
||||
}
|
||||
else if (!PedanticMode) // Otherwise just interpolate the player sprite
|
||||
else // Otherwise just interpolate the player sprite
|
||||
{
|
||||
PLAYERp pp = tu->PlayerP;
|
||||
tsp->x -= mulscale16(pp->posx - pp->oposx, 65536-smoothratio);
|
||||
|
@ -1678,7 +1678,7 @@ drawscreen(PLAYERp pp, double smoothratio)
|
|||
tz = camerapp->oposz + xs_CRoundToInt(fmulscale16(camerapp->posz - camerapp->oposz, smoothratio));
|
||||
// TODO: It'd be better to check pp->input.q16angvel instead, problem is that
|
||||
// it's been repurposed for the q16ang diff while tying input to framerate
|
||||
if (PedanticMode || (pp != Player+myconnectindex) ||
|
||||
if (cl_syncinput || (pp != Player+myconnectindex) ||
|
||||
(TEST(pp->Flags, PF_DEAD) && (loc.q16avel == 0)))
|
||||
{
|
||||
tq16ang = camerapp->oq16ang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16ang + IntToFixed(1024) - camerapp->oq16ang) - IntToFixed(1024), smoothratio));
|
||||
|
@ -1739,7 +1739,7 @@ drawscreen(PLAYERp pp, double smoothratio)
|
|||
if (TEST_BOOL1(pp->remote_sprite))
|
||||
tq16ang = IntToFixed(pp->remote_sprite->ang);
|
||||
else
|
||||
tq16ang = GetQ16AngleFromVect(pp->sop_remote->xmid - tx, pp->sop_remote->ymid - ty);
|
||||
tq16ang = gethiq16angle(pp->sop_remote->xmid - tx, pp->sop_remote->ymid - ty);
|
||||
}
|
||||
|
||||
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
|
||||
|
@ -1759,8 +1759,7 @@ drawscreen(PLAYERp pp, double smoothratio)
|
|||
if (!TEST(pp->Flags, PF_VIEW_FROM_CAMERA|PF_VIEW_FROM_OUTSIDE))
|
||||
{
|
||||
tz += bob_amt;
|
||||
tz += PedanticMode ? camerapp->bob_z :
|
||||
pp->obob_z + xs_CRoundToInt(fmulscale16(pp->bob_z - pp->obob_z, smoothratio));
|
||||
tz += pp->obob_z + xs_CRoundToInt(fmulscale16(pp->bob_z - pp->obob_z, smoothratio));
|
||||
|
||||
// recoil only when not in camera
|
||||
tq16horiz = tq16horiz + IntToFixed(pp->recoil_horizoff);
|
||||
|
|
|
@ -105,8 +105,6 @@ SWBOOL SavegameLoaded = false;
|
|||
SWBOOL FinishedLevel = false;
|
||||
short screenpeek = 0;
|
||||
|
||||
SWBOOL PedanticMode;
|
||||
|
||||
SWBOOL LocationInfo = 0;
|
||||
void drawoverheadmap(int cposx, int cposy, int czoom, short cang);
|
||||
SWBOOL PreCaching = TRUE;
|
||||
|
@ -308,8 +306,6 @@ void InitLevelGlobals(void)
|
|||
sumowasseen = false;
|
||||
zillawasseen = false;
|
||||
memset(BossSpriteNum,-1,sizeof(BossSpriteNum));
|
||||
|
||||
PedanticMode = false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -751,7 +747,7 @@ void GameTicker(void)
|
|||
gameupdatetime.Unclock();
|
||||
|
||||
// Get input again to update q16ang/q16horiz.
|
||||
if (!PedanticMode)
|
||||
if (!cl_syncinput)
|
||||
getinput(&loc, TRUE);
|
||||
|
||||
smoothratio = I_GetTimeFrac() * MaxSmoothRatio;
|
||||
|
|
|
@ -123,8 +123,6 @@ inline int RANDOM(void)
|
|||
|
||||
#include "pragmas.h"
|
||||
|
||||
extern SWBOOL PedanticMode;
|
||||
|
||||
//
|
||||
// Map directions/degrees
|
||||
//
|
||||
|
@ -262,29 +260,12 @@ inline int32_t FIXED(int32_t msw, int32_t lsw)
|
|||
#define ANGLE_2_PLAYER(pp,x,y) (NORM_ANGLE(getangle(pp->posx-(x), pp->posy-(y))))
|
||||
#define NORM_Q16ANGLE(ang) ((ang) & 0x7FFFFFF)
|
||||
|
||||
static fixed_t FORCE_INLINE GetQ16AngleFromVect(int32_t xvect, int32_t yvect)
|
||||
{
|
||||
return (PedanticMode ? getq16angle : gethiq16angle)(xvect, yvect);
|
||||
}
|
||||
|
||||
static fixed_t FORCE_INLINE PedanticQ16AngleFloor(fixed_t ang)
|
||||
{
|
||||
return PedanticMode ? xs_FloorToInt(ang) : ang;
|
||||
}
|
||||
|
||||
int StdRandomRange(int range);
|
||||
#define STD_RANDOM_P2(pwr_of_2) (MOD_P2(rand(),(pwr_of_2)))
|
||||
#define STD_RANDOM_RANGE(range) (StdRandomRange(range))
|
||||
#define STD_RANDOM() (rand())
|
||||
|
||||
#if 0
|
||||
// TODO: PedanticMode
|
||||
#define RANDOM_NEG(x,y) (PedanticMode \
|
||||
? ((RANDOM_P2(((x)<<(y))<<1) - (x))<<(y)) \
|
||||
: (RANDOM_P2(((x)<<(y))<<1) - ((x) <<(y))))
|
||||
#else
|
||||
#define RANDOM_NEG(x,y) ((RANDOM_P2(((x)<<(y))<<1) - (x))<<(y))
|
||||
#endif
|
||||
|
||||
#define MOVEx(vel,ang) (((int)(vel) * (int)sintable[NORM_ANGLE((ang) + 512)]) >> 14)
|
||||
#define MOVEy(vel,ang) (((int)(vel) * (int)sintable[NORM_ANGLE((ang))]) >> 14)
|
||||
|
|
|
@ -196,7 +196,7 @@ getinput(InputPacket *loc, SWBOOL tied)
|
|||
if (buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && pp->sop))
|
||||
{
|
||||
turnheldtime += synctics;
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
{
|
||||
if (turnheldtime >= TURBOTURNTIME)
|
||||
q16angvel -= IntToFixed(turnamount);
|
||||
|
@ -209,7 +209,7 @@ getinput(InputPacket *loc, SWBOOL tied)
|
|||
else if (buttonMap.ButtonDown(gamefunc_Turn_Right) || (buttonMap.ButtonDown(gamefunc_Strafe_Right) && pp->sop))
|
||||
{
|
||||
turnheldtime += synctics;
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
{
|
||||
if (turnheldtime >= TURBOTURNTIME)
|
||||
q16angvel += IntToFixed(turnamount);
|
||||
|
@ -243,10 +243,10 @@ getinput(InputPacket *loc, SWBOOL tied)
|
|||
q16horz = clamp(q16horz, -IntToFixed(MAXHORIZVEL), IntToFixed(MAXHORIZVEL));
|
||||
|
||||
void DoPlayerTeleportPause(PLAYERp pp);
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
{
|
||||
q16angvel = xs_FloorToInt(q16angvel);
|
||||
q16horz = xs_FloorToInt(q16horz);
|
||||
q16angvel = q16angvel;
|
||||
q16horz = q16horz;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1549,7 +1549,7 @@ DoPlayerTurn(PLAYERp pp, fixed_t *pq16ang, fixed_t q16angvel)
|
|||
{
|
||||
#define TURN_SHIFT 2
|
||||
|
||||
if (!PedanticMode && (pq16ang == &pp->q16ang))
|
||||
if (!cl_syncinput && (pq16ang == &pp->q16ang))
|
||||
{
|
||||
SET(pp->Flags2, PF2_INPUT_CAN_TURN);
|
||||
pp->q16ang = pp->input.q16ang;
|
||||
|
@ -1579,8 +1579,8 @@ DoPlayerTurn(PLAYERp pp, fixed_t *pq16ang, fixed_t q16angvel)
|
|||
// make the first turn in the clockwise direction
|
||||
// the rest will follow
|
||||
delta_ang = GetDeltaAngle(pp->turn180_target, FixedToInt(*pq16ang));
|
||||
if (PedanticMode)
|
||||
*pq16ang = IntToFixed(NORM_ANGLE(FixedToInt(*pq16ang) + (labs(delta_ang) >> TURN_SHIFT)));
|
||||
if (cl_syncinput)
|
||||
*pq16ang = NORM_Q16ANGLE(*pq16ang + ((labs(delta_ang) >> TURN_SHIFT) << FRACBITS));
|
||||
else
|
||||
// Add at least 1 unit to ensure the turn direction is clockwise
|
||||
*pq16ang = NORM_Q16ANGLE(*pq16ang + max(FRACUNIT, FloatToFixed(scaleAdjustmentToInterval(labs(delta_ang) >> TURN_SHIFT))));
|
||||
|
@ -1599,8 +1599,8 @@ DoPlayerTurn(PLAYERp pp, fixed_t *pq16ang, fixed_t q16angvel)
|
|||
short delta_ang;
|
||||
|
||||
delta_ang = GetDeltaAngle(pp->turn180_target, FixedToInt(*pq16ang));
|
||||
if (PedanticMode)
|
||||
*pq16ang = IntToFixed(NORM_ANGLE(FixedToInt(*pq16ang) + (delta_ang >> TURN_SHIFT)));
|
||||
if (cl_syncinput)
|
||||
*pq16ang = IntToFixed(NORM_ANGLE(FixedToInt(*pq16ang) + (delta_ang >> TURN_SHIFT)));
|
||||
else
|
||||
*pq16ang = NORM_Q16ANGLE(*pq16ang + FloatToFixed(scaleAdjustmentToInterval(delta_ang >> TURN_SHIFT)));
|
||||
|
||||
|
@ -1634,7 +1634,7 @@ DoPlayerTurn(PLAYERp pp, fixed_t *pq16ang, fixed_t q16angvel)
|
|||
q16angvel += q16angvel / 4;
|
||||
|
||||
*pq16ang += (q16angvel * synctics) / 32;
|
||||
*pq16ang = PedanticQ16AngleFloor(NORM_Q16ANGLE(*pq16ang));
|
||||
*pq16ang = NORM_Q16ANGLE(*pq16ang);
|
||||
|
||||
// update players sprite angle
|
||||
// NOTE: It's also updated in UpdatePlayerSprite, but needs to be
|
||||
|
@ -1837,8 +1837,7 @@ PlayerAutoLook(PLAYERp pp)
|
|||
|
||||
if (!TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING))
|
||||
{
|
||||
if ((PedanticMode || !TEST(pp->Flags, PF_MOUSE_AIMING_ON))
|
||||
&& TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE)) // If the floor is sloped
|
||||
if (!TEST(pp->Flags, PF_MOUSE_AIMING_ON) && TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE)) // If the floor is sloped
|
||||
{
|
||||
// Get a point, 512 units ahead of player's position
|
||||
x = pp->posx + (sintable[(FixedToInt(pp->q16ang) + 512) & 2047] >> 5);
|
||||
|
@ -1861,7 +1860,7 @@ PlayerAutoLook(PLAYERp pp)
|
|||
if ((pp->cursectnum == tempsect) ||
|
||||
(klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)))
|
||||
{
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizoff += (j - k) * 160;
|
||||
else
|
||||
pp->q16horizoff += FloatToFixed(scaleAdjustmentToInterval(mulscale16((j - k), 160)));
|
||||
|
@ -1875,7 +1874,7 @@ PlayerAutoLook(PLAYERp pp)
|
|||
// tilt when climbing but you can't even really tell it
|
||||
if (pp->q16horizoff < IntToFixed(100))
|
||||
{
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizoff += IntToFixed((((100 - FixedToInt(pp->q16horizoff)) >> 3) + 1));
|
||||
else
|
||||
pp->q16horizoff += FloatToFixed(scaleAdjustmentToInterval(FixedToFloat(((IntToFixed(100) - pp->q16horizoff) >> 3) + FRACUNIT)));
|
||||
|
@ -1887,7 +1886,7 @@ PlayerAutoLook(PLAYERp pp)
|
|||
// you're not on a slope
|
||||
if (pp->q16horizoff > 0)
|
||||
{
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizoff -= IntToFixed(((FixedToInt(pp->q16horizoff) >> 3) + 1));
|
||||
else
|
||||
{
|
||||
|
@ -1897,7 +1896,7 @@ PlayerAutoLook(PLAYERp pp)
|
|||
}
|
||||
if (pp->q16horizoff < 0)
|
||||
{
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizoff += IntToFixed((((FixedToInt(-pp->q16horizoff)) >> 3) + 1));
|
||||
else
|
||||
{
|
||||
|
@ -1918,7 +1917,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz)
|
|||
// //DSPRINTF(ds,"FixedToInt(pp->q16horizoff), %d", FixedToInt(pp->q16horizoff));
|
||||
// MONO_PRINT(ds);
|
||||
|
||||
if (!PedanticMode && (pq16horiz == &pp->q16horiz))
|
||||
if (!cl_syncinput && (pq16horiz == &pp->q16horiz))
|
||||
{
|
||||
SET(pp->Flags2, PF2_INPUT_CAN_AIM);
|
||||
pp->q16horiz = pp->input.q16horiz;
|
||||
|
@ -1939,7 +1938,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz)
|
|||
|
||||
if ((pp->input.actions & SB_CENTERVIEW) || pp->centering)
|
||||
{
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizbase = IntToFixed(100);
|
||||
else if (pp->q16horizbase > IntToFixed(100))
|
||||
{
|
||||
|
@ -1965,7 +1964,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz)
|
|||
// adjust *pq16horiz negative
|
||||
if (pp->input.actions & SB_AIM_DOWN)
|
||||
{
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizbase -= IntToFixed((HORIZ_SPEED/2));
|
||||
else
|
||||
pp->q16horizbase -= FloatToFixed(scaleAdjustmentToInterval((HORIZ_SPEED/2)));
|
||||
|
@ -1974,7 +1973,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz)
|
|||
// adjust *pq16horiz positive
|
||||
if (pp->input.actions & SB_AIM_UP)
|
||||
{
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizbase += IntToFixed((HORIZ_SPEED/2));
|
||||
else
|
||||
pp->q16horizbase += FloatToFixed(scaleAdjustmentToInterval((HORIZ_SPEED/2)));
|
||||
|
@ -1991,7 +1990,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz)
|
|||
// adjust *pq16horiz negative
|
||||
if (pp->input.actions & SB_LOOK_DOWN)
|
||||
{
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizbase -= IntToFixed(HORIZ_SPEED);
|
||||
else
|
||||
pp->q16horizbase -= FloatToFixed(scaleAdjustmentToInterval(HORIZ_SPEED));
|
||||
|
@ -2000,7 +1999,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz)
|
|||
// adjust *pq16horiz positive
|
||||
if (pp->input.actions & SB_LOOK_UP)
|
||||
{
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizbase += IntToFixed(HORIZ_SPEED);
|
||||
else
|
||||
pp->q16horizbase += FloatToFixed(scaleAdjustmentToInterval(HORIZ_SPEED));
|
||||
|
@ -2020,7 +2019,7 @@ DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz)
|
|||
for (i = 1; i; i--)
|
||||
{
|
||||
// this formula does not work for *pq16horiz = 101-103
|
||||
if (PedanticMode)
|
||||
if (cl_syncinput)
|
||||
pp->q16horizbase += IntToFixed(25) - (pp->q16horizbase >> 2);
|
||||
else
|
||||
pp->q16horizbase += FloatToFixed(scaleAdjustmentToInterval(FixedToFloat(IntToFixed(25) - (pp->q16horizbase >> 2))));
|
||||
|
@ -6603,10 +6602,10 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
|
|||
if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum,
|
||||
pp->posx, pp->posy, pp->posz, pp->cursectnum))
|
||||
{
|
||||
q16ang2 = GetQ16AngleFromVect(kp->x - pp->posx, kp->y - pp->posy);
|
||||
q16ang2 = gethiq16angle(kp->x - pp->posx, kp->y - pp->posy);
|
||||
|
||||
delta_q16ang = GetDeltaQ16Angle(q16ang2, pp->q16ang);
|
||||
pp->camq16ang = pp->q16ang = NORM_Q16ANGLE(pp->q16ang + PedanticQ16AngleFloor(delta_q16ang >> 4));
|
||||
pp->camq16ang = pp->q16ang = NORM_Q16ANGLE(pp->q16ang + (delta_q16ang >> 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7708,7 +7707,7 @@ domovethings(void)
|
|||
// Mostly done in order to force updates to oq16ang/oq16horiz.
|
||||
// Don't do so for a dead player which may follow
|
||||
// the killer if present, due to angle interpolation.
|
||||
if (!PedanticMode && !TEST(pp->Flags, PF_DEAD))
|
||||
if (!cl_syncinput && !TEST(pp->Flags, PF_DEAD))
|
||||
{
|
||||
auto currFlags2 = pp->Flags2;
|
||||
if (prevFlags2 & currFlags2 & PF2_INPUT_CAN_TURN)
|
||||
|
|
Loading…
Reference in a new issue