Skip to content

Commit 9b92adf

Browse files
committed
Disallowed negative cost for set/get_inven_ap_cost
1 parent 67c6ee6 commit 9b92adf

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

sfall/Modules/Inventory.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ static __declspec(naked) void inven_pickup_skip_drag_hack() {
820820
}
821821

822822
static int invenApCost, invenApCostDef;
823-
static char invenApQPReduction;
823+
static signed char invenApQPReduction;
824824

825825
static __declspec(naked) void inven_ap_cost_hack() {
826826
__asm {
@@ -837,13 +837,13 @@ inline static void ApplyInvenApCostPatch() {
837837
}
838838

839839
void __fastcall Inventory::SetInvenApCost(int cost) {
840-
invenApCost = cost;
840+
invenApCost = (cost < 0) ? 0 : cost;
841841
if (!onlyOnceAP) ApplyInvenApCostPatch();
842842
}
843843

844844
long Inventory::GetInvenApCost() {
845845
long perkLevel = fo::func::perk_level(fo::var::obj_dude, fo::PERK_quick_pockets);
846-
return invenApCost - (invenApQPReduction * perkLevel);
846+
return max(0, invenApCost - (invenApQPReduction * perkLevel));
847847
}
848848

849849
void InventoryReset() {

0 commit comments

Comments
 (0)