X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=host.c;h=5c50ba791499266d80394d0f7392da7faf990fa0;hp=d8d98795f6ac0a89fa80616e48569302e50c248a;hb=HEAD;hpb=4d00f11db53273b8624b8ce95f066450dad0a298 diff --git a/host.c b/host.c index d8d98795..78536822 100644 --- a/host.c +++ b/host.c @@ -44,7 +44,6 @@ host_static_t host; cvar_t host_framerate = {CF_CLIENT | CF_SERVER, "host_framerate","0", "locks frame timing to this value in seconds, 0.05 is 20fps for example, note that this can easily run too fast, use cl_maxfps if you want to limit your framerate instead, or sys_ticrate to limit server speed"}; // shows time used by certain subsystems cvar_t host_speeds = {CF_CLIENT | CF_SERVER, "host_speeds","0", "reports how much time is used in server/graphics/sound"}; -cvar_t host_maxwait = {CF_CLIENT | CF_SERVER, "host_maxwait","1000", "maximum sleep time requested from the operating system in millisecond. Larger sleeps will be done using multiple host_maxwait length sleeps. Lowering this value will increase CPU load, but may help working around problems with accuracy of sleep times."}; cvar_t developer = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "developer","0", "shows debugging messages and information (recommended for all developers and level designers); the value -1 also suppresses buffering and logging these messages"}; cvar_t developer_extra = {CF_CLIENT | CF_SERVER, "developer_extra", "0", "prints additional debugging messages, often very verbose!"}; @@ -105,12 +104,12 @@ void Host_Error (const char *error, ...) Con_Printf(CON_ERROR "Host_Error: %s\n", hosterrorstring1); // LadyHavoc: if crashing very early, or currently shutting down, do - // Sys_Abort instead + // Sys_Error instead if (host.framecount < 3 || host.state == host_shutdown) - Sys_Abort ("Host_Error during %s: %s", host.framecount < 3 ? "startup" : "shutdown", hosterrorstring1); + Sys_Error ("Host_Error during %s: %s", host.framecount < 3 ? "startup" : "shutdown", hosterrorstring1); if (hosterror) - Sys_Abort ("Host_Error: recursively entered (original error was: %s new error is: %s)", hosterrorstring2, hosterrorstring1); + Sys_Error ("Host_Error: recursively entered (original error was: %s new error is: %s)", hosterrorstring2, hosterrorstring1); hosterror = true; dp_strlcpy(hosterrorstring2, hosterrorstring1, sizeof(hosterrorstring2)); @@ -125,7 +124,7 @@ void Host_Error (const char *error, ...) host.hook.SV_Shutdown(); if (cls.state == ca_dedicated) - Sys_Abort("Host_Error: %s", hosterrorstring1); // dedicated servers exit + Sys_Error("Host_Error: %s", hosterrorstring1); // dedicated servers exit // prevent an endless loop if the error was triggered by a command Cbuf_Clear(cmd_local->cbuf); @@ -159,6 +158,11 @@ static void Host_Version_f(cmd_state_t *cmd) Con_Printf("Version: %s\n", engineversion); } +void Host_UpdateVersion(void) +{ + dpsnprintf(engineversion, sizeof(engineversion), "%s %s%s %s", gamename ? gamename : "DarkPlaces", DP_OS_NAME, cls.state == ca_dedicated ? " dedicated" : "", buildstring); +} + static void Host_Framerate_c(cvar_t *var) { if (var->value < 0.00001 && var->value != 0) @@ -253,12 +257,13 @@ static void Host_LoadConfig_f(cmd_state_t *cmd) // Xonotic QC complains/breaks if its cvars are deleted before its m_shutdown() is called if(MR_Shutdown) MR_Shutdown(); - // append a menu restart command to execute after the config - Cbuf_AddText(cmd, "\nmenu_restart\n"); #endif - // reset all cvars, commands and aliases to init values Cmd_RestoreInitState(); - // reset cvars to their defaults, and then exec startup scripts again +#ifdef CONFIG_MENU + // Must re-add menu.c commands or load menu.dat before executing quake.rc or handling events + MR_Init(); +#endif + // exec startup scripts again Host_AddConfigText(cmd); } @@ -278,7 +283,6 @@ static void Host_InitLocal (void) Cvar_RegisterVariable (&host_framerate); Cvar_RegisterCallback (&host_framerate, Host_Framerate_c); Cvar_RegisterVariable (&host_speeds); - Cvar_RegisterVariable (&host_maxwait); Cvar_RegisterVariable (&host_isclient); Cvar_RegisterVariable (&developer); @@ -294,7 +298,7 @@ static void Host_InitLocal (void) Cvar_RegisterVariable (&r_texture_jpeg_fastpicmip); } -char engineversion[128]; +char engineversion[128]; ///< version string for the corner of the console, crash messages, status command, etc static qfile_t *locksession_fh = NULL; @@ -340,7 +344,7 @@ void Host_LockSession(void) } else { - Sys_Abort("session lock %s could not be acquired. Please run with -sessionid and an unique session name.\n", p); + Sys_Error("session lock %s could not be acquired. Please run with -sessionid and an unique session name.\n", p); } } } @@ -385,7 +389,7 @@ static void Host_Init (void) host.state = host_init; if (setjmp(host.abortframe)) // Huh?! - Sys_Abort("Engine initialization failed. Check the console (if available) for additional information.\n"); + Sys_Error("Engine initialization failed. Check the console (if available) for additional information.\n"); if (Sys_CheckParm("-profilegameonly")) Sys_AllowProfiling(false); @@ -430,6 +434,10 @@ static void Host_Init (void) if (Sys_CheckParm ("-dedicated") || !cl_available) cls.state = ca_dedicated; + // set and print initial version string (will be updated when gamename is changed) + Host_UpdateVersion(); // checks for cls.state == ca_dedicated + Con_Printf("%s\n", engineversion); + // initialize console command/cvar/alias/command execution systems Cmd_Init(); @@ -449,10 +457,6 @@ static void Host_Init (void) // initialize filesystem (including fs_basedir, fs_gamedir, -game, scr_screenshot_name, gamename) FS_Init(); - // ASAP! construct a version string for the corner of the console and for crash messages - dpsnprintf (engineversion, sizeof (engineversion), "%s %s%s, buildstring: %s", gamename, DP_OS_NAME, cls.state == ca_dedicated ? " dedicated" : "", buildstring); - Con_Printf("%s\n", engineversion); - // initialize process nice level Sys_InitProcessNice(); @@ -683,7 +687,7 @@ void Host_Main(void) oldtime = Sys_DirtyTime(); // Main event loop - while(host.state != host_shutdown) + while(host.state < host_shutdown) // see Sys_HandleCrash() comments { // Something bad happened, or the server disconnected if (setjmp(host.abortframe))