]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
removed the ^7 after player names in various engine messages and made
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 13 Jun 2007 08:42:51 +0000 (08:42 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 13 Jun 2007 08:42:51 +0000 (08:42 +0000)
the player name change code append the ^7 if the name contains color
codes and the last one is not ^7, this gets rid of spurious ^7 tags seen
by non-DP clients

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7409 d7cf8633-e32d-0410-b094-e92efae38249

host.c
host_cmd.c
sv_main.c

diff --git a/host.c b/host.c
index 0a4df3d0ba540417d126d9c14ae4878675b4a851..fa64cf64e16bb35ec03d5bd21e8afe6382706188 100644 (file)
--- a/host.c
+++ b/host.c
@@ -369,7 +369,7 @@ if (crash = true), don't bother sending signofs
 void SV_DropClient(qboolean crash)
 {
        int i;
-       Con_Printf("Client \"%s^%i\" dropped\n", host_client->name, STRING_COLOR_DEFAULT);
+       Con_Printf("Client \"%s\" dropped\n", host_client->name);
 
        // make sure edict is not corrupt (from a level change for example)
        host_client->edict = PRVM_EDICT_NUM(host_client - svs.clients + 1);
index f37626bd9701ea9502788374aeffda2e40961890..4920a35a330ac79ff513ab4db29479a9aff6db51 100644 (file)
@@ -97,7 +97,7 @@ void Host_Status_f (void)
                }
                else
                        hours = 0;
-               print ("#%-3u %-16.16s^%i  %3i  %2i:%02i:%02i\n", j+1, client->name, STRING_COLOR_DEFAULT, client->frags, hours, minutes, seconds);
+               print ("#%-3u %-16.16s  %3i  %2i:%02i:%02i\n", j+1, client->name, client->frags, hours, minutes, seconds);
                print ("   %s\n", client->netconnection ? client->netconnection->address : "botclient");
        }
 }
@@ -796,11 +796,36 @@ void Host_Name_f (void)
                }
        }
 
+       // find the last color tag offset and decide if we need to add a reset tag
+       for (i = 0, j = -1;host_client->name[i];i++)
+       {
+               if (host_client->name[i] == STRING_COLOR_TAG)
+               {
+                       if (host_client->name[i+1] >= '0' && host_client->name[i+1] <= '9')
+                       {
+                               j = i;
+                               // if this happens to be a reset  tag then we don't need one
+                               if (host_client->name[i+1] == '0' + STRING_COLOR_DEFAULT)
+                                       j = -1;
+                               i++;
+                               continue;
+                       }
+                       if (host_client->name[i+1] == STRING_COLOR_TAG)
+                       {
+                               i++;
+                               continue;
+                       }
+               }
+       }
+       // does not end in the default color string, so add it
+       if (j >= 0 && strlen(host_client->name) < sizeof(host_client->name) - 2)
+               memcpy(host_client->name + strlen(host_client->name), STRING_COLOR_DEFAULT_STR, strlen(STRING_COLOR_DEFAULT_STR) + 1);
+
        host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
        if (strcmp(host_client->old_name, host_client->name))
        {
                if (host_client->spawned)
-                       SV_BroadcastPrintf("%s^%i changed name to %s\n", host_client->old_name, STRING_COLOR_DEFAULT, host_client->name);
+                       SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
                strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
                // send notification to all clients
                MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
@@ -970,13 +995,13 @@ void Host_Say(qboolean teamonly)
        }
        // note this uses the chat prefix \001
        if (!fromServer && !teamonly)
-               dpsnprintf (text, sizeof(text), "\001%s" STRING_COLOR_DEFAULT_STR ": %s", host_client->name, p1);
+               dpsnprintf (text, sizeof(text), "\001%s: %s", host_client->name, p1);
        else if (!fromServer && teamonly)
-               dpsnprintf (text, sizeof(text), "\001(%s" STRING_COLOR_DEFAULT_STR "): %s", host_client->name, p1);
+               dpsnprintf (text, sizeof(text), "\001(%s): %s", host_client->name, p1);
        else if(*(sv_adminnick.string))
-               dpsnprintf (text, sizeof(text), "\001<%s" STRING_COLOR_DEFAULT_STR "> %s", sv_adminnick.string, p1);
+               dpsnprintf (text, sizeof(text), "\001<%s> %s", sv_adminnick.string, p1);
        else
-               dpsnprintf (text, sizeof(text), "\001<%s" STRING_COLOR_DEFAULT_STR "> %s", hostname.string, p1);
+               dpsnprintf (text, sizeof(text), "\001<%s> %s", hostname.string, p1);
        p2 = text + strlen(text);
        while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
        {
@@ -1427,7 +1452,7 @@ void Host_Spawn_f (void)
                PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
 
                if (svs.maxclients > 1 || cls.state == ca_dedicated)
-                       Con_Printf("%s^%i entered the game\n", host_client->name, STRING_COLOR_DEFAULT);
+                       Con_Printf("%s entered the game\n", host_client->name);
 
                PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
        }
index 47b474e5b85da6976dfb4bd9a40982c92c102094..3d31072856fa28cc77313e41fe42a71f26f76afa 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -1717,7 +1717,7 @@ static void SV_UpdateToReliableMessages (void)
                if (strcmp(host_client->old_name, host_client->name))
                {
                        if (host_client->spawned)
-                               SV_BroadcastPrintf("%s^%i changed name to %s\n", host_client->old_name, STRING_COLOR_DEFAULT, host_client->name);
+                               SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
                        strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
                        // send notification to all clients
                        MSG_WriteByte (&sv.reliable_datagram, svc_updatename);