more filtertext whitespace options
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2904 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -75,7 +75,7 @@ void newname(const char *name)
|
||||
if(name[0])
|
||||
{
|
||||
c2sinit = false;
|
||||
filtertext(player1->name, name, false, MAXNAMELEN);
|
||||
filtertext(player1->name, name, 0, MAXNAMELEN);
|
||||
if(!player1->name[0]) s_strcpy(player1->name, "unarmed");
|
||||
}
|
||||
else conoutf("your name is: %s", player1->name);
|
||||
@@ -95,7 +95,7 @@ void changeteam(int team, bool respawn) // force team and respawn
|
||||
{
|
||||
c2sinit = false;
|
||||
if(m_flags) tryflagdrop(false);
|
||||
filtertext(player1->team, team_string(team), false, MAXTEAMLEN);
|
||||
filtertext(player1->team, team_string(team), 0, MAXTEAMLEN);
|
||||
if(respawn)
|
||||
{
|
||||
addmsg(SV_CHANGETEAM, "r");
|
||||
|
||||
@@ -247,7 +247,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
{
|
||||
d = newclient(cn);
|
||||
getstring(text, p);
|
||||
filtertext(text, text, false, MAXNAMELEN);
|
||||
filtertext(text, text, 0, MAXNAMELEN);
|
||||
if(!text[0]) s_strcpy(text, "unarmed");
|
||||
if(d->name[0]) // already connected
|
||||
{
|
||||
@@ -261,7 +261,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
}
|
||||
s_strncpy(d->name, text, MAXNAMELEN+1);
|
||||
getstring(text, p);
|
||||
filtertext(d->team, text, false, MAXTEAMLEN);
|
||||
filtertext(d->team, text, 0, MAXTEAMLEN);
|
||||
setskin(d, getint(p));
|
||||
if(m_flags) loopi(2)
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ void conoutf(const char *s, ...)
|
||||
{
|
||||
s_sprintfdv(sf, s);
|
||||
string sp;
|
||||
filtertext(sp, sf);
|
||||
filtertext(sp, sf, 2);
|
||||
puts(sp);
|
||||
con.addline(sf);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ void getstring(char *text, ucharbuf &p, int len)
|
||||
}
|
||||
|
||||
|
||||
void filtertext(char *dst, const char *src, bool whitespace, int len)
|
||||
void filtertext(char *dst, const char *src, int whitespace, int len)
|
||||
{
|
||||
for(int c = *src; c; c = *++src)
|
||||
{
|
||||
@@ -85,7 +85,7 @@ void filtertext(char *dst, const char *src, bool whitespace, int len)
|
||||
{
|
||||
case '\f': ++src; continue;
|
||||
}
|
||||
if(isspace(c) ? whitespace && c == ' ' : isprint(c))
|
||||
if(isspace(c) ? whitespace && (whitespace>1 || c == ' ') : isprint(c))
|
||||
{
|
||||
*dst++ = c;
|
||||
if(!--len) break;
|
||||
|
||||
+1
-1
@@ -621,7 +621,7 @@ extern void putuint(ucharbuf &p, int n);
|
||||
extern int getuint(ucharbuf &p);
|
||||
extern void sendstring(const char *t, ucharbuf &p);
|
||||
extern void getstring(char *t, ucharbuf &p, int len = MAXTRANS);
|
||||
extern void filtertext(char *dst, const char *src, bool whitespace = true, int len = sizeof(string)-1);
|
||||
extern void filtertext(char *dst, const char *src, int whitespace = 1, int len = sizeof(string)-1);
|
||||
extern void startintermission();
|
||||
extern void restoreserverstate(vector<entity> &ents);
|
||||
extern uchar *retrieveservers(uchar *buf, int buflen);
|
||||
|
||||
@@ -289,29 +289,20 @@ hudmessages hudmsgs;
|
||||
void hudoutf(const char *s, ...)
|
||||
{
|
||||
s_sprintfdv(sf, s);
|
||||
string sp;
|
||||
filtertext(sp, sf);
|
||||
s = sf;
|
||||
hudmsgs.addline(s);
|
||||
conoutf(s);
|
||||
hudmsgs.addline(sf);
|
||||
conoutf(sf);
|
||||
}
|
||||
|
||||
void hudonlyf(const char *s, ...)
|
||||
{
|
||||
s_sprintfdv(sf, s);
|
||||
string sp;
|
||||
filtertext(sp, sf);
|
||||
s = sf;
|
||||
hudmsgs.addline(s);
|
||||
hudmsgs.addline(sf);
|
||||
}
|
||||
|
||||
void hudeditf(const char *s, ...)
|
||||
{
|
||||
s_sprintfdv(sf, s);
|
||||
string sp;
|
||||
filtertext(sp, sf);
|
||||
s = sf;
|
||||
hudmsgs.editlastline(s);
|
||||
hudmsgs.editlastline(sf);
|
||||
}
|
||||
|
||||
bool insideradar(const vec ¢erpos, float radius, const vec &o)
|
||||
|
||||
@@ -2330,7 +2330,7 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1
|
||||
else
|
||||
{
|
||||
getstring(text, p);
|
||||
filtertext(text, text, false, MAXNAMELEN);
|
||||
filtertext(text, text, 0, MAXNAMELEN);
|
||||
if(!text[0]) s_strcpy(text, "unarmed");
|
||||
s_strncpy(cl->name, text, MAXNAMELEN+1);
|
||||
|
||||
@@ -2465,13 +2465,13 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1
|
||||
{
|
||||
QUEUE_MSG;
|
||||
getstring(text, p);
|
||||
filtertext(text, text, false, MAXNAMELEN);
|
||||
filtertext(text, text, 0, MAXNAMELEN);
|
||||
if(!text[0]) s_strcpy(text, "unarmed");
|
||||
QUEUE_STR(text);
|
||||
if(strcmp(cl->name, text)) logger->writeline(log::info,"[%s] %s changed his name to %s", cl->hostname, cl->name, text);
|
||||
s_strncpy(cl->name, text, MAXNAMELEN+1);
|
||||
getstring(text, p);
|
||||
filtertext(cl->team, text, false, MAXTEAMLEN);
|
||||
filtertext(cl->team, text, 0, MAXTEAMLEN);
|
||||
QUEUE_STR(text);
|
||||
getint(p);
|
||||
QUEUE_MSG;
|
||||
|
||||
Reference in New Issue
Block a user