From 9b92adfa51e3a7098b850c4c0ecb41df0bb39c2d Mon Sep 17 00:00:00 2001 From: NovaRain Date: Mon, 11 May 2026 13:34:18 +0800 Subject: [PATCH] Disallowed negative cost for set/get_inven_ap_cost --- sfall/Modules/Inventory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sfall/Modules/Inventory.cpp b/sfall/Modules/Inventory.cpp index 1351beb2..c875eb59 100644 --- a/sfall/Modules/Inventory.cpp +++ b/sfall/Modules/Inventory.cpp @@ -820,7 +820,7 @@ skipDrag: } static int invenApCost, invenApCostDef; -static char invenApQPReduction; +static signed char invenApQPReduction; static __declspec(naked) void inven_ap_cost_hack() { __asm { @@ -837,13 +837,13 @@ inline static void ApplyInvenApCostPatch() { } void __fastcall Inventory::SetInvenApCost(int cost) { - invenApCost = cost; + invenApCost = (cost < 0) ? 0 : cost; if (!onlyOnceAP) ApplyInvenApCostPatch(); } long Inventory::GetInvenApCost() { long perkLevel = fo::func::perk_level(fo::var::obj_dude, fo::PERK_quick_pockets); - return invenApCost - (invenApQPReduction * perkLevel); + return max(0, invenApCost - (invenApQPReduction * perkLevel)); } void InventoryReset() {