From 5b2a1d13a1b7a1f74a398930cecdbb42e85d8020 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Thu, 11 Aug 2022 14:30:06 +0300 Subject: [PATCH] Fix displaying secondary weapon mode stats --- src/inventory.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/inventory.cc b/src/inventory.cc index c962936..9beaaa5 100644 --- a/src/inventory.cc +++ b/src/inventory.cc @@ -2433,6 +2433,11 @@ static void inventoryRenderSummary() HIT_MODE_RIGHT_WEAPON_PRIMARY, }; + const int secondaryHitModes[2] = { + HIT_MODE_LEFT_WEAPON_SECONDARY, + HIT_MODE_RIGHT_WEAPON_SECONDARY, + }; + const int unarmedHitModes[2] = { HIT_MODE_PUNCH, HIT_MODE_KICK, @@ -2510,13 +2515,29 @@ static void inventoryRenderSummary() continue; } - int range = _item_w_range(_stack[0], hitModes[index]); + // SFALL: Fix displaying secondary mode weapon range. + int hitMode = hitModes[index]; + if (_stack[0] == gDude) { + int actions[2]; + interfaceGetItemActions(&(actions[0]), &(actions[1])); + + bool isSecondary = actions[index] == INTERFACE_ITEM_ACTION_SECONDARY || + actions[index] == INTERFACE_ITEM_ACTION_SECONDARY_AIMING; + + if (isSecondary) { + hitMode = secondaryHitModes[index]; + } + } + + int range = _item_w_range(_stack[0], hitMode); int damageMin; int damageMax; weaponGetDamageMinMax(item, &damageMin, &damageMax); - int attackType = weaponGetAttackTypeForHitMode(item, hitModes[index]); + // CE: Fix displaying secondary mode weapon damage (affects throwable + // melee weapons - knifes, spears, etc.). + int attackType = weaponGetAttackTypeForHitMode(item, hitMode); formattedText[0] = '\0';