diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index db8d2d33..738b9f00 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -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"); diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index a037d448..308573da 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -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) { diff --git a/source/src/console.cpp b/source/src/console.cpp index ed428930..99f0af0a 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -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); } diff --git a/source/src/protocol.cpp b/source/src/protocol.cpp index 5c21f9d4..1d1e6325 100644 --- a/source/src/protocol.cpp +++ b/source/src/protocol.cpp @@ -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; diff --git a/source/src/protos.h b/source/src/protos.h index 56914f01..274080a3 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -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 &ents); extern uchar *retrieveservers(uchar *buf, int buflen); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 634389ce..4167619d 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -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) diff --git a/source/src/server.cpp b/source/src/server.cpp index fae9c3ec..b6bbd270 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -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;