Skip to content

Commit

Permalink
Adjust bounds calculation in getUnoccupiedAdjacentCoords
Browse files Browse the repository at this point in the history
Reduced track width and height by one to account for zero-based indexing in coordinate calculations. This change ensures accurate boundary checks and prevents potential out-of-bounds errors.
  • Loading branch information
IllianiCBT committed Jan 15, 2025
1 parent f4b7479 commit 3b3df3d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1061,8 +1061,9 @@ public static void deployForceToCoords(StratconCoords coords, int forceID, Campa
*/
private static @Nullable StratconCoords getUnoccupiedAdjacentCoords(StratconCoords originCoords,
StratconTrackState trackState) {
final int trackWidth = trackState.getWidth();
final int trackHeight = trackState.getHeight();
// We need to reduce width/height by one because coordinates index from 0, not 1
final int trackWidth = trackState.getWidth() - 1;
final int trackHeight = trackState.getHeight() - 1;

List<StratconCoords> suitableCoords = new ArrayList<>();
for (int direction : ALL_DIRECTIONS) {
Expand Down

0 comments on commit 3b3df3d

Please sign in to comment.