Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cgame/cg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ If you have questions concerning this license or the applicable additional terms

#define CMD_BACKUP 64
#define CMD_MASK ( CMD_BACKUP - 1 )

#define CMD_BACKUP_EXT 128
#define CMD_MASK_EXT ( CMD_BACKUP_EXT - 1 )
// allow a lot of command backups for very fast systems
// multiple commands may be combined into a single packet, so this
// needs to be larger than PACKET_BACKUP
Expand Down Expand Up @@ -273,6 +276,8 @@ typedef enum {
CG_R_ADDLINEARLIGHTTOSCENE,
CG_PC_REMOVE_ALL_GLOBAL_DEFINES,
CG_GETCLIPBOARDDATA,
CG_CMDBACKUP_EXT,

CG_TRAP_GETVALUE = COM_TRAP_GETVALUE,
#endif

Expand Down
14 changes: 12 additions & 2 deletions src/client/cl_cgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ static qboolean CL_GetUserCmd( int cmdNumber, usercmd_t *ucmd ) {

// the usercmd has been overwritten in the wrapping
// buffer because it is too far out of date
if ( cl.cmdNumber - cmdNumber >= CMD_BACKUP ) {
if ( cl.cmdNumber - cmdNumber >= cl.cmdBackup ) {
return qfalse;
}

*ucmd = cl.cmds[ cmdNumber & CMD_MASK ];
*ucmd = cl.cmds[ cmdNumber & cl.cmdMask ];

return qtrue;
}
Expand Down Expand Up @@ -684,6 +684,11 @@ static qboolean CL_CG_GetValue( char* value, int valueSize, const char* key ) {
return qtrue;
}

if ( !Q_stricmp( key, "trap_CmdBackup_Ext_Legacy" ) ) {
Com_sprintf( value, valueSize, "%i", CG_CMDBACKUP_EXT );
return qtrue;
}

return qfalse;
}

Expand Down Expand Up @@ -1200,6 +1205,11 @@ static intptr_t CL_CgameSystemCalls( intptr_t *args ) {
CL_GetClipboardData( VMA(1), args[2] );
return 0;

case CG_CMDBACKUP_EXT:
cl.cmdBackup = CMD_BACKUP_EXT;
cl.cmdMask = CMD_MASK_EXT;
return 0;

case CG_TRAP_GETVALUE:
return CL_CG_GetValue( VMA(1), args[2], VMA(3) );

Expand Down
4 changes: 2 additions & 2 deletions src/client/cl_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ static void CL_CreateNewCommands( void ) {

// generate a command for this frame
cl.cmdNumber++;
cmdNum = cl.cmdNumber & CMD_MASK;
cmdNum = cl.cmdNumber & cl.cmdMask;
cl.cmds[cmdNum] = CL_CreateCmd();
}

Expand Down Expand Up @@ -939,7 +939,7 @@ void CL_WritePacket( void ) {

// write all the commands, including the predicted command
for ( i = 0 ; i < count ; i++ ) {
j = (cl.cmdNumber - count + i + 1) & CMD_MASK;
j = (cl.cmdNumber - count + i + 1) & cl.cmdMask;
cmd = &cl.cmds[j];
MSG_WriteDeltaUsercmdKey (&buf, key, oldcmd, cmd);
oldcmd = cmd;
Expand Down
3 changes: 3 additions & 0 deletions src/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,9 @@ void CL_ClearState( void ) {
// S_StopAllSounds();

Com_Memset( &cl, 0, sizeof( cl ) );

cl.cmdBackup = CMD_BACKUP;
cl.cmdMask = CMD_MASK;
}

/*
Expand Down
9 changes: 6 additions & 3 deletions src/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,12 @@ typedef struct {

// cmds[cmdNumber] is the predicted command, [cmdNumber-1] is the last
// properly generated command
usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds
int cmdNumber; // incremented each frame, because multiple
// frames may need to be packed into a single packet
usercmd_t cmds[CMD_BACKUP_EXT]; // each mesage will send several old cmds
int cmdNumber; // incremented each frame, because multiple
// frames may need to be packed into a single packet

int cmdBackup;
int cmdMask;

// Arnout: double tapping
doubleTap_t doubleTap;
Expand Down