]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use white color prefix in chat on names with any color in them
authorMario <mario.mario@y7mail.com>
Thu, 9 Jan 2014 03:18:04 +0000 (14:18 +1100)
committerMario <mario.mario@y7mail.com>
Thu, 9 Jan 2014 03:18:04 +0000 (14:18 +1100)
qcsrc/server/cl_player.qc

index 0229d3ed5734a9aebe9f77021c79e4d249d939bb..60e20ed76a20c57e918c8bcbe9da19e550aaffc0 100644 (file)
@@ -689,7 +689,7 @@ float Say(entity source, float teamsay, entity privatesay, string msgin, float f
 //   0 = reject
 //  -1 = fake accept
 {
-       string msgstr, colorstr, cmsgstr, namestr, fullmsgstr, sourcemsgstr, fullcmsgstr, sourcecmsgstr;
+       string msgstr, colorstr, cmsgstr, namestr, fullmsgstr, sourcemsgstr, fullcmsgstr, sourcecmsgstr, colorprefix;
        float flood;
        var .float flood_field;
        entity head;
@@ -734,14 +734,19 @@ float Say(entity source, float teamsay, entity privatesay, string msgin, float f
        else
                namestr = source.netname;
 
+       if(strdecolorize(namestr) == namestr)
+               colorprefix = "^3";
+       else
+               colorprefix = "^7";
+
        if(msgin != "")
        {
                if(privatesay)
                {
-                       msgstr = strcat("\{1}\{13}* ^3", namestr, "^3 tells you: ^7");
+                       msgstr = strcat("\{1}\{13}* ", colorprefix, namestr, "^3 tells you: ^7");
                        privatemsgprefixlen = strlen(msgstr);
                        msgstr = strcat(msgstr, msgin);
-                       cmsgstr = strcat(colorstr, "^3", namestr, "^3 tells you:\n^7", msgin);
+                       cmsgstr = strcat(colorstr, colorprefix, namestr, "^3 tells you:\n^7", msgin);
                        if(autocvar_g_chat_teamcolors)
                                privatemsgprefix = strcat("\{1}\{13}* ^3You tell ", playername(privatesay), ": ^7");
                        else
@@ -749,12 +754,12 @@ float Say(entity source, float teamsay, entity privatesay, string msgin, float f
                }
                else if(teamsay)
                {
-                       msgstr = strcat("\{1}\{13}", colorstr, "(^3", namestr, colorstr, ") ^7", msgin);
-                       cmsgstr = strcat(colorstr, "(^3", namestr, colorstr, ")\n^7", msgin);
+                       msgstr = strcat("\{1}\{13}", colorstr, "(", colorprefix, namestr, colorstr, ") ^7", msgin);
+                       cmsgstr = strcat(colorstr, "(", colorprefix, namestr, colorstr, ")\n^7", msgin);
                }
                else
                {
-                       msgstr = strcat("\{1}", namestr, "^7: ", msgin);
+                       msgstr = strcat("\{1}", colorprefix, namestr, "^7: ", msgin);
                        cmsgstr = "";
                }
                msgstr = strcat(strreplace("\n", " ", msgstr), "\n"); // newlines only are good for centerprint