From 6949a9d31e866c366cd719e9c8a2d2ae3a577260 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 13 Jun 2007 08:42:51 +0000 Subject: [PATCH] removed the ^7 after player names in various engine messages and made 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 | 2 +- host_cmd.c | 39 ++++++++++++++++++++++++++++++++------- sv_main.c | 2 +- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/host.c b/host.c index 0a4df3d0..fa64cf64 100644 --- 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); diff --git a/host_cmd.c b/host_cmd.c index f37626bd..4920a35a 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -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"); } diff --git a/sv_main.c b/sv_main.c index 47b474e5..3d310728 100644 --- 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); -- 2.39.2