From 6a8a88095604e2ed8013134fea17629eb1734ec5 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 --- code/game/wp_saberLoad.cpp | 2 +- codemp/cgame/cg_draw.c | 2 +- codemp/cgame/cg_newDraw.c | 2 +- codemp/game/NPC_stats.c | 2 +- codemp/game/bg_saberLoad.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/game/wp_saberLoad.cpp b/code/game/wp_saberLoad.cpp index 1b89f34b8f..298d1775eb 100644 --- a/code/game/wp_saberLoad.cpp +++ b/code/game/wp_saberLoad.cpp @@ -490,7 +490,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 ) { diff --git a/codemp/cgame/cg_draw.c b/codemp/cgame/cg_draw.c index 8b793c1593..bc6e4983a7 100644 --- a/codemp/cgame/cg_draw.c +++ b/codemp/cgame/cg_draw.c @@ -3978,7 +3978,7 @@ static float CG_DrawTeamOverlay( float y, qboolean right, qboolean upper ) { } else { xx = x + w - TINYCHAR_WIDTH; } - 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 4920ad8a68..3293411e58 100644 --- a/codemp/game/NPC_stats.c +++ b/codemp/game/NPC_stats.c @@ -2554,7 +2554,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 ae7460dc1c..a2d02cd2ab 100644 --- a/codemp/game/bg_saberLoad.c +++ b/codemp/game/bg_saberLoad.c @@ -532,7 +532,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 ) {