modified colorname buffer assignment

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4109 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
ac_stef
2009-01-04 15:31:48 +00:00
parent 6b41796c15
commit b526aeda6c
4 changed files with 17 additions and 11 deletions
+3 -1
View File
@@ -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];
}
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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);
+11 -7
View File
@@ -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;
}