Skip to content

Commit c4f0970

Browse files
committed
getClosestUnitInRadius -> getClosestUnit to be consistent with Game.h
1 parent fdaed5a commit c4f0970

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/main/java/bwapi/BuildingPlacer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ static TilePosition getBuildLocation(final UnitType type, final TilePosition des
4343
Region pTargRegion = null;
4444
switch (type) {
4545
case Protoss_Pylon:
46-
final Unit pSpecialUnitTarget = game.getClosestUnitInRadius(
47-
desiredPosition.toPosition(), 999999, u -> u.getPlayer().equals(game.self()) && !u.isPowered());
46+
final Unit pSpecialUnitTarget = game.getClosestUnit(
47+
desiredPosition.toPosition(), u -> u.getPlayer().equals(game.self()) && !u.isPowered());
4848
if (pSpecialUnitTarget != null) {
4949
desiredPosition = pSpecialUnitTarget.getPosition().toTilePosition();
5050
trimPlacement = false;

src/main/java/bwapi/Game.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,19 @@ public Unit getClosestUnitInRectangle(final Position center, final int left, fin
511511
.min(Comparator.comparingInt(u -> u.getDistance(center))).orElse(null);
512512
}
513513

514-
public Unit getClosestUnitInRadius(final Position center, final int radius) {
515-
return getClosestUnitInRadius(center, radius, u -> true);
514+
public Unit getClosestUnit(final Position center) {
515+
return getClosestUnit(center, 999999);
516516
}
517517

518-
public Unit getClosestUnitInRadius(final Position center, final int radius, final UnitFilter filter) {
518+
public Unit getClosestUnit(final Position center, final UnitFilter filter) {
519+
return getClosestUnit(center, 999999, filter);
520+
}
521+
522+
public Unit getClosestUnit(final Position center, final int radius) {
523+
return getClosestUnit(center, radius, u -> true);
524+
}
525+
526+
public Unit getClosestUnit(final Position center, final int radius, final UnitFilter filter) {
519527
return getUnitsInRadius(center, radius, filter).stream()
520528
.min(Comparator.comparingInt(u -> u.getDistance(center))).orElse(null);
521529
}
@@ -528,11 +536,11 @@ public int mapHeight() {
528536
return mapHeight;
529537
}
530538

531-
public int mapPixelWidth() {
539+
int mapPixelWidth() {
532540
return mapPixelWidth;
533541
}
534542

535-
public int mapPixelHeight() {
543+
int mapPixelHeight() {
536544
return mapPixelHeight;
537545
}
538546

0 commit comments

Comments
 (0)