From 19f1b34facf77d7c0858b910e6579e635712e98a Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 23 Oct 2004 10:00:38 +0000 Subject: [PATCH] removed number field from client_t struct as it seemed to be behaving unreliably in SV_DropClient (resulting in changes to the scoreboard entry for client 0, regardless of which client was dropped) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4698 d7cf8633-e32d-0410-b094-e92efae38249 --- host.c | 9 ++++++--- host_cmd.c | 4 ++-- pr_cmds.c | 2 +- server.h | 2 -- sv_main.c | 9 ++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/host.c b/host.c index 2ac62557..fd2b3a57 100644 --- a/host.c +++ b/host.c @@ -404,6 +404,7 @@ if (crash = true), don't bother sending signofs */ void SV_DropClient(qboolean crash) { + int i; Con_Printf("Client \"%s\" dropped\n", host_client->name); // send any final messages (don't check for errors) @@ -445,14 +446,16 @@ void SV_DropClient(qboolean crash) host_client->colors = 0; host_client->frags = 0; // send notification to all clients + // get number of client manually just to make sure we get it right... + i = host_client - svs.clients; MSG_WriteByte (&sv.reliable_datagram, svc_updatename); - MSG_WriteByte (&sv.reliable_datagram, host_client->number); + MSG_WriteByte (&sv.reliable_datagram, i); MSG_WriteString (&sv.reliable_datagram, host_client->name); MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors); - MSG_WriteByte (&sv.reliable_datagram, host_client->number); + MSG_WriteByte (&sv.reliable_datagram, i); MSG_WriteByte (&sv.reliable_datagram, host_client->colors); MSG_WriteByte (&sv.reliable_datagram, svc_updatefrags); - MSG_WriteByte (&sv.reliable_datagram, host_client->number); + MSG_WriteByte (&sv.reliable_datagram, i); MSG_WriteShort (&sv.reliable_datagram, host_client->frags); // free the client now diff --git a/host_cmd.c b/host_cmd.c index 7683e59d..17bade24 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -767,7 +767,7 @@ void Host_Name_f (void) strcpy(host_client->old_name, host_client->name); // send notification to all clients MSG_WriteByte (&sv.reliable_datagram, svc_updatename); - MSG_WriteByte (&sv.reliable_datagram, host_client->number); + MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients); MSG_WriteString (&sv.reliable_datagram, host_client->name); } } @@ -986,7 +986,7 @@ void Host_Color_f(void) host_client->old_colors = host_client->colors; // send notification to all clients MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors); - MSG_WriteByte (&sv.reliable_datagram, host_client->number); + MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients); MSG_WriteByte (&sv.reliable_datagram, host_client->colors); } } diff --git a/pr_cmds.c b/pr_cmds.c index 7a85f1ff..06803886 100644 --- a/pr_cmds.c +++ b/pr_cmds.c @@ -2230,7 +2230,7 @@ void PF_setcolor (void) client->old_colors = client->colors; // send notification to all clients MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors); - MSG_WriteByte (&sv.reliable_datagram, client->number); + MSG_WriteByte (&sv.reliable_datagram, client - svs.clients); MSG_WriteByte (&sv.reliable_datagram, client->colors); } } diff --git a/server.h b/server.h index 04512bce..15f51932 100644 --- a/server.h +++ b/server.h @@ -116,8 +116,6 @@ typedef struct client_s qboolean sendsignon; // remove this client immediately qboolean deadsocket; - // index of this client in the svs.clients array - int number; // reliable messages must be sent periodically double last_message; diff --git a/sv_main.c b/sv_main.c index 6d9a20b7..8110dce9 100644 --- a/sv_main.c +++ b/sv_main.c @@ -279,7 +279,7 @@ void SV_SendServerinfo (client_t *client) char message[128]; // edicts get reallocated on level changes, so we need to update it here - client->edict = EDICT_NUM(client->number + 1); + client->edict = EDICT_NUM((client - svs.clients) + 1); // LordHavoc: clear entityframe tracking @@ -364,7 +364,6 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection) strcpy(client->name, "unconnected"); strcpy(client->old_name, "unconnected"); - client->number = clientnum; client->spawned = false; client->edict = EDICT_NUM(clientnum+1); client->message.data = client->msgbuf; @@ -1137,7 +1136,7 @@ void SV_UpdateToReliableMessages (void) strcpy(host_client->old_name, host_client->name); // send notification to all clients MSG_WriteByte (&sv.reliable_datagram, svc_updatename); - MSG_WriteByte (&sv.reliable_datagram, host_client->number); + MSG_WriteByte (&sv.reliable_datagram, i); MSG_WriteString (&sv.reliable_datagram, host_client->name); } @@ -1150,7 +1149,7 @@ void SV_UpdateToReliableMessages (void) host_client->old_colors = host_client->colors; // send notification to all clients MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors); - MSG_WriteByte (&sv.reliable_datagram, host_client->number); + MSG_WriteByte (&sv.reliable_datagram, i); MSG_WriteByte (&sv.reliable_datagram, host_client->colors); } @@ -1161,7 +1160,7 @@ void SV_UpdateToReliableMessages (void) host_client->old_frags = host_client->frags; // send notification to all clients MSG_WriteByte (&sv.reliable_datagram, svc_updatefrags); - MSG_WriteByte (&sv.reliable_datagram, host_client->number); + MSG_WriteByte (&sv.reliable_datagram, i); MSG_WriteShort (&sv.reliable_datagram, host_client->frags); } } -- 2.39.2