Skip to content

fix: null-guard enum choices in GameRulesetSchemaEntry (list-game-ruleset-schemas crash) - #194

Closed
sandsand244263 wants to merge 4 commits into
overtools:masterfrom
sandsand244263:fix/ruleset-schema-null
Closed

sandsand244263 wants to merge 4 commits into
overtools:masterfrom
sandsand244263:fix/ruleset-schema-null

Conversation

@sandsand244263

Copy link
Copy Markdown

Fixes #193.

Problem

list-game-ruleset-schemas aborts with a NullReferenceException on the current live build (CN 2.25.0.0.154461N, DataTool v2.25.0.0+1151), so the custom-game setting schema cannot be dumped at all. list-game-rulesets fails in the same model code.

GameRulesetSchemaEntry.cs:38 dereferences two reference-typed values without checking them:

DefaultValue = val2.m_default.ToString(),
Choices = val2.m_3FE1EA9E.Select(...).ToArray()
  • val2.m_3FE1EA9E (the enum choice array) is null for at least one entry on this build → .Select() throws
  • val2.m_default is a teStructuredDataAssetRef<STUIdentifier> reference type and can also be null → would throw one line earlier

Because the exception escapes from the Select in GameRulesetSchema.Init, the whole dump dies on the first malformed entry.

Change

Null-conditional access with a safe fallback:

DefaultValue = val2.m_default?.ToString(),
Choices = val2.m_3FE1EA9E?.Select(x => new RulesetSchemaValueEnumChoice {
    DisplayText = GetString(x.m_displayText),
    Identifier = x.m_identifier
}).ToArray() ?? Array.Empty<RulesetSchemaValueEnumChoice>()

Plus using System; for Array.Empty.

No behaviour change for well-formed entries — the same data is produced when the fields are present.

Verification

On the same client that previously crashed:

DataTool.exe "E:/Overwatch" list-game-ruleset-schemas --language=zhCN --rcn --json --out=ruleset_schemas.json
[Core] Execution finished in 00:00:00.51

→ ruleset_schemas.json, 125 schemas written, no exception.

(Array.Empty<T>() requires System; added that using to the file.)

ZingBallyhoo and others added 4 commits October 11, 2026 15:21
lets pretend that this is a scalable design for flags in the first place. CN/KR players are gonna want global content :')
m_3FE1EA9E can be null on current builds, and m_default is a reference
type; either throws NullReferenceException and aborts the whole
list-game-ruleset-schemas dump. Falls back to an empty choice array.
@sandsand244263

Copy link
Copy Markdown
Author

Understood — thanks for taking a look. I will keep it local on my side. Closing this to keep the tracker clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants