From 5dea48daf494adbf28c75cb74e478e5bc15fbff4 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Fri, 30 Jan 2009 22:12:09 +0000 Subject: Client now works around the fact R1Q2 servers always report the highest protocol number they support in svc_serverdata message, regardless of the actual protocol version being used. Be silent and try to preserve reliable data at least when client demo message overflows, do not dump entire message. Use playerstate coordinates for positioning player's own entity in case it is invisible regardless of server protocol version. Changed ‘map_allsolid_bug’ default to 0, since it seems to break some mods. Implemented ‘recycle’ command for dedicated servers. Correctly parse comments from ‘/etc/default/q2pro’ config file. Install SIGHUP handler when running dedicated server only. It can now be used to reopen server logfile for rotation. Allow ${arg1-arg2} syntax when expanding alias parameters. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/common.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 11 deletions(-) (limited to 'source/common.c') diff --git a/source/common.c b/source/common.c index 5d91f12..28cd816 100644 --- a/source/common.c +++ b/source/common.c @@ -270,6 +270,22 @@ static void logfile_write( const char *string ) { FS_Write( text, len, com_logFile ); } +#ifdef __unix__ +/* +============= +Com_FlushLogs + +When called from SIGHUP handler on UNIX-like systems, +will close and reopen logfile handle for rotation. +============= +*/ +void Com_FlushLogs( void ) { + if( logfile_enable ) { + logfile_enable_changed( logfile_enable ); + } +} +#endif + /* ============= Com_Printf @@ -446,7 +462,7 @@ void Com_Error( comErrorType_t code, const char *fmt, ... ) { #if USE_CLIENT CL_Shutdown(); #endif - Qcommon_Shutdown( qtrue ); + Qcommon_Shutdown(); Sys_Error( "%s", com_errorMsg ); } @@ -490,27 +506,36 @@ Both client and server can use this, and it will do the apropriate things. ============= */ -void Com_Quit( const char *reason ) { - if( reason && *reason ) { - char buffer[MAX_STRING_TOKENS]; +void Com_Quit( const char *reason, killtype_t type ) { + char buffer[MAX_STRING_TOKENS]; + char *what = type == KILL_RESTART ? "restarted" : "quit"; + if( reason && *reason ) { Q_snprintf( buffer, sizeof( buffer ), - "Server quit: %s\n", reason ); - SV_Shutdown( buffer, KILL_DROP ); + "Server %s: %s\n", what, reason ); } else { - SV_Shutdown( "Server quit\n", KILL_DROP ); + Q_snprintf( buffer, sizeof( buffer ), + "Server %s\n", what ); } + SV_Shutdown( buffer, type ); + #if USE_CLIENT CL_Shutdown(); #endif - Qcommon_Shutdown( qfalse ); + Qcommon_Shutdown(); Sys_Quit(); } static void Com_Quit_f( void ) { - Com_Quit( Cmd_Args() ); + Com_Quit( Cmd_Args(), KILL_DROP ); +} + +#if !USE_CLIENT +static void Com_Recycle_f( void ) { + Com_Quit( Cmd_Args(), KILL_RESTART ); } +#endif /* @@ -1075,7 +1100,7 @@ size_t Com_Uptime_m( char *buffer, size_t size ) { } size_t Com_Random_m( char *buffer, size_t size ) { - return Q_scnprintf( buffer, size, "%d", ( rand() ^ ( rand() >> 8 ) ) % 10 ); + return Q_scnprintf( buffer, size, "%d", rand_byte() % 10 ); } static size_t Com_MapList_m( char *buffer, size_t size ) { @@ -1233,6 +1258,20 @@ void Com_Color_g( genctx_t *ctx ) { } #endif +void Com_PlayerToEntityState( const player_state_t *ps, entity_state_t *es ) { + vec_t pitch; + + VectorScale( ps->pmove.origin, 0.125f, es->origin ); + + pitch = ps->viewangles[PITCH]; + if( pitch > 180 ) { + pitch -= 360; + } + es->angles[PITCH] = pitch / 3; + es->angles[YAW] = ps->viewangles[YAW]; + es->angles[ROLL] = 0; +} + #if USE_CLIENT || USE_MVD_CLIENT || USE_MVD_SERVER const cmd_option_t o_record[] = { { "h", "help", "display this message" }, @@ -1463,6 +1502,9 @@ void Qcommon_Init( int argc, char **argv ) { Cmd_AddCommand( "lasterror", Com_LastError_f ); Cmd_AddCommand( "quit", Com_Quit_f ); +#if !USE_CLIENT + Cmd_AddCommand( "recycle", Com_Recycle_f ); +#endif srand( Sys_Milliseconds() ); @@ -1646,7 +1688,7 @@ void Qcommon_Frame( void ) { Qcommon_Shutdown ================= */ -void Qcommon_Shutdown( qboolean fatalError ) { +void Qcommon_Shutdown( void ) { NET_Shutdown(); logfile_close(); FS_Shutdown( qtrue ); -- cgit v1.2.3