Don't use uninitialized ps from BotAI_GetClientState

If BotAI_GetPlayerState returns qfalse, ps is untouched and in
some cases means uninitialized. So don't use it if not valid.
This commit is contained in:
Zack Middleton 2017-06-07 19:02:01 -05:00
parent 74aa4268b2
commit 6e340f9a5b
4 changed files with 18 additions and 13 deletions

View file

@ -100,8 +100,7 @@ int BotIsFirstInRankings(bot_state_t *bs) {
//skip spectators
if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
//
BotAI_GetClientState(i, &ps);
if (score < ps.persistant[PERS_SCORE]) return qfalse;
if (BotAI_GetClientState(i, &ps) && score < ps.persistant[PERS_SCORE]) return qfalse;
}
return qtrue;
}
@ -124,8 +123,7 @@ int BotIsLastInRankings(bot_state_t *bs) {
//skip spectators
if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
//
BotAI_GetClientState(i, &ps);
if (score > ps.persistant[PERS_SCORE]) return qfalse;
if (BotAI_GetClientState(i, &ps) && score > ps.persistant[PERS_SCORE]) return qfalse;
}
return qtrue;
}
@ -150,8 +148,7 @@ char *BotFirstClientInRankings(void) {
//skip spectators
if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
//
BotAI_GetClientState(i, &ps);
if (ps.persistant[PERS_SCORE] > bestscore) {
if (BotAI_GetClientState(i, &ps) && ps.persistant[PERS_SCORE] > bestscore) {
bestscore = ps.persistant[PERS_SCORE];
bestclient = i;
}
@ -180,8 +177,7 @@ char *BotLastClientInRankings(void) {
//skip spectators
if (atoi(Info_ValueForKey(buf, "t")) == TEAM_SPECTATOR) continue;
//
BotAI_GetClientState(i, &ps);
if (ps.persistant[PERS_SCORE] < worstscore) {
if (BotAI_GetClientState(i, &ps) && ps.persistant[PERS_SCORE] < worstscore) {
worstscore = ps.persistant[PERS_SCORE];
bestclient = i;
}