/* * CL_NewUserCommand */ void CL_NewUserCommand( int realmsec ) { usercmd_t *ucmd; if( !CL_NextUserCommandTimeReached( realmsec ) ) return; if( cls.state < CA_ACTIVE ) return; cl.cmdNum = cls.ucmdHead; ucmd = &cl.cmds[cl.cmdNum & CMD_MASK]; ucmd->serverTimeStamp = cl.serverTime; // return the time stamp to the server cl.cmd_time[cl.cmdNum & CMD_MASK] = cls.realtime; // control cinematics by buttons if( ucmd->buttons && SCR_GetCinematicTime() > 0 && cls.realtime > 1000 + SCR_GetCinematicTime() ) { // skip the rest of the cinematic SCR_FinishCinematic(); SCR_UpdateScreen(); } // snap push fracs so client and server version match ucmd->forwardfrac = ( (int)( UCMD_PUSHFRAC_SNAPSIZE * ucmd->forwardfrac ) ) / UCMD_PUSHFRAC_SNAPSIZE; ucmd->sidefrac = ( (int)( UCMD_PUSHFRAC_SNAPSIZE * ucmd->sidefrac ) ) / UCMD_PUSHFRAC_SNAPSIZE; ucmd->upfrac = ( (int)( UCMD_PUSHFRAC_SNAPSIZE * ucmd->upfrac ) ) / UCMD_PUSHFRAC_SNAPSIZE; if( cl.cmdNum > 0 ) ucmd->msec = ucmd->serverTimeStamp - cl.cmds[( cl.cmdNum-1 ) & CMD_MASK].serverTimeStamp; else ucmd->msec = 20; if( ucmd->msec < 1 ) ucmd->msec = 1; // advance head and init the new command cls.ucmdHead++; ucmd = &cl.cmds[cls.ucmdHead & CMD_MASK]; memset( ucmd, 0, sizeof( usercmd_t ) ); // start up with the most recent viewangles ucmd->angles[0] = ANGLE2SHORT( cl.viewangles[0] ); ucmd->angles[1] = ANGLE2SHORT( cl.viewangles[1] ); ucmd->angles[2] = ANGLE2SHORT( cl.viewangles[2] ); }
/* * CL_NewUserCommand */ void CL_NewUserCommand( int realmsec ) { usercmd_t *ucmd; if( !CL_NextUserCommandTimeReached( realmsec ) ) return; if( cls.state < CA_ACTIVE ) return; cl.cmdNum = cls.ucmdHead; ucmd = &cl.cmds[cl.cmdNum & CMD_MASK]; ucmd->serverTimeStamp = cl.serverTime; // return the time stamp to the server cl.cmd_time[cl.cmdNum & CMD_MASK] = cls.realtime; // snap push fracs so client and server version match ucmd->forwardmove = ( (int)( UCMD_PUSHFRAC_SNAPSIZE * ucmd->forwardmove ) ) / UCMD_PUSHFRAC_SNAPSIZE; ucmd->sidemove = ( (int)( UCMD_PUSHFRAC_SNAPSIZE * ucmd->sidemove ) ) / UCMD_PUSHFRAC_SNAPSIZE; ucmd->upmove = ( (int)( UCMD_PUSHFRAC_SNAPSIZE * ucmd->upmove ) ) / UCMD_PUSHFRAC_SNAPSIZE; if( cl.cmdNum > 0 ) ucmd->msec = ucmd->serverTimeStamp - cl.cmds[( cl.cmdNum-1 ) & CMD_MASK].serverTimeStamp; else ucmd->msec = 20; if( ucmd->msec < 1 ) ucmd->msec = 1; // advance head and init the new command cls.ucmdHead++; ucmd = &cl.cmds[cls.ucmdHead & CMD_MASK]; memset( ucmd, 0, sizeof( usercmd_t ) ); // start up with the most recent viewangles ucmd->angles[0] = ANGLE2SHORT( cl.viewangles[0] ); ucmd->angles[1] = ANGLE2SHORT( cl.viewangles[1] ); ucmd->angles[2] = ANGLE2SHORT( cl.viewangles[2] ); }