Skip to content

Commit 6840711

Browse files
author
bytekeeper
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents f046df5 + 33d2f01 commit 6840711

27 files changed

+210
-329
lines changed

src/main/java/bwapi/BuildingPlacer.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class BuildingPlacer {
44
private static final int MAX_RANGE = 64;
5-
private static TilePosition gDirections[] = {
5+
private static TilePosition[] gDirections = {
66
new TilePosition(1, 1),
77
new TilePosition(0, 1),
88
new TilePosition(-1, 1),
@@ -12,7 +12,7 @@ class BuildingPlacer {
1212
new TilePosition(0, -1),
1313
new TilePosition(-1, -1)
1414
};
15-
private static BuildTemplate buildTemplates[] = // [13 + 1]
15+
private static BuildTemplate[] buildTemplates = // [13 + 1]
1616
{
1717
new BuildTemplate(32, 0, 0, 1),
1818
new BuildTemplate(0, 32, 1, 0),
@@ -363,8 +363,8 @@ private static class BuildTemplate {
363363

364364
static class PlacementReserve {
365365
public final int maxSearch;
366-
byte data[][];
367-
byte save[][];
366+
byte[][] data;
367+
byte[][] save;
368368

369369
PlacementReserve(final int maxRange) {
370370
maxSearch = Math.min(Math.max(0, maxRange), MAX_RANGE);
@@ -446,8 +446,6 @@ boolean hasValidSpace() {
446446
return false;
447447
}
448448

449-
;
450-
451449
void backup() {
452450
System.arraycopy(save, 0, data, 0, save.length);
453451
}

src/main/java/bwapi/Color.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Color {
88
public final static Color Blue = new Color(165);
99
public final static Color Teal = new Color(159);
1010
public final static Color Purple = new Color(164);
11-
public final static Color Orange = new Color(179);
11+
public final static Color Orange = new Color(156);
1212
public final static Color Brown = new Color(19);
1313
public final static Color White = new Color(255);
1414
public final static Color Yellow = new Color(135);
@@ -19,7 +19,7 @@ public class Color {
1919

2020
private static final RGBQUAD RGBRESERVE = new RGBQUAD(0, 0, 0, 0xFF);
2121

22-
private static final RGBQUAD defaultPalette[] = {
22+
private static final RGBQUAD[] defaultPalette = {
2323
new RGBQUAD(0, 0, 0), RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE,
2424
RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE,
2525
new RGBQUAD(24, 36, 44), new RGBQUAD(72, 36, 20), new RGBQUAD(92, 44, 20), new RGBQUAD(112, 48, 20), new RGBQUAD(104, 60, 36), new RGBQUAD(124, 64, 24), new RGBQUAD(120, 76, 44), new RGBQUAD(168, 8, 8),
@@ -55,7 +55,7 @@ RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESER
5555
};
5656

5757
private static boolean rgbInitialized;
58-
private static byte closestColor[][][] = new byte[64][64][64];
58+
private static byte[][][] closestColor = new byte[64][64][64];
5959
public final int id;
6060

6161
public Color(final int r, final int g, final int b) {

src/main/java/bwapi/Game.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import static bwapi.UnitType.*;
1515

1616
public class Game {
17-
private static final int damageRatio[][] = {
17+
private static final int[][] damageRatio = {
1818
// Ind, Sml, Med, Lrg, Non, Unk
1919
{0, 0, 0, 0, 0, 0}, // Independent
2020
{0, 128, 192, 256, 0, 0}, // Explosive
@@ -24,7 +24,7 @@ public class Game {
2424
{0, 0, 0, 0, 0, 0}, // None
2525
{0, 0, 0, 0, 0, 0} // Unknown
2626
};
27-
private static final boolean bPsiFieldMask[][] = {
27+
private static final boolean[][] bPsiFieldMask = {
2828
{false, false, false, false, false, true, true, true, true, true, true, false, false, false, false, false},
2929
{false, false, true, true, true, true, true, true, true, true, true, true, true, true, false, false},
3030
{false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false},

src/main/java/bwapi/Player.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.Set;
55
import java.util.stream.Collectors;
66

7-
import static bwapi.TextColor.*;
87
import static bwapi.UnitType.*;
98
import static bwapi.UpgradeType.*;
109
import static bwapi.WeaponType.*;
@@ -215,31 +214,31 @@ public Color getColor() {
215214
public TextColor getTextColor() {
216215
switch (playerData.getColor()) {
217216
case 111: // red
218-
return BrightRed;
217+
return TextColor.BrightRed;
219218
case 165: // blue
220-
return Blue;
219+
return TextColor.Blue;
221220
case 159: // teal
222-
return Teal;
221+
return TextColor.Teal;
223222
case 164: // purp
224-
return Purple;
225-
case 179: // oj
226-
return Orange;
223+
return TextColor.Purple;
224+
case 156: // orange with fix from @n00byEdge
225+
return TextColor.Orange;
227226
case 19: // brown
228-
return Brown;
227+
return TextColor.Brown;
229228
case 84: // white
230-
return PlayerWhite;
229+
return TextColor.PlayerWhite;
231230
case 135: // yellow
232-
return PlayerYellow;
231+
return TextColor.PlayerYellow;
233232
case 185: // green p9
234-
return DarkGreen;
233+
return TextColor.DarkGreen;
235234
case 136: // p10
236-
return LightYellow;
235+
return TextColor.LightYellow;
237236
case 134: // p11
238-
return Tan;
237+
return TextColor.Tan;
239238
case 51: // p12
240-
return GreyBlue;
239+
return TextColor.GreyBlue;
241240
default:
242-
return Default;
241+
return TextColor.Default;
243242
}
244243
}
245244

src/main/java/bwapi/Position.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public Position(final int x, final int y) {
1818
}
1919

2020
private static int getApproxDistance(final int x1, final int y1, final int x2, final int y2) {
21-
int min = Math.abs(x1 - x2);
22-
int max = Math.abs(y1 - y2);
21+
int max = Math.abs(x1 - x2);
22+
int min = Math.abs(y1 - y2);
2323
if (max < min) {
2424
final int temp = min;
2525
min = max;
2626
max = temp;
2727
}
2828

29-
if (min < (max >> 2)) {
29+
if (min <= (max >> 2)) {
3030
return max;
3131
}
3232

src/main/java/bwapi/Race.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ public enum Race {
1717
Unknown(8);
1818

1919
public static Race[] races = new Race[8 + 1];
20-
static UnitType workerTypes[] = {
20+
static UnitType[] workerTypes = {
2121
Zerg_Drone, Terran_SCV, Protoss_Probe,
2222
UnitType.None, UnitType.None, UnitType.None, // unused
2323
UnitType.Unknown, UnitType.None, UnitType.Unknown // random, none, unk
2424
};
25-
static UnitType baseTypes[] = {
25+
static UnitType[] baseTypes = {
2626
Zerg_Hatchery, Terran_Command_Center, Protoss_Nexus,
2727
UnitType.None, UnitType.None, UnitType.None, // unused
2828
UnitType.Unknown, UnitType.None, UnitType.Unknown // random, none, unk
2929
};
30-
static UnitType refineryTypes[] = {
30+
static UnitType[] refineryTypes = {
3131
Zerg_Extractor, Terran_Refinery, Protoss_Assimilator,
3232
UnitType.None, UnitType.None, UnitType.None, // unused
3333
UnitType.Unknown, UnitType.None, UnitType.Unknown // random, none, unk
3434
};
35-
static UnitType transportTypes[] = {
35+
static UnitType[] transportTypes = {
3636
Zerg_Overlord, Terran_Dropship, Protoss_Shuttle,
3737
UnitType.None, UnitType.None, UnitType.None, // unused
3838
UnitType.Unknown, UnitType.None, UnitType.Unknown // random, none, unk
3939
};
40-
static UnitType supplyTypes[] = {
40+
static UnitType[] supplyTypes = {
4141
Zerg_Overlord, Terran_Supply_Depot, Protoss_Pylon,
4242
UnitType.None, UnitType.None, UnitType.None, // unused
4343
UnitType.Unknown, UnitType.None, UnitType.Unknown // random, none, unk

src/main/java/bwapi/TechType.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public enum TechType {
4949
Unknown(46);
5050

5151
/// IMPLEMENTATION
52-
private static int defaultOreCost[] = // Same as default gas cost
52+
private static int[] defaultOreCost = // Same as default gas cost
5353
{100, 200, 200, 100, 0, 150, 0, 200, 100, 150, 100, 100, 0, 100, 0, 200, 100, 100, 0, 200, 150, 150, 150, 0, 100, 200, 0, 200, 0, 100, 100, 100, 200};
54-
private static int defaultTimeCost[] =
54+
private static int[] defaultTimeCost =
5555
{1200, 1500, 1800, 1200, 0, 1200, 0, 1200, 1800, 1500, 1200, 1200, 0, 1200, 0, 1500, 1500, 1200, 0, 1800, 1200, 1800, 1500, 0, 1200, 1200, 0, 1800, 0, 1800, 1800, 1500, 1800};
56-
private static int defaultEnergyCost[] =
56+
private static int[] defaultEnergyCost =
5757
{0, 100, 100, 0, 50, 0, 100, 75, 150, 25, 25, 0, 0, 150, 100, 150, 0, 75, 75, 75, 100, 150, 100, 0, 50, 125, 0, 150, 0, 50, 75, 100, 0, 0, 1};
58-
private static UnitType whatResearches[] = {
58+
private static UnitType[] whatResearches = {
5959
UnitType.Terran_Academy, UnitType.Terran_Covert_Ops, UnitType.Terran_Science_Facility, UnitType.Terran_Machine_Shop,
6060
UnitType.None, UnitType.Terran_Machine_Shop, UnitType.None, UnitType.Terran_Science_Facility, UnitType.Terran_Physics_Lab,
6161
UnitType.Terran_Control_Tower, UnitType.Terran_Covert_Ops, UnitType.Zerg_Hatchery, UnitType.None, UnitType.Zerg_Queens_Nest,
@@ -66,14 +66,14 @@ public enum TechType {
6666
UnitType.Zerg_Hydralisk_Den, UnitType.None, UnitType.None, UnitType.None, UnitType.None, UnitType.None, UnitType.None, UnitType.None, UnitType.None, UnitType.None, UnitType.None, UnitType.None,
6767
UnitType.None, UnitType.None, UnitType.Unknown
6868
};
69-
private static Race techRaces[] = {
69+
private static Race[] techRaces = {
7070
Race.Terran, Race.Terran, Race.Terran, Race.Terran, Race.Terran, Race.Terran, Race.Terran, Race.Terran, Race.Terran, Race.Terran, Race.Terran,
7171
Race.Zerg, Race.Zerg, Race.Zerg, Race.Zerg, Race.Zerg, Race.Zerg, Race.Zerg, Race.Zerg,
7272
Race.Protoss, Race.Protoss, Race.Protoss, Race.Protoss, Race.Protoss,
7373
Race.Terran, Race.Protoss, Race.None, Race.Protoss, Race.Protoss, Race.Protoss, Race.Terran, Race.Protoss, Race.Zerg, Race.None, Race.Terran,
7474
Race.None, Race.None, Race.None, Race.None, Race.None, Race.None, Race.None, Race.None, Race.None, Race.None, Race.Terran, Race.Unknown
7575
};
76-
private static WeaponType techWeapons[] = {
76+
private static WeaponType[] techWeapons = {
7777
WeaponType.None, WeaponType.Lockdown, WeaponType.EMP_Shockwave, WeaponType.Spider_Mines, WeaponType.None, WeaponType.None, WeaponType.None, WeaponType.Irradiate, WeaponType.Yamato_Gun,
7878
WeaponType.None, WeaponType.None, WeaponType.None, WeaponType.None, WeaponType.Spawn_Broodlings, WeaponType.Dark_Swarm, WeaponType.Plague, WeaponType.Consume, WeaponType.Ensnare, WeaponType.Parasite,
7979
WeaponType.Psionic_Storm, WeaponType.None, WeaponType.None, WeaponType.Stasis_Field, WeaponType.None, WeaponType.Restoration, WeaponType.Disruption_Web, WeaponType.None, WeaponType.Mind_Control,
@@ -83,21 +83,21 @@ public enum TechType {
8383
private static int TARG_UNIT = 1;
8484
private static int TARG_POS = 2;
8585
private static int TARG_BOTH = 3;
86-
private static int techTypeFlags[] = {
86+
private static int[] techTypeFlags = {
8787
0, TARG_UNIT, TARG_BOTH, TARG_POS, TARG_BOTH, 0, TARG_UNIT, TARG_UNIT, TARG_UNIT, 0, 0, 0,
8888
TARG_UNIT, TARG_UNIT, TARG_BOTH, TARG_BOTH, TARG_UNIT, TARG_BOTH, TARG_UNIT, TARG_BOTH, TARG_UNIT,
8989
TARG_BOTH, TARG_BOTH, TARG_UNIT, TARG_UNIT, TARG_BOTH, 0, TARG_UNIT, TARG_UNIT, TARG_UNIT, TARG_UNIT,
9090
TARG_BOTH, 0, 0, TARG_BOTH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TARG_BOTH
9191
};
92-
private static Order techOrders[] = {
92+
private static Order[] techOrders = {
9393
Order.None, CastLockdown, CastEMPShockwave, PlaceMine, CastScannerSweep, Order.None, CastDefensiveMatrix,
9494
CastIrradiate, FireYamatoGun, Order.None, Order.None, Order.None, CastInfestation, CastSpawnBroodlings,
9595
CastDarkSwarm, CastPlague, CastConsume, CastEnsnare, CastParasite, CastPsionicStorm,
9696
CastHallucination, CastRecall, CastStasisField, Order.None, CastRestoration, CastDisruptionWeb,
9797
Order.None, CastMindControl, Order.None, CastFeedback, CastOpticalFlare, CastMaelstrom, Order.None, Order.None, MedicHeal,
9898
Order.None, Order.None, Order.None, Order.None, Order.None, Order.None, Order.None, Order.None, Order.None, Order.None, NukePaint, Order.Unknown
9999
};
100-
private static UnitType techWhatUses[][] = {
100+
private static UnitType[][] techWhatUses = {
101101
// Stimpacks
102102
{UnitType.Terran_Marine, UnitType.Terran_Firebat, UnitType.Hero_Jim_Raynor_Marine, UnitType.Hero_Gui_Montag},
103103
// Lockdown

src/main/java/bwapi/Unit.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,25 +164,19 @@ public int getDistance(final Position target) {
164164
}
165165
/////// Compute distance
166166

167-
// retrieve left/top/right/bottom values for calculations
168-
final int left = target.x - 1;
169-
final int top = target.y - 1;
170-
final int right = target.x + 1;
171-
final int bottom = target.y + 1;
172-
173167
// compute x distance
174-
int xDist = getLeft() - right;
168+
int xDist = getLeft() - target.x;
175169
if (xDist < 0) {
176-
xDist = left - getRight();
170+
xDist = target.x - (getRight() + 1);
177171
if (xDist < 0) {
178172
xDist = 0;
179173
}
180174
}
181175

182176
// compute y distance
183-
int yDist = getTop() - bottom;
177+
int yDist = getTop() - target.y;
184178
if (yDist < 0) {
185-
yDist = top - getBottom();
179+
yDist = target.y - (getBottom() + 1);
186180
if (yDist < 0) {
187181
yDist = 0;
188182
}
@@ -741,8 +735,6 @@ public boolean isMoving() {
741735
return unitData.isMoving();
742736
}
743737

744-
;
745-
746738
public boolean isParasited() {
747739
return unitData.isParasited();
748740
}

src/main/java/bwapi/UnitType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package bwapi;
22

33
import java.util.*;
4-
import java.util.stream.Collectors;
54

65
import static bwapi.TechType.*;
76

0 commit comments

Comments
 (0)