Strip colors from server name when searching through server list
This commit is contained in:
1 parent
fcf1b9168c
commit
94013752d7
3 files changed
+21
-1
No files matched your search
+3
-1
@@ -9649,11 +9649,13 @@ static UINT32 localservercount;
|
||||
|
||||
static void M_SearchServerList(void)
|
||||
{
|
||||
char servername[MAXSERVERNAME+1] = {0};
|
||||
serverlistsearchedcount = 0;
|
||||
|
||||
for (UINT32 i = 0; i < serverlistcount; ++i)
|
||||
{
|
||||
if (menuinput.length == 0 || strcasestr(serverlist[i].info.servername, menuinput.buffer) != NULL)
|
||||
StripColors(servername, serverlist[i].info.servername, MAXSERVERNAME);
|
||||
if (menuinput.length == 0 || strcasestr(servername, menuinput.buffer) != NULL)
|
||||
serverlistsearched[serverlistsearchedcount++] = i;
|
||||
}
|
||||
|
||||
|
||||
@@ -1828,6 +1828,21 @@ void CopyCaretColors(char *p, const char *s, int n)
|
||||
strncpy(p, s, n);
|
||||
}
|
||||
|
||||
void StripColors(char *dst, char *src, size_t n)
|
||||
{
|
||||
size_t j = 0;
|
||||
|
||||
for (size_t i = 0; j < n && src[i] != 0; ++i)
|
||||
{
|
||||
char c = src[i];
|
||||
|
||||
if ((c & 0x80) == 0)
|
||||
dst[j++] = c;
|
||||
}
|
||||
|
||||
dst[j] = 0;
|
||||
}
|
||||
|
||||
/** Token parser for TEXTURES, ANIMDEFS, and potentially other lumps later down the line.
|
||||
* Was originally R_GetTexturesToken when I was coding up the TEXTURES parser, until I realized I needed it for ANIMDEFS too.
|
||||
* Parses up to the next whitespace character or comma. When finding the start of the next token, whitespace is skipped.
|
||||
|
||||
@@ -87,6 +87,9 @@ INT32 axtoi(const char *hexStg);
|
||||
|
||||
void CopyCaretColors(char *p, const char *s, int n);
|
||||
|
||||
// Remove color codes from string
|
||||
void StripColors(char *dst, char *src, size_t n);
|
||||
|
||||
const char *GetRevisionString(void);
|
||||
|
||||
// Vector/matrix math
|
||||
|
||||
Reference in new issue
Block a user