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
134 stars 171 forks source link

[0.50.01-SNAPSHOT] Mechanics & Aero Teks cause NPE on right-click - (previously: mechanical wunderkind disturbs resting code gods) #4948

Closed Tzahr closed 1 month ago

Tzahr commented 1 month ago

Prerequisites and Pre-Issue Checklist

Severity *

Medium (Gameplay Limitation): Non-core functionality is impaired, providing a suboptimal but playable experience.

Brief Description *

In attached save, a newborn called Klaas Olatunji was generated with Tech/Mechanic skills. Right clicking him in the personnel menu causes an NPE.

Error logs the following error:

04:45:19,286 ERROR [mekhq.MekHQ] {AWT-EventQueue-0} mekhq.MekHQ.lambda$main$1(MekHQ.java:290) - Uncaught java.lang.NullPointerException detected. Please open up an issue containing all logs, the game save file, and customs at https://github.com/MegaMek/megamek/issues . If Sentry is enabled, the error has also been logged. java.lang.NullPointerException: Cannot invoke "megamek.common.options.IOption.getType()" because the return value of "mekhq.campaign.personnel.PersonnelOptions.getOption(String)" is null at mekhq.gui.adapter.PersonnelTableMouseAdapter.createPopupMenu(PersonnelTableMouseAdapter.java:2197) at mekhq.gui.adapter.JPopupMenuAdapter.maybeShowPopup(JPopupMenuAdapter.java:74) at mekhq.gui.adapter.JPopupMenuAdapter.mouseReleased(JPopupMenuAdapter.java:69) at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6621) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398) at java.desktop/java.awt.Component.processEvent(Component.java:6386) at java.desktop/java.awt.Container.processEvent(Container.java:2266) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4996) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Steps to Reproduce

No response

Operating System *

Windows 11

Java Version *

21.0.3

MekHQ Suite Version *

Free Text (type manually)

Custom MekHQ Version

Nightly v0.50.1 - Rev. b5a4f6a63622f97b768c9dcb2124f544cc986ce8

Attach Files

mekhq.log 1st Rimward Hussars THE MECHANICAL CHILD.zip customs.zip

Final Checklist

Tzahr commented 1 month ago

Upon further investigation, it appears this NPE happens for every Mechanic and AeroSpace Tek, while MekTeks and BA Techs are unaffected. EDIT 2: On a hunch, I checked if if the Clan Tech Knowledge SPA was still enabled in my game and discovered it was. Manually removing it cleared up the the NPE. This will likely require a conversion handler.

Tzahr commented 1 month ago

This will auto-sanitize on saving and reloading, and is therefore an edge transition case that a simple save and reload will fix. No further action required - closing.