Skip to content

Commit 23ad3be

Browse files
authored
Merge pull request #77 from dgant/perf-and-bwem
Miscellaneous performance & QOL changes
2 parents 92d8318 + 08d77a1 commit 23ad3be

15 files changed

+56
-41
lines changed

src/main/java/bwapi/BulletType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public enum BulletType {
5959
Arrays.stream(BulletType.values()).forEach(v -> idToEnum[v.id] = v);
6060
}
6161

62-
final int id;
62+
public final int id;
6363

6464
BulletType(final int id) {
6565
this.id = id;

src/main/java/bwapi/CommandType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public enum CommandType {
3232
Arrays.stream(CommandType.values()).forEach(v -> idToEnum[v.id] = v);
3333
}
3434

35-
final int id;
35+
public final int id;
3636

3737
CommandType(final int id) {
3838
this.id = id;

src/main/java/bwapi/EventType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public enum EventType {
3333
Arrays.stream(EventType.values()).forEach(v -> idToEnum[v.id] = v);
3434
}
3535

36-
final int id;
36+
public final int id;
3737

3838
EventType(int id) {
3939
this.id = id;

src/main/java/bwapi/Game.java

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,7 @@ final public boolean isWalkable(final int walkX, final int walkY) {
935935
}
936936

937937
final public boolean isWalkable(final WalkPosition position) {
938-
if (!position.isValid(this)) {
939-
return false;
940-
}
941-
return walkable[position.x][position.y];
938+
return position.isValid(this) && walkable[position.x][position.y];
942939
}
943940

944941
/**
@@ -955,15 +952,12 @@ final public boolean isWalkable(final WalkPosition position) {
955952
* - 5: Very high ground doodad
956953
* .
957954
*/
958-
public int getGroundHeight(final int tileX, final int tileY) {
959-
return getGroundHeight(new TilePosition(tileX, tileY));
955+
final public int getGroundHeight(final int tileX, final int tileY) {
956+
return isValidTile(tileX, tileY) ? groundHeight[tileX][tileY] : 0;
960957
}
961958

962-
public int getGroundHeight(final TilePosition position) {
963-
if (!position.isValid(this)) {
964-
return 0;
965-
}
966-
return groundHeight[position.x][position.y];
959+
final public int getGroundHeight(final TilePosition position) {
960+
return getGroundHeight(position.x, position.y);
967961
}
968962

969963
final public boolean isBuildable(final int tileX, final int tileY) {
@@ -1077,23 +1071,23 @@ final public boolean hasPowerPrecise(final Position position, final UnitType uni
10771071
return hasPowerPrecise(position.x, position.y, unitType);
10781072
}
10791073

1080-
final public boolean hasPower(final int tileX, final int tileY) {
1081-
return hasPower(new TilePosition(tileX, tileY));
1074+
final public boolean hasPower(final TilePosition position) {
1075+
return hasPower(position.x, position.y);
10821076
}
10831077

1084-
final public boolean hasPower(final int tileX, final int tileY, final UnitType unitType) {
1085-
return hasPower(new TilePosition(tileX, tileY), unitType);
1078+
final public boolean hasPower(final int tileX, final int tileY) {
1079+
return hasPower(tileX, tileY, UnitType.None);
10861080
}
10871081

1088-
final public boolean hasPower(final TilePosition position) {
1089-
return hasPower(position.x, position.y, UnitType.None);
1082+
final public boolean hasPower(final TilePosition position, final UnitType unitType) {
1083+
return hasPower(position.x, position.y, unitType);
10901084
}
10911085

1092-
final public boolean hasPower(final TilePosition position, final UnitType unitType) {
1086+
final public boolean hasPower(final int tileX, final int tileY, final UnitType unitType) {
10931087
if (unitType.id >= 0 && unitType.id < UnitType.None.id) {
1094-
return hasPowerPrecise(position.x * 32 + unitType.tileWidth() * 16, position.y * 32 + unitType.tileHeight() * 16, unitType);
1088+
return hasPowerPrecise(tileX * 32 + unitType.tileWidth() * 16, tileY * 32 + unitType.tileHeight() * 16, unitType);
10951089
}
1096-
return hasPowerPrecise(position.x * 32, position.y * 32, UnitType.None);
1090+
return hasPowerPrecise(tileY * 32, tileY * 32, UnitType.None);
10971091
}
10981092

10991093
final public boolean hasPower(final int tileX, final int tileY, final int tileWidth, final int tileHeight) {

src/main/java/bwapi/GameType.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public enum GameType {
3535
Arrays.stream(GameType.values()).forEach(v -> idToEnum[v.id] = v);
3636
}
3737

38-
39-
final int id;
38+
public final int id;
4039

4140
GameType(final int id) {
4241
this.id = id;

src/main/java/bwapi/Latency.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public enum Latency {
2323
Arrays.stream(Latency.values()).forEach(v -> idToEnum[v.id] = v);
2424
}
2525

26-
final int id;
26+
public final int id;
2727

2828
Latency(final int id) {
2929
this.id = id;

src/main/java/bwapi/Order.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ public enum Order {
209209
Arrays.stream(Order.values()).forEach(v -> idToEnum[v.id] = v);
210210
}
211211

212-
213-
final int id;
212+
public final int id;
214213

215214
Order(final int id) {
216215
this.id = id;

src/main/java/bwapi/PlayerType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public enum PlayerType {
2626
Arrays.stream(PlayerType.values()).forEach(v -> idToEnum[v.id] = v);
2727
}
2828

29-
final int id;
29+
public final int id;
3030

3131
PlayerType(final int id) {
3232
this.id = id;

src/main/java/bwapi/Race.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public enum Race {
5858
Arrays.stream(Race.values()).forEach(v -> idToEnum[v.id] = v);
5959
}
6060

61-
final int id;
61+
public final int id;
6262

6363
Race(final int id) {
6464
this.id = id;

src/main/java/bwapi/ShapeType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enum ShapeType {
2121
Arrays.stream(ShapeType.values()).forEach(v -> idToEnum[v.id] = v);
2222
}
2323

24-
final int id;
24+
public final int id;
2525

2626
ShapeType(final int id) {
2727
this.id = id;

0 commit comments

Comments
 (0)