Skip to content

Commit e3f8446

Browse files
committed
some manual fixes
1 parent ad32c2b commit e3f8446

3 files changed

Lines changed: 30 additions & 20 deletions

File tree

src/main/java/bwapi/Color.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @note Starcraft uses a 256 color palette for rendering. Thus, the colors available are
1010
* limited to this palette.
1111
*
12-
* @see Colors
12+
* @see Color
1313
*/
1414
public class Color {
1515
public final static Color Red = new Color(111);
@@ -67,14 +67,24 @@ RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESER
6767
public final int id;
6868

6969
/**
70-
* A constructor that uses the color at the specified palette index.
70+
* A constructor that uses the color index in the palette that is closest to the
71+
* given rgb values. On its first call, the colors in the palette will be sorted for fast indexing.
7172
*
72-
* @param id The index of the color in the 256-color palette.
73+
* @note This function computes the distance of the RGB values and may not be accurate.
74+
*
75+
* @param red The amount of red.
76+
* @param green The amount of green.
77+
* @param blue The amount of blue.
7378
*/
74-
public Color(final int r, final int g, final int b) {
75-
id = getRGBIndex(r, g, b);
79+
public Color(final int red, final int green, final int blue) {
80+
id = getRGBIndex(red, green, blue);
7681
}
7782

83+
/**
84+
* A constructor that uses the color at the specified palette index.
85+
*
86+
* @param id The index of the color in the 256-color palette.
87+
*/
7888
public Color(final int id) {
7989
this.id = id;
8090
}

src/main/java/bwapi/Game.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,43 +1537,39 @@ public List<TilePosition> getStartLocations() {
15371537

15381538
/**
15391539
* Prints text to the screen as a notification. This function allows text
1540-
* formatting using Text members. The behaviour of this function is the same as printf,
1541-
* located in header cstdio.
1540+
* formatting using Text members.
15421541
*
15431542
* @note That text printed through this function is not seen by other players or in replays.
15441543
*
1545-
* @param format Text formatting. See std#printf for more information. Refrain from passing non-constant strings directly in this parameter.
1546-
* @param ... The arguments that will be formatted using the given text formatting.
1544+
* @param string String to print.
15471545
*
1548-
* @see Text, std#printf
1546+
* @see Text
15491547
*/
15501548
public void printf(final String string) {
15511549
addCommand(Printf, client.addString(string), 0);
15521550
}
15531551

15541552
/**
1555-
* Sends a text message to all other players in the game. The behaviour of
1556-
* this function is the same as std#printf, located in header cstdio.
1553+
* Sends a text message to all other players in the game.
15571554
*
15581555
* @note In a single player game this function can be used to execute cheat codes.
15591556
*
1560-
* @param format Text formatting. See std#printf for more information. Refrain from passing non-constant strings directly in this parameter.
1557+
* @param string String to send.
15611558
*
1562-
* @see sendTextEx, std#printf
1559+
* @see sendTextEx
15631560
*/
15641561
public void sendText(final String string) {
15651562
addCommand(SendText, client.addString(string), 0);
15661563
}
15671564

15681565
/**
15691566
* An extended version of Game#sendText which allows messages to be forwarded to
1570-
* allies. The behaviour of this function is the same as std#printf, located in
1571-
* header cstdio.
1567+
* allies.
15721568
*
15731569
* @param toAllies If this parameter is set to true, then the message is only sent to allied players, otherwise it will be sent to all players.
1574-
* @param format Text formatting. See std#printf for more information. Refrain from passing non-constant strings directly in this parameter.
1570+
* @param string String to send.
15751571
*
1576-
* @see sendText, std#printf
1572+
* @see sendText
15771573
*/
15781574
public void sendTextEx(final boolean toAllies, final String string) {
15791575
addCommand(SendText, client.addString(string), toAllies ? 1 : 0);

src/main/java/bwapi/Region.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ public int getDistance(final Region other) {
216216
return getCenter().getApproxDistance(other.getCenter());
217217
}
218218

219+
public List<Unit> getUnits() {
220+
return getUnits(u -> true);
221+
}
222+
219223
/**
220224
* Retrieves a List<Unit> containing all the units that are in this region.
221225
* Also has the ability to filter the units before the creation of the List<Unit>.
@@ -227,9 +231,9 @@ public int getDistance(final Region other) {
227231
*
228232
* @see UnitFilter
229233
*/
230-
public List<Unit> getUnits() {
234+
public List<Unit> getUnits(final UnitFilter pred) {
231235
return game.getUnitsInRectangle(getBoundsLeft(), getBoundsTop(), getBoundsRight(), getBoundsBottom(),
232-
u -> equals(u.getRegion()));
236+
u -> equals(u.getRegion()) && pred.operation(u));
233237
}
234238

235239
@Override

0 commit comments

Comments
 (0)