Merge pull request #338 from Arkshine/fix/client_print_color

Improve client_print_color by inserting default color code at the start of string
This commit is contained in:
Vincent Herbet 2016-01-16 14:13:22 +01:00
commit 60ebc444ab

View File

@ -337,6 +337,12 @@ static cell AMX_NATIVE_CALL client_print_color(AMX *amx, cell *params) /* 3 para
g_langMngr.SetDefLang(i); g_langMngr.SetDefLang(i);
msg = format_amxstring(amx, params, 3, len); msg = format_amxstring(amx, params, 3, len);
if (*msg > 4) // Insert default color code at the start if not present, otherwise message will not be colored.
{
memmove(msg + 1, msg, ke::Min(len++, 191));
*msg = 1;
}
if (len > 190) // Server crashes after byte 190. (190 + \n = 191) if (len > 190) // Server crashes after byte 190. (190 + \n = 191)
{ {
len = 190; len = 190;
@ -369,6 +375,12 @@ static cell AMX_NATIVE_CALL client_print_color(AMX *amx, cell *params) /* 3 para
msg = format_amxstring(amx, params, 3, len); msg = format_amxstring(amx, params, 3, len);
if (*msg > 4) // Insert default color code at the start if not present, otherwise message will not be colored.
{
memmove(msg + 1, msg, ke::Min(len++, 191));
*msg = 1;
}
if (len > 190) // Server crashes after byte 190. (190 + \n = 191) if (len > 190) // Server crashes after byte 190. (190 + \n = 191)
{ {
len = 190; len = 190;