-
Notifications
You must be signed in to change notification settings - Fork 340
Open
Labels
(RFE) EnhancementRequests for Enhancement, new features or implementationsRequests for Enhancement, new features or implementationsGood First IssueA good issue to tackle for new MegaMek developersA good issue to tackle for new MegaMek developersImprovement to Existing FeatureUsed with the RFE tag to indicate an improvement to an existing featureUsed with the RFE tag to indicate an improvement to an existing featureMap and BoardSpecific Issues related to a Map, Board or TilesetSpecific Issues related to a Map, Board or Tileset
Description
Enhancement Type *
New Feature
Brief Description of Enhancement *
Problem:
We keep finding NPEs when various checks require a Hex instance but can happen to units that are off-board.
Board.getHex() returns a null value if the position it receives is not on the game board, but the code is full of chained calls that expect a Hex instance so they can query it for terrain or level information.
Proposed solution:
- Create an "off-board Hex" subclass (or flag field in Hex) so that Board can return a valid Hex instance when a position is off-board, which will return various default values for terrain queries. This is similar to the way Targetable works for hexes.
- Find all instances where we check for
hex == nulland remove them, or replace them with a check forisOffboard(). - [Optional] also create
isOnboard()to avoid lots of!hex.isOffboard()calls.
We should be able to replace a number of null checks, cleaning up the code, while also laying a foundation for future off-board functionality.
Use Cases or Rationale
- Handling some off-board artillery attacks (counter-battery fire)
- Handling SPAs that refer to specific Terrain types but which may be present in off-board units.
- [Future] possibly allowing integration of low-altitude and ground maps for e.g. AA ground units and bombing on the Low-Altitude map.
Attach Files
No response
MegaMek Suite Version *
0.50.03
Final Verification
- I confirm this request hasn't already been submitted (checked the tracker)
- I've discussed or asked about this enhancement on MegaMek Discord
- I’m opening this on the correct repo (MegaMek, MegaMekLab, or MekHQ)
Metadata
Metadata
Assignees
Labels
(RFE) EnhancementRequests for Enhancement, new features or implementationsRequests for Enhancement, new features or implementationsGood First IssueA good issue to tackle for new MegaMek developersA good issue to tackle for new MegaMek developersImprovement to Existing FeatureUsed with the RFE tag to indicate an improvement to an existing featureUsed with the RFE tag to indicate an improvement to an existing featureMap and BoardSpecific Issues related to a Map, Board or TilesetSpecific Issues related to a Map, Board or Tileset