Skip to content

Commit 296e4d8

Browse files
committed
null checks for minimap icons
1 parent 5d7d3ce commit 296e4d8

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUIMinimap.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,22 @@ else if (simUnit.isHero()) {
121121
if (simUnit.isBuilding()) {
122122
dimensions = 10;
123123
}
124+
if (this.teamColors[unit.getSimulationUnit().getPlayerIndex()] == null) {
125+
System.err.println("Warning: minimapIcon team colors icon for player " + unit.getSimulationUnit().getPlayerIndex() + "is null");
126+
}
124127
minimapIcon = this.teamColors[unit.getSimulationUnit().getPlayerIndex()];
125128
}
126129
final int offset = dimensions / 2;
127-
batch.draw(minimapIcon,
128-
(this.minimapFilledArea.x + (((unit.location[0] - this.playableMapArea.getX())
129-
/ (this.playableMapArea.getWidth())) * this.minimapFilledArea.width)) - offset,
130-
(this.minimapFilledArea.y + (((unit.location[1] - this.playableMapArea.getY())
131-
/ (this.playableMapArea.getHeight())) * this.minimapFilledArea.height)) - offset,
132-
dimensions, dimensions);
130+
if (minimapIcon != null) {
131+
batch.draw(minimapIcon,
132+
(this.minimapFilledArea.x + (((unit.location[0] - this.playableMapArea.getX())
133+
/ (this.playableMapArea.getWidth())) * this.minimapFilledArea.width)) - offset,
134+
(this.minimapFilledArea.y + (((unit.location[1] - this.playableMapArea.getY())
135+
/ (this.playableMapArea.getHeight())) * this.minimapFilledArea.height)) - offset,
136+
dimensions, dimensions);
137+
} else {
138+
System.err.println("Warning: minimapIcon is null for unit " + simUnit.getName() + " with type " + simUnit.getUnitType().getTypeId());
139+
}
133140
batch.setColor(1, 1, 1, 1);
134141
}
135142
}

0 commit comments

Comments
 (0)