engine: client: always pass a valid pointer to usercmd_t in ref_params_t to prevent crassh when client.dll reads them during demo playback

This commit is contained in:
Alibek Omarov
2025-05-05 03:40:18 +03:00
parent 47c4844024
commit 3d26ba1ed8
5 changed files with 10 additions and 10 deletions

View File

@@ -642,9 +642,7 @@ static void CL_ReadDemoUserCmd( qboolean discard )
pcmd->sendsize = 1;
// always delta'ing from null
cl.cmd = &pcmd->cmd;
MSG_ReadDeltaUsercmd( &buf, &nullcmd, cl.cmd );
MSG_ReadDeltaUsercmd( &buf, &nullcmd, &pcmd->cmd );
// make sure what interp info contain angles from different frames
// or lerping will stop working
@@ -656,13 +654,16 @@ static void CL_ReadDemoUserCmd( qboolean discard )
// record update
a->starttime = demo.timestamp;
VectorCopy( cl.cmd->viewangles, a->viewangles );
VectorCopy( pcmd->cmd.viewangles, a->viewangles );
demo.lasttime = demo.timestamp;
}
// NOTE: we need to have the current outgoing sequence correct
// so we can do prediction correctly during playback
cls.netchan.outgoing_sequence = outgoing_sequence;
// save last usercmd
cl.cmd = pcmd->cmd;
}
}
@@ -1145,8 +1146,7 @@ void CL_DemoInterpolateAngles( void )
QuaternionSlerp( q2, q1, frac, q );
QuaternionAngle( q, cl.viewangles );
}
else if( cl.cmd != NULL )
VectorCopy( cl.cmd->viewangles, cl.viewangles );
else VectorCopy( cl.cmd.viewangles, cl.viewangles );
}
/*

View File

@@ -673,7 +673,7 @@ static void CL_CreateCmd( void )
}
// demo always have commands so don't overwrite them
if( !cls.demoplayback ) cl.cmd = &pcmd->cmd;
if( !cls.demoplayback ) cl.cmd = pcmd->cmd;
// predict all unacknowledged movements
CL_PredictMovement( false );

View File

@@ -973,7 +973,7 @@ void CL_MoveSpectatorCamera( void )
CL_SetUpPlayerPrediction( false, true );
CL_SetSolidPlayers( cl.playernum );
CL_RunUsercmd( &cls.spectator_state, &cls.spectator_state, cl.cmd, true, &time, (uint)( time * 100.0 ));
CL_RunUsercmd( &cls.spectator_state, &cls.spectator_state, &cl.cmd, true, &time, (uint)( time * 100.0 ));
VectorCopy( cls.spectator_state.client.velocity, cl.simvel );
VectorCopy( cls.spectator_state.client.origin, cl.simorg );

View File

@@ -165,7 +165,7 @@ static void V_SetRefParams( ref_params_t *fd )
// get pointers to movement vars and user cmd
fd->movevars = &clgame.movevars;
fd->cmd = cl.cmd;
fd->cmd = &cl.cmd;
// setup viewport
fd->viewport[0] = clgame.viewport[0];

View File

@@ -234,7 +234,7 @@ typedef struct
cl_local_data_t local;
// player final info
usercmd_t *cmd; // cl.commands[outgoing_sequence].cmd
usercmd_t cmd; // cl.commands[outgoing_sequence].cmd
vec3_t viewangles;
vec3_t viewheight;
vec3_t punchangle;