]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
fix bug with ClientDisconnect not being called if a client drops between "spawn"...
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 0300386c20d9c472b89518e0fe8a9c4c3e3a88bb..9eaa3ba4d18a55c3bf7cc041c9e5235f610bfe6c 100644 (file)
--- a/host.c
+++ b/host.c
@@ -401,9 +401,11 @@ void SV_DropClient(qboolean crash)
                // free the client (the body stays around)
                if (!crash)
                {
-                       // LordHavoc: no opportunity for resending, so use unreliable
+                       // LordHavoc: no opportunity for resending, so use unreliable 3 times
                        MSG_WriteByte(&host_client->message, svc_disconnect);
                        NetConn_SendUnreliableMessage(host_client->netconnection, &host_client->message);
+                       NetConn_SendUnreliableMessage(host_client->netconnection, &host_client->message);
+                       NetConn_SendUnreliableMessage(host_client->netconnection, &host_client->message);
                }
                // break the net connection
                NetConn_Close(host_client->netconnection);
@@ -413,18 +415,19 @@ void SV_DropClient(qboolean crash)
        // call qc ClientDisconnect function
        // LordHavoc: don't call QC if server is dead (avoids recursive
        // Host_Error in some mods when they run out of edicts)
-       if (host_client->active && sv.active && host_client->edict && host_client->spawned)
+       if (host_client->clientconnectcalled && sv.active && host_client->edict)
        {
                // call the prog function for removing a client
                // this will set the body to a dead frame, among other things
                int saveSelf = pr_global_struct->self;
+               host_client->clientconnectcalled = false;
                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;
        }
 
        // remove leaving player from scoreboard
-       //host_client->edict->v->netname = PR_SetString(host_client->name);
+       //host_client->edict->v->netname = PR_SetEngineString(host_client->name);
        //if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors)))
        //      val->_float = 0;
        //host_client->edict->v->frags = 0;
@@ -685,8 +688,6 @@ void Host_ServerFrame (void)
                if (sv.paused || (cl.islocalgame && (key_dest != key_game || key_consoleactive)))
                        sv.frametime = 0;
 
-               pr_global_struct->frametime = sv.frametime;
-
                // set the time and clear the general datagram
                SV_ClearDatagram();
 
@@ -694,9 +695,6 @@ void Host_ServerFrame (void)
                // come in midframe (particularly if host is running really slow)
                NetConn_ServerFrame();
 
-               // read client messages
-               SV_RunClients();
-
                // move things around and think unless paused
                if (sv.frametime)
                        SV_Physics();
@@ -798,13 +796,7 @@ void _Host_Frame (float time)
                time2 = Sys_DoubleTime();
 
        // update audio
-       if (cls.signon == SIGNONS && cl_entities[cl.viewentity].state_current.active)
-       {
-               // LordHavoc: this used to use renderer variables (eww)
-               S_Update(&cl_entities[cl.viewentity].render.matrix);
-       }
-       else
-               S_Update(&identitymatrix);
+       S_Update(&r_refdef.viewentitymatrix);
 
        CDAudio_Update();
 
@@ -1067,6 +1059,9 @@ void Host_Shutdown(void)
        }
        isdown = true;
 
+       // be quiet while shutting down
+       S_StopAllSounds();
+
        // disconnect client from server if active
        CL_Disconnect();