diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 34d21e7a..64dd4970 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1063,7 +1063,7 @@ void CL_CheckForResend( void ) if( cls.connect_retry == CL_TEST_RETRIES_NORESPONCE ) { // too many fails use default connection method - Msg( "hi-speed coonection is failed, use default method\n" ); + Con_Printf( "hi-speed connection is failed, use default method\n" ); Netchan_OutOfBandPrint( NS_CLIENT, adr, "getchallenge\n" ); Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE ); cls.connect_time = host.realtime; @@ -1775,7 +1775,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) if( cls.connect_retry >= CL_TEST_RETRIES ) { // too many fails use default connection method - Msg( "hi-speed coonection is failed, use default method\n" ); + Con_Printf( "hi-speed connection is failed, use default method\n" ); Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" ); Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE ); cls.connect_time = host.realtime; @@ -1807,7 +1807,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) if( cls.connect_retry >= CL_TEST_RETRIES ) { // too many fails use default connection method - Msg( "hi-speed coonection is failed, use default method\n" ); + Con_Printf( "hi-speed connection is failed, use default method\n" ); Netchan_OutOfBandPrint( NS_CLIENT, from, "getchallenge\n" ); Cvar_SetValue( "cl_dlmax", FRAGMENT_MIN_SIZE ); cls.connect_time = host.realtime; @@ -2190,7 +2190,8 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename ) } else { - Con_Printf( "Downloaded %i bytes for purported %i byte file, ignoring download\n", cls.netchan.tempbuffersize, p->nDownloadSize ); + Con_Printf( "Downloaded %i bytes for purported %i byte file, ignoring download\n", + cls.netchan.tempbuffersize, p->nDownloadSize ); } if( cls.netchan.tempbuffer ) diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 6e028ced..3c9be410 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -1039,7 +1039,7 @@ void CL_CreateCustomizationList( void ) pResource = &cl.resourcelist[i]; if( !COM_CreateCustomization( &pPlayer->customdata, pResource, cl.playernum, 0, NULL, NULL )) - Con_Printf( "problem with client customization %i, ignoring...", pResource ); + Con_Printf( "problem with client customization %s, ignoring...", pResource->szFileName ); } } diff --git a/engine/client/cl_pmove.c b/engine/client/cl_pmove.c index f564bf0e..7c9c44f4 100644 --- a/engine/client/cl_pmove.c +++ b/engine/client/cl_pmove.c @@ -1220,6 +1220,7 @@ void CL_PredictMovement( qboolean repredicting ) int i, stoppoint; qboolean runfuncs; double f = 1.0; + cl_entity_t *ent; double time; if( cls.state != ca_active || cls.spectator ) @@ -1349,8 +1350,7 @@ void CL_PredictMovement( qboolean repredicting ) if( FBitSet( to->client.flags, FL_ONGROUND )) { - cl_entity_t *ent = CL_GetEntityByIndex( cl.local.lastground ); - + ent = CL_GetEntityByIndex( cl.local.lastground ); cl.local.onground = cl.local.lastground; cl.local.moving = false; diff --git a/engine/client/cl_scrn.c b/engine/client/cl_scrn.c index aa0d84c5..8c08bf64 100644 --- a/engine/client/cl_scrn.c +++ b/engine/client/cl_scrn.c @@ -126,7 +126,7 @@ void SCR_NetSpeeds( void ) if( !host.allow_console ) return; - if( !net_speeds->value || cls.demoplayback || cls.state != ca_active ) + if( !net_speeds->value || cls.state != ca_active ) return; // prevent to get too big values at max diff --git a/engine/client/console.c b/engine/client/console.c index cb741ab1..8c5af579 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -2043,9 +2043,9 @@ void Con_DrawDebug( void ) if( scr_download->value != -1.0f ) { - Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% (%f elapsed)", - host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart ); - x = glState.width - 400; + Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs", + host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart ); + x = glState.width - 500; y = con.curFont->charHeight * 1.05f; Con_DrawString( x, y, dlstring, g_color_table[7] ); } diff --git a/engine/client/gl_image.c b/engine/client/gl_image.c index 7d6882c5..880422e8 100644 --- a/engine/client/gl_image.c +++ b/engine/client/gl_image.c @@ -311,9 +311,9 @@ void R_SetTextureParameters( void ) if( GL_Support( GL_TEXTURE_LOD_BIAS )) { if( gl_texture_lodbias->value < -glConfig.max_texture_lod_bias ) - Cvar_SetValue( "gl_mipmap_bias", -glConfig.max_texture_lod_bias ); + Cvar_SetValue( "gl_texture_lodbias", -glConfig.max_texture_lod_bias ); else if( gl_texture_lodbias->value > glConfig.max_texture_lod_bias ) - Cvar_SetValue( "gl_mipmap_bias", glConfig.max_texture_lod_bias ); + Cvar_SetValue( "gl_texture_lodbias", glConfig.max_texture_lod_bias ); } ClearBits( gl_texture_anisotropy->flags, FCVAR_CHANGED ); diff --git a/engine/common/crtlib.c b/engine/common/crtlib.c index 3e73020a..b0163afe 100644 --- a/engine/common/crtlib.c +++ b/engine/common/crtlib.c @@ -562,7 +562,22 @@ int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list ar { size_t result; +#ifndef _MSC_VER result = vsnprintf( buffer, buffersize, format, args ); +#else + __try + { + result = _vsnprintf( buffer, buffersize, format, args ); + } + + // to prevent crash while output + __except( EXCEPTION_EXECUTE_HANDLER ) + { + Q_strncpy( buffer, "^1sprintf throw exception^7\n", buffersize ); +// memset( buffer, 0, buffersize ); + result = buffersize; + } +#endif if( result < 0 || result >= buffersize ) { diff --git a/engine/common/filesystem.c b/engine/common/filesystem.c index 4a0c4682..6c7c766b 100644 --- a/engine/common/filesystem.c +++ b/engine/common/filesystem.c @@ -1596,7 +1596,7 @@ static file_t *FS_SysOpen( const char *filepath, const char *mode ) opt |= O_BINARY; break; default: - MsgDev( D_ERROR, "FS_SysOpen: %s: unknown char %c in mode (%s)\n", filepath, mode[ind], mode ); + MsgDev( D_ERROR, "FS_SysOpen: %s: unknown char (%c) in mode (%s)\n", filepath, mode[ind], mode ); break; } } diff --git a/engine/common/host.c b/engine/common/host.c index d802e0bd..22367392 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -46,10 +46,10 @@ host_parm_t host; // host parms sysinfo_t SI; CVAR_DEFINE( host_developer, "developer", "0", 0, "engine is in development-mode" ); +CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" ); convar_t *host_gameloaded; convar_t *host_clientloaded; convar_t *host_limitlocal; -convar_t host_developer; convar_t *host_maxfps; convar_t *host_framerate; convar_t *con_gamemaps; @@ -148,7 +148,7 @@ void Host_CheckSleep( void ) if( host.type == HOST_DEDICATED ) { // let the dedicated server some sleep -// Sys_Sleep( 1 ); + Sys_Sleep( 1 ); } else { @@ -413,15 +413,23 @@ double Host_CalcFPS( void ) // NOTE: we should play demos with same fps as it was recorded #ifndef XASH_DEDICATED if( CL_IsPlaybackDemo() || CL_IsRecordDemo( )) + { fps = CL_GetDemoFramerate(); - else -#endif - if( Host_IsLocalGame( )) + } + else if( Host_IsLocalGame( )) + { fps = host_maxfps->value; + } + else +#endif + if( Host_IsDedicated() ) + { + fps = sys_ticrate.value; + } else { fps = host_maxfps->value; - if( fps == 0.0 ) fps = HOST_FPS; // default for multiplayer + fps = bound( MIN_FPS, fps, MAX_FPS ); } #ifndef XASH_DEDICATED @@ -462,8 +470,16 @@ qboolean Host_FilterTime( float time ) // limit fps to withing tolerable range fps = bound( MIN_FPS, fps, MAX_FPS ); - if(( host.realtime - oldtime ) < ( 1.0 / fps )) - return false; + if( host.type == HOST_DEDICATED ) + { + if(( host.realtime - oldtime ) < ( 1.0 / ( fps + 1.0 ))) + return false; + } + else + { + if(( host.realtime - oldtime ) < ( 1.0 / fps )) + return false; + } } host.frametime = host.realtime - oldtime; @@ -795,6 +811,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha #ifdef _WIN32 Wcon_CreateConsole(); // system console used by dedicated server or show fatal errors #endif + // timeBeginPeriod( 1 ); // a1ba: Do we need this? // NOTE: this message couldn't be passed into game console but it doesn't matter MsgDev( D_NOTE, "Sys_LoadLibrary: Loading xash.dll - ok\n" ); @@ -812,6 +829,13 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha // share developer level across all dlls Q_snprintf( dev_level, sizeof( dev_level ), "%i", developer ); Cvar_DirectSet( &host_developer, dev_level ); + Cvar_RegisterVariable( &sys_ticrate ); + + if( Sys_GetParmFromCmdLine( "-sys_ticrate", ticrate )) + { + fps = bound( MIN_FPS, atof( ticrate ), MAX_FPS ); + Cvar_SetValue( "sys_ticrate", fps ); + } Con_Init(); // early console running to catch all the messages Cmd_AddCommand( "exec", Host_Exec_f, "execute a script file" ); @@ -871,7 +895,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa Cmd_AddCommand ( "crash", Host_Crash_f, "a way to force a bus error for development reasons"); } - host_maxfps = Cvar_Get( "fps_max", "100", FCVAR_ARCHIVE, "host fps upper limit" ); + host_maxfps = Cvar_Get( "fps_max", "72", FCVAR_ARCHIVE, "host fps upper limit" ); host_framerate = Cvar_Get( "host_framerate", "0", 0, "locks frame timing to this value in seconds" ); host_gameloaded = Cvar_Get( "host_gameloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded game.dll" ); host_clientloaded = Cvar_Get( "host_clientloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" ); diff --git a/engine/common/hpak.c b/engine/common/hpak.c index 1c4fa210..392dd3b0 100644 --- a/engine/common/hpak.c +++ b/engine/common/hpak.c @@ -1023,7 +1023,7 @@ void HPAK_Extract_f( void ) if( entry->disksize <= 0 || entry->disksize >= HPAK_MAX_SIZE ) { - MsgDev( D_WARN, "Unable to extract data, size invalid: %i\n", nDataSize ); + MsgDev( D_WARN, "Unable to extract data, size invalid: %s\n", Q_memprint( entry->disksize )); continue; } diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index 5589f8cd..8a5118af 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -1528,7 +1528,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod ) { if( ft1 > ft2 ) { - Con_Printf( S_WARN "Entity patch %s is older than bsp. Ignored.\n", entfilename ); + Con_Printf( S_WARN "Entity patch is older than bsp. Ignored.\n" ); } else if(( entpatch = FS_LoadFile( entfilename, &entpatchsize, true )) != NULL ) { diff --git a/engine/common/zone.c b/engine/common/zone.c index 3608dd4c..d5be638d 100644 --- a/engine/common/zone.c +++ b/engine/common/zone.c @@ -164,11 +164,16 @@ static const char *Mem_CheckFilename( const char *filename ) const char *out = filename; int i; - if( !out ) return dummy; + if( !COM_CheckString( out )) + return dummy; + for( i = 0; i < 128; i++, out++ ) - if( *out == '\0' ) break; // valid name - if( i == 128 ) return dummy; - return filename; + { + if( *out == '\0' ) + return filename; // valid name + } + + return dummy; } static void Mem_FreeBlock( memheader_t *mem, const char *filename, int fileline ) diff --git a/engine/menu_int.h b/engine/menu_int.h index bc7b156a..6ad0a413 100644 --- a/engine/menu_int.h +++ b/engine/menu_int.h @@ -168,9 +168,8 @@ typedef struct ui_enginefuncs_s int (*pfnCompareFileTime)( const char *filename1, const char *filename2, int *iCompare ); const char *(*pfnGetModeString)( int vid_mode ); - - int (*COM_SaveFile)( const char *filename, const void *data, int len ); - int (*pfnDeleteFile)( const char *filename ); + int (*COM_SaveFile)( const char *filename, const void *data, long len ); + int (*COM_RemoveFile)( const char *filepath ); } ui_enginefuncs_t; typedef struct ui_textfuncs_s { diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index dbb571ec..4e91953b 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -72,8 +72,11 @@ void SV_BroadcastPrintf( sv_client_t *ignore, char *fmt, ... ) } } - // echo to console - Con_DPrintf( "%s", string ); + if( Host_IsDedicated() ) + { + // echo to console + Con_DPrintf( string ); + } } /* diff --git a/engine/server/sv_frame.c b/engine/server/sv_frame.c index 28b1bc07..339b106b 100644 --- a/engine/server/sv_frame.c +++ b/engine/server/sv_frame.c @@ -60,8 +60,8 @@ static void SV_AddEntitiesToPacket( edict_t *pViewEnt, edict_t *pClient, client_ byte *clientpvs; byte *clientphs; qboolean fullvis = false; - sv_client_t *netclient; sv_client_t *cl = NULL; + qboolean player; entity_state_t *state; int e; @@ -101,15 +101,29 @@ static void SV_AddEntitiesToPacket( edict_t *pViewEnt, edict_t *pClient, client_ if( CHECKVISBIT( ents->sended, e )) continue; + if( e >= 1 && e <= svs.maxclients ) + player = 1; + else player = 0; + + if( player ) + { + sv_client_t *cl = &svs.clients[e - 1]; + + if( cl->state != cs_spawned ) + continue; + + if( FBitSet( cl->flags, FCL_HLTV_PROXY )) + continue; + } + if( FBitSet( ent->v.effects, EF_REQUEST_PHS )) pset = clientphs; else pset = clientpvs; state = &ents->entities[ents->num_entities]; - netclient = SV_ClientFromEdict( ent, true ); // add entity to the net packet - if( svgame.dllFuncs.pfnAddToFullPack( state, e, ent, pClient, sv.hostflags, ( netclient != NULL ), pset )) + if( svgame.dllFuncs.pfnAddToFullPack( state, e, ent, pClient, sv.hostflags, player, pset )) { // to prevent adds it twice through portals SETVISBIT( ents->sended, e ); @@ -807,7 +821,7 @@ void SV_SendClientMessages( void ) { cl = sv.current_client; - if( !cl->state || FBitSet( cl->flags, FCL_FAKECLIENT )) + if( cl->state <= cs_zombie || FBitSet( cl->flags, FCL_FAKECLIENT )) continue; if( FBitSet( cl->flags, FCL_SKIP_NET_MESSAGE )) diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 9a736988..533efb6d 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -876,6 +876,10 @@ void SV_InitEdict( edict_t *pEdict ) SV_FreePrivateData( pEdict ); memset( &pEdict->v, 0, sizeof( entvars_t )); pEdict->v.pContainingEntity = pEdict; + pEdict->v.controller[0] = 0x7F; + pEdict->v.controller[1] = 0x7F; + pEdict->v.controller[2] = 0x7F; + pEdict->v.controller[3] = 0x7F; pEdict->free = false; }