fix bug with ClientDisconnect not being called if a client drops between "spawn"...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 25 May 2005 07:17:44 +0000 (07:17 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 25 May 2005 07:17:44 +0000 (07:17 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5333 d7cf8633-e32d-0410-b094-e92efae38249

host.c
host_cmd.c
server.h
sv_main.c

diff --git a/host.c b/host.c
index 3a39f26..9eaa3ba 100644 (file)
--- a/host.c
+++ b/host.c
@@ -415,11 +415,12 @@ 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;
index d68b251..f28ac17 100644 (file)
@@ -1279,6 +1279,7 @@ void Host_Spawn_f (void)
                        (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
 
                // call the spawn function
+               host_client->clientconnectcalled = true;
                pr_global_struct->time = sv.time;
                pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
                PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
index a35b42c..51e5d6b 100644 (file)
--- a/server.h
+++ b/server.h
@@ -113,6 +113,8 @@ typedef struct client_s
 {
        // false = empty client slot
        qboolean active;
+       // false = don't do ClientDisconnect on drop
+       qboolean clientconnectcalled;
        // false = don't send datagrams
        qboolean spawned;
        // has been told to go to another level
index 44ae62c..8818902 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -291,6 +291,7 @@ void SV_SendServerinfo (client_t *client)
                        (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i];
 
                // call the spawn function
+               host_client->clientconnectcalled = true;
                pr_global_struct->time = sv.time;
                pr_global_struct->self = EDICT_TO_PROG(client->edict);
                PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");