From 69ac8c9f44c91fd1b7477779bfc79a1dbac713a1 Mon Sep 17 00:00:00 2001 From: DJScias Date: Wed, 16 Oct 2024 19:31:16 +0200 Subject: [PATCH] Add extra nilguard check in TriggerBufferedUpdate References #17 --- CHANGELOG.md | 3 ++- core.lua | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6df58c..d8ca4f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ 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. @@ -15,6 +15,7 @@ Nil-guard potential bar data, ref #17 ### 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 diff --git a/core.lua b/core.lua index 5014a6d..99b7df2 100644 --- a/core.lua +++ b/core.lua @@ -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;