Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m_rawinput changes take no effect if weapon prediction is disabled #3254

Closed
SamVanheer opened this issue Mar 3, 2022 · 1 comment
Closed

Comments

@SamVanheer
Copy link

SamVanheer commented Mar 3, 2022

Changing the m_rawinput cvar doesn't change the raw input behavior if the cl_lw cvar is 0.

This is because the input code checks the current time using gpGlobals->time:

if ( gpGlobals && gpGlobals->time - s_flRawInputUpdateTime > 1.0f )
{
s_flRawInputUpdateTime = gpGlobals->time;
m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;
}

Which is only updated if weapon prediction is enabled:

// Get current clock
gpGlobals->time = time;

To fix this the input code should get the current time from the engine and use that instead:

const float currentTime = gEngfuncs.GetClientTime();

if ((currentTime - s_flRawInputUpdateTime) > 1.0f || s_flRawInputUpdateTime == 0.0f)
{
	s_flRawInputUpdateTime = currentTime;
	m_bRawInput = CVAR_GET_FLOAT("m_rawinput") != 0;
}

This global variable declaration can also be removed:

extern globalvars_t *gpGlobals;

Note that because the weapon prediction code sets the time to what's passed in from the engine the time can sometimes be that of an older frame being run again, so the value will be in the past. This doesn't break anything but it could delay the change taking effect by a frame. See #3252 for a change related to that.

@SamVanheer
Copy link
Author

This fix is made obsolete by the fix for #3255 which removes the need to check for the current time altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant