From 9f7a486c4f8ea5fc31d066fe24fa20750ae7e77b Mon Sep 17 00:00:00 2001 From: Jim Cameron Date: Mon, 24 Jan 2022 21:17:55 +0000 Subject: [PATCH] Added check that weapon has ammo in reload_weapon_hotkey. Without this the game would try to reload weapons that did not have ammo, which could cause it to access off the end of the player ammo clips array with strange results. --- src/GameSrc/weapons.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/GameSrc/weapons.c b/src/GameSrc/weapons.c index b0965a08..5074d012 100644 --- a/src/GameSrc/weapons.c +++ b/src/GameSrc/weapons.c @@ -1444,6 +1444,12 @@ uchar reload_weapon_hotkey(ushort key, uint32_t context, intptr_t data) { int num_types; int i, cur; + // Don't attempt to reload a weapon that doesn't use ammo! + if ((ws->type == GUN_SUBCLASS_BEAM) || + (ws->type == GUN_SUBCLASS_HANDTOHAND)) { + return FALSE; // nice try + } + if (!differ) { // attempts to reload the current weapon with the same ammo type it // held before, but if that fails will reload with anything available.