mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
SW: Tie player input to frame rate.
This commit is contained in:
parent
8b10f53450
commit
cba38c5cfc
4 changed files with 108 additions and 34 deletions
|
@ -2013,8 +2013,16 @@ drawscreen(PLAYERp pp)
|
|||
tx = camerapp->oposx + mulscale16(camerapp->posx - camerapp->oposx, smoothratio);
|
||||
ty = camerapp->oposy + mulscale16(camerapp->posy - camerapp->oposy, smoothratio);
|
||||
tz = camerapp->oposz + mulscale16(camerapp->posz - camerapp->oposz, smoothratio);
|
||||
tq16ang = camerapp->oq16ang + mulscale16(((camerapp->q16ang + fix16_from_int(1024) - camerapp->oq16ang) & 0x7FFFFFF) - fix16_from_int(1024), smoothratio);
|
||||
tq16horiz = camerapp->oq16horiz + mulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio);
|
||||
if (PEDANTIC_MODE)
|
||||
{
|
||||
tq16ang = camerapp->oq16ang + mulscale16(((camerapp->q16ang + fix16_from_int(1024) - camerapp->oq16ang) & 0x7FFFFFF) - fix16_from_int(1024), smoothratio);
|
||||
tq16horiz = camerapp->oq16horiz + mulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio);
|
||||
}
|
||||
else
|
||||
{
|
||||
tq16ang = pp->camq16ang;
|
||||
tq16horiz = pp->camq16horiz;
|
||||
}
|
||||
tsectnum = camerapp->cursectnum;
|
||||
|
||||
//ASSERT(tsectnum >= 0 && tsectnum <= MAXSECTORS);
|
||||
|
|
|
@ -2392,6 +2392,8 @@ void dsprintf_null(char *str, const char *format, ...)
|
|||
va_list arglist;
|
||||
}
|
||||
|
||||
void getinput(SW_PACKET *, SWBOOL);
|
||||
|
||||
void MoveLoop(void)
|
||||
{
|
||||
int pnum;
|
||||
|
@ -2432,6 +2434,10 @@ void MoveLoop(void)
|
|||
// demosync_record();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Get input again to update q16ang/q16horiz.
|
||||
if (!PEDANTIC_MODE)
|
||||
getinput(&loc, TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3032,7 +3038,7 @@ double elapsedInputTicks;
|
|||
double scaleAdjustmentToInterval(double x) { return x * (120 / synctics) / (1000.0 / elapsedInputTicks); }
|
||||
|
||||
void
|
||||
getinput(SW_PACKET *loc)
|
||||
getinput(SW_PACKET *loc, SWBOOL tied)
|
||||
{
|
||||
int i;
|
||||
PLAYERp pp = Player + myconnectindex;
|
||||
|
@ -3061,8 +3067,12 @@ getinput(SW_PACKET *loc)
|
|||
newpp = ppp;
|
||||
}
|
||||
|
||||
// reset all syncbits
|
||||
loc->bits = 0;
|
||||
static double lastInputTicks;
|
||||
|
||||
auto const currentHiTicks = timerGetHiTicks();
|
||||
elapsedInputTicks = currentHiTicks - lastInputTicks;
|
||||
|
||||
lastInputTicks = currentHiTicks;
|
||||
|
||||
// MAKE SURE THIS WILL GET SET
|
||||
SET_LOC_KEY(loc->bits, SK_QUIT_GAME, MultiPlayQuitFlag);
|
||||
|
@ -3135,7 +3145,7 @@ getinput(SW_PACKET *loc)
|
|||
// If in 2D follow mode, scroll around using glob vars
|
||||
// Tried calling this in domovethings, but key response it too poor, skips key presses
|
||||
// Note: ScrollMode2D = Follow mode, so this get called only during follow mode
|
||||
if (ScrollMode2D && pp == Player + myconnectindex && !Prediction)
|
||||
if (!tied && ScrollMode2D && pp == Player + myconnectindex && !Prediction)
|
||||
MoveScrollMode2D(Player + myconnectindex);
|
||||
|
||||
// !JIM! Added M_Active() so that you don't move at all while using menus
|
||||
|
@ -3168,6 +3178,9 @@ getinput(SW_PACKET *loc)
|
|||
keymove = NORMALKEYMOVE;
|
||||
}
|
||||
|
||||
if (tied)
|
||||
keymove = 0;
|
||||
|
||||
info.dz = (info.dz * move_scale)>>8;
|
||||
info.dyaw = (info.dyaw * turn_scale)>>8;
|
||||
|
||||
|
@ -3209,18 +3222,28 @@ getinput(SW_PACKET *loc)
|
|||
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
||||
{
|
||||
turnheldtime += synctics;
|
||||
if (turnheldtime >= TURBOTURNTIME)
|
||||
q16avel -= fix16_from_int(turnamount);
|
||||
if (PEDANTIC_MODE)
|
||||
{
|
||||
if (turnheldtime >= TURBOTURNTIME)
|
||||
q16avel -= fix16_from_int(turnamount);
|
||||
else
|
||||
q16avel -= fix16_from_int(PREAMBLETURN);
|
||||
}
|
||||
else
|
||||
q16avel -= fix16_from_int(PREAMBLETURN);
|
||||
q16avel = fix16_ssub(q16avel, fix16_from_float(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN)));
|
||||
}
|
||||
else if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
||||
{
|
||||
turnheldtime += synctics;
|
||||
if (turnheldtime >= TURBOTURNTIME)
|
||||
q16avel += fix16_from_int(turnamount);
|
||||
if (PEDANTIC_MODE)
|
||||
{
|
||||
if (turnheldtime >= TURBOTURNTIME)
|
||||
q16avel += fix16_from_int(turnamount);
|
||||
else
|
||||
q16avel += fix16_from_int(PREAMBLETURN);
|
||||
}
|
||||
else
|
||||
q16avel += fix16_from_int(PREAMBLETURN);
|
||||
q16avel = fix16_sadd(q16avel, fix16_from_float(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3249,27 +3272,42 @@ getinput(SW_PACKET *loc)
|
|||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
vel += -keymove;
|
||||
|
||||
vel = clamp(vel, -MAXVEL, MAXVEL);
|
||||
svel = clamp(svel, -MAXSVEL, MAXSVEL);
|
||||
|
||||
q16avel = fix16_clamp(q16avel, -fix16_from_int(MAXANGVEL), fix16_from_int(MAXANGVEL));
|
||||
q16horz = fix16_clamp(q16horz, -fix16_from_int(MAXHORIZVEL), fix16_from_int(MAXHORIZVEL));
|
||||
|
||||
if (PEDANTIC_MODE)
|
||||
{
|
||||
q16avel = fix16_floor(q16avel);
|
||||
q16horz = fix16_floor(q16horz);
|
||||
}
|
||||
else
|
||||
{
|
||||
void DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16avel);
|
||||
void DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz);
|
||||
DoPlayerTurn(pp, &pp->camq16ang, q16avel);
|
||||
DoPlayerHorizon(pp, &pp->camq16horiz, q16horz);
|
||||
}
|
||||
|
||||
momx = mulscale9(vel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 512)]);
|
||||
momy = mulscale9(vel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang))]);
|
||||
loc->vel += vel;
|
||||
loc->svel += svel;
|
||||
|
||||
momx += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang))]);
|
||||
momy += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 1536)]);
|
||||
if (!tied)
|
||||
{
|
||||
vel = clamp(loc->vel, -MAXVEL, MAXVEL);
|
||||
svel = clamp(loc->svel, -MAXSVEL, MAXSVEL);
|
||||
|
||||
loc->vel = momx;
|
||||
loc->svel = momy;
|
||||
loc->q16avel = q16avel;
|
||||
loc->q16horz = q16horz;
|
||||
momx = mulscale9(vel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 512)]);
|
||||
momy = mulscale9(vel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang))]);
|
||||
|
||||
momx += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang))]);
|
||||
momy += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 1536)]);
|
||||
|
||||
loc->vel = momx;
|
||||
loc->svel = momy;
|
||||
}
|
||||
|
||||
loc->q16avel += q16avel;
|
||||
loc->q16horz += q16horz;
|
||||
|
||||
if (!CommEnabled)
|
||||
{
|
||||
|
|
|
@ -915,6 +915,7 @@ faketimerhandler(void)
|
|||
{
|
||||
int i, j, k;
|
||||
PLAYERp pp;
|
||||
void getinput(SW_PACKET *, SWBOOL);
|
||||
extern SWBOOL BotMode;
|
||||
|
||||
#if 0
|
||||
|
@ -945,7 +946,7 @@ faketimerhandler(void)
|
|||
if (Player[myconnectindex].movefifoend - movefifoplc >= 100)
|
||||
return;
|
||||
|
||||
getinput(&loc);
|
||||
getinput(&loc, FALSE);
|
||||
|
||||
AveragePacket.vel += loc.vel;
|
||||
AveragePacket.svel += loc.svel;
|
||||
|
@ -955,6 +956,8 @@ faketimerhandler(void)
|
|||
AveragePacket.q16horiz = Player[myconnectindex].camq16horiz;
|
||||
SET(AveragePacket.bits, loc.bits);
|
||||
|
||||
Bmemset(&loc, 0, sizeof(loc));
|
||||
|
||||
pp = Player + myconnectindex;
|
||||
|
||||
if (pp->movefifoend & (MovesPerPacket-1))
|
||||
|
@ -979,6 +982,7 @@ faketimerhandler(void)
|
|||
|
||||
pp->inputfifo[Player[myconnectindex].movefifoend & (MOVEFIFOSIZ - 1)] = loc;
|
||||
pp->movefifoend++;
|
||||
Bmemset(&loc, 0, sizeof(loc));
|
||||
|
||||
#if 0
|
||||
// AI Bot stuff
|
||||
|
|
|
@ -1542,6 +1542,18 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16avel)
|
|||
{
|
||||
#define TURN_SHIFT 2
|
||||
|
||||
if (!PEDANTIC_MODE && (pq16ang == &pp->q16ang))
|
||||
{
|
||||
*pq16ang = pp->input.q16ang;
|
||||
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
|
||||
if (!Prediction)
|
||||
{
|
||||
if (pp->PlayerUnderSprite >= 0)
|
||||
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TEST(pp->Flags, PF_TURN_180))
|
||||
{
|
||||
if (TEST_SYNC_KEY(pp, SK_TURN_180))
|
||||
|
@ -1581,11 +1593,14 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16avel)
|
|||
else
|
||||
*pq16ang = NORM_Q16ANGLE(fix16_sadd(*pq16ang, fix16_from_float(scaleAdjustmentToInterval(delta_ang >> TURN_SHIFT))));
|
||||
|
||||
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
|
||||
if (!Prediction)
|
||||
if (pq16ang == &pp->q16ang)
|
||||
{
|
||||
if (pp->PlayerUnderSprite >= 0)
|
||||
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
|
||||
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
|
||||
if (!Prediction)
|
||||
{
|
||||
if (pp->PlayerUnderSprite >= 0)
|
||||
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
|
||||
}
|
||||
}
|
||||
|
||||
// get new delta to see how close we are
|
||||
|
@ -1616,11 +1631,14 @@ DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16avel)
|
|||
// NOTE: It's also updated in UpdatePlayerSprite, but needs to be
|
||||
// here to cover
|
||||
// all cases.
|
||||
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
|
||||
if (!Prediction)
|
||||
if (pq16ang == &pp->q16ang)
|
||||
{
|
||||
if (pp->PlayerUnderSprite >= 0)
|
||||
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
|
||||
sprite[pp->PlayerSprite].ang = fix16_to_int(*pq16ang);
|
||||
if (!Prediction)
|
||||
{
|
||||
if (pp->PlayerUnderSprite >= 0)
|
||||
sprite[pp->PlayerUnderSprite].ang = fix16_to_int(*pq16ang);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1893,9 +1911,15 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
|
|||
// //DSPRINTF(ds,"fix16_to_int(pp->q16horizoff), %d", fix16_to_int(pp->q16horizoff));
|
||||
// MONO_PRINT(ds);
|
||||
|
||||
if (!PEDANTIC_MODE && (pq16horiz == &pp->q16horiz))
|
||||
{
|
||||
*pq16horiz = pp->input.q16horiz;
|
||||
return;
|
||||
}
|
||||
|
||||
// Fixme: This should probably be made optional.
|
||||
if (cl_slopetilting)
|
||||
PlayerAutoLook(pp);
|
||||
PlayerAutoLook(pp);
|
||||
|
||||
if (q16horz)
|
||||
{
|
||||
|
@ -1929,9 +1953,9 @@ DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16horz)
|
|||
{
|
||||
if (PEDANTIC_MODE)
|
||||
pp->q16horizbase += fix16_from_int((HORIZ_SPEED/2));
|
||||
}
|
||||
else
|
||||
pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_float(scaleAdjustmentToInterval((HORIZ_SPEED/2))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue