2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-01 01:25:38 +03:00

Merge pull request #155 from WPMGPRoSToTeMa/kickfeatures

Added replacing escape sequences in kick reason (#154)
This commit is contained in:
theAsmodai 2016-02-02 19:24:44 +03:00
commit 30a97dfaab

View File

@ -6067,6 +6067,42 @@ void SV_BanId_f(void)
host_client = save;
}
#ifdef REHLDS_FIXES
void ReplaceEscapeSequences(char *str)
{
size_t len = 0;
for (size_t i = 0; str[i] != '\0'; i++)
{
if (str[i] == '\\')
{
switch (str[++i])
{
case 't':
str[len++] = '\t';
break;
case 'n':
str[len++] = '\n';
break;
case '\\':
str[len++] = '\\';
break;
// TODO: or ignore it?
default:
str[len++] = '\\';
str[len++] = str[i];
break;
}
}
else
{
str[len++] = str[i];
}
}
str[len] = '\0';
}
#endif // REHLDS_FIXES
/* <ab1ec> ../engine/sv_main.c:8040 */
void Host_Kick_f(void)
{
@ -6209,6 +6245,13 @@ void Host_Kick_f(void)
const char *message = dataLen + p;
if (message)
{
#ifdef REHLDS_FIXES
char reason[256];
Q_strncpy(reason, message, sizeof(reason) - 1);
reason[sizeof(reason) - 1] = '\0';
ReplaceEscapeSequences(reason);
message = reason;
#endif // REHLDS_FIXES
SV_ClientPrintf("Kicked by %s: %s\n", who, message);
Log_Printf(
"Kick: \"%s<%i><%s><>\" was kicked by \"%s\" (message \"%s\")\n",