From 0af68dc90c83bd45fa64a7d8e3cf5e47fd0074da Mon Sep 17 00:00:00 2001 From: razor Date: Mon, 19 Feb 2024 22:05:26 +1100 Subject: [PATCH] [Shared] misc loop overrun fixes (#1201) * misc loop overrun fixes * revert RT_BEAM changes the extra iteration is intentional to seal the tri strip * revert inadvertent whitespace changes (cherry picked from commit 6a8a88095604e2ed8013134fea17629eb1734ec5) --- codemp/cgame/cg_draw.c | 2 +- codemp/cgame/cg_newDraw.c | 2 +- codemp/game/NPC_stats.c | 2 +- codemp/game/bg_saberLoad.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codemp/cgame/cg_draw.c b/codemp/cgame/cg_draw.c index 53496a9336..131e8d2d45 100644 --- a/codemp/cgame/cg_draw.c +++ b/codemp/cgame/cg_draw.c @@ -6045,7 +6045,7 @@ static float CG_DrawTeamOverlay( float y, qboolean right, qboolean upper ) { } else { xx = x + w - TINYCHAR_WIDTH*cgs.widthRatioCoef; } - for (j = 0; j <= PW_NUM_POWERUPS; j++) { + for (j = 0; j < PW_NUM_POWERUPS; j++) { if (ci->powerups & (1 << j)) { item = BG_FindItemForPowerup( j ); diff --git a/codemp/cgame/cg_newDraw.c b/codemp/cgame/cg_newDraw.c index 6fb6e93848..ab2b384284 100644 --- a/codemp/cgame/cg_newDraw.c +++ b/codemp/cgame/cg_newDraw.c @@ -367,7 +367,7 @@ void CG_DrawNewTeamInfo(rectDef_t *rect, float text_x, float text_y, float scale if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) { xx = rect->x + 1; - for (j = 0; j <= PW_NUM_POWERUPS; j++) { + for (j = 0; j < PW_NUM_POWERUPS; j++) { if (ci->powerups & (1 << j)) { item = BG_FindItemForPowerup( j ); diff --git a/codemp/game/NPC_stats.c b/codemp/game/NPC_stats.c index fd17306fba..6c10489375 100644 --- a/codemp/game/NPC_stats.c +++ b/codemp/game/NPC_stats.c @@ -2556,7 +2556,7 @@ qboolean NPC_ParseParms( const char *NPCName, gentity_t *NPC ) } //FIXME: need to precache the weapon, too? (in above func) weap = GetIDForString( WPTable, value ); - if ( weap >= WP_NONE && weap <= WP_NUM_WEAPONS )///*WP_BLASTER_PISTOL*/WP_SABER ) //?! + if ( weap >= WP_NONE && weap < WP_NUM_WEAPONS )///*WP_BLASTER_PISTOL*/WP_SABER ) //?! { NPC->client->ps.weapon = weap; NPC->client->ps.stats[STAT_WEAPONS] |= ( 1 << NPC->client->ps.weapon ); diff --git a/codemp/game/bg_saberLoad.c b/codemp/game/bg_saberLoad.c index 1a6803e6e2..1071c545e4 100644 --- a/codemp/game/bg_saberLoad.c +++ b/codemp/game/bg_saberLoad.c @@ -554,7 +554,7 @@ static void Saber_ParseSaberType( saberInfo_t *saber, const char **p ) { if ( COM_ParseString( p, &value ) ) return; saberType = GetIDForString( saberTable, value ); - if ( saberType >= SABER_SINGLE && saberType <= NUM_SABERS ) + if ( saberType >= SABER_SINGLE && saberType < NUM_SABERS ) saber->type = (saberType_t)saberType; } static void Saber_ParseSaberModel( saberInfo_t *saber, const char **p ) {