Skip to content

Commit e905674

Browse files
authored
Sbardef null fix (#1613)
don't allow elements to be set to null
1 parent 056258d commit e905674

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

Core/Resources/Definitions/StatusBar/StatusBarDefinition.cs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,33 @@ public class StatusBarFileDef
2121

2222
public class StatusBarDefinition
2323
{
24-
public const string HiddenLayoutName = "Hidden";
25-
24+
private List<StatusBarNumberFontDef> m_numberFonts = [];
25+
private List<StatusBarHudFontDef> m_hudFonts = [];
26+
private List<StatusBarLayoutDef> m_statusBars = [];
27+
28+
public const string HiddenLayoutName = "Hidden";
29+
2630
[JsonPropertyName("numberfonts")]
27-
public List<StatusBarNumberFontDef> NumberFonts { get; set; } = [];
31+
public List<StatusBarNumberFontDef> NumberFonts
32+
{
33+
get => m_numberFonts;
34+
set => m_numberFonts = value ?? [];
35+
}
2836

2937
// v1.1 Extension: HUD Fonts
3038
[JsonPropertyName("hudfonts")]
31-
public List<StatusBarHudFontDef> HudFonts { get; set; } = [];
39+
public List<StatusBarHudFontDef> HudFonts
40+
{
41+
get => m_hudFonts;
42+
set => m_hudFonts = value ?? [];
43+
}
3244

3345
[JsonPropertyName("statusbars")]
34-
public List<StatusBarLayoutDef> StatusBars { get; set; } = [];
46+
public List<StatusBarLayoutDef> StatusBars
47+
{
48+
get => m_statusBars;
49+
set => m_statusBars = value ?? [];
50+
}
3551

3652
public void Parse(string data)
3753
{
@@ -138,6 +154,8 @@ public class StatusBarHudFontDef
138154

139155
public class StatusBarLayoutDef
140156
{
157+
private StatusBarElementWrapper[] m_children = [];
158+
141159
[JsonPropertyName("name")]
142160
public string Name { get; set; } = string.Empty;
143161

@@ -151,7 +169,11 @@ public class StatusBarLayoutDef
151169
public string? FillFlat { get; set; }
152170

153171
[JsonPropertyName("children")]
154-
public StatusBarElementWrapper[] Children { get; set; } = [];
172+
public StatusBarElementWrapper[] Children
173+
{
174+
get => m_children;
175+
set => m_children = value ?? [];
176+
}
155177

156178
[JsonIgnore]
157179
public bool CoverageSet { get; set; }

RELEASENOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- Fix spawn blood to use hard-coded vanilla frames when dehacked is present.
3434
- Fix tracer lines drawing over sprites with software emulation.
3535
- Fix to match boom behavior to parsing dehacked integers with failures defaulting to zero.
36+
- Fix SBARDEF crash when children element was explicity set to null.
3637

3738
## Misc:
3839
- Refactor of old Status Bar renderer to data-driven SBARDEF format.

0 commit comments

Comments
 (0)