/** * @brief SV_Init */ void SV_Init(void) { SV_UptimeReset(); SV_AddOperatorCommands(); // serverinfo vars Cvar_Get("timelimit", "0", CVAR_SERVERINFO); sv_gametype = Cvar_Get("g_gametype", "4", CVAR_SERVERINFO | CVAR_LATCH); Cvar_Get("sv_keywords", "", CVAR_SERVERINFO); // unused. Kept for GameTracker.com compatibility Cvar_Get("protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO | CVAR_ROM); sv_mapname = Cvar_Get("mapname", "nomap", CVAR_SERVERINFO | CVAR_ROM); sv_privateClients = Cvar_Get("sv_privateClients", "0", CVAR_SERVERINFO); sv_hostname = Cvar_Get("sv_hostname", "ETLHost", CVAR_SERVERINFO | CVAR_ARCHIVE); sv_minRate = Cvar_Get("sv_minRate", "0", CVAR_ARCHIVE | CVAR_SERVERINFO); sv_maxclients = Cvar_Get("sv_maxclients", "20", CVAR_SERVERINFO | CVAR_LATCH); sv_maxRate = Cvar_Get("sv_maxRate", "0", CVAR_ARCHIVE | CVAR_SERVERINFO); sv_dlRate = Cvar_Get("sv_dlRate", "100", CVAR_ARCHIVE | CVAR_SERVERINFO); sv_minPing = Cvar_Get("sv_minPing", "0", CVAR_ARCHIVE | CVAR_SERVERINFO); sv_maxPing = Cvar_Get("sv_maxPing", "0", CVAR_ARCHIVE | CVAR_SERVERINFO); sv_floodProtect = Cvar_Get("sv_floodProtect", "1", CVAR_ARCHIVE | CVAR_SERVERINFO); sv_friendlyFire = Cvar_Get("g_friendlyFire", "1", CVAR_SERVERINFO | CVAR_ARCHIVE); sv_maxlives = Cvar_Get("g_maxlives", "0", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SERVERINFO); sv_needpass = Cvar_Get("g_needpass", "0", CVAR_SERVERINFO | CVAR_ROM); // systeminfo // added cvar_t for sv_cheats so server engine can reference it sv_cheats = Cvar_Get("sv_cheats", "1", CVAR_SYSTEMINFO | CVAR_ROM); sv_serverid = Cvar_Get("sv_serverid", "0", CVAR_SYSTEMINFO | CVAR_ROM); sv_pure = Cvar_Get("sv_pure", "1", CVAR_SYSTEMINFO); Cvar_Get("sv_paks", "", CVAR_SYSTEMINFO | CVAR_ROM); Cvar_Get("sv_pakNames", "", CVAR_SYSTEMINFO | CVAR_ROM); Cvar_Get("sv_referencedPaks", "", CVAR_SYSTEMINFO | CVAR_ROM); Cvar_Get("sv_referencedPakNames", "", CVAR_SYSTEMINFO | CVAR_ROM); #ifdef FEATURE_ANTICHEAT // note: // we might add CVAR_LATCH flag to wh_active saving SV_InitWallhack() call when not needed // but it may be helpfully (see sound issue) when wh_active isn't active all the time - we should give that a try // just enable sv_wh_active by random intervals ... (would also save CPU usage too) sv_wh_active = Cvar_Get("sv_wh_active", "0", CVAR_ARCHIVE); // Note on bounding box dimensions: // The default values are considerably larger than the normal values (36 and 72) used by ET. // The reason for this is that it is better to predict a player as visible when // he/she is not than the contrary. // It may give a slight advantage to cheaters using wallhacks, but IMO it is not significant. // You can change these Cvars, but if you set them to smaller values then it may happen that // players do not become immediately visible when you go around corners. sv_wh_bbox_horz = Cvar_Get("sv_wh_bbox_horz", "60", CVAR_ARCHIVE); // was 50 - now real player x bbox size(36) + offset if (sv_wh_bbox_horz->integer < 20) { Cvar_Set("sv_wh_bbox_horz", "20"); } if (sv_wh_bbox_horz->integer > 100) { Cvar_Set("sv_wh_bbox_horz", "100"); } sv_wh_bbox_vert = Cvar_Get("sv_wh_bbox_vert", "100", CVAR_ARCHIVE); // was 60 - now real player y bbox size(72) + offset if (sv_wh_bbox_vert->integer < 40) { Cvar_Set("sv_wh_bbox_vert", "40"); } if (sv_wh_bbox_vert->integer > 150) { Cvar_Set("sv_wh_bbox_vert", "150"); } sv_wh_check_fov = Cvar_Get("wh_check_fov", "0", CVAR_ARCHIVE); SV_InitWallhack(); #endif // server vars sv_rconPassword = Cvar_Get("rconPassword", "", CVAR_TEMP); sv_privatePassword = Cvar_Get("sv_privatePassword", "", CVAR_TEMP); sv_fps = Cvar_Get("sv_fps", "20", CVAR_TEMP); sv_timeout = Cvar_Get("sv_timeout", "40", CVAR_TEMP); // used in game (also vid_restart) sv_dl_timeout = Cvar_Get("sv_dl_timeout", "240", CVAR_TEMP); sv_zombietime = Cvar_Get("sv_zombietime", "2", CVAR_TEMP); Cvar_Get("nextmap", "", CVAR_TEMP); sv_allowDownload = Cvar_Get("sv_allowDownload", "1", CVAR_ARCHIVE); // master servers Cvar_Get("sv_master1", "etmaster.idsoftware.com", CVAR_PROTECTED); Cvar_Get("sv_master2", "master.etlegacy.com", CVAR_PROTECTED); #ifdef FEATURE_TRACKER // tracker server Cvar_Get("sv_tracker", "et-tracker.trackbase.net:4444", CVAR_PROTECTED); #endif sv_reconnectlimit = Cvar_Get("sv_reconnectlimit", "3", 0); sv_tempbanmessage = Cvar_Get("sv_tempbanmessage", "You have been kicked and are temporarily banned from joining this server.", 0); sv_padPackets = Cvar_Get("sv_padPackets", "0", 0); sv_killserver = Cvar_Get("sv_killserver", "0", 0); sv_mapChecksum = Cvar_Get("sv_mapChecksum", "", CVAR_ROM); sv_lanForceRate = Cvar_Get("sv_lanForceRate", "1", CVAR_ARCHIVE); sv_onlyVisibleClients = Cvar_Get("sv_onlyVisibleClients", "0", 0); sv_showAverageBPS = Cvar_Get("sv_showAverageBPS", "0", 0); // net debugging // create user set cvars Cvar_Get("g_userTimeLimit", "0", 0); Cvar_Get("g_userAlliedRespawnTime", "0", 0); Cvar_Get("g_userAxisRespawnTime", "0", 0); Cvar_Get("g_maxlives", "0", 0); Cvar_Get("g_altStopwatchMode", "0", CVAR_ARCHIVE); Cvar_Get("g_minGameClients", "8", CVAR_SERVERINFO); Cvar_Get("g_complaintlimit", "6", CVAR_ARCHIVE); Cvar_Get("gamestate", "-1", CVAR_WOLFINFO | CVAR_ROM); Cvar_Get("g_currentRound", "0", CVAR_WOLFINFO); Cvar_Get("g_nextTimeLimit", "0", CVAR_WOLFINFO); Cvar_Get("g_fastres", "0", CVAR_ARCHIVE); Cvar_Get("g_fastResMsec", "1000", CVAR_ARCHIVE); Cvar_Get("g_voteFlags", "0", CVAR_ROM | CVAR_SERVERINFO); Cvar_Get("g_antilag", "1", CVAR_ARCHIVE | CVAR_SERVERINFO); Cvar_Get("g_needpass", "0", CVAR_SERVERINFO); sv_wwwDownload = Cvar_Get("sv_wwwDownload", "0", CVAR_ARCHIVE); sv_wwwBaseURL = Cvar_Get("sv_wwwBaseURL", "", CVAR_ARCHIVE); sv_wwwDlDisconnected = Cvar_Get("sv_wwwDlDisconnected", "0", CVAR_ARCHIVE); sv_wwwFallbackURL = Cvar_Get("sv_wwwFallbackURL", "", CVAR_ARCHIVE); sv_packetdelay = Cvar_Get("sv_packetdelay", "0", CVAR_CHEAT); // note: redirecting of clients to other servers relies on this, // ET://someserver.com sv_fullmsg = Cvar_Get("sv_fullmsg", "Server is full.", CVAR_ARCHIVE); sv_advert = Cvar_Get("sv_advert", "1", CVAR_ARCHIVE); sv_protect = Cvar_Get("sv_protect", "0", CVAR_ARCHIVE); sv_protectLog = Cvar_Get("sv_protectLog", "", CVAR_ARCHIVE); SV_InitAttackLog(); // init the server side demo recording stuff // serverside demo recording variables sv_demoState = Cvar_Get("sv_demoState", "0", CVAR_ROM); sv_democlients = Cvar_Get("sv_democlients", "0", CVAR_ROM); sv_autoDemo = Cvar_Get("sv_autoDemo", "0", CVAR_ARCHIVE); cl_freezeDemo = Cvar_Get("cl_freezeDemo", "0", CVAR_TEMP); // port from client-side to freeze server-side demos sv_demoTolerant = Cvar_Get("sv_demoTolerant", "0", CVAR_ARCHIVE); sv_demopath = Cvar_Get("sv_demopath", "", CVAR_ARCHIVE); // init the botlib here because we need the pre-compiler in the UI SV_BotInitBotLib(); svs.serverLoad = -1; #if defined(FEATURE_IRC_SERVER) && defined(DEDICATED) IRC_Init(); #endif #ifdef FEATURE_TRACKER Tracker_Init(); #endif }
/* ==================== Host_Init ==================== */ static void Host_Init (void) { int i; const char* os; char vabuf[1024]; if (COM_CheckParm("-profilegameonly")) Sys_AllowProfiling(false); // LordHavoc: quake never seeded the random number generator before... heh if (COM_CheckParm("-benchmark")) { Xrand_Init(1); srand(0); // predictable random sequence for -benchmark } else { Xrand_Init(0); srand((unsigned int)time(NULL)); } Cvar_InitTable(); // FIXME: this is evil, but possibly temporary // LordHavoc: doesn't seem very temporary... // LordHavoc: made this a saved cvar // COMMANDLINEOPTION: Console: -developer enables warnings and other notices (RECOMMENDED for mod developers) if (COM_CheckParm("-developer")) { developer.value = developer.integer = 1; developer.string = "1"; } if (COM_CheckParm("-developer2") || COM_CheckParm("-developer3")) { developer.value = developer.integer = 1; developer.string = "1"; developer_extra.value = developer_extra.integer = 1; developer_extra.string = "1"; developer_insane.value = developer_insane.integer = 1; developer_insane.string = "1"; developer_memory.value = developer_memory.integer = 1; developer_memory.string = "1"; developer_memorydebug.value = developer_memorydebug.integer = 1; developer_memorydebug.string = "1"; } if (COM_CheckParm("-developer3")) { gl_paranoid.integer = 1;gl_paranoid.string = "1"; gl_printcheckerror.integer = 1;gl_printcheckerror.string = "1"; } // COMMANDLINEOPTION: Console: -nostdout disables text output to the terminal the game was launched from if (COM_CheckParm("-nostdout")) sys_nostdout = 1; // used by everything Memory_Init(); // initialize console command/cvar/alias/command execution systems Cmd_Init(); // initialize memory subsystem cvars/commands Memory_Init_Commands(); // initialize console and logging and its cvars/commands Con_Init(); // initialize various cvars that could not be initialized earlier u8_Init(); Curl_Init_Commands(); Cmd_Init_Commands(); Sys_Init_Commands(); COM_Init_Commands(); FS_Init_Commands(); // initialize console window (only used by sys_win.c) Sys_InitConsole(); // initialize the self-pack (must be before COM_InitGameType as it may add command line options) FS_Init_SelfPack(); // detect gamemode from commandline options or executable name COM_InitGameType(); // construct a version string for the corner of the console os = DP_OS_NAME; #ifdef VECXIS_RELEASE dpsnprintf (engineversion, sizeof (engineversion), "vdprm %s (Running %s) %s", os, gamename, buildstring); #else dpsnprintf (engineversion, sizeof (engineversion), "DarkPlacesRM %s (Running %s) %s", os, gamename, buildstring); #endif Con_Printf("%s\n", engineversion); // initialize process nice level Sys_InitProcessNice(); // initialize ixtable Mathlib_Init(); // initialize filesystem (including fs_basedir, fs_gamedir, -game, scr_screenshot_name) FS_Init(); // register the cvars for session locking Host_InitSession(); // must be after FS_Init Crypto_Init(); Crypto_Init_Commands(); NetConn_Init(); Curl_Init(); //PR_Init(); //PR_Cmd_Init(); PRVM_Init(); Mod_Init(); World_Init(); SV_Init(); V_Init(); // some cvars needed by server player physics (cl_rollangle etc) Host_InitCommands(); Host_InitLocal(); Host_ServerOptions(); IRC_Init(); Thread_Init(); if (cls.state == ca_dedicated) Cmd_AddCommand ("disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)"); else { Con_DPrintf("Initializing client\n"); R_Modules_Init(); Palette_Init(); #ifdef CONFIG_MENU MR_Init_Commands(); #endif VID_Shared_Init(); VID_Init(); Render_Init(); S_Init(); #ifdef CONFIG_CD CDAudio_Init(); #endif Key_Init(); CL_Init(); } // save off current state of aliases, commands and cvars for later restore if FS_GameDir_f is called // NOTE: menu commands are freed by Cmd_RestoreInitState Cmd_SaveInitState(); // FIXME: put this into some neat design, but the menu should be allowed to crash // without crashing the whole game, so this should just be a short-time solution // here comes the not so critical stuff if (setjmp(host_abortframe)) { return; } Host_AddConfigText(); Cbuf_Execute(); // if stuffcmds wasn't run, then quake.rc is probably missing, use default if (!host_stuffcmdsrun) { Cbuf_AddText("exec default.cfg\nexec " CONFIGFILENAME "\nexec autoexec.cfg\nstuffcmds\n"); Cbuf_Execute(); } // put up the loading image so the user doesn't stare at a black screen... SCR_BeginLoadingPlaque(true); #ifdef CONFIG_MENU if (cls.state != ca_dedicated) { MR_Init(); } #endif // check for special benchmark mode // COMMANDLINEOPTION: Client: -benchmark <demoname> runs a timedemo and quits, results of any timedemo can be found in gamedir/benchmark.log (for example id1/benchmark.log) i = COM_CheckParm("-benchmark"); if (i && i + 1 < com_argc) if (!sv.active && !cls.demoplayback && !cls.connect_trying) { Cbuf_AddText(va(vabuf, sizeof(vabuf), "timedemo %s\n", com_argv[i + 1])); Cbuf_Execute(); } // check for special demo mode // COMMANDLINEOPTION: Client: -demo <demoname> runs a playdemo and quits i = COM_CheckParm("-demo"); if (i && i + 1 < com_argc) if (!sv.active && !cls.demoplayback && !cls.connect_trying) { Cbuf_AddText(va(vabuf, sizeof(vabuf), "playdemo %s\n", com_argv[i + 1])); Cbuf_Execute(); } // COMMANDLINEOPTION: Client: -capturedemo <demoname> captures a playdemo and quits i = COM_CheckParm("-capturedemo"); if (i && i + 1 < com_argc) if (!sv.active && !cls.demoplayback && !cls.connect_trying) { Cbuf_AddText(va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", com_argv[i + 1])); Cbuf_Execute(); } if (cls.state == ca_dedicated || COM_CheckParm("-listen")) if (!sv.active && !cls.demoplayback && !cls.connect_trying) { Cbuf_AddText("startmap_dm\n"); Cbuf_Execute(); } if (!sv.active && !cls.demoplayback && !cls.connect_trying) { #ifdef CONFIG_MENU Cbuf_AddText("togglemenu 1\n"); #endif Cbuf_Execute(); } Con_DPrint("========Initialized=========\n"); //Host_StartVideo(); if (cls.state != ca_dedicated) SV_StartThread(); }