]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - pr_cmds.c
fix problems with losing colors on connect and leaving ghosts on the scoreboard and...
[xonotic/darkplaces.git] / pr_cmds.c
index 57851749d27c1529518850de7dfe65a59ebf582d..dca3e92786e0d2843a751be7f98c8f205a174645 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -2218,15 +2218,21 @@ void PF_setcolor (void)
        }
 
        client = svs.clients + entnum-1;
-       if ((val = GETEDICTFIELDVALUE(client->edict, eval_clientcolors)))
-               val->_float = i;
+       if (client->edict)
+       {
+               if ((val = GETEDICTFIELDVALUE(client->edict, eval_clientcolors)))
+                       val->_float = i;
+               client->edict->v->team = (i & 15) + 1;
+       }
        client->colors = i;
-       client->old_colors = i;
-       client->edict->v->team = (i & 15) + 1;
-
-       MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
-       MSG_WriteByte (&sv.reliable_datagram, entnum - 1);
-       MSG_WriteByte (&sv.reliable_datagram, i);
+       if (client->old_colors != client->colors)
+       {
+               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->colors);
+       }
 }
 
 /*