From 9235bde6796d2d6c894043d10c7cf6a1ddd65be5 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 25 May 2005 07:17:44 +0000 Subject: [PATCH] fix bug with ClientDisconnect not being called if a client drops between "spawn" and "begin" commands, now it is reliably called git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5333 d7cf8633-e32d-0410-b094-e92efae38249 --- host.c | 3 ++- host_cmd.c | 1 + server.h | 2 ++ sv_main.c | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/host.c b/host.c index 3a39f269..9eaa3ba4 100644 --- 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; diff --git a/host_cmd.c b/host_cmd.c index d68b2518..f28ac176 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -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"); diff --git a/server.h b/server.h index a35b42cd..51e5d6b2 100644 --- 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 diff --git a/sv_main.c b/sv_main.c index 44ae62c4..8818902a 100644 --- 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"); -- 2.39.2