Browse Source

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

pull/2/head
Alibek Omarov 6 years ago
parent
commit
0681209114
  1. 4
      engine/common/dedicated.c
  2. 2
      engine/common/filesystem.c
  3. 9
      engine/common/host.c
  4. 6
      engine/common/net_ws.c
  5. 2
      engine/common/sys_con.c
  6. 2
      engine/platform/sdl/events.c
  7. 2
      engine/server/sv_client.c
  8. 2
      engine/server/sv_game.c
  9. 4
      engine/server/sv_init.c
  10. 4
      engine/server/sv_main.c
  11. 2
      engine/server/sv_pmove.c
  12. 2
      engine/server/sv_save.c

4
engine/common/dedicated.c

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

2
engine/common/filesystem.c

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

9
engine/common/host.c

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

6
engine/common/net_ws.c

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

2
engine/common/sys_con.c

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

2
engine/platform/sdl/events.c

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

2
engine/server/sv_client.c

@ -2036,7 +2036,7 @@ void SV_TSourceEngineQuery( netadr_t from )
MSG_WriteByte( &buf, count ); MSG_WriteByte( &buf, count );
MSG_WriteByte( &buf, svs.maxclients ); MSG_WriteByte( &buf, svs.maxclients );
MSG_WriteByte( &buf, PROTOCOL_VERSION ); 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' ); MSG_WriteByte( &buf, 'W' );
if( Q_stricmp( GI->gamefolder, "valve" )) if( Q_stricmp( GI->gamefolder, "valve" ))

2
engine/server/sv_game.c

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

4
engine/server/sv_init.c

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

4
engine/server/sv_main.c

@ -532,7 +532,7 @@ qboolean SV_IsSimulating( void )
if( !SV_HasActivePlayers( )) if( !SV_HasActivePlayers( ))
return false; return false;
if( host.type == HOST_DEDICATED ) if( Host_IsDedicated() )
return true; // always active for dedicated servers return true; // always active for dedicated servers
// allow to freeze everything in singleplayer // 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, "bots", va( "%d", bots ), len ); // bot count
Info_SetValueForKey( s, "gamedir", GI->gamefolder, len ); // gamedir Info_SetValueForKey( s, "gamedir", GI->gamefolder, len ); // gamedir
Info_SetValueForKey( s, "map", sv.name, len ); // current map 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, "password", "0", len ); // is password set
Info_SetValueForKey( s, "os", "w", len ); // Windows Info_SetValueForKey( s, "os", "w", len ); // Windows
Info_SetValueForKey( s, "secure", "0", len ); // server anti-cheat Info_SetValueForKey( s, "secure", "0", len ); // server anti-cheat

2
engine/server/sv_pmove.c

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

2
engine/server/sv_save.c

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

Loading…
Cancel
Save