]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
removed number field from client_t struct as it seemed to be behaving unreliably...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 23 Oct 2004 10:00:38 +0000 (10:00 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 23 Oct 2004 10:00:38 +0000 (10:00 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4698 d7cf8633-e32d-0410-b094-e92efae38249

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

diff --git a/host.c b/host.c
index 2ac62557a1c9464977567e5c9bb94b46c183ebe6..fd2b3a57d43d4fd39683e82141e83940055ba510 100644 (file)
--- 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
index 7683e59d409d1a016010606d469adae162b2d620..17bade245742e43ff7ebb7b93bd3901a767811a1 100644 (file)
@@ -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);
                }
        }
index 7a85f1fff79cc2f70872de5870ab1dc3065e038f..06803886f14387f7438deb6f50b833971485f261 100644 (file)
--- 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);
        }
 }
index 04512bce2776f65d28954d6072f7d867252b85a6..15f519325d181c8320e8a29cd9ab5e52664121ca 100644 (file)
--- 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;
index 6d9a20b7d3d5123d308f8ff7666ea71b867d4d16..8110dce937188ba92c370f513b3477c3fda8c46d 100644 (file)
--- 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);
                }
        }