Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.49.18 Space Battle Uncaught Exception with Warship Attacking Fighter Squadron #5204

Closed
BLR-IIC opened this issue Feb 25, 2024 · 6 comments · Fixed by #5251
Closed

0.49.18 Space Battle Uncaught Exception with Warship Attacking Fighter Squadron #5204

BLR-IIC opened this issue Feb 25, 2024 · 6 comments · Fixed by #5251
Assignees

Comments

@BLR-IIC
Copy link

BLR-IIC commented Feb 25, 2024

Bug occurred as described in title. When it happened, the game would not continue past the firing phase - I couldn't click on the skip firing or done firing buttons because they were grayed out. Every time I clicked on the squadron to target, the uncaught exception window would pop up again. Log and save file attached.

Naval-1.sav.gz
megameklog.zip

@HammerGS
Copy link
Member

Couple of things in the logs.

megamek.MegaMek.lambda$main$0(MegaMek.java:63) - Uncaught Exception Detected
java.lang.ClassCastException: class megamek.common.AeroSpaceFighter cannot be cast to class megamek.common.FighterSquadron (megamek.common.AeroSpaceFighter and megamek.common.FighterSquadron are in unnamed module of loader 'app')
	at megamek.server.GameManager.applyAeroCritical(GameManager.java:25113)
	at megamek.server.GameManager.applyCriticalHit(GameManager.java:24353)
	at megamek.server.GameManager.criticalAero(GameManager.java:26742)
	at megamek.server.GameManager.checkAeroCrits(GameManager.java:26692)
	at megamek.server.GameManager.damageEntity(GameManager.java:21995)
	at megamek.server.GameManager.damageEntity(GameManager.java:21547)
	at megamek.common.weapons.WeaponHandler.handleEntityDamage(WeaponHandler.java:1549)
	at megamek.common.weapons.WeaponHandler.handle(WeaponHandler.java:1126)
	at megamek.common.weapons.BayWeaponHandler.handle(BayWeaponHandler.java:126)
	at megamek.server.GameManager.handleAttacks(GameManager.java:34734)
	at megamek.server.GameManager.handleAttacks(GameManager.java:34670)
	at megamek.server.GameManager.endCurrentPhase(GameManager.java:2430)
	at megamek.server.GameManager.changeToNextTurn(GameManager.java:2745)
	at megamek.server.GameManager.endCurrentTurn(GameManager.java:1594)
	at megamek.server.GameManager.receiveAttack(GameManager.java:13206)
	at megamek.server.GameManager.handlePacket(GameManager.java:779)
	at megamek.server.Server.handle(Server.java:1277)
	at megamek.server.Server$PacketPump.run(Server.java:113)
	at java.base/java.lang.Thread.run(Thread.java:829)

and

21:24:57,696 ERROR [megamek.MegaMek] {AWT-EventQueue-0}
megamek.MegaMek.lambda$main$0(MegaMek.java:63) - Uncaught Exception Detected
java.lang.NullPointerException
	at megamek.client.ui.swing.FiringDisplay.hexMoused(FiringDisplay.java:2160)
	at megamek.client.ui.swing.boardview.BoardView.processBoardViewEvent(BoardView.java:966)
	at megamek.client.ui.swing.boardview.BoardView.mouseAction(BoardView.java:4908)
	at megamek.client.ui.swing.boardview.BoardView.mouseAction(BoardView.java:4931)
	at megamek.client.ui.swing.boardview.BoardView.mousePressed(BoardView.java:4622)
	at java.desktop/java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:287)

@Sleet01 Sleet01 self-assigned this Feb 27, 2024
@BLR-IIC
Copy link
Author

BLR-IIC commented Feb 28, 2024

I encountered the bug again today. I'm not sure what happened to cause this again - maybe the squadron was already damaged?
megamek.log
warship-vs-squadron.sav.gz

@Sleet01
Copy link
Collaborator

Sleet01 commented Feb 28, 2024

@BLR-IIC It looks like there's an issue with dealing critical damage to Squadrons, but my initial code inspection didn't reveal the root cause. I'll see if I can suss it out.

@EvilAtlas
Copy link

I may have encountered the same issue. The game refused to let warships fire at anything beyond short range for the whole game, and then when one of the squadrons (apparently) got mauled, I hit a nullpointerexception and got stuck partway through firing results.

Files are attached, in case they're useful.
broken_naval.zip

@HammerGS
Copy link
Member

Likely related to the Aerospace stuff in 49.18

12:18:51,022 ERROR [megamek.MegaMek] {Packet Pump}
megamek.MegaMek.lambda$main$0(MegaMek.java:63) - Uncaught Exception Detected
java.lang.ClassCastException: class megamek.common.AeroSpaceFighter cannot be cast to class megamek.common.FighterSquadron (megamek.common.AeroSpaceFighter and megamek.common.FighterSquadron are in unnamed module of loader 'app')
	at megamek.server.GameManager.applyAeroCritical(GameManager.java:25113)
	at megamek.server.GameManager.applyCriticalHit(GameManager.java:24353)
	at megamek.server.GameManager.criticalAero(GameManager.java:26742)
	at megamek.server.GameManager.checkAeroCrits(GameManager.java:26692)
	at megamek.server.GameManager.damageEntity(GameManager.java:21995)
	at megamek.server.GameManager.damageEntity(GameManager.java:21547)
	at megamek.common.weapons.WeaponHandler.handleEntityDamage(WeaponHandler.java:1549)
	at megamek.common.weapons.CapitalMissileBayHandler.handle(CapitalMissileBayHandler.java:248)
	at megamek.server.GameManager.handleAttacks(GameManager.java:34734)
	at megamek.server.GameManager.handleAttacks(GameManager.java:34670)
	at megamek.server.GameManager.endCurrentPhase(GameManager.java:2430)
	at megamek.server.GameManager.changeToNextTurn(GameManager.java:2745)
	at megamek.server.GameManager.endCurrentTurn(GameManager.java:1594)
	at megamek.server.GameManager.receiveAttack(GameManager.java:13206)
	at megamek.server.GameManager.handlePacket(GameManager.java:779)
	at megamek.server.Server.handle(Server.java:1277)
	at megamek.server.Server$PacketPump.run(Server.java:113)
	at java.base/java.lang.Thread.run(Thread.java:829)
12:19:24,915 ERROR [megamek.MegaMek] {AWT-EventQueue-0}
megamek.MegaMek.lambda$main$0(MegaMek.java:63) - Uncaught Exception Detected
java.lang.NullPointerException
	at megamek.client.ui.swing.FiringDisplay.hexMoused(FiringDisplay.java:2160)
	at megamek.client.ui.swing.boardview.BoardView.processBoardViewEvent(BoardView.java:966)
	at megamek.client.ui.swing.boardview.BoardView.mouseAction(BoardView.java:4908)
	at megamek.client.ui.swing.boardview.BoardView.mouseAction(BoardView.java:4931)
	at megamek.client.ui.swing.boardview.BoardView.mousePressed(BoardView.java:4622)
	at java.desktop/java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:287)

@Sleet01
Copy link
Collaborator

Sleet01 commented Mar 15, 2024

Issue appears to be in the way we were trying to look up the Squadron containing an individual fighter when applying criticals to the Squadron. We can follow the reference from a Fighter Squadron to its constituent fighters, but when trying to reverse that look-up we were getting a null value.

The fix is to:
A) enable that look-up to work properly by populating it correctly when fighters are added to the Squadron;
B) only apply Squadron-wide criticals to Capital Fighters that actually belong to a Squadron (this should be a hard requirement of even single Capital Fighters but I haven't looked deeply enough into the rest of that code to say for sure).

I was unable to reproduce the short-range-only issue; I believe that was fixed in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants