Skip to content

Commit 439f744

Browse files
author
bytekeeper
committed
More smaller clean-ups.
1 parent 9107408 commit 439f744

File tree

7 files changed

+17
-42
lines changed

7 files changed

+17
-42
lines changed

src/main/java/bwem/BWMapInitializer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ void initialize() {
6868

6969
getGraph().collectInformation();
7070

71-
7271
getGraph().createBases(getData());
7372
}
7473

@@ -649,8 +648,7 @@ void onBlockingNeutralDestroyed(Neutral pBlocking) {
649648
// Unblock the Tiles of pBlocking:
650649
for (int dy = 0; dy < pBlocking.getSize().getY(); ++dy)
651650
for (int dx = 0; dx < pBlocking.getSize().getX(); ++dx) {
652-
getData()
653-
.getTile(pBlocking.getTopLeft().add(new TilePosition(dx, dy)))
651+
getData().getTile(pBlocking.getTopLeft().add(new TilePosition(dx, dy)))
654652
.resetAreaId();
655653
setAreaIdInTile(pBlocking.getTopLeft().add(new TilePosition(dx, dy)));
656654
}

src/main/java/bwem/Graph.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import bwapi.WalkPosition;
1919
import bwem.util.BwemExt;
2020
import bwem.util.CheckMode;
21+
import bwem.util.Pred;
2122
import bwem.util.Utils;
2223

2324
import java.util.*;
@@ -80,7 +81,7 @@ public Area getNearestArea(final WalkPosition walkPosition) {
8081
// findCond
8182
(MiniTile miniTile, WalkPosition unused) -> (miniTile.getAreaId().intValue() > 0),
8283
// visitCond
83-
(MiniTile miniTile, WalkPosition unused) -> true);
84+
Pred.accept());
8485

8586
return getArea(w);
8687
}
@@ -338,7 +339,7 @@ public void createChokePoints(
338339
// findCond
339340
(MiniTile miniTile, WalkPosition unused) -> miniTile.isWalkable(),
340341
// visitCond
341-
(MiniTile miniTile, WalkPosition unused) -> true);
342+
Pred.accept());
342343

343344
final List<WalkPosition> list = new ArrayList<>();
344345
list.add(center);

src/main/java/bwem/PathingResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Result of a path query including the approximated length of the path.
55
*/
6-
public class PathingResult {
6+
public final class PathingResult {
77

88
private final CPPath cpPath;
99
private final int approxDistance;

src/main/java/bwem/Tile.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,27 +210,12 @@ void setInternalData(int internalData) {
210210
* Corresponds to BWAPI::getGroundHeight divided by 2.
211211
*/
212212
public enum GroundHeight {
213-
LOW_GROUND(0),
214-
HIGH_GROUND(1),
215-
VERY_HIGH_GROUND(2);
213+
LOW_GROUND, // Height 0
214+
HIGH_GROUND, // Height 1
215+
VERY_HIGH_GROUND; // Height 2
216216

217-
private final int val;
218-
219-
GroundHeight(final int val) {
220-
this.val = val;
221-
}
222-
223-
static GroundHeight parseGroundHeight(final int height) {
224-
for (final GroundHeight val : GroundHeight.values()) {
225-
if (val.intValue() == height) {
226-
return val;
227-
}
228-
}
229-
throw new IllegalArgumentException("Unrecognized height: " + height);
230-
}
231-
232-
int intValue() {
233-
return this.val;
217+
static GroundHeight parseGroundHeight(int height) {
218+
return values()[height];
234219
}
235220
}
236221
}

src/main/java/bwem/util/Markable.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,13 @@ public final class Markable {
2222

2323
public Markable(final StaticMarkable staticMarkable) {
2424
this.staticMarkable = staticMarkable;
25-
this.lastMark = 0;
26-
}
27-
28-
private StaticMarkable getStaticMarkable() {
29-
return this.staticMarkable;
3025
}
3126

3227
public boolean isUnmarked() {
33-
return (this.lastMark != getStaticMarkable().getCurrentMark());
28+
return (this.lastMark != staticMarkable.getCurrentMark());
3429
}
3530

3631
public void setMarked() {
37-
this.lastMark = getStaticMarkable().getCurrentMark();
38-
}
39-
40-
public void setUnmarked() {
41-
this.lastMark = getStaticMarkable().getCurrentMark() - 1;
32+
this.lastMark = staticMarkable.getCurrentMark();
4233
}
4334
}

src/main/java/bwem/util/Pred.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@
1515
@FunctionalInterface
1616
public interface Pred<T, P> {
1717
boolean test(T tile, P position);
18+
19+
static <T, P> Pred<T, P> accept() {
20+
return (tile, position) -> true;
21+
}
1822
}

src/main/java/bwem/util/StaticMarkable.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
public final class StaticMarkable {
2020
private int currentMark;
2121

22-
public StaticMarkable() {
23-
this.currentMark = 0;
24-
}
25-
26-
public int getCurrentMark() {
22+
int getCurrentMark() {
2723
return this.currentMark;
2824
}
2925

0 commit comments

Comments
 (0)