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

java.lang.IllegalArgumentException: Attacker or target not valid at megamek.common.actions.ThrashAttackAction.toHit #4949

Closed
Sebmono opened this issue Dec 11, 2023 · 3 comments · Fixed by #4960
Labels

Comments

@Sebmono
Copy link

Sebmono commented Dec 11, 2023

Environment

0.49.15
Windows 10
Java Vendor: Eclipse Adoptium
Java Version: 11.0.13

Description

image
I get the above error after clicking the 'Done' button at the end of the Round 15 Firing Phase.

Exact reproduction steps with the below campaign and MegaMek save file:

  1. Load the below campaign save file.
  2. Click Load Saved Game from the Briefing Room for the TankBase - Hostile - Prevent Evac scenario.
  3. Select OK, load the BA_01.sav file below.
  4. Game > Edit Bots > Replace all with Princess > OK
  5. Have Booster fire autorifle at pilot north of her.
  6. Have Voltage fire autorifle at crew north of him.
  7. Have Jester fire all weapons at Cataphract closest to him.
  8. Have Calamity fire all weapons at Cataphract closest to her (same one as Jester).
  9. Select Done.
  10. After Fire Phase resolution log is produced, click done.
  11. Error.

Files

Provide the .cpnx campaign file that this issue occurs in.
Poznan Heavy Lancers02.cpnx.gz

Also here is the MegaMek in-mission save file it occurs in.
BA_01.sav.gz

Provide any custom units that you are using in this campaign so that it will load on the developers machine.
Black Knight BL-7-KNT Hussar.zip

Provide any other files that you have customized in this campaign like the factions.xml for example.
I'm using the customized "Heavy" scenarios from Discord here: https://discord.com/channels/458705327911731231/1125131384835555491/1125151393515327498
scenariotemplates.zip

And provide the megamek.log and mekhq.log files for any NPEs or errors that MekHQ might be reporting.
mekhq.log
megamek.log

@HammerGS
Copy link
Member

From the MekHQ log


java.lang.IllegalArgumentException: Attacker or target not valid
	at megamek.common.actions.ThrashAttackAction.toHit(ThrashAttackAction.java:51)
	at megamek.common.Compute.canPhysicalTarget(Compute.java:5879)
	at megamek.common.Entity.isEligibleForPhysical(Entity.java:9933)
	at megamek.common.Entity.isEligibleFor(Entity.java:9719)
	at megamek.common.Infantry.isEligibleFor(Infantry.java:1068)
	at megamek.server.GameManager.setIneligible(GameManager.java:3609)
	at megamek.server.GameManager.prepareForPhase(GameManager.java:1989)
	at megamek.server.GameManager.changePhase(GameManager.java:1586)
	at megamek.server.GameManager.endCurrentPhase(GameManager.java:2426)
	at megamek.server.GameManager.checkReady(GameManager.java:1376)
	at megamek.server.GameManager.handlePacket(GameManager.java:722)
	at megamek.server.Server.handle(Server.java:1265)
	at megamek.server.Server$PacketPump.run(Server.java:111)
	at java.base/java.lang.Thread.run(Thread.java:829)

@HammerGS HammerGS pinned this issue Dec 11, 2023
@HammerGS HammerGS transferred this issue from MegaMek/mekhq Dec 11, 2023
@HammerGS HammerGS added the Bug label Dec 11, 2023
@HammerGS HammerGS changed the title Uncaught java.lang.IllegalArgumentException detected java.lang.IllegalArgumentException: Attacker or target not valid at megamek.common.actions.ThrashAttackAction.toHit Dec 11, 2023
@HoneySkull
Copy link
Collaborator

Thought about that too, but there should be no condition where there input parameter are null - so this check indicates some kind of a problem that would be masked if it treated it as impossible. If it's changed to return impossible instead of throwing an illegal argument error, then I would still recommend posting an error to the error log.

@HoneySkull
Copy link
Collaborator

HoneySkull commented Dec 16, 2023

ThrashAttack - is different than all the other attack actions when checking for physical attacks, the class gets newed up instead of the toHit function being static like all the others. ThrashAttack looks up the target and entity from the 'game' interface and not the entity and target passed into the constructor. I'm suspect the game object is out of sync with the target and entity the object it is constructed with. All the other 'toHit' methods on the Attack Actions are static and pass in and use the Entity ID and target.

HammerGS added a commit that referenced this issue Dec 21, 2023
+ PR #4957: More tooltips colors (set FG color and BG color for more
tooltips, add highlight, weapon, quirk client settings, consolidate some
colors into existing client setting colors)

+ PR #4922: Add deployment options (There is a lot in this one see note
from PR link for specifics)
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