Fix off-by-one range checks in Team Arena UI

This commit is contained in:
Zack Middleton 2015-01-12 18:26:47 -06:00
parent d62dfd87f9
commit 5020361be4

View file

@ -1314,7 +1314,7 @@ static void UI_DrawPlayerModel(rectDef_t *rect) {
}
static void UI_DrawNetSource(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
if (ui_netSource.integer < 0 || ui_netSource.integer > numNetSources) {
if (ui_netSource.integer < 0 || ui_netSource.integer >= numNetSources) {
ui_netSource.integer = 0;
}
Text_Paint(rect->x, rect->y, scale, color, va("Source: %s", netSources[ui_netSource.integer]), 0, 0, textStyle);
@ -1347,7 +1347,7 @@ static void UI_DrawNetMapCinematic(rectDef_t *rect, float scale, vec4_t color) {
static void UI_DrawNetFilter(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
if (ui_serverFilterType.integer < 0 || ui_serverFilterType.integer > numServerFilters) {
if (ui_serverFilterType.integer < 0 || ui_serverFilterType.integer >= numServerFilters) {
ui_serverFilterType.integer = 0;
}
Text_Paint(rect->x, rect->y, scale, color, va("Filter: %s", serverFilters[ui_serverFilterType.integer].description), 0, 0, textStyle);
@ -1394,7 +1394,7 @@ static void UI_DrawTierMapName(rectDef_t *rect, float scale, vec4_t color, int t
i = 0;
}
j = trap_Cvar_VariableValue("ui_currentMap");
if (j < 0 || j > MAPS_PER_TIER) {
if (j < 0 || j >= MAPS_PER_TIER) {
j = 0;
}
@ -1408,7 +1408,7 @@ static void UI_DrawTierGameType(rectDef_t *rect, float scale, vec4_t color, int
i = 0;
}
j = trap_Cvar_VariableValue("ui_currentMap");
if (j < 0 || j > MAPS_PER_TIER) {
if (j < 0 || j >= MAPS_PER_TIER) {
j = 0;
}
@ -1707,13 +1707,13 @@ static int UI_OwnerDrawWidth(int ownerDraw, float scale) {
s = va("%i. %s", ownerDraw-UI_REDTEAM1 + 1, text);
break;
case UI_NETSOURCE:
if (ui_netSource.integer < 0 || ui_netSource.integer > numNetSources) {
if (ui_netSource.integer < 0 || ui_netSource.integer >= numNetSources) {
ui_netSource.integer = 0;
}
s = va("Source: %s", netSources[ui_netSource.integer]);
break;
case UI_NETFILTER:
if (ui_serverFilterType.integer < 0 || ui_serverFilterType.integer > numServerFilters) {
if (ui_serverFilterType.integer < 0 || ui_serverFilterType.integer >= numServerFilters) {
ui_serverFilterType.integer = 0;
}
s = va("Filter: %s", serverFilters[ui_serverFilterType.integer].description );
@ -2795,7 +2795,7 @@ static void UI_StartSinglePlayer(void) {
i = 0;
}
j = trap_Cvar_VariableValue("ui_currentMap");
if (j < 0 || j > MAPS_PER_TIER) {
if (j < 0 || j >= MAPS_PER_TIER) {
j = 0;
}