MegaMek / megamek

MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight using giant robots, tanks, and/or infantry on a hex-based map.
http://www.megamek.org
GNU General Public License v2.0
296 stars 286 forks source link

48.0 NPE during post-movement indirect attack phase #3156

Closed gsparks3 closed 2 years ago

gsparks3 commented 3 years ago

Environment

Megamek 48.0 OpenJDK 11.0.10 Standalone Megamek

Description

During a large multiplayer game, we encountered a NPE when attempting to move from the post-movement indirect attack phase to the firing phase. The cause is not 100% certain, but while the issue consistently reproduces when loading from an autosave at the beginning of said phase, we were able to avoid it by reloading from an earlier autosave (the beginning of the movement phase) and NOT having a vehicle crew abandon a vehicle that had made an indirect artillery attack that turn prior to the movement phase, so that may be related.

Reproduction steps:

  1. Open the provided savegame. For ease of use, join as "The Bloody Revelation (WoB 18th Div)"
  2. Hit Done on all TAG-equipped units. Use /skip to skip any remaining units. (Alternately, link a second client as "Soup" and similarly hit Done).
  3. Observe the NPE in the logs.
java.lang.NullPointerException
    at megamek.common.weapons.ArtilleryWeaponIndirectFireHandler.handle(ArtilleryWeaponIndirectFireHandler.java:162)
    at megamek.server.Server.handleAttacks(Server.java:35528)
    at megamek.server.Server.handleAttacks(Server.java:35457)
    at megamek.server.Server.endCurrentPhase(Server.java:2947)
    at megamek.server.Server.changeToNextTurn(Server.java:3202)
    at megamek.server.Server.endCurrentTurn(Server.java:2212)
    at megamek.server.Server.skipCurrentTurn(Server.java:3280)
    at megamek.server.commands.SkipCommand.run(SkipCommand.java:53)
    at megamek.server.Server.processCommand(Server.java:31255)
    at megamek.server.Server.handle(Server.java:31335)
    at megamek.server.Server$1.packetReceived(Server.java:397)
    at megamek.common.net.AbstractConnection.processConnectionEvent(AbstractConnection.java:603)
    at megamek.common.net.AbstractConnection.processPacket(AbstractConnection.java:508)
    at megamek.common.net.AbstractConnection.update(AbstractConnection.java:453)
    at megamek.server.ConnectionHandler.run(ConnectionHandler.java:49)
    at java.base/java.lang.Thread.run(Thread.java:834)

Above is when using the /skip command to finish the turn. A different NPE is encountered when connecting an extra Megamek client and using Done to finish the last unit's turn.

Exception in thread "Packet Pump" java.lang.NullPointerException
    at megamek.common.weapons.ArtilleryWeaponIndirectFireHandler.handle(ArtilleryWeaponIndirectFireHandler.java:162)
    at megamek.server.Server.handleAttacks(Server.java:35528)
    at megamek.server.Server.handleAttacks(Server.java:35457)
    at megamek.server.Server.endCurrentPhase(Server.java:2947)
    at megamek.server.Server.changeToNextTurn(Server.java:3202)
    at megamek.server.Server.endCurrentTurn(Server.java:2212)
    at megamek.server.Server.receiveAttack(Server.java:13429)
    at megamek.server.Server.handle(Server.java:31381)
    at megamek.server.Server$PacketPump.run(Server.java:254)

Files

The savegame and megameklog files of both types mentioned above are attached. autosave_2021-09-19_01-07-12.sav.gz megameklogDone.txt megameklogSkip.txt

NickAragua commented 3 years ago

Did someone have a Sparrowhawk? And if so, was it mounting an arrow IV on an external pod?

Edit: ok, who mounted a Sniper artillery piece on a 30 ton fighter?

gsparks3 commented 3 years ago

A Sparrowhawk was present earlier in the battle, but it definitely should not be equipped with an artillery piece, or any external ordnance at all. The Sniper was mounted on a Marksman Artillery Vehicle (Light PPC).

Although when I load the save, I see the icon of the destroyed vehicle is displaying as a Sparrowhawk, despite being labeled as a Marksman ... units using incorrect icons, usually icons of other units present in the battle, has been an intermittent issue in our multiplayer games with an unknown cause that we have not yet been able to determine. Often, when encountered, cycling "Show damage on the unit icon" off and on in Client Settings seems to fix it, at least for units that are still active, but that does not seem to be the case here for the incorrect destroyed-unit icon.

Attached is the game log for confirmation that Sniper fire was from said Marksman, only (CTRL+F "sniper" to confirm). gamelog_2021-09-19_02-54-33.zip

Edit: Managed to find the mentioned autosave from the beginning of the movement phase, where the Marksman tank had not yet been abandoned but had already fired its Sniper during the indirect fire phase. Attached for additional testing. autosave_2021-09-19_00-38-24.sav.gz

NickAragua commented 3 years ago

Nice, somehow abandoning the Marksman causes the artillery attack to be treated as if it came from the Sparrowhawk instead.

gsparks3 commented 3 years ago

Bizarre. For bonus points, the Sparrowhawk was long dead at that time ...