Convert from caret colors when sending SERVERINFO

This commit is contained in:
James R 2019-07-03 17:11:38 -07:00
parent f87b883ba5
commit f802e9fbcb

View file

@ -1306,6 +1306,70 @@ static boolean CL_SendJoin(void)
return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak));
}
static void
CopyCaretColors (char *p, const char *s, int n)
{
char *t;
int m;
int c;
if (!n)
return;
while (( t = strchr(s, '^') ))
{
m = ( t - s );
if (m >= n)
{
memcpy(p, s, n);
return;
}
else
memcpy(p, s, m);
p += m;
n -= m;
s += m;
if (!n)
return;
if (s[1])
{
c = toupper(s[1]);
if (isdigit(c))
c = 0x80 + ( c - '0' );
else if (c >= 'A' && c <= 'F')
c = 0x80 + ( c - 'A' );
else
c = 0;
if (c)
{
*p++ = c;
n--;
if (!n)
return;
}
else
{
if (n < 2)
break;
memcpy(p, s, 2);
p += 2;
n -= 2;
}
s += 2;
}
else
break;
}
strncpy(p, s, n);
}
static void SV_SendServerInfo(INT32 node, tic_t servertime)
{
UINT8 *p;
@ -1334,8 +1398,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
(dedicated ? SV_DEDICATED : 0)
);
strncpy(netbuffer->u.serverinfo.servername, cv_servername.string,
CopyCaretColors(netbuffer->u.serverinfo.servername, cv_servername.string,
MAXSERVERNAME);
strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7);