From 7e36a195905191cc13107cffa21c48a87343a210 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 22 May 2006 00:00:11 +0000 Subject: [PATCH] committed fix for bug atDIVINE (kami no buggu) --- amxmodx/amxmodx.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index ea32ce90..642d595e 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -357,8 +357,24 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param * int len = 0; g_langMngr.SetDefLang(params[1]); char* message = NULL; + + /** + * Earlier versions would ignore invalid bounds. + * Now, bounds are only checked for internal operations. + * "channel" stores the valid channel that core uses. + * "g_hudset.channel" stores the direct channel passed to the engine. + */ bool aut = (g_hudset.channel == -1) ? true : false; + int channel = -1; + if (!aut) + { + /** + * guarantee this to be between 0-4 + * if it's not auto, we don't care + */ + channel = abs(g_hudset.channel % 5); + } if (params[1] == 0) { for (int i = 1; i <= gpGlobals->maxClients; ++i) @@ -371,10 +387,12 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param * message = UTIL_SplitHudMessage(format_amxstring(amx, params, 2, len)); if (aut) { - g_hudset.channel = pPlayer->NextHUDChannel(); - pPlayer->channels[g_hudset.channel] = gpGlobals->time; + channel = pPlayer->NextHUDChannel(); + pPlayer->channels[channel] = gpGlobals->time; + g_hudset.channel = channel; } - pPlayer->hudmap[g_hudset.channel] = 0; + //don't need to set g_hudset! + pPlayer->hudmap[channel] = 0; UTIL_HudMessage(pPlayer->pEdict, g_hudset, message); } } @@ -394,10 +412,11 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param * { if (aut) { - g_hudset.channel = pPlayer->NextHUDChannel(); - pPlayer->channels[g_hudset.channel] = gpGlobals->time; + channel = pPlayer->NextHUDChannel(); + pPlayer->channels[channel] = gpGlobals->time; + g_hudset.channel = channel; } - pPlayer->hudmap[g_hudset.channel] = 0; + pPlayer->hudmap[channel] = 0; UTIL_HudMessage(pPlayer->pEdict, g_hudset, message); } }