Commit 3a06b402 authored by Richard Gobeille's avatar Richard Gobeille

Duke3d: fix issues with the player looking up/down after loading a save

This limits the output of scaleAdjustmentToInterval() to a maximum of one second worth per frame drawn, clamps q16horizoff to the same range as q16horiz, and zeroes the last input clock after loading.
parent 2b7c5d82
......@@ -2994,8 +2994,9 @@ enddisplayweapon:
#define MAXANGVEL 1024
#define MAXHORIZVEL 256
int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0;
int32_t g_myAimMode, g_myAimStat, g_oldAimStat;
int32_t mouseyaxismode = -1;
double g_lastInputTicks;
enum inputlock_t
{
......@@ -3108,13 +3109,15 @@ void P_GetInput(int const playerNum)
input.svel -= info.dx * keyMove / analogExtent;
input.fvel -= info.dz * keyMove / analogExtent;
static double lastInputTicks;
auto const currentHiTicks = timerGetHiTicks();
double const elapsedInputTicks = currentHiTicks - lastInputTicks;
auto const currentHiTicks = timerGetHiTicks();
double elapsedInputTicks = currentHiTicks - g_lastInputTicks;
lastInputTicks = currentHiTicks;
if (!g_lastInputTicks)
elapsedInputTicks = 0;
auto scaleAdjustmentToInterval = [=](double x) { return x * REALGAMETICSPERSEC / (1000.0 / elapsedInputTicks); };
g_lastInputTicks = currentHiTicks;
auto scaleAdjustmentToInterval = [=](double x) { return x * REALGAMETICSPERSEC / (1000.0 / min(elapsedInputTicks, 1000.0)); };
if (BUTTON(gamefunc_Strafe))
{
......@@ -3351,7 +3354,8 @@ void P_GetInput(int const playerNum)
if (thisPlayer.horizSkew)
pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_float(scaleAdjustmentToInterval(fix16_to_float(thisPlayer.horizSkew))));
pPlayer->q16horiz = fix16_clamp(pPlayer->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX));
pPlayer->q16horiz = fix16_clamp(pPlayer->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX));
pPlayer->q16horizoff = fix16_clamp(pPlayer->q16horizoff, F16(HORIZ_MIN), F16(HORIZ_MAX));
}
static int32_t P_DoCounters(int playerNum)
......
......@@ -309,6 +309,7 @@ extern int32_t g_numObituaries;
extern int32_t g_numSelfObituaries;
extern int32_t mouseyaxismode;
extern int32_t ticrandomseed;
extern double g_lastInputTicks;
#define SHOOT_HARDCODED_ZVEL INT32_MIN
......
......@@ -1667,6 +1667,7 @@ static void G_ResetAllPlayers(void)
void G_ResetTimers(bool saveMoveCnt)
{
g_lastInputTicks = 0;
totalclock = g_cloudClock = ototalclock = lockclock = 0;
ready2send = 1;
g_levelTextTime = 85;
......@@ -1680,14 +1681,19 @@ void G_ResetTimers(bool saveMoveCnt)
void G_ClearFIFO(void)
{
g_lastInputTicks = 0;
localInput = {};
Bmemset(&inputfifo, 0, sizeof(input_t) * MOVEFIFOSIZ * MAXPLAYERS);
for (int p = 0; p < MAXPLAYERS; ++p)
{
if (g_player[p].input != NULL)
Bmemset(g_player[p].input, 0, sizeof(input_t));
g_player[p].vote = g_player[p].gotvote = 0;
*g_player[p].input = {};
g_player[p].vote = 0;
g_player[p].gotvote = 0;
g_player[p].horizSkew = 0;
g_player[p].horizAngleAdjust = 0;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment