X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=host.c;h=465545ad74c7f7ac088537e0d80f5c2ae1c1e202;hb=3781ea12c92801177ab06db1a816de94c6bc696c;hp=cc7102a8014636ac8cf11e0c81f3f4516d2920f9;hpb=195a5f4e8031dcc37d16fc81e7dc9da044721b33;p=xonotic%2Fdarkplaces.git diff --git a/host.c b/host.c index cc7102a8..465545ad 100644 --- a/host.c +++ b/host.c @@ -133,11 +133,17 @@ This shuts down both the client and server ================ */ char hosterrorstring[4096]; +extern char sv_spawnmap[MAX_QPATH]; +extern char sv_loadgame[MAX_OSPATH]; void Host_Error (const char *error, ...) { va_list argptr; static qboolean inerror = false; + // make sure we don't get in a loading loop + sv_loadgame[0] = 0; + sv_spawnmap[0] = 0; + // LordHavoc: if first frame has not been shown, or currently shutting // down, do Sys_Error instead if (!host_loopactive || host_shuttingdown) @@ -164,6 +170,8 @@ void Host_Error (const char *error, ...) va_end (argptr); Con_Printf ("Host_Error: %s\n",hosterrorstring); + CL_Parse_DumpPacket(); + PR_Crash(); if (sv.active) @@ -175,6 +183,9 @@ void Host_Error (const char *error, ...) CL_Disconnect (); cls.demonum = -1; + // unload any partially loaded models + Mod_ClearErrorModels(); + inerror = false; longjmp (host_abortserver, 1); @@ -184,26 +195,42 @@ void Host_ServerOptions (void) { int i, numplayers; - numplayers = 1; - - i = COM_CheckParm ("-dedicated"); - if (i) + if (cl_available) { - cls.state = ca_dedicated; - numplayers = 0; - if (i != (com_argc - 1)) - numplayers = atoi (com_argv[i+1]); + // client exists, check what mode the user wants + i = COM_CheckParm ("-dedicated"); + if (i) + { + cls.state = ca_dedicated; + numplayers = 8; + if (i != (com_argc - 1)) + numplayers = atoi (com_argv[i+1]); + if (COM_CheckParm ("-listen")) + Sys_Error ("Only one of -dedicated or -listen can be specified"); + } + else + { + numplayers = 1; + cls.state = ca_disconnected; + i = COM_CheckParm ("-listen"); + if (i) + { + numplayers = 8; + if (i != (com_argc - 1)) + numplayers = atoi (com_argv[i+1]); + } + } } else - cls.state = ca_disconnected; - - i = COM_CheckParm ("-listen"); - if (i) { - if (cls.state == ca_dedicated) - Sys_Error ("Only one of -dedicated or -listen can be specified"); - numplayers = 0; - if (i != (com_argc - 1)) + // no client in the executable, start dedicated server + if (COM_CheckParm ("-listen")) + Sys_Error ("-listen not available in a dedicated server executable"); + numplayers = 8; + cls.state = ca_dedicated; + // check for -dedicated specifying how many players + i = COM_CheckParm ("-dedicated"); + if (i && i != (com_argc - 1)) numplayers = atoi (com_argv[i+1]); } @@ -294,13 +321,13 @@ Writes key bindings and archived cvars to config.cfg */ void Host_WriteConfiguration (void) { - QFile *f; + qfile_t *f; // dedicated servers initialize the host but don't parse and set the // config.cfg cvars if (host_initialized && cls.state != ca_dedicated) { - f = Qopen (va("%s/config.cfg",com_gamedir), "w"); + f = FS_Open ("config.cfg", "w", false); if (!f) { Con_Printf ("Couldn't write config.cfg.\n"); @@ -310,7 +337,7 @@ void Host_WriteConfiguration (void) Key_WriteBindings (f); Cvar_WriteVariables (f); - Qclose (f); + FS_Close (f); } } @@ -445,6 +472,8 @@ void SV_DropClient (qboolean crash) MSG_WriteByte (&client->message, host_client - svs.clients); MSG_WriteByte (&client->message, 0); } + + NET_Heartbeat (1); } /* @@ -472,6 +501,9 @@ void Host_ShutdownServer(qboolean crash) // stop all client sounds immediately CL_Disconnect (); + NET_Heartbeat (2); + NET_Heartbeat (2); + // flush any pending messages - like the score!!! start = Sys_DoubleTime(); do @@ -666,6 +698,9 @@ void Host_ServerFrame (void) // send all messages to the clients SV_SendClientMessages (); + +// send an heartbeat if enough time has passed since the last one + NET_Heartbeat (0); } @@ -706,6 +741,9 @@ void _Host_Frame (float time) // process console commands Cbuf_Execute (); + // LordHavoc: map and load are delayed until video is initialized + Host_PerformSpawnServerAndLoadGame(); + NET_Poll(); // if running the server locally, make intentions now @@ -794,11 +832,11 @@ void Host_Frame (float time) time1 = Sys_DoubleTime (); _Host_Frame (time); - time2 = Sys_DoubleTime (); - + time2 = Sys_DoubleTime (); + timetotal += time2 - time1; timecount++; - + if (timecount < 1000) return; @@ -818,7 +856,6 @@ void Host_Frame (float time) //============================================================================ void Render_Init(void); -void QuakeIO_Init(void); /* ==================== @@ -842,7 +879,6 @@ void Host_Init (void) Memory_Init_Commands(); R_Modules_Init(); Cbuf_Init (); - QuakeIO_Init (); V_Init (); COM_Init (); Host_InitLocal (); @@ -860,32 +896,28 @@ void Host_Init (void) if (cls.state != ca_dedicated) { - VID_InitCvars(); - - Gamma_Init(); - Palette_Init(); - -#ifndef _WIN32 // on non win32, mouse comes before video for security reasons - IN_Init (); -#endif - VID_Init (vid_fullscreen.integer, vid_width.integer, vid_height.integer); + VID_Shared_Init(); + VID_Init(); Render_Init(); S_Init (); CDAudio_Init (); - Sbar_Init (); CL_Init (); -#ifdef _WIN32 // on non win32, mouse comes before video for security reasons - IN_Init (); -#endif } Cbuf_InsertText ("exec quake.rc\n"); + Cbuf_Execute (); + Cbuf_Execute (); + Cbuf_Execute (); + Cbuf_Execute (); host_initialized = true; - - Sys_Printf ("========Quake Initialized=========\n"); + + Con_Printf ("========Quake Initialized=========\n"); + + if (cls.state != ca_dedicated) + VID_Open(); } @@ -900,20 +932,19 @@ to run quit through here before the final handoff to the sys code. void Host_Shutdown(void) { static qboolean isdown = false; - + if (isdown) { - printf ("recursive shutdown\n"); + Con_Printf ("recursive shutdown\n"); return; } isdown = true; - Host_WriteConfiguration (); + Host_WriteConfiguration (); CDAudio_Shutdown (); NET_Shutdown (); S_Shutdown(); - IN_Shutdown (); if (cls.state != ca_dedicated) {