Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
XutaxKamay committed Sep 13, 2024
2 parents b5e44d0 + d03c92b commit 30ad2cc
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 183 deletions.
2 changes: 1 addition & 1 deletion dx9sdk/include/dxva.h
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ typedef enum _DXVA_SampleFormat {
DXVA_SampleSubStream = 7
} DXVA_SampleFormat;

#define DXVA_ExtractSampleFormat(_sf) ((_sf) & (DXVA_SampleFormatMask))
#define DXVA_ExtraMovementSampleFormatMask))

#define DXVA_ExtractExtColorData(_sf, _Mask, _Shift) \
(((_sf) >> (_Shift)) & (_Mask))
Expand Down
23 changes: 17 additions & 6 deletions engine/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "client.h"
#include "client_pch.h"
#include "clockdriftmgr.h"
#include "host.h"
#include "sound.h"
#include <inetchannel.h>
#include "checksum_engine.h"
Expand Down Expand Up @@ -593,7 +594,7 @@ void CL_ReadPackets ( bool bFinalTick )
// While clock correction is off, we have the old behavior of matching the client and server clocks.
if (CClockDriftMgr::IsClockCorrectionEnabled())
{
cl.m_ClockDriftMgr.IncrementCachedTickCount(bFinalTick);
cl.GetClockDriftMgr().IncrementCachedTickCount(bFinalTick);
g_ClientGlobalVariables.tickcount = cl.GetClientTickCount();
g_ClientGlobalVariables.curtime = cl.GetTime();
}
Expand Down Expand Up @@ -2081,7 +2082,7 @@ void CL_DecayLights (void)
}


void CL_ExtraMouseUpdate( float frametime )
void CL_ExtraMovementUpdate( float frametime )
{
// Not ready for commands yet.
if ( !cl.IsActive() )
Expand All @@ -2102,7 +2103,7 @@ void CL_ExtraMouseUpdate( float frametime )
int nextcommandnr = cl.lastoutgoingcommand + cl.chokedcommands + 1;

// Have client .dll create and store usercmd structure
g_ClientDLL->ExtraMouseSample( nextcommandnr, frametime, !cl.m_bPaused );
g_ClientDLL->ExtraMovementSample( cl.GetClockDriftMgr().m_nNumberOfTicks, nextcommandnr, frametime, !cl.m_bPaused );
}

/*
Expand Down Expand Up @@ -2159,7 +2160,7 @@ void CL_SendMove( void )
}
}

void CL_Move(float accumulated_extra_samples, bool bFinalTick )
void CL_Move(float frametime, bool bFinalTick )
{
if ( !cl.IsConnected() )
return;
Expand Down Expand Up @@ -2205,10 +2206,20 @@ void CL_Move(float accumulated_extra_samples, bool bFinalTick )

int nextcommandnr = cl.lastoutgoingcommand + cl.chokedcommands + 1;

// Have client .dll create and store usercmd structure
// TODO_ENHANCED:
// Sooo why do we ignore interval per tick overlap here?
// Because the mouse accumulators even in low fps are always reset to zero anyway after the first tick.
// Movements will be instead calculate inside CL_ExtraMovementSample with the correct frametime.

// Doing host_state.interval_per_tick - frametime was just to calculate the previous frametime, but it has issues:
// Before even if you had low fps, the mouse will only be updated only once even if CreateMove is called multiple times.
// So basically, no matter the frametime you had, the mouse will never update its angles anyway with the correct amount (multiple interval per ticks.);
// Because GetRawMouseAccumulators will always be zero, except with old behavior with GetCursorPos.
// So, instead the frametime has been divided by the number ticks been ran, so we get the right amount to adjust everytime.
// Technically it's even safe to remove now the calculation for movements since they'll calculated inside CL_ExtraMovementSample now.
g_ClientDLL->CreateMove(
nextcommandnr,
host_state.interval_per_tick - accumulated_extra_samples,
frametime,
!cl.IsPaused() );

// Store new usercmd to dem file
Expand Down
2 changes: 1 addition & 1 deletion engine/cl_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void CL_RegisterResources ( void );
// cl_input
//
void CL_Move( float accumulated_extra_samples, bool bFinalTick );
void CL_ExtraMouseUpdate( float remainder );
void CL_ExtraMovementUpdate( float remainder );

void CL_ClearState (void);
void CL_ReadPackets ( bool framefinished ); // Read packets from server and other sources (ping requests, etc.)
Expand Down
26 changes: 9 additions & 17 deletions engine/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2623,7 +2623,7 @@ Runs all active servers
==================
*/

void _Host_RunFrame_Input( float accumulated_extra_samples, bool bFinalTick )
void _Host_RunFrame_Input( float frametime, bool bFinalTick )
{
VPROF_BUDGET( "_Host_RunFrame_Input", _T("Input") );

Expand Down Expand Up @@ -2656,7 +2656,7 @@ void _Host_RunFrame_Input( float accumulated_extra_samples, bool bFinalTick )
g_HostTimes.EndFrameSegment( FRAME_SEGMENT_CMD_EXECUTE );

// Send any current movement commands to server and flush reliable buffer even if not moving yet.
CL_Move( accumulated_extra_samples, bFinalTick );
CL_Move( frametime, bFinalTick );

#endif

Expand Down Expand Up @@ -3054,7 +3054,6 @@ void _Host_RunFrame (float time)
{
MDLCACHE_COARSE_LOCK_(g_pMDLCache);
static double host_remainder = 0.0f;
double prevremainder;
bool shouldrender;

#if defined( RAD_TELEMETRY_ENABLED )
Expand Down Expand Up @@ -3104,11 +3103,6 @@ void _Host_RunFrame (float time)

shouldrender = !sv.IsDedicated();

// FIXME: Could track remainder as fractional ticks instead of msec
prevremainder = host_remainder;
if ( prevremainder < 0 )
prevremainder = 0;

#if !defined(SWDS)
if ( !demoplayer->IsPlaybackPaused() )
#endif
Expand Down Expand Up @@ -3136,7 +3130,7 @@ void _Host_RunFrame (float time)
host_remainder -= numticks * host_state.interval_per_tick;
}

cl.m_ClockDriftMgr.m_nNumberOfTicks = numticks;
cl.GetClockDriftMgr().m_nNumberOfTicks = numticks;

host_nexttick = host_state.interval_per_tick - host_remainder;

Expand Down Expand Up @@ -3240,14 +3234,14 @@ void _Host_RunFrame (float time)
g_ClientGlobalVariables.next_interpolation_amount = cl.m_tickRemainder / host_state.interval_per_tick;

// TODO_ENHANCED:
// Update the mouse as last so we can get the right viewangles while taking screenshot.
// Update the mouse as first so we can get the right viewangles while rendering.
// 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 );
CL_ExtraMovementUpdate( host_frametime );
#endif
for ( int tick = 0; tick < numticks; tick++ )
{
Expand Down Expand Up @@ -3300,8 +3294,7 @@ void _Host_RunFrame (float time)
//---------------------------------------------------------
// CL_RunPrediction( PREDICTION_NORMAL );

_Host_RunFrame_Input( prevremainder, bFinalTick );
prevremainder = 0;
_Host_RunFrame_Input( host_frametime, bFinalTick );

//-------------------
//
Expand Down Expand Up @@ -3436,14 +3429,14 @@ void _Host_RunFrame (float time)
g_ServerGlobalVariables.tickcount = sv.m_nTickCount;

// TODO_ENHANCED:
// Update the mouse as last so we can get the right viewangles while taking screenshot.
// Update the mouse as first so we can get the right viewangles while rendering.
// 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 );
CL_ExtraMovementUpdate( host_frametime );

// THREADED: Run Client
// -------------------
Expand Down Expand Up @@ -3518,8 +3511,7 @@ void _Host_RunFrame (float time)
bool bFinalTick = tick==(serverticks-1) ? true : false;
// Run prediction before inputs if fps is lower than tickrate
// CL_RunPrediction( PREDICTION_NORMAL );
_Host_RunFrame_Input( prevremainder, bFinalTick );
prevremainder = 0;
_Host_RunFrame_Input( host_frametime, bFinalTick );
// process any asynchronous network traffic (TCP), set net_time
NET_RunFrame( Plat_FloatTime() );
}
Expand Down
6 changes: 3 additions & 3 deletions game/client/cdll_client_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ class CHLClient : public IBaseClientDLL
virtual void IN_SetSampleTime( float frametime );
// Create movement command
virtual void CreateMove ( int sequence_number, float input_sample_frametime, bool active );
virtual void ExtraMouseSample( int sequence_number, float frametime, bool active );
virtual void ExtraMovementSample( int number_of_ticks_this_frame, int current_command, float frametime, bool active );
virtual bool WriteUsercmdDeltaToBuffer( bf_write *buf, int from, int to, bool isnewcommand );
virtual void EncodeUserCmdToBuffer( bf_write& buf, int slot );
virtual void DecodeUserCmdFromBuffer( bf_read& buf, int slot );
Expand Down Expand Up @@ -1419,15 +1419,15 @@ int CHLClient::IN_KeyEvent( int eventcode, ButtonCode_t keynum, const char *pszC
return input->KeyEvent( eventcode, keynum, pszCurrentBinding );
}

void CHLClient::ExtraMouseSample( int sequence_number, float frametime, bool active )
void CHLClient::ExtraMovementSample( int number_of_ticks_this_frame, int current_command, float frametime, bool active )
{
Assert( C_BaseEntity::IsAbsRecomputationsEnabled() );
Assert( C_BaseEntity::IsAbsQueriesValid() );

C_BaseAnimating::AutoAllowBoneAccess boneaccess( true, false );

MDLCACHE_CRITICAL_SECTION();
input->ExtraMouseSample( sequence_number, frametime, active );
input->ExtraMovementSample( number_of_ticks_this_frame, current_command, frametime, active );
}

void CHLClient::IN_SetSampleTime( float frametime )
Expand Down
2 changes: 1 addition & 1 deletion game/client/iinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract_class IInput
virtual int GetButtonBits( int ) = 0;
// Create movement command
virtual void CreateMove ( int sequence_number, float input_sample_frametime, bool active ) = 0;
virtual void ExtraMouseSample( int sequence_number, float frametime, bool active ) = 0;
virtual void ExtraMovementSample( int number_of_ticks_this_frame, int current_command, float frametime, bool active ) = 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 DecodeUserCmdFromBuffer( bf_read& buf, int slot ) = 0;
Expand Down
Loading

0 comments on commit 30ad2cc

Please sign in to comment.