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
297 stars 286 forks source link

Soft lock on end of fire phase #582

Closed Axe64 closed 7 years ago

Axe64 commented 7 years ago

I cant hit done at the end of my fire phase it broke my multiplayer game.

https://megamek.org/bb/attachment.php?aid=1601 33333 (1).sav.gz

HammerGS commented 7 years ago

NPE -

FiringDisplay: tried to select non-existant entity: -1
boardview1: loading images for board
Loading wreckMarker image for BattleMaster BLR-4S on the fly.
Loading wreckMarker image for Dragon DRG-7N on the fly.
error: server got invalid attack packet from connection 3, Entity was null!
FiringDisplay: tried to select non-existant entity: -1
error: server got invalid attack packet from connection 3, Entity was null!
FiringDisplay: tried to select non-existant entity: -1
error: server got invalid attack packet from connection 3, Entity was null!
FiringDisplay: tried to select non-existant entity: -1
error: server got invalid attack packet from connection 3, Entity was null!
FiringDisplay: tried to select non-existant entity: -1
error: server got invalid attack packet from connection 3, Entity was null!
FiringDisplay: tried to select non-existant entity: -1
Ejecting crew size: 1
java.lang.NullPointerException
    at megamek.server.Server.deliverMissileSmoke(Server.java:9698)
    at megamek.common.weapons.LRMSmokeWarheadHandler.specialResolution(LRMSmokeWarheadHandler.java:101)
    at megamek.common.weapons.MissileWeaponHandler.handle(MissileWeaponHandler.java:710)
    at megamek.server.Server.handleAttacks(Server.java:34208)
    at megamek.server.Server.handleAttacks(Server.java:34137)
    at megamek.server.Server.endCurrentPhase(Server.java:2947)
    at megamek.server.Server.changeToNextTurn(Server.java:3269)
    at megamek.server.Server.endCurrentTurn(Server.java:2314)
    at megamek.server.Server.skipCurrentTurn(Server.java:3353)
    at megamek.server.commands.SkipCommand.run(SkipCommand.java:53)
    at megamek.server.Server.processCommand(Server.java:29899)
    at megamek.server.Server.handle(Server.java:29977)
    at megamek.server.Server$1.packetReceived(Server.java:499)
    at megamek.common.net.AbstractConnection.processConnectionEvent(AbstractConnection.java:604)
    at megamek.common.net.AbstractConnection.processPacket(AbstractConnection.java:509)
    at megamek.common.net.AbstractConnection.update(AbstractConnection.java:454)
    at megamek.server.ConnectionHandler.run(ConnectionHandler.java:49)
    at java.lang.Thread.run(Unknown Source)
s: error reading command: null
    Last 50 commands that were sent (oldest first): 250 470 480 510 80 80 80 80 80 80 80 80 300 250 300 250 300 250 300 250 300 250 80 140 90 140 140 140 140 140 140 140 190 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 185 190 

    Last 50 commands that were received (oldest first): 20 25 130 130 130 130 130 80 
pheonixstorm commented 7 years ago

Try not to forget the log file when you create a bug report. The devs get cranky when those are left out ;)

Axe64 commented 7 years ago

heres another save where it did the same thing but on development version i have more logs. the save is of the turn leading up yo the bug but doesnt seem to happen if we dont shoot eachother.

logs (2).zip bugged.sav.gz

HammerGS commented 7 years ago

Seems to be related to Smoke LRMs. Is someone using them.

Axe64 commented 7 years ago

45K.sav.gz this is the saves of when it bugged out it seems to not bug out if we dont shoot each other but once we did it would lock up. no smoke rounds were used either but there was a accidental fire.

heres more of the bug that happened right away in another game bug.zip

arlith commented 7 years ago

The later saves have a different issue:

java.lang.ArrayIndexOutOfBoundsException: 1 at megamek.common.Crew.isActive(Crew.java:574) at megamek.common.Crew.hasActiveCommandConsole(Crew.java:1304) at megamek.common.actions.WeaponAttackAction.toHit(WeaponAttackAction.java:685) at megamek.common.actions.WeaponAttackAction.toHit(WeaponAttackAction.java:280) at megamek.common.actions.WeaponAttackAction.toHit(WeaponAttackAction.java:252) at megamek.common.weapons.Weapon.fire(Weapon.java:46) at megamek.server.Server.resolveOnlyWeaponAttacks(Server.java:14281) at megamek.server.Server.endCurrentPhase(Server.java:2954) at megamek.server.Server.changeToNextTurn(Server.java:3278) at megamek.server.Server.endCurrentTurn(Server.java:2319) at megamek.server.Server.skipCurrentTurn(Server.java:3362) at megamek.server.commands.SkipCommand.run(SkipCommand.java:53) at megamek.server.Server.processCommand(Server.java:30752) at megamek.server.Server.handle(Server.java:30830) at megamek.server.Server$1.packetReceived(Server.java:502) at megamek.common.net.AbstractConnection.processConnectionEvent(AbstractConnection.java:604) at megamek.common.net.AbstractConnection.processPacket(AbstractConnection.java:509) at megamek.common.net.AbstractConnection.update(AbstractConnection.java:454) at megamek.server.ConnectionHandler.run(ConnectionHandler.java:49) at java.lang.Thread.run(Thread.java:748)

arlith commented 7 years ago

Alright, things got a little smoky in here, but I got this figured out.

It looks like LRM/SRM smoke munitions were using old rules, where each 5 point cluster for LRMs or each missile for SRMs would create heavy smoke in one hex. The way the code worked is it would smoke the center, and then it would start looking at adjacent hexes. It would skip hexes that already had heavy smoke in them. The problem is, if it ran out of potential hexes, it would return null, which causes an NPE. Looks like you were throwing a helluva lot of smoke in a small area, so eventually it ran out of valid hexes.

Now, turns out current TO errata drastically dials back smoke. Now, smoke munitions only ever smoke one hex, and if the damage from the launcher is < 5, it's light smoke, otherwise it's heavy smoke. This eliminates some logic for finding adjacent hexes and fixes the possible NPE.