diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 5d68e3ea..1e7a2000 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -53,11 +53,13 @@ bool duplicatename(playerent *d, char *name = NULL) return false; } -char *colorname(playerent *d, int num, char *name, const char *prefix) +char *colorname(playerent *d, char *name, const char *prefix) { if(!name) name = d->name; if(name[0] && !duplicatename(d, name)) return name; static string cname[4]; + static int num = 0; + num = (num + 1) % 4; s_sprintf(cname[num])("%s%s \fs\f6(%d)\fr", prefix, name, d->clientnum); return cname[num]; } diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 156f4dd5..30469c06 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -295,12 +295,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", colorname(d, 0), colorname(d, 1, text)); + conoutf("%s is now known as %s", colorname(d), colorname(d, text)); } else // new client { c2sinit = false; // send new players my info again - conoutf("connected: %s", colorname(d, 0, text)); + conoutf("connected: %s", colorname(d, text)); } s_strncpy(d->name, text, MAXNAMELEN+1); getstring(text, p); diff --git a/source/src/protos.h b/source/src/protos.h index 44a5279e..5fdd01c9 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -379,7 +379,7 @@ extern bool tryrespawn(); extern void findplayerstart(playerent *d, bool mapcenter = false, int arenaspawn = -1); extern void serveropcommand(int cmd, int arg1); extern void refreshsopmenu(void *menu, bool init); -extern char *colorname(playerent *d, int num = 0, char *name = NULL, const char *prefix = ""); +extern char *colorname(playerent *d, char *name = NULL, const char *prefix = ""); extern char *colorping(int ping); extern void togglespect(); extern playerent *updatefollowplayer(int shiftdirection = 0); diff --git a/source/src/server.cpp b/source/src/server.cpp index 618d0ab7..4ef71bd2 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1626,18 +1626,22 @@ enet_uint32 atoip(const char *s) return res; } -const char *iptoa(enet_uint32 ip, int buf = 0) +const char *iptoa(enet_uint32 ip) { - static string s[2]; buf &= 1; + static string s[2]; + static int buf = 0; + buf = (buf + 1) % 2; s_sprintf(s[buf])("%d.%d.%d.%d", (ip >> 24) & 255, (ip >> 16) & 255, (ip >> 8) & 255, ip & 255); return s[buf]; } -const char *iprtoa(struct iprange *ipr, int buf = 0) +const char *iprtoa(struct iprange *ipr) { - static string s[2]; buf &= 1; + static string s[2]; + static int buf = 0; + buf = (buf + 1) % 2; if(ipr->lr == ipr->ur) s_strcpy(s[buf], iptoa(ipr->lr)); - else s_sprintf(s[buf])("%s-%s", iptoa(ipr->lr, 0), iptoa(ipr->ur, 1)); + else s_sprintf(s[buf])("%s-%s", iptoa(ipr->lr), iptoa(ipr->ur)); return s[buf]; } @@ -1693,13 +1697,13 @@ void readblacklist(const char *name) if(blacklist[i].lr == blacklist[i - 1].lr && blacklist[i].ur == blacklist[i - 1].ur) logger->writeline(log::info," blacklist entry %s got dropped (double entry)", iprtoa(&blacklist[i])); else - logger->writeline(log::info," blacklist entry %s got dropped (already covered by %s)", iprtoa(&blacklist[i], 0), iprtoa(&blacklist[i - 1], 1)); + logger->writeline(log::info," blacklist entry %s got dropped (already covered by %s)", iprtoa(&blacklist[i]), iprtoa(&blacklist[i - 1])); } blacklist.remove(i--); continue; } if(blacklist[i].lr <= blacklist[i - 1].ur) { - if(verbose) logger->writeline(log::info," blacklist entries %s and %s are joined due to overlap", iprtoa(&blacklist[i - 1], 0), iprtoa(&blacklist[i], 1)); + if(verbose) logger->writeline(log::info," blacklist entries %s and %s are joined due to overlap", iprtoa(&blacklist[i - 1]), iprtoa(&blacklist[i])); blacklist[i - 1].ur = blacklist[i].ur; blacklist.remove(i--); continue; }