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

Fix 5483: Make various calls safer from NPE and ensure searchlight target on board #5485

Conversation

Sleet01
Copy link
Collaborator

@Sleet01 Sleet01 commented May 18, 2024

Fixes an issue where the firing phase would throw an NPE if:

  1. Planetary Conditions are lower light level than daylight,
  2. Searchlights are on,
  3. A unit that has yet to deploy, or has fled the board this turn, is at the top of the entities list

Root cause is twofold:
A) automatically selecting an off-board unit while checking to see if the selected friendly unit could use its Searchlight;
B) trying to get the hex location of units that don't have coords, in order to calculate if they are in the selected unit's arc.

This fix adds safety checks around these calls / tests to avoid this in the future, but per our Discord conversation, we
should definitely consider a non-null Coord value to represent "not on any board", especially if we will be adding more
simultaneous maps in the future.

Testing:

  • Tested fix in 0.49.19.1 MM to verify handling
  • Tested fix applied to 0.49.20 code via MHQ
  • Ran all three projects' unit tests

Close #5483

@HammerGS HammerGS merged commit 31a6aa3 into MegaMek:master May 18, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPE when clicking on a mech
3 participants