MegaMek / mekhq

MekHQ is a java helper program for the MegaMek game that allows users to load a list of entities from an XML file, perform repairs and customizations, and then save the new entities to another XML file that can be loaded into MegaMek.
http://megamek.org
132 stars 170 forks source link

49.10: UnitMarketOffer::writeToXML NPE #3456

Closed AfroSamurai34 closed 1 year ago

AfroSamurai34 commented 2 years ago

Environment

What version of MekHQ does your issue apply to? 49.10 What operating system are you using? Windows 10 What java version are you using? If unsure it will state your java version at the top of the mekhq.log file. java 11

Description

When attempting to save campaign file, recieve an error message stating cannot save. Screenshot (20)

Files

mekhq.log megamek.log Autosave-1-My Campaign-30610312.cpnx.gz

Windchild292 commented 2 years ago
0:04:44,089 ERROR [mekhq.gui.CampaignGUI] {AWT-EventQueue-0}
mekhq.gui.CampaignGUI.saveCampaign(CampaignGUI.java:1305) - 
java.lang.NullPointerException
    at mekhq.campaign.market.unitMarket.UnitMarketOffer.writeToXML(UnitMarketOffer.java:125)
    at mekhq.campaign.market.unitMarket.AbstractUnitMarket.writeBodyToXML(AbstractUnitMarket.java:243)
    at mekhq.campaign.market.unitMarket.AbstractUnitMarket.writeToXML(AbstractUnitMarket.java:231)
    at mekhq.campaign.Campaign.writeToXML(Campaign.java:4184)
    at mekhq.gui.CampaignGUI.saveCampaign(CampaignGUI.java:1296)
    at mekhq.gui.CampaignGUI.saveCampaign(CampaignGUI.java:1269)
Windchild292 commented 2 years ago

UnitMarketOffer::getUnit is returning null. That shouldn't be possible, which means it's a deeper issue than the cause above.

pheonixstorm commented 2 years ago

I had this happen in one of the 0.49.9 nightlies. I was hoping to see it a second time but it hasn't happened since. In my case the problem was with a conventional fighter. I could load the unit market and all check boxes worked except the conventional fight section, it caused an NPE when I tried to view it.

Until there is a fix you can advance to the new month if you are already half way into the month or have a save prior to the new month.

Windchild292 commented 2 years ago

Do you have a working save? The above autosave was corrupted on upload.

Windchild292 commented 2 years ago

*potentially on upload

AfroSamurai34 commented 2 years ago

My Campaign30610312.cpnx.gz This one might be a little better. Just tried it, deleted some salvage conventional fighters that were salvage remnants (which might not be related anyhow) and then went to unit market, and the UI crashed on me.

AfroSamurai34 commented 2 years ago

phoenixstorm's workaround worked for me...I advanced to the end of the month, whereupon the unit market reset, and I both could view conventional fighters in the unitmarket and check/uncheck the conventional fighter box in the gui, and it not only DIDNT throw a NPE at me, but I was able to save again. This had the additional benefit of some "ghost" ordanance clearing up in the repair bay, because once I was able to save again, I was able to reload....which cleared that problem out. I did notice some odd behavior shortly after that though, apparently some "subcontracted" mechs/mechwarriors I had hired on that had been destroyed reappeared as available for hire. And when you hire them, the mech is in the same shape it was (salvage/destroyed) as it was when they ran their last mission.

AfroSamurai34 commented 2 years ago

Last session I played, I noticed that I got an NPE when firing up MM (Thru MHQ). cancelled, reloaded in the lobby, and instead of configuring everything to run precision and caseless AC ammo as I usually do, I left everything on default ammo types. No NPE, no locking up. The conventional fighter that was in the unit market that was causing it to crash may or may not have had bombs attached to it....which was part of some of the error messages both in the unit market and the repair bay. Last thing I noticed, is that some (most?) of the CV, VTOLS, and other vehicles that have autocannons don't have the option to load alternative munitions....maybe this is what's causing the conflicts? Hope these observations help, love the game!

Windchild292 commented 1 year ago

I require the following files before this can be investigated further: image

Windchild292 commented 1 year ago

This is subsumed by #3542 and fixed by #3545