commit 15c406a443ffa8f5ba5d42317d88d55c5b00dc00
Author: Turo Lamminen <turol@iki.fi>
AuthorDate: Thu Nov 17 14:55:21 2022 +0200
Commit: Turo Lamminen <turol@users.noreply.github.com>
CommitDate: Sat Jan 27 17:34:21 2024 +0200
heretic: Add error checking in G_NextWeapon to silence cppcheck warning
---
src/heretic/g_game.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c
index 8f060923..95830ccb 100644
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -258,6 +258,12 @@ static int G_NextWeapon(int direction)
}
}
+ // The current weapon must be present in weapon_order_table
+ // otherwise something has gone terribly wrong
+ if (i >= arrlen(weapon_order_table)) {
+ I_Error("Internal error: weapon %d not present in weapon_order_table", weapon);
+ }
+
// Switch weapon. Don't loop forever.
start_i = i;
do