Fix startup NullReferenceException on WorldBox 0.51.2 (resilient power-tab lookup)#72
Open
Skilvin wants to merge 1 commit into
Open
Conversation
GetTab() now falls back to finding the PowersTab by object name when the hard-coded UI hierarchy path no longer matches (0.51.1+), and the WrappedPowersTab constructor guards against a null tab to avoid an NRE during vanilla-tab reconstruction. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On WorldBox 0.51.2 (build 719@5dec), starting the game with mods enabled crashes during NML's vanilla-tab reconstruction:
Root cause
PowerButtonCreator.GetTab(pId)locates the tab through a hard-coded UI hierarchy path:In 0.51.2 this hierarchy changed, so
transform.Find(...)returnsnull,GetTabreturnsnull, andnew WrappedPowersTab(null)throws an NRE onTab.name.Changes
general/PowerButtonCreator.cs—GetTab: keep the fast hard-coded path, but fall back to locating the tab by its GameObject name viaResources.FindObjectsOfTypeAll<PowersTab>()when the path no longer matches. This makes the lookup resilient to UI-hierarchy changes.general/ui/tab/WrappedPowersTab.cs— constructor: add a null guard so the wrapper never NREs even if a tab is still not found (setsModifiable = falseand returns early).Testing
Built in Debug and tested in-game on WorldBox 0.51.2 (experimental):
WrappedPowersTab..ctorNRE at boot,