Skip to content

Commit

Permalink
Merge pull request #18 from Vittorioux/main
Browse files Browse the repository at this point in the history
Fix for enemy groups out of bound.
  • Loading branch information
brentjs0 authored Aug 11, 2024
2 parents 26e7793 + 3c086c4 commit 81b8a04
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/ebhack/MapData.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public NPC getNPC(int n) {
}

public EnemyGroup getEnemyGroup(int n) {
return enemyGroups.get(n);
return n < enemyGroups.size() ? enemyGroups.get(n) : null;
}

public MapEnemyGroup getMapEnemyGroup(int n) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ebhack/MapDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ public void drawEnemyPlate(Graphics2D g, Rectangle2D rect, int mapEnemyGroupId)
*/
public int drawEnemyGroup(Graphics2D g, Rectangle2D bounds, Point origin, int probability, int enemyGroupId) {
EnemyGroup enemyGroup = map.getEnemyGroup(enemyGroupId);
if (enemyGroup == null)
return 0;
int maxX = origin.x;
AffineTransform stashed = g.getTransform();
g.translate(bounds.getX(), bounds.getY());
Expand Down

0 comments on commit 81b8a04

Please sign in to comment.