All pastes #343314 Raw Edit

Someone

public text v1 · immutable
·published 2007-02-06 23:12 UTC
rendered paste body
// get action every X snapshot - ping based
// store ping for other calls
int isCommandTime( void ) {
	static int server_time = 0;
	usercmd_t u_cmd;
	int lastCmdNo, snapDelay = ( int )seth.value[ VAR_SNAPDELAY ];

	if ( snapDelay == 0 )
		return 1;

	if( server_time == 0 ) {
		server_time = eth.cg_time;
		return 1;
	}

	lastCmdNo = orig_syscall( CG_GETCURRENTCMDNUMBER );
	orig_syscall( CG_GETUSERCMD, lastCmdNo, &u_cmd );

	eth.myping = eth.cg_time - u_cmd.serverTime;

	if (
		( ( eth.cg_time - server_time ) / snapDelay ) >
		( ( eth.cg_time - u_cmd.serverTime ) / snapDelay )
	) {
		server_time = eth.cg_time;
		return 1;
	}

	return 0;
}