commit 57c127b8613ffc065a99046427b48bd0ac501d9a
Author: Turo Lamminen <turol@iki.fi>
AuthorDate: Thu Nov 17 14:55:41 2022 +0200
Commit: Turo Lamminen <turol@users.noreply.github.com>
CommitDate: Sat Jan 27 17:34:21 2024 +0200
strife: Add error checking in G_NextWeapon to silence cppcheck warning
---
src/strife/g_game.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/strife/g_game.c b/src/strife/g_game.c
index 813f0d74..56925dbf 100644
--- a/src/strife/g_game.c
+++ b/src/strife/g_game.c
@@ -312,6 +312,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.
start_i = i;
do