From 28aa73a859d71f802d961dfed617a7ea8b01cf8a Mon Sep 17 00:00:00 2001 From: rftrdev <102184004+rftrdev@users.noreply.github.com> Date: Sat, 2 Sep 2023 23:01:17 -0700 Subject: [PATCH] Clamp coolness to valid values when generating ARC ammo cache (#220) Fixes #217 --- Strategic/Rebel Command.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Strategic/Rebel Command.cpp b/Strategic/Rebel Command.cpp index b5ce30aa..84f6f69f 100644 --- a/Strategic/Rebel Command.cpp +++ b/Strategic/Rebel Command.cpp @@ -4429,7 +4429,8 @@ void SetupInfo() && (gGameOptions.ubGameStyle == STYLE_SCIFI || !Item[i].scifi)) { // coolness runs from 1-10, so apply offset - ItemIdCache::ammo[Item[i].ubCoolness-1].push_back(i); + const UINT8 coolness = min(max(1, Item[i].ubCoolness), 10); + ItemIdCache::ammo[coolness-1].push_back(i); } } }