mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 14:52:00 +00:00
Fix duplicate bots displayed in Team Arena ingame add bot menu
The key handler allowed going 2 beyond the end of the bot list and the display function clamped to 0 causing the first bot to be shown 3 times. Attempting to add the bot in gametypes < GT_TEAM would fallback to Sarge in UI_GetBotNameByNumber() (who isn't the first bot) and gametypes >= GT_TEAM would access characterList past known values (typically NULL but if teaminfo.txt contained 63 characters it would access out of bounds memory).
This commit is contained in:
parent
da861ff3a2
commit
10abac8fa0
1 changed files with 5 additions and 11 deletions
|
@ -1751,16 +1751,10 @@ static int UI_OwnerDrawWidth(int ownerDraw, float scale) {
|
||||||
static void UI_DrawBotName(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
|
static void UI_DrawBotName(rectDef_t *rect, float scale, vec4_t color, int textStyle) {
|
||||||
int value = uiInfo.botIndex;
|
int value = uiInfo.botIndex;
|
||||||
int game = trap_Cvar_VariableValue("g_gametype");
|
int game = trap_Cvar_VariableValue("g_gametype");
|
||||||
const char *text = "";
|
const char *text;
|
||||||
if (game >= GT_TEAM) {
|
if (game >= GT_TEAM) {
|
||||||
if (value >= uiInfo.characterCount) {
|
|
||||||
value = 0;
|
|
||||||
}
|
|
||||||
text = uiInfo.characterList[value].name;
|
text = uiInfo.characterList[value].name;
|
||||||
} else {
|
} else {
|
||||||
if (value >= UI_GetNumBots()) {
|
|
||||||
value = 0;
|
|
||||||
}
|
|
||||||
text = UI_GetBotNameByNumber(value);
|
text = UI_GetBotNameByNumber(value);
|
||||||
}
|
}
|
||||||
Text_Paint(rect->x, rect->y, scale, color, text, 0, 0, textStyle);
|
Text_Paint(rect->x, rect->y, scale, color, text, 0, 0, textStyle);
|
||||||
|
@ -2548,16 +2542,16 @@ static qboolean UI_BotName_HandleKey(int flags, float *special, int key) {
|
||||||
value += select;
|
value += select;
|
||||||
|
|
||||||
if (game >= GT_TEAM) {
|
if (game >= GT_TEAM) {
|
||||||
if (value >= uiInfo.characterCount + 2) {
|
if (value >= uiInfo.characterCount) {
|
||||||
value = 0;
|
value = 0;
|
||||||
} else if (value < 0) {
|
} else if (value < 0) {
|
||||||
value = uiInfo.characterCount + 2 - 1;
|
value = uiInfo.characterCount - 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (value >= UI_GetNumBots() + 2) {
|
if (value >= UI_GetNumBots()) {
|
||||||
value = 0;
|
value = 0;
|
||||||
} else if (value < 0) {
|
} else if (value < 0) {
|
||||||
value = UI_GetNumBots() + 2 - 1;
|
value = UI_GetNumBots() - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uiInfo.botIndex = value;
|
uiInfo.botIndex = value;
|
||||||
|
|
Loading…
Reference in a new issue