Remove useless host.type set, replace HOST_DEDICATED checks by Host_IsDedicated

This commit is contained in:
Alibek Omarov 2018-05-01 17:27:14 +03:00
parent becd0eba03
commit 0681209114
12 changed files with 20 additions and 21 deletions

View File

@ -388,7 +388,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
numi = (short *)(pinhl + 1);
}
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
{
// skip frames loading
if( loaded ) *loaded = true; // done
@ -494,4 +494,4 @@ void Mod_UnloadSpriteModel( model_t *mod )
memset( mod, 0, sizeof( *mod ));
}
#endif // XASH_DEDICATED
#endif // XASH_DEDICATED

View File

@ -1446,7 +1446,7 @@ void FS_Init( void )
#endif
// ignore commandlineoption "-game" for other stuff
if( host.type == HOST_NORMAL || host.type == HOST_DEDICATED )
if( host.type == HOST_NORMAL || Host_IsDedicated() )
{
stringlistinit( &dirs );
listdirectory( &dirs, "./", false );

View File

@ -145,7 +145,7 @@ Host_CheckSleep
*/
void Host_CheckSleep( void )
{
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
{
// let the dedicated server some sleep
Sys_Sleep( 1 );
@ -470,7 +470,7 @@ qboolean Host_FilterTime( float time )
// limit fps to withing tolerable range
fps = bound( MIN_FPS, fps, MAX_FPS );
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
{
if(( host.realtime - oldtime ) < ( 1.0 / ( fps + 1.0 )))
return false;
@ -746,7 +746,6 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
}
}
host.type = HOST_NORMAL; // predict state
host.con_showalways = true;
#ifdef XASH_DEDICATED
@ -925,7 +924,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
ID_Init();
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
{
#ifdef _WIN32
Wcon_InitConsoleCommands ();
@ -967,7 +966,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
oldtime = Sys_DoubleTime() - 0.1;
if( host.type == HOST_DEDICATED && GameState->nextstate == STATE_RUNFRAME )
if( Host_IsDedicated() && GameState->nextstate == STATE_RUNFRAME )
Con_Printf( "type 'map <mapname>' to run server... (TAB-autocomplete is working too)\n" );
// main window message loop

View File

@ -1450,7 +1450,7 @@ void NET_SendPacket( netsrc_t sock, size_t length, const void *data, netadr_t to
return;
#endif
}
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
{
MsgDev( D_ERROR, "NET_SendPacket: %s to %s\n", NET_ErrorString(), NET_AdrToString( to ));
}
@ -1642,13 +1642,13 @@ static void NET_OpenIP( void )
if( !port ) port = PORT_SERVER; // forcing to default
net.ip_sockets[NS_SERVER] = NET_IPSocket( net_ipname->string, port, false );
if( !NET_IsSocketValid( net.ip_sockets[NS_SERVER] ) && host.type == HOST_DEDICATED )
if( !NET_IsSocketValid( net.ip_sockets[NS_SERVER] ) && Host_IsDedicated() )
Host_Error( "Couldn't allocate dedicated server IP port %d.\n", port );
sv_port = port;
}
// dedicated servers don't need client ports
if( host.type == HOST_DEDICATED ) return;
if( Host_IsDedicated() ) return;
if( !NET_IsSocketValid( net.ip_sockets[NS_CLIENT] ) )
{

View File

@ -22,7 +22,7 @@ GNU General Public License for more details.
#define XASH_COLORIZE_CONSOLE
// use with caution, running engine in Qt Creator may cause a freeze in read() call
// I was never encountered this bug anywhere else, so still enable by default
#define XASH_USE_SELECT
// #define XASH_USE_SELECT
#endif
#ifdef XASH_USE_SELECT

View File

@ -397,7 +397,7 @@ static void SDLash_EventFilter( SDL_Event *event )
return;
if( ( host.status == HOST_SHUTDOWN ) ||
( host.type == HOST_DEDICATED ) )
( Host_IsDedicated() ) )
break; // no need to activate
switch( event->window.event )
{

View File

@ -2036,7 +2036,7 @@ void SV_TSourceEngineQuery( netadr_t from )
MSG_WriteByte( &buf, count );
MSG_WriteByte( &buf, svs.maxclients );
MSG_WriteByte( &buf, PROTOCOL_VERSION );
MSG_WriteByte( &buf, host.type == HOST_DEDICATED ? 'D' : 'L' );
MSG_WriteByte( &buf, Host_IsDedicated() ? 'D' : 'L' );
MSG_WriteByte( &buf, 'W' );
if( Q_stricmp( GI->gamefolder, "valve" ))

View File

@ -3393,7 +3393,7 @@ pfnIsDedicatedServer
*/
int pfnIsDedicatedServer( void )
{
return (host.type == HOST_DEDICATED);
return Host_IsDedicated();
}
/*

View File

@ -568,7 +568,7 @@ void SV_ActivateServer( int runPhysics )
Log_Printf( "Started map \"%s\" (CRC \"%u\")\n", sv.name, sv.worldmapCRC );
// dedicated server purge unused resources here
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
Mod_FreeUnused ();
host.movevars_changed = true;
@ -709,7 +709,7 @@ void SV_SetupClients( void )
svs.maxclients = (int)sv_maxclients->value;
// dedicated servers are can't be single player and are usually DM
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
svs.maxclients = bound( 4, svs.maxclients, MAX_CLIENTS );
else svs.maxclients = bound( 1, svs.maxclients, MAX_CLIENTS );

View File

@ -532,7 +532,7 @@ qboolean SV_IsSimulating( void )
if( !SV_HasActivePlayers( ))
return false;
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
return true; // always active for dedicated servers
// allow to freeze everything in singleplayer
@ -735,7 +735,7 @@ void SV_AddToMaster( netadr_t from, sizebuf_t *msg )
Info_SetValueForKey( s, "bots", va( "%d", bots ), len ); // bot count
Info_SetValueForKey( s, "gamedir", GI->gamefolder, len ); // gamedir
Info_SetValueForKey( s, "map", sv.name, len ); // current map
Info_SetValueForKey( s, "type", (host.type == HOST_DEDICATED) ? "d" : "l", len ); // dedicated or local
Info_SetValueForKey( s, "type", (Host_IsDedicated()) ? "d" : "l", len ); // dedicated or local
Info_SetValueForKey( s, "password", "0", len ); // is password set
Info_SetValueForKey( s, "os", "w", len ); // Windows
Info_SetValueForKey( s, "secure", "0", len ); // server anti-cheat

View File

@ -514,7 +514,7 @@ static void pfnPlaybackEventFull( int flags, int clientindex, word eventindex, f
ent = EDICT_NUM( clientindex + 1 );
if( !SV_IsValidEdict( ent )) return;
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
flags |= FEV_NOTHOST; // no local clients for dedicated server
SV_PlaybackEventFull( flags, ent, eventindex,

View File

@ -1996,7 +1996,7 @@ qboolean SV_LoadGame( const char *pPath )
file_t *pFile;
int flags;
if( host.type == HOST_DEDICATED )
if( Host_IsDedicated() )
return false;
if( !COM_CheckString( pPath ))