fix: resolve NullReferenceException in postLoad() - fixes #56#59
Open
formeo wants to merge 1 commit intoMarvinBeym:masterfrom
Open
fix: resolve NullReferenceException in postLoad() - fixes #56#59formeo wants to merge 1 commit intoMarvinBeym:masterfrom
formeo wants to merge 1 commit intoMarvinBeym:masterfrom
Conversation
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.
Bugfix Summary for Issue #56
Problem Description
The MscModApi module was crashing with a NullReferenceException in
postLoad()method, causing the mod to be disabled completely.Error Message:
Root Cause Analysis
The main issue was in
ReplacedGamePartsDelayedInitializer.cswhere several objects were accessed without null checks:FsmVariables.GlobalVariables.FindFsmBool("PlayerStop")- The PlayMaker FSM variables might not be initialized when PostLoad() is calledReplacedGameParts.modsParts- Could be null ifLoadCleanup()wasn't called or failedreplacedGamePartsDelayedInitializer- Could be null ifPreLoad()wasn't executedFiles Modified
1.
Source code/MscModApi/Parts/ReplacePart/ReplacedGamePartsDelayedInitializer.csChanges:
ReplacedGameParts.modsPartsininitializingRequiredpropertyFsmVariables.GlobalVariablesbefore callingFindFsmBool()playerStopbefore accessing.ValueMscModApi.disableLoadingMovementLocksettingmodsPartscollectionsInvokeAll()2.
Source code/MscModApi/MscModApi.csChanges:
replacedGamePartsDelayedInitializerinPostLoad()3.
Source code/MscModApi/Parts/ReplacePart/ReplacedGameParts.csChanges:
modsPartsinSave()methodmodParts.Value,mod,replacedGameParts, andoriginalPart4.
Source code/MscModApi/Caching/Cache.csChanges:
cachedGameObjectsif nullTryGetValueinstead of direct indexerTesting Recommendations
Breaking Changes
None. All changes are backward compatible and add defensive programming without changing the API.
Additional Improvements Made
[MscModApi]prefix for easier debugging'{replacedGameParts.id}→'{replacedGameParts.id}')