- Move Duke's input scaling for unsynchronised input to backend as InputScale().

This commit is contained in:
Mitchell Richters 2020-09-04 17:53:36 +10:00
parent 722537a1f0
commit 290e615807
3 changed files with 20 additions and 10 deletions

View file

@ -47,6 +47,8 @@ ESyncBits ActionsToSend = 0;
static int dpad_lock = 0;
bool sendPause;
static double lastCheck;
//==========================================================================
//
//
@ -402,3 +404,18 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput)
}
double InputScale()
{
if (!cl_syncinput)
{
double now = I_msTimeF();
double elapsedInputTicks = lastCheck > 0 ? min(now - lastCheck, 1000.0 / GameTicRate) : 1;
lastCheck = now;
return elapsedInputTicks * GameTicRate / 1000.0;
}
else
{
return 1;
}
}

View file

@ -98,3 +98,4 @@ enum GameFunction_t
void SetupGameButtons();
void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput);
extern ESyncBits ActionsToSend;
double InputScale();

View file

@ -1001,16 +1001,8 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
{
double elapsedInputTicks;
auto const p = &ps[myconnectindex];
auto now = I_msTimeF();
// do not let this become too large - it would create overflows resulting in undefined behavior. The very first tic must not use the timer difference at all because the timer has not been set yet.
// This really needs to have the timer fixed to be robust, doing it ad-hoc here is not really safe.
if (lastCheck > 0) elapsedInputTicks = min(now - lastCheck, 1000.0 / REALGAMETICSPERSEC);
else elapsedInputTicks = 1;
lastCheck = now;
if (paused)
{
loc = {};
@ -1022,7 +1014,7 @@ static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
setlocalplayerinput(p);
}
double scaleAdjust = !cl_syncinput ? elapsedInputTicks * REALGAMETICSPERSEC / 1000.0 : 1;
double const scaleAdjust = InputScale();
InputPacket input{};
if (isRRRA() && (p->OnMotorcycle || p->OnBoat))