Fixed in_strafe and others

since CL_ExtraMouseUpdate is called before CreateMove now
This commit is contained in:
Kamay Xutax 2024-09-11 15:19:49 +02:00
parent 6e5facd8cc
commit 497a61b029
8 changed files with 24 additions and 14 deletions

View file

@ -2099,8 +2099,10 @@ void CL_ExtraMouseUpdate( float frametime )
return; return;
#endif #endif
int nextcommandnr = cl.lastoutgoingcommand + cl.chokedcommands + 1;
// Have client .dll create and store usercmd structure // Have client .dll create and store usercmd structure
g_ClientDLL->ExtraMouseSample( frametime, !cl.m_bPaused ); g_ClientDLL->ExtraMouseSample( nextcommandnr, frametime, !cl.m_bPaused );
} }
/* /*

View file

@ -3246,6 +3246,7 @@ void _Host_RunFrame (float time)
// continuous controllers affecting the view are also simulated this way // continuous controllers affecting the view are also simulated this way
// but they have a cap applied by IN_SetSampleTime() so they are not also // but they have a cap applied by IN_SetSampleTime() so they are not also
// simulated during input gathering // simulated during input gathering
g_ClientGlobalVariables.frametime = host_frametime;
CL_ExtraMouseUpdate( host_frametime ); CL_ExtraMouseUpdate( host_frametime );
#endif #endif
for ( int tick = 0; tick < numticks; tick++ ) for ( int tick = 0; tick < numticks; tick++ )
@ -3432,7 +3433,17 @@ void _Host_RunFrame (float time)
serverticks = numticks; serverticks = numticks;
g_ClientGlobalVariables.simTicksThisFrame = clientticks; g_ClientGlobalVariables.simTicksThisFrame = clientticks;
g_ServerGlobalVariables.simTicksThisFrame = serverticks; g_ServerGlobalVariables.simTicksThisFrame = serverticks;
g_ServerGlobalVariables.tickcount = sv.m_nTickCount; g_ServerGlobalVariables.tickcount = sv.m_nTickCount;
// TODO_ENHANCED:
// Update the mouse as last so we can get the right viewangles while taking screenshot.
// The mouse is always simulated for the current frame's time
// This makes updates smooth in every case
// continuous controllers affecting the view are also simulated this way
// but they have a cap applied by IN_SetSampleTime() so they are not also
// simulated during input gathering
g_ClientGlobalVariables.frametime = host_frametime;
CL_ExtraMouseUpdate( host_frametime );
// THREADED: Run Client // THREADED: Run Client
// ------------------- // -------------------

View file

@ -630,7 +630,7 @@ public:
virtual void IN_SetSampleTime( float frametime ); virtual void IN_SetSampleTime( float frametime );
// Create movement command // Create movement command
virtual void CreateMove ( int sequence_number, float input_sample_frametime, bool active ); virtual void CreateMove ( int sequence_number, float input_sample_frametime, bool active );
virtual void ExtraMouseSample( float frametime, bool active ); virtual void ExtraMouseSample( int sequence_number, float frametime, bool active );
virtual bool WriteUsercmdDeltaToBuffer( bf_write *buf, int from, int to, bool isnewcommand ); virtual bool WriteUsercmdDeltaToBuffer( bf_write *buf, int from, int to, bool isnewcommand );
virtual void EncodeUserCmdToBuffer( bf_write& buf, int slot ); virtual void EncodeUserCmdToBuffer( bf_write& buf, int slot );
virtual void DecodeUserCmdFromBuffer( bf_read& buf, int slot ); virtual void DecodeUserCmdFromBuffer( bf_read& buf, int slot );
@ -1419,7 +1419,7 @@ int CHLClient::IN_KeyEvent( int eventcode, ButtonCode_t keynum, const char *pszC
return input->KeyEvent( eventcode, keynum, pszCurrentBinding ); return input->KeyEvent( eventcode, keynum, pszCurrentBinding );
} }
void CHLClient::ExtraMouseSample( float frametime, bool active ) void CHLClient::ExtraMouseSample( int sequence_number, float frametime, bool active )
{ {
Assert( C_BaseEntity::IsAbsRecomputationsEnabled() ); Assert( C_BaseEntity::IsAbsRecomputationsEnabled() );
Assert( C_BaseEntity::IsAbsQueriesValid() ); Assert( C_BaseEntity::IsAbsQueriesValid() );
@ -1427,7 +1427,7 @@ void CHLClient::ExtraMouseSample( float frametime, bool active )
C_BaseAnimating::AutoAllowBoneAccess boneaccess( true, false ); C_BaseAnimating::AutoAllowBoneAccess boneaccess( true, false );
MDLCACHE_CRITICAL_SECTION(); MDLCACHE_CRITICAL_SECTION();
input->ExtraMouseSample( frametime, active ); input->ExtraMouseSample( sequence_number, frametime, active );
} }
void CHLClient::IN_SetSampleTime( float frametime ) void CHLClient::IN_SetSampleTime( float frametime )

View file

@ -37,7 +37,7 @@ public:
virtual int GetButtonBits( int ) = 0; virtual int GetButtonBits( int ) = 0;
// Create movement command // Create movement command
virtual void CreateMove ( int sequence_number, float input_sample_frametime, bool active ) = 0; virtual void CreateMove ( int sequence_number, float input_sample_frametime, bool active ) = 0;
virtual void ExtraMouseSample( float frametime, bool active ) = 0; virtual void ExtraMouseSample( int sequence_number, float frametime, bool active ) = 0;
virtual bool WriteUsercmdDeltaToBuffer( bf_write *buf, int from, int to, bool isnewcommand ) = 0; virtual bool WriteUsercmdDeltaToBuffer( bf_write *buf, int from, int to, bool isnewcommand ) = 0;
virtual void EncodeUserCmdToBuffer( bf_write& buf, int slot ) = 0; virtual void EncodeUserCmdToBuffer( bf_write& buf, int slot ) = 0;
virtual void DecodeUserCmdFromBuffer( bf_read& buf, int slot ) = 0; virtual void DecodeUserCmdFromBuffer( bf_read& buf, int slot ) = 0;

View file

@ -1016,12 +1016,11 @@ if active == 1 then we are 1) not playing back demos ( where our commands are ig
================ ================
*/ */
void CInput::ExtraMouseSample( float frametime, bool active ) void CInput::ExtraMouseSample( int sequence_number, float frametime, bool active )
{ {
VPROF( "CInput::ExtraMouseSample" ); VPROF( "CInput::ExtraMouseSample" );
CUserCmd dummy; CUserCmd *cmd = &m_pCommands[sequence_number % MULTIPLAYER_BACKUP];
CUserCmd *cmd = &dummy;
cmd->Reset(); cmd->Reset();
@ -1132,8 +1131,6 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo
CUserCmd *cmd = &m_pCommands[ sequence_number % MULTIPLAYER_BACKUP ]; CUserCmd *cmd = &m_pCommands[ sequence_number % MULTIPLAYER_BACKUP ];
CVerifiedUserCmd *pVerified = &m_pVerifiedCommands[ sequence_number % MULTIPLAYER_BACKUP ]; CVerifiedUserCmd *pVerified = &m_pVerifiedCommands[ sequence_number % MULTIPLAYER_BACKUP ];
cmd->Reset();
cmd->command_number = sequence_number; cmd->command_number = sequence_number;
QAngle viewangles; QAngle viewangles;

View file

@ -47,7 +47,7 @@ public:
virtual void Shutdown_All( void ); virtual void Shutdown_All( void );
virtual int GetButtonBits( int ); virtual int GetButtonBits( int );
virtual void CreateMove ( int sequence_number, float input_sample_frametime, bool active ); virtual void CreateMove ( int sequence_number, float input_sample_frametime, bool active );
virtual void ExtraMouseSample( float frametime, bool active ); virtual void ExtraMouseSample( int sequence_number, float frametime, bool active );
virtual bool WriteUsercmdDeltaToBuffer( bf_write *buf, int from, int to, bool isnewcommand ); virtual bool WriteUsercmdDeltaToBuffer( bf_write *buf, int from, int to, bool isnewcommand );
virtual void EncodeUserCmdToBuffer( bf_write& buf, int slot ); virtual void EncodeUserCmdToBuffer( bf_write& buf, int slot );
virtual void DecodeUserCmdFromBuffer( bf_read& buf, int slot ); virtual void DecodeUserCmdFromBuffer( bf_read& buf, int slot );

View file

@ -150,7 +150,7 @@ static void CalcDemoViewOverride( Vector &origin, QAngle &angles )
{ {
engine->SetViewAngles( s_DemoAngle ); engine->SetViewAngles( s_DemoAngle );
input->ExtraMouseSample( gpGlobals->absoluteframetime, true ); input->ExtraMouseSample( 0, gpGlobals->absoluteframetime, true );
engine->GetViewAngles( s_DemoAngle ); engine->GetViewAngles( s_DemoAngle );

View file

@ -653,7 +653,7 @@ public:
// If the game is running faster than the tick_interval framerate, then we do extra mouse sampling to avoid jittery input // If the game is running faster than the tick_interval framerate, then we do extra mouse sampling to avoid jittery input
// This code path is much like the normal move creation code, except no move is created // This code path is much like the normal move creation code, except no move is created
virtual void ExtraMouseSample( float frametime, bool active ) = 0; virtual void ExtraMouseSample( int sequence_number, float frametime, bool active ) = 0;
// Encode the delta (changes) between the CUserCmd in slot from vs the one in slot to. The game code will have // Encode the delta (changes) between the CUserCmd in slot from vs the one in slot to. The game code will have
// matching logic to read the delta. // matching logic to read the delta.