]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
fix darkplaces-dedicated.exe building to open a console
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 7c0957cce449557551aee0624d0cd42e008f08fb..c5c783b56eec9cd3dd702f078da35ad2f68a2e0e 100644 (file)
--- a/host.c
+++ b/host.c
@@ -321,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");
@@ -337,7 +337,7 @@ void Host_WriteConfiguration (void)
                Key_WriteBindings (f);
                Cvar_WriteVariables (f);
 
-               Qclose (f);
+               FS_Close (f);
        }
 }
 
@@ -425,26 +425,25 @@ void SV_DropClient (qboolean crash)
        int i;
        client_t *client;
 
+       Con_Printf ("Client \"%s\" dropped\n", host_client->name);
+
        if (!crash)
        {
                // send any final messages (don't check for errors)
-               if (NET_CanSendMessage (host_client->netconnection))
+               if (host_client->netconnection && !host_client->netconnection->disconnected)
                {
+#if 1
+                       // LordHavoc: no opportunity for resending, so reliable is silly
                        MSG_WriteByte (&host_client->message, svc_disconnect);
-                       NET_SendMessage (host_client->netconnection, &host_client->message);
-               }
-
-               if (sv.active && host_client->edict && host_client->spawned) // LordHavoc: don't call QC if server is dead (avoids recursive Host_Error in some mods when they run out of edicts)
-               {
-               // call the prog function for removing a client
-               // this will set the body to a dead frame, among other things
-                       saveSelf = pr_global_struct->self;
-                       pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
-                       PR_ExecuteProgram (pr_global_struct->ClientDisconnect, "QC function ClientDisconnect is missing");
-                       pr_global_struct->self = saveSelf;
+                       NET_SendUnreliableMessage (host_client->netconnection, &host_client->message);
+#else
+                       if (NET_CanSendMessage (host_client->netconnection))
+                       {
+                               MSG_WriteByte (&host_client->message, svc_disconnect);
+                               NET_SendMessage (host_client->netconnection, &host_client->message);
+                       }
+#endif
                }
-
-               Sys_Printf ("Client %s removed\n",host_client->name);
        }
 
 // break the net connection
@@ -453,11 +452,24 @@ void SV_DropClient (qboolean crash)
 
 // free the client (the body stays around)
        host_client->active = false;
+       // note: don't clear name yet
+       net_activeconnections--;
+
+       if (sv.active && host_client->edict && host_client->spawned) // LordHavoc: don't call QC if server is dead (avoids recursive Host_Error in some mods when they run out of edicts)
+       {
+       // call the prog function for removing a client
+       // this will set the body to a dead frame, among other things
+               saveSelf = pr_global_struct->self;
+               pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
+               PR_ExecuteProgram (pr_global_struct->ClientDisconnect, "QC function ClientDisconnect is missing");
+               pr_global_struct->self = saveSelf;
+       }
+
+       // now clear name (after ClientDisconnect was called)
        host_client->name[0] = 0;
        host_client->old_frags = -999999;
-       net_activeconnections--;
 
-// send notification to all clients
+       // send notification to all clients
        for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
        {
                if (!client->active)
@@ -541,7 +553,7 @@ void Host_ShutdownServer(qboolean crash)
 
        for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
                if (host_client->active)
-                       SV_DropClient(crash);
+                       SV_DropClient(crash); // server shutdown
 
 //
 // clear structures
@@ -856,7 +868,6 @@ void Host_Frame (float time)
 //============================================================================
 
 void Render_Init(void);
-void QuakeIO_Init(void);
 
 /*
 ====================
@@ -880,7 +891,6 @@ void Host_Init (void)
        Memory_Init_Commands();
        R_Modules_Init();
        Cbuf_Init ();
-       QuakeIO_Init ();
        V_Init ();
        COM_Init ();
        Host_InitLocal ();
@@ -898,7 +908,6 @@ void Host_Init (void)
 
        if (cls.state != ca_dedicated)
        {
-               Gamma_Init();
                Palette_Init();
                VID_Shared_Init();
                VID_Init();