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

48.0 NPE on designating a hex with TAG for incoming Homing Arrow IV #2920

Closed
gsparks3 opened this issue Jun 7, 2021 · 3 comments · Fixed by #2930
Closed

48.0 NPE on designating a hex with TAG for incoming Homing Arrow IV #2920

gsparks3 opened this issue Jun 7, 2021 · 3 comments · Fixed by #2930
Labels

Comments

@gsparks3
Copy link
Collaborator

gsparks3 commented Jun 7, 2021

Environment

Standalone Megamek 48.0
Windows 10
Java 11.0.10

Description

During a campaign game, we encountered a game-stall-inducing NPE on designating a hex with TAG with an incoming Homing Arrow IV round. Log files and a save that allows reproduction are provided.

Steps to reproduce:

  1. Start the saved game as player "sprero"
  2. Target a ground hex within 8 hexes of the nearby marker for the incoming Homing AIV round and hit "Done".
  3. Observe the game stall and NPE in the log.

Files

megameklog.txt
homingAIVtagCrash.sav.gz

@HammerGS
Copy link
Member

HammerGS commented Jun 7, 2021

megamek.common.HexTarget cannot be cast to class megamek.common.Entity (megamek.common.HexTarget and megamek.common.Entity are in unnamed module of loader 'app') at megamek.common.weapons.WeaponHandler.calcCounterAV(WeaponHandler.java:249) at megamek.common.weapons.ArtilleryWeaponIndirectHomingHandler.handleAMS(ArtilleryWeaponIndirectHomingHandler.java:472) at megamek.common.weapons.ArtilleryWeaponIndirectHomingHandler.handle(ArtilleryWeaponIndirectHomingHandler.java:207) 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) at java.base/java.lang.Thread.run(Thread.java:834)

@HammerGS HammerGS added the Bug label Jun 7, 2021
@sixlettervariables
Copy link
Contributor

It looks like we might could just exclude non-entities here:

protected int calcCounterAV() {
if (!checkPDConditions()) {
return 0;
}
int counterAV = 0;
int amsAV = 0;
double pdAV = 0;
Entity entityTarget = (Entity) target;

Not familiar enough with that code block to suggest it though.

@sixlettervariables
Copy link
Contributor

Proximate cause is the base checkPDConditions excludes non-entities, but ArtilleryWeaponIndirectHomingHandler overrides and does not:

/**
* Checks to see if the basic conditions needed for point defenses to work are in place
* Artillery weapons need to change this slightly
*/
protected boolean checkPDConditions() {
advancedPD = game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ADV_POINTDEF);
if ((target == null) || !advancedPD) {
return false;
}
return true;
}

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

Successfully merging a pull request may close this issue.

3 participants