Skip to content

Commit

Permalink
Add extra nilguard check in TriggerBufferedUpdate
Browse files Browse the repository at this point in the history
References #17
  • Loading branch information
DJScias committed Oct 16, 2024
1 parent 25d882f commit 69ac8c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Nil-guard potential bar data, ref #17

## [6.3.1] - Unreleased
## [6.3.1] - 2024-10-16

### Changed
- Optimize ExperiencerModuleBarsMixin:TriggerBufferedUpdate.

### Fixed
- Safeguard reputation GetBarData being nil (fixes [#17](https://github.com/DJScias/Experiencer2/issues/17)).
- Safeguard ExperiencerModuleBarsMixin:Refresh against potential nil data values.
- Safeguard ExperiencerModuleBarsMixin:TriggerBufferedUpdate against potential nil data values.

## [6.3.0] - 2024-09-22

Expand Down
14 changes: 13 additions & 1 deletion core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,19 @@ function ExperiencerModuleBarsMixin:TriggerBufferedUpdate(instant)
return;
end

local data = self.module:GetBarData();
local data;
local barData = self.module:GetBarData() or {}; -- Ensure barData is a table even if GetBarData() is nil.

data = {
id = barData.id, -- No default for id as nil might be valid.
level = barData.level or 0, -- Default to 0 if level is nil.
min = barData.min or 0, -- Default to 0 if min is nil.
max = barData.max or 1, -- Default to 1 if max is nil.
current = barData.current or 0, -- Default to 0 if current is nil.
rested = barData.rested, -- No default for rested as nil might be valid.
visual = barData.visual -- No default for visual as nil might be valid.
};

local valueHasChanged = true;
local isLoss = false;

Expand Down

0 comments on commit 69ac8c9

Please sign in to comment.