Fix checking cvar's bounds

This commit is contained in:
Ni3znajomy 2015-03-26 21:31:16 +01:00
parent b4b86113e4
commit 4d3c49f93b

View File

@ -40,16 +40,19 @@ static cell AMX_NATIVE_CALL create_cvar(AMX *amx, cell *params)
float minVal = amx_ctof(params[6]); float minVal = amx_ctof(params[6]);
float maxVal = amx_ctof(params[8]); float maxVal = amx_ctof(params[8]);
if (hasMax && minVal > maxVal) if (hasMin && hasMax)
{
if (minVal > maxVal)
{ {
LogError(amx, AMX_ERR_NATIVE, "The minimum value can not be above the maximum value"); LogError(amx, AMX_ERR_NATIVE, "The minimum value can not be above the maximum value");
return 0; return 0;
} }
else if (hasMin && maxVal < minVal) else if (maxVal < minVal)
{ {
LogError(amx, AMX_ERR_NATIVE, "The maximum value can not be below the minimum value"); LogError(amx, AMX_ERR_NATIVE, "The maximum value can not be below the minimum value");
return 0; return 0;
} }
}
g_CvarManager.SetCvarMin(info, hasMin, minVal, plugin->getId()); g_CvarManager.SetCvarMin(info, hasMin, minVal, plugin->getId());
g_CvarManager.SetCvarMax(info, hasMax, maxVal, plugin->getId()); g_CvarManager.SetCvarMax(info, hasMax, maxVal, plugin->getId());