Browse Source

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

pull/2/head
Alibek Omarov 7 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 @@ -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 ) @@ -494,4 +494,4 @@ void Mod_UnloadSpriteModel( model_t *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 ) @@ -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 );

9
engine/common/host.c

@ -145,7 +145,7 @@ Host_CheckSleep @@ -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 ) @@ -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 @@ -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 @@ -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 @@ -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

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 @@ -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 ) @@ -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] ) )
{

2
engine/common/sys_con.c

@ -22,7 +22,7 @@ GNU General Public License for more details. @@ -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

2
engine/platform/sdl/events.c

@ -397,7 +397,7 @@ static void SDLash_EventFilter( SDL_Event *event ) @@ -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 )
{

2
engine/server/sv_client.c

@ -2036,7 +2036,7 @@ void SV_TSourceEngineQuery( netadr_t from ) @@ -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" ))

2
engine/server/sv_game.c

@ -3393,7 +3393,7 @@ pfnIsDedicatedServer @@ -3393,7 +3393,7 @@ pfnIsDedicatedServer
*/
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 ) @@ -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 ) @@ -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 );

4
engine/server/sv_main.c

@ -532,7 +532,7 @@ qboolean SV_IsSimulating( void ) @@ -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 ) @@ -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

2
engine/server/sv_pmove.c

@ -514,7 +514,7 @@ static void pfnPlaybackEventFull( int flags, int clientindex, word eventindex, f @@ -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,

2
engine/server/sv_save.c

@ -1996,7 +1996,7 @@ qboolean SV_LoadGame( const char *pPath ) @@ -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 ))

Loading…
Cancel
Save