diff --git a/source/src/client.cpp b/source/src/client.cpp index d2f0c530..f04bb817 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -180,7 +180,7 @@ void toserver(char *text) { bool toteam = text && text[0] == '%'; if(toteam) text++; - conoutf("%s:\f%d %s", player1->name, toteam ? 1 : 0, text); + conoutf("%s:\f%d %s", colorname(player1), toteam ? 1 : 0, text); addmsg(toteam ? SV_TEAMTEXT : SV_TEXT, "rs", text); } diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 2a81f4f8..7b049c91 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -47,13 +47,13 @@ bool duplicatename(playerent *d, char *name = NULL) return false; } -char *colorname(playerent *d, char *name, char *prefix) +char *colorname(playerent *d, int num, char *name, char *prefix) { if(!name) name = d->name; if(name[0] && !duplicatename(d, name)) return name; - static string cname; - s_sprintf(cname)("%s%s \fs\f5(%d)\fr", prefix, name, d->clientnum); - return cname; + static string cname[4]; + s_sprintf(cname[num])("%s%s \fs\f5(%d)\fr", prefix, name, d->clientnum); + return cname[num]; } void newname(char *name) @@ -578,21 +578,21 @@ void flagmsg(int flag, int action) { playsound(S_FLAGPICKUP); if(f.actor==player1) conoutf("\f2you got the enemy flag"); - else conoutf("\f2%s got %s flag", f.actor->name, (own ? "your": "the enemy")); + else conoutf("\f2%s got %s flag", colorname(f.actor), (own ? "your": "the enemy")); break; } case SV_FLAGDROP: { playsound(S_FLAGDROP); if(f.actor==player1) conoutf("\f2you lost the flag"); - else conoutf("\f2%s lost %s flag", f.actor->name, (own ? "your" : "the enemy")); + else conoutf("\f2%s lost %s flag", colorname(f.actor), (own ? "your" : "the enemy")); break; } case SV_FLAGRETURN: { playsound(S_FLAGRETURN); if(f.actor==player1) conoutf("\f2you returned your flag"); - else conoutf("\f2%s returned %s flag", f.actor->name, (own ? "your" : "the enemy")); + else conoutf("\f2%s returned %s flag", colorname(f.actor), (own ? "your" : "the enemy")); break; } case SV_FLAGSCORE: @@ -603,7 +603,7 @@ void flagmsg(int flag, int action) conoutf("\f2you scored"); addmsg(SV_FLAGS, "ri", ++player1->flagscore); } - else conoutf("\f2%s scored for %s team", f.actor->name, (own ? "the enemy" : "your")); + else conoutf("\f2%s scored for %s team", colorname(f.actor), (own ? "the enemy" : "your")); break; } case SV_FLAGRESET: @@ -666,7 +666,7 @@ void refreshsopmenu(void *menu, bool init) { string &s = mlines.add().cmd; s_sprintf(s)("%s %d", menu==kickmenu ? "kick" : (menu==banmenu ? "ban" : (menu==forceteammenu ? "forceteam" : "givemaster")), i); - menumanual(menu, item++, players[i]->name, s); + menumanual(menu, item++, colorname(players[i]), s); } } diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 8f44bc2c..bb6a87a7 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -147,7 +147,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) getstring(text, p); playerent *d = getclient(cn); if(!d) break; - conoutf("%s:\f1 %s", d->name, text); + conoutf("%s:\f1 %s", colorname(d), text); break; } @@ -161,7 +161,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) else if(d) { getstring(text, p); - conoutf("%s:\f0 %s", d->name, text); + conoutf("%s:\f0 %s", colorname(d), text); } else return; break; @@ -202,12 +202,12 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) if(d->name[0]) // already connected { if(strcmp(d->name, text)) - conoutf("%s is now known as %s", d->name, &text); + conoutf("%s is now known as %s", colorname(d, 0), colorname(d, 1, text)); } else // new client { c2sinit = false; // send new players my info again - conoutf("connected: %s", &text); + conoutf("connected: %s", colorname(d, 0, text)); gun_changed = true; } s_strncpy(d->name, text, MAXNAMELEN+1); @@ -229,7 +229,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) int cn = getint(p); playerent *d = getclient(cn); if(!d) break; - if(d->name[0]) conoutf("player %s disconnected", d->name); + if(d->name[0]) conoutf("player %s disconnected", colorname(d)); zapplayer(players[cn]); break; } @@ -314,11 +314,11 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) act = a; if(isteam(a->team, d->team)) { - conoutf("\f2%s %s his teammate (%s)", colorname(a), death, colorname(d)); + conoutf("\f2%s %s his teammate (%s)", colorname(a, 0), death, colorname(d, 1)); } else { - conoutf("\f2%s %s %s", colorname(a), death, colorname(d)); + conoutf("\f2%s %s %s", colorname(a, 0), death, colorname(d, 1)); } if(gib) addgib(d); } diff --git a/source/src/protos.h b/source/src/protos.h index 0412c282..57a95c19 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -155,7 +155,7 @@ extern void arenarespawn(); extern void respawn(); extern void serveropcommand(int cmd, int arg1); extern void refreshsopmenu(void *menu, bool init); -extern char *colorname(playerent *d, char *name = NULL, char *prefix = ""); +extern char *colorname(playerent *d, int num = 0, char *name = NULL, char *prefix = ""); // scoreboard extern void showscores(bool on); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index f1d6063e..b8c02d3c 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -188,7 +188,7 @@ void drawradar(int w, int h) } glTranslatef(-(centerpos.x-res/2)/worldsize*radarsize, -(centerpos.y-res/2)/worldsize*radarsize, 0); - drawradarent(player1->o.x*coordtrans, player1->o.y*coordtrans, player1->yaw, player1->state==CS_ALIVE ? (isattacking(player1) ? 2 : 0) : 1, 2, iconsize, isattacking(player1), player1->name); // local player + drawradarent(player1->o.x*coordtrans, player1->o.y*coordtrans, player1->yaw, player1->state==CS_ALIVE ? (isattacking(player1) ? 2 : 0) : 1, 2, iconsize, isattacking(player1), colorname(player1)); // local player loopv(players) // other players {