BattletechModders / ModTek

Mod system for HBS's PC game BattleTech.
GNU Lesser General Public License v2.1
121 stars 34 forks source link

JumpJetDef Handling Error Causes NullReferenceExceptions #203

Closed korgano closed 2 years ago

korgano commented 2 years ago

ModTek version 2.0.6

ModTek will find JumpJetDef JSON files in folder declared in mod.json, and add said JSONs to Manifest.CSV, but not to the game's list of items. This then causes crashes whenever said JSONs are called on, such as during the Bonus Rewards process or when starting combat with a unit equipped with said jumpjets added via console.

I have video of the bug happening in real-time in DNSpy: BattleTech 1.9.1 w/ ModTek 2.0.6 JumpJet error

I also have screencaps of the ModTek log and Manifest, which show that ModTek at least partially completed the task of adding the jumpjets to the game: ModTek log showing multiple custom jumpjets added to the game Modded Manifest.CSV showing custom jumpjets with proper filepaths

Process to reproduce: -Create a folder for jumpjet templates and at least one jumpjet template -Associate folder with JumpJetDefs in mod.json file -Create itemCollection file/reward event that gives player custom jumpjet -Load into save right before Reward UI appears -Use DNSpy to find ShopDefItem.ToSalvageDef -Setup breakpoints throughout ShopItemType.JumpJet -Custom jumpjet will pass 'jumpJetDef = null' -At 'if (jumpJetDef != null)', process will skip back to beginning upon null JumpJetDef reading -NullReferenceException error occurs after game runs through reward process

wmtorode commented 2 years ago

Created a custom jumpjetdef and was able to load it into the game without issue.

Custom jumpjet showed up in skirmish mechbay and on a custom mechdefs created to test it and was able to be deployed without issue.

Was further able to load into the skirmish mechbay with an example jumpjet def provided by the reporter without issue.

Finally the above data shows modtek to be acting correctly as it does indeed find the jump jet and add it to the manifest with the correct file path, that the datamanager fails to load the def is not a modtek issue.

wmtorode commented 2 years ago

JwTest.zip Test mod used to prove out correct loading of custom jumpjetdefs