From 38f1ee5f88cff13e4caf739b80ddd25895198c76 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 11 Jun 2005 00:38:24 +0000 Subject: [PATCH] sv_public now defaults to 0 except on dedicated servers cleaned up Host_ServerOptions code significantly git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5420 d7cf8633-e32d-0410-b094-e92efae38249 --- host.c | 55 ++++++++++++++++++++++--------------------------------- netconn.c | 3 ++- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/host.c b/host.c index 385a1c2b..a7b9d2af 100644 --- a/host.c +++ b/host.c @@ -166,49 +166,38 @@ void Host_ServerOptions (void) // COMMANDLINEOPTION: Server: -dedicated [playerlimit] starts a dedicated server (with a command console), default playerlimit is 8 // COMMANDLINEOPTION: Server: -listen [playerlimit] starts a multiplayer server with graphical client, like singleplayer but other players can connect, default playerlimit is 8 - if (cl_available) + // if no client is in the executable or -dedicated is specified on + // commandline, start a dedicated server + i = COM_CheckParm ("-dedicated"); + if (i || !cl_available) { - // client exists, check what mode the user wants - i = COM_CheckParm ("-dedicated"); + cls.state = ca_dedicated; + // check for -dedicated specifying how many players + if (i && i + 1 < com_argc && atoi (com_argv[i+1]) >= 1) + svs.maxclients = atoi (com_argv[i+1]); + if (COM_CheckParm ("-listen")) + Sys_Error ("Only one of -dedicated or -listen can be specified"); + // default sv_public on for dedicated servers (often hosted by serious administrators), off for listen servers (often hosted by clueless users) + Cvar_SetValue("sv_public", 1); + } + else if (cl_available) + { + // client exists and not dedicated, check if -listen is specified + cls.state = ca_disconnected; + i = COM_CheckParm ("-listen"); if (i) { - cls.state = ca_dedicated; // default players unless specified if (i + 1 < com_argc && atoi (com_argv[i+1]) >= 1) svs.maxclients = atoi (com_argv[i+1]); - if (COM_CheckParm ("-listen")) - Sys_Error ("Only one of -dedicated or -listen can be specified"); } else { - cls.state = ca_disconnected; - i = COM_CheckParm ("-listen"); - if (i) - { - // default players unless specified - if (i + 1 < com_argc && atoi (com_argv[i+1]) >= 1) - svs.maxclients = atoi (com_argv[i+1]); - } - else - { - // default players in some games, singleplayer in most - if (gamemode != GAME_GOODVSBAD2 && gamemode != GAME_NEXUIZ && gamemode != GAME_BATTLEMECH) - svs.maxclients = 1; - } + // default players in some games, singleplayer in most + if (gamemode != GAME_GOODVSBAD2 && gamemode != GAME_NEXUIZ && gamemode != GAME_BATTLEMECH) + svs.maxclients = 1; } } - else - { - // no client in the executable, always start dedicated server - if (COM_CheckParm ("-listen")) - Sys_Error ("-listen not available in a dedicated server executable"); - cls.state = ca_dedicated; - // check for -dedicated specifying how many players - i = COM_CheckParm ("-dedicated"); - // default players unless specified - if (i && i + 1 < com_argc && atoi (com_argv[i+1]) >= 1) - svs.maxclients = atoi (com_argv[i+1]); - } svs.maxclients = bound(1, svs.maxclients, MAX_SCOREBOARD); @@ -681,7 +670,7 @@ void Host_ServerFrame (void) } sv.timer += host_realframetime; - + // run the world state // don't allow simulation to run too fast or too slow or logic glitches can occur for (framecount = 0;framecount < framelimit && sv.timer > 0;framecount++) diff --git a/netconn.c b/netconn.c index 0b7e0eb1..8a464042 100755 --- a/netconn.c +++ b/netconn.c @@ -25,7 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MASTER_PORT 27950 -cvar_t sv_public = {0, "sv_public", "1"}; +// note this defaults on for dedicated servers, off for listen servers +cvar_t sv_public = {0, "sv_public", "0"}; static cvar_t sv_heartbeatperiod = {CVAR_SAVE, "sv_heartbeatperiod", "120"}; // FIXME: resolve DNS on masters whenever their value changes and cache it (to avoid major delays in active servers when they heartbeat) -- 2.39.2