Page MenuHomeFeedback Tracker

Divide by zero error on vests
Confirmed Internally, NormalPublic

Description

When deconstructing the Alice vest so it has no capacity for storage the inventory UI code encounters a situation that is not yet handled in code.
s. steps to reproduce

Class:      'SCR_InventoryStorageLBSUI'
Function: 'GetOccupiedVolumePercentage'
Stack trace:
Scripts/Game/UI/Inventory/SCR_InventoryStorageBaseUI.c:1098 Function GetOccupiedVolumePercentage
Scripts/Game/UI/Inventory/SCR_InventoryMenuUI.c:2617 Function ResetHighlightsOnAvailableStorages
Scripts/Game/UI/Inventory/SCR_InventoryMenuUI.c:2336 Function Action_StepBack
Scripts/Game/UI/Inventory/SCR_InventoryMenuUI.c:674 Function OnAction
Scripts/Game/UI/Components/SCR_InventoryNavigationButtonBack.c:40 Function OnInput

To fix this I think all that needs to be done is add a divide by zero check on the function SCR_InventoryStorageBaseUI::GetOccupiedVolumePercentage :

//------------------------------------------------------------------------------------------------
float GetOccupiedVolumePercentage(BaseInventoryStorageComponent storage, float occupiedSpace = 0)
{
    if (!storage)
        return -1;

    float occupiedVolumePercantage;
    float capacity = GetMaxVolumeCapacity(storage);
    if (capacity <= 0) return -1; // <<<<<< Check here. Not sure if return -1 or return 0 would be the goal here
    
    if (occupiedSpace != 0)
        occupiedVolumePercantage = Math.Round(occupiedSpace / (capacity / 100));
    else
        occupiedVolumePercantage = Math.Round(GetOccupiedVolume(storage) / (capacity / 100));
    
    return occupiedVolumePercantage;
}

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce
  1. Spawn {2835A0EA3B79E63E}Prefabs/Characters/Vests/Vest_ALICE/Variants/Vest_ALICE_rifleman.et
  2. Remove all attachment besides the belt and knife
  3. Open the inventory
  4. See exception

Event Timeline

Arkensor created this task.Sep 6 2022, 10:32 AM
Geez changed the task status from New to Awaiting internal Testing.Sep 9 2022, 9:35 AM
Geez changed the task status from Awaiting internal Testing to Confirmed Internally.Oct 6 2022, 2:10 PM