Skip to content

Commit 93a9791

Browse files
committed
Cleanup
1 parent 0e35168 commit 93a9791

File tree

11 files changed

+37
-88
lines changed

11 files changed

+37
-88
lines changed

src/main/java/bwapi/BWClient.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public Game getGame() {
2727
/**
2828
* @return JBWAPI performance metrics.
2929
*/
30-
@SuppressWarnings("unused")
3130
public PerformanceMetrics getPerformanceMetrics() {
3231
return performanceMetrics;
3332
}
@@ -36,11 +35,17 @@ public PerformanceMetrics getPerformanceMetrics() {
3635
* @return The number of frames between the one exposed to the bot and the most recent received by JBWAPI.
3736
* This tracks the size of the frame buffer except when the game is paused (which results in multiple frames arriving with the same count).
3837
*/
39-
@SuppressWarnings("unused")
4038
public int framesBehind() {
4139
return botWrapper == null ? 0 : Math.max(0, client.clientData().gameData().getFrameCount() - getGame().getFrameCount());
4240
}
4341

42+
/**
43+
* For internal test use.
44+
*/
45+
Client getClient() {
46+
return client;
47+
}
48+
4449
/**
4550
* Start the game with default settings.
4651
*/

src/main/java/bwapi/BotWrapper.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
/*
2-
MIT License
3-
4-
Copyright (c) 2018 Hannes Bredberg
5-
Modified work Copyright (c) 2018 Jasper
6-
7-
Permission is hereby granted, free of charge, to any person obtaining a copy
8-
of this software and associated documentation files (the "Software"), to deal
9-
in the Software without restriction, including without limitation the rights
10-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
copies of the Software, and to permit persons to whom the Software is
12-
furnished to do so, subject to the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included in all
15-
copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23-
SOFTWARE.
24-
*/
25-
261
package bwapi;
272

283
import java.nio.ByteBuffer;

src/main/java/bwapi/Bullet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* represents a new Bullet.
2222
* <p>
2323
* If {@link Flag#CompleteMapInformation} is disabled, then a {@link Bullet} is accessible if and only if
24-
* it is visible. Otherwise if {@link Flag#CompleteMapInformation} is timersEnabled, then all Bullets
24+
* it is visible. Otherwise if {@link Flag#CompleteMapInformation} is enabled, then all Bullets
2525
* in the game are accessible.
2626
*
2727
* @see Game#getBullets
@@ -54,7 +54,7 @@ public int getID() {
5454
* return value will be false regardless of the Bullet's true existence. This is because
5555
* absolutely no state information on invisible enemy bullets is made available to the AI.
5656
* <p>
57-
* If {@link Flag#CompleteMapInformation} is timersEnabled, then this function is accurate for all
57+
* If {@link Flag#CompleteMapInformation} is enabled, then this function is accurate for all
5858
* {@link Bullet} information.
5959
*
6060
* @return true if the bullet exists or is visible, false if the bullet was destroyed or has gone out of scope.

src/main/java/bwapi/CommandTemp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* Latency Compensation:
5-
* Only need to implement LatCom for current frame, the server updates the next frame already if latcom is timersEnabled.
5+
* Only need to implement LatCom for current frame, the server updates the next frame already if latcom is enabled.
66
* Use Caches for all internal state that might be affected by latcom, and add the (current) frame, to let Player & Unit
77
* check if they need to use the cached/latcom version of the value or the from server (or a combination of both)
88
* <p>

src/main/java/bwapi/FrameBuffer.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
/*
2-
MIT License
3-
4-
Copyright (c) 2018 Hannes Bredberg
5-
Modified work Copyright (c) 2018 Jasper
6-
7-
Permission is hereby granted, free of charge, to any person obtaining a copy
8-
of this software and associated documentation files (the "Software"), to deal
9-
in the Software without restriction, including without limitation the rights
10-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
copies of the Software, and to permit persons to whom the Software is
12-
furnished to do so, subject to the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included in all
15-
copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23-
SOFTWARE.
24-
*/
25-
261
package bwapi;
272

283
import com.sun.jna.Platform;

src/main/java/bwapi/Game.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public List<Player> getPlayers() {
329329

330330
/**
331331
* Retrieves the set of all accessible units.
332-
* If {@link Flag#CompleteMapInformation} is timersEnabled, then the set also includes units that are not
332+
* If {@link Flag#CompleteMapInformation} is enabled, then the set also includes units that are not
333333
* visible to the player.
334334
* <p>
335335
* Units that are inside refineries are not included in this set.
@@ -624,13 +624,13 @@ public void pingMinimap(final Position p) {
624624
}
625625

626626
/**
627-
* Checks if the state of the given flag is timersEnabled or not.
627+
* Checks if the state of the given flag is enabled or not.
628628
* <p>
629-
* Flags may only be timersEnabled at the start of the match during the {@link BWEventListener#onStart}
629+
* Flags may only be enabled at the start of the match during the {@link BWEventListener#onStart}
630630
* callback.
631631
*
632632
* @param flag The {@link Flag} entry describing the flag's effects on BWAPI.
633-
* @return true if the given flag is timersEnabled, false if the flag is disabled.
633+
* @return true if the given flag is enabled, false if the flag is disabled.
634634
* @see Flag
635635
*/
636636
public boolean isFlagEnabled(final Flag flag) {
@@ -640,7 +640,7 @@ public boolean isFlagEnabled(final Flag flag) {
640640
/**
641641
* Enables the state of a given flag.
642642
* <p>
643-
* Flags may only be timersEnabled at the start of the match during the {@link BWEventListener#onStart}
643+
* Flags may only be enabled at the start of the match during the {@link BWEventListener#onStart}
644644
* callback.
645645
*
646646
* @param flag The {@link Flag} entry describing the flag's effects on BWAPI.
@@ -1640,7 +1640,7 @@ public boolean issueCommand(final Collection<Unit> units, final UnitCommand comm
16401640

16411641
/**
16421642
* Retrieves the set of units that are currently selected by the user outside of
1643-
* BWAPI. This function requires that{@link Flag#UserInput} be timersEnabled.
1643+
* BWAPI. This function requires that{@link Flag#UserInput} be enabled.
16441644
*
16451645
* @return A List<Unit> containing the user's selected units. If {@link Flag#UserInput} is disabled,
16461646
* then this set is always empty.
@@ -2163,7 +2163,7 @@ public boolean isDebug() {
21632163
/**
21642164
* Checks the state of latency compensation.
21652165
*
2166-
* @return true if latency compensation is timersEnabled, false if it is disabled.
2166+
* @return true if latency compensation is enabled, false if it is disabled.
21672167
* @see #setLatCom
21682168
*/
21692169
public boolean isLatComEnabled() {
@@ -2174,9 +2174,9 @@ public boolean isLatComEnabled() {
21742174
* Changes the state of latency compensation. Latency compensation
21752175
* modifies the state of BWAPI's representation of units to reflect the implications of
21762176
* issuing a command immediately after the command was performed, instead of waiting
2177-
* consecutive frames for the results. Latency compensation is timersEnabled by default.
2177+
* consecutive frames for the results. Latency compensation is enabled by default.
21782178
*
2179-
* @param isEnabled Set whether the latency compensation feature will be timersEnabled (true) or disabled (false).
2179+
* @param isEnabled Set whether the latency compensation feature will be enabled (true) or disabled (false).
21802180
* @see #isLatComEnabled
21812181
*/
21822182
public void setLatCom(final boolean isEnabled) {
@@ -2278,11 +2278,11 @@ public boolean setVision(Player player, boolean enabled) {
22782278
}
22792279

22802280
/**
2281-
* Checks if the GUI is timersEnabled.
2281+
* Checks if the GUI is enabled.
22822282
* <p>
22832283
* The GUI includes all drawing functions of BWAPI, as well as screen updates from Broodwar.
22842284
*
2285-
* @return true if the GUI is timersEnabled, and everything is visible, false if the GUI is disabled and drawing
2285+
* @return true if the GUI is enabled, and everything is visible, false if the GUI is disabled and drawing
22862286
* functions are rejected
22872287
* @see #setGUI
22882288
*/
@@ -2341,7 +2341,7 @@ public boolean setMap(final String mapFileName) {
23412341
/**
23422342
* Sets the state of the fog of war when watching a replay.
23432343
*
2344-
* @param reveal The state of the reveal all flag. If false, all fog of war will be timersEnabled. If true,
2344+
* @param reveal The state of the reveal all flag. If false, all fog of war will be enabled. If true,
23452345
* then the fog of war will be revealed. It is true by default.
23462346
*/
23472347
public boolean setRevealAll(boolean reveal) {

src/main/java/bwapi/PerformanceMetrics.java

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

33
/**
4-
* When performance diagnostics are timersEnabled, collects various performance metrics.
4+
* Collects various performance metrics.
55
*/
66
public class PerformanceMetrics {
77

src/main/java/bwapi/Unit.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* becoming invalid).
2020
* <p>
2121
* Every Unit in the game is either accessible or inaccessible. To determine if an AI can access
22-
* a particular unit, BWAPI checks to see if {@link Flag#CompleteMapInformation} is timersEnabled. So there
23-
* are two cases to consider - either the flag is timersEnabled, or it is disabled:
22+
* a particular unit, BWAPI checks to see if {@link Flag#CompleteMapInformation} is enabled. So there
23+
* are two cases to consider - either the flag is enabled, or it is disabled:
2424
* <p>
2525
* If {@link Flag#CompleteMapInformation} is disabled, then a unit is accessible if and only if it is visible.
2626
* <p>
@@ -31,7 +31,7 @@
3131
* AI must watch for {@link BWEventListener#onUnitDestroy} messages from BWAPI, which is only called for visible units
3232
* which get destroyed.
3333
* <p>
34-
* If {@link Flag#CompleteMapInformation} is timersEnabled, then all units that exist in the game are accessible, and
34+
* If {@link Flag#CompleteMapInformation} is enabled, then all units that exist in the game are accessible, and
3535
* {@link Unit#exists} is accurate for all units. Similarly {@link BWEventListener#onUnitDestroy} messages are generated for all
3636
* units that get destroyed, not just visible ones.
3737
* <p>
@@ -128,7 +128,7 @@ public boolean exists() {
128128
/**
129129
* Retrieves the unit identifier for this unit as seen in replay data.
130130
* <p>
131-
* This is only available if {@link Flag#CompleteMapInformation} is timersEnabled.
131+
* This is only available if {@link Flag#CompleteMapInformation} is enabled.
132132
*
133133
* @return An integer containing the replay unit identifier.
134134
* @see #getID
@@ -1882,7 +1882,7 @@ public boolean isResearching() {
18821882

18831883
/**
18841884
* Checks if this unit has been selected in the user interface. This
1885-
* function is only available if the flag Flag#UserInput is timersEnabled.
1885+
* function is only available if the flag Flag#UserInput is enabled.
18861886
*
18871887
* @return true if this unit is currently selected, and false if this unit is not selected
18881888
* @see Game#getSelectedUnits
@@ -2046,7 +2046,7 @@ public boolean isVisible() {
20462046
* @param player The player to check visibility for. If this parameter is omitted, then the BWAPI player obtained from {@link Game#self()} will be used.
20472047
* @return true if this unit is visible to the specified player, and false if it is not.
20482048
* <p>
2049-
* If the {@link Flag#CompleteMapInformation} flag is timersEnabled, existing units hidden by the
2049+
* If the {@link Flag#CompleteMapInformation} flag is enabled, existing units hidden by the
20502050
* fog of war will be accessible, but isVisible will still return false.
20512051
* @see #exists
20522052
*/

src/test/java/bwapi/GameBuilder.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010

1111
public class GameBuilder {
1212

13+
private final static String RESOURCES = "src/test/resources/";
1314
public final static String DEFAULT_MAP_FILE = "(2)Benzene.scx";
14-
public final static String DEFAULT_BUFFER_PATH = "src/test/resources/" + DEFAULT_MAP_FILE + "_frame0_buffer.bin";
15+
public final static String DEFAULT_BUFFER_PATH = RESOURCES + DEFAULT_MAP_FILE + "_frame0_buffer.bin";
1516

1617
public static Game createGame() throws IOException {
1718
return createGame(DEFAULT_MAP_FILE);
1819
}
1920

2021
public static Game createGame(String mapName) throws IOException {
21-
final ByteBuffer buffer = binToBuffer(DEFAULT_BUFFER_PATH);
22+
final ByteBuffer buffer = binToBuffer(RESOURCES + mapName + "_frame0_buffer.bin");
2223
return createGame(new Client(buffer));
2324
}
2425

@@ -29,14 +30,6 @@ public static Game createGame(Client client) {
2930
return game;
3031
}
3132

32-
public static Game createGameUnchecked() {
33-
try {
34-
return GameBuilder.createGame();
35-
} catch (IOException exception) {
36-
throw new RuntimeException(exception);
37-
}
38-
}
39-
4033
public static ByteBuffer binToBuffer(String binLocation) throws IOException {
4134
final byte[] compressedBytes = Files.readAllBytes(Paths.get(binLocation));
4235
final ByteArrayOutputStream out = new ByteArrayOutputStream();

src/test/java/bwapi/GameStateDumper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ public void onStart() {
3636
}
3737

3838
private void dumpBuffer(String name) throws IOException {
39-
// TODO
40-
//ByteBuffer buf = game.getClient().clientData().buffer.getBuffer();
41-
ByteBuffer buf = null;
39+
ByteBuffer buf = client.getClient().mapFile();
4240
buf.rewind();
4341
byte[] bytearr = new byte[buf.remaining()];
4442
buf.get(bytearr);

0 commit comments

Comments
 (0)