Skip to content

Commit 191dd13

Browse files
committed
add setlatcom to the api
1 parent 6d8deb0 commit 191dd13

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/main/java/JavaBWAPIBackend/Client.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ public class BulletData {
281281
public int remainingLatencyFrames() { return sharedMemory.getInt(GameOffset + 16); }
282282
public int remainingLatencyTime() { return sharedMemory.getInt(GameOffset + 20); }
283283
public boolean hasLatCom() { return sharedMemory.get(GameOffset + 24) != 0; }
284+
public void setLatcom(boolean enable) { sharedMemory.put(GameOffset + 24, (byte)(enable ? 1 : 0)); }
284285
public boolean hasGUI() { return sharedMemory.get(GameOffset + 25) != 0; }
285286
public int replayFrameCount() { return sharedMemory.getInt(GameOffset + 28); }
286287
public int randomSeed() { return sharedMemory.getInt(GameOffset + 32); }

src/main/java/bwapi/Game.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,10 @@ public boolean isLatComEnabled() {
791791
return gameData.hasLatCom();
792792
}
793793

794-
//TODO
795-
//public void setLatCom(boolean isEnabled);
794+
795+
public void setLatCom(final boolean isEnabled) {
796+
gameData.setLatcom(isEnabled);
797+
}
796798

797799
public int getInstanceNumber() {
798800
return gameData.getInstanceID();

src/test/java/game/GameTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package game;
2+
3+
import bwapi.BWClient;
4+
import bwapi.DefaultBWListener;
5+
import bwapi.Game;
6+
7+
public class GameTest extends DefaultBWListener {
8+
final BWClient bwClient;
9+
10+
Game game;
11+
12+
GameTest() {
13+
bwClient = new BWClient(this);
14+
bwClient.startGame();
15+
}
16+
17+
public void onStart() {
18+
game = bwClient.getGame();
19+
assert game != null;
20+
assert game.isLatComEnabled();
21+
game.setLatCom(false);
22+
assert !game.isLatComEnabled();
23+
}
24+
25+
public static void main(String[] args) {
26+
new GameTest();
27+
}
28+
}

0 commit comments

Comments
 (0)