Skip to content

Commit 2cd8e37

Browse files
author
Jasper Geurtz
committed
Rename AsyncClientData to ClientDataAsync
1 parent a259143 commit 2cd8e37

5 files changed

Lines changed: 25 additions & 25 deletions

File tree

‎src/main/java/bwapi/BotWrapperAsync.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ void startNewGame(WrappedBuffer liveData, PerformanceMetrics performanceMetrics)
2626
frameBuffer.initialize(liveData, performanceMetrics);
2727

2828
this.performanceMetrics = performanceMetrics;
29-
AsyncClientData asyncClientData = new AsyncClientData(liveData);
30-
botGame = new Game(asyncClientData);
29+
ClientDataAsync clientDataAsync = new ClientDataAsync(liveData);
30+
botGame = new Game(clientDataAsync);
3131
botGame.setConfiguration(configuration);
3232
botGame.botClientData().setBuffer(liveData);
3333
gameOver = false;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
* and dynamic information through pre-shifted slice views.
66
* Automatically generated by DumpToClient.
77
*/
8-
class AsyncClientData extends ClientData {
8+
class ClientDataAsync extends ClientData {
99
private WrappedBuffer staticBuffer;
1010
private PackedWrappedBuffer staticPackedView;
1111
PackedWrappedBuffer packedBuffer;
1212

13-
AsyncClientData() {
13+
ClientDataAsync() {
1414
super();
1515
}
1616

17-
AsyncClientData(WrappedBuffer staticBuffer) {
17+
ClientDataAsync(WrappedBuffer staticBuffer) {
1818
super();
1919
setStaticBuffer(staticBuffer);
2020
}

‎src/main/java/bwapi/FrameBuffer.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void enqueueFrame() {
120120

121121
// Copy dynamic game information into the current frame buffer slot.
122122
// Static information (e.g. walkability/buildability/regions) is accessed
123-
// directly from the main shared memory buffer by AsyncClientData.
123+
// directly from the main shared memory buffer by ClientDataAsync.
124124
if (stepGame == 0) {
125125
copyBuffer(liveData, dataBuffer.get(indexGame()));
126126
} else {
@@ -174,7 +174,7 @@ void dequeue() {
174174
*
175175
* To minimize both memory footprint and copy time, we:
176176
* 1. Omit static map and region data (groundHeight, isWalkable, isBuildable, regions), which are read directly
177-
* from the main shared memory buffer via AsyncClientData.
177+
* from the main shared memory buffer via ClientDataAsync.
178178
* 2. Omit client-to-server output buffers (strings, shapes, commands, unitCommands), which are flushed directly
179179
* to live shared memory by SideEffectQueue at the end of the frame.
180180
* 3. Pack the remaining 3 dynamic ranges into a 4.08 MB PackedWrappedBuffer (using pre-shifted slice views so

‎src/test/java/DumpToClient.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,16 @@ public static void main(String[] args) throws IOException {
162162
out.println(" * and dynamic information through pre-shifted slice views.");
163163
out.println(" * Automatically generated by DumpToClient.");
164164
out.println(" */");
165-
out.println("class AsyncClientData extends ClientData {");
165+
out.println("class ClientDataAsync extends ClientData {");
166166
out.println(" private WrappedBuffer staticBuffer;");
167167
out.println(" private PackedWrappedBuffer staticPackedView;");
168168
out.println(" PackedWrappedBuffer packedBuffer;");
169169
out.println("");
170-
out.println(" AsyncClientData() {");
170+
out.println(" ClientDataAsync() {");
171171
out.println(" super();");
172172
out.println(" }");
173173
out.println("");
174-
out.println(" AsyncClientData(WrappedBuffer staticBuffer) {");
174+
out.println(" ClientDataAsync(WrappedBuffer staticBuffer) {");
175175
out.println(" super();");
176176
out.println(" setStaticBuffer(staticBuffer);");
177177
out.println(" }");
@@ -239,9 +239,9 @@ public static void main(String[] args) throws IOException {
239239
out.println(" }");
240240
out.println("}");
241241
}
242-
String asyncClientDataText = swAsync.toString().replace("\r\n", "\n");
243-
Files.write(Paths.get("src/main/java/bwapi/AsyncClientData.java"),
244-
asyncClientDataText.getBytes(StandardCharsets.UTF_8),
242+
String clientDataAsyncText = swAsync.toString().replace("\r\n", "\n");
243+
Files.write(Paths.get("src/main/java/bwapi/ClientDataAsync.java"),
244+
clientDataAsyncText.getBytes(StandardCharsets.UTF_8),
245245
StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
246246
}
247247

src/test/java/bwapi/AsyncClientDataTest.java renamed to src/test/java/bwapi/ClientDataAsyncTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import static org.junit.Assert.*;
66

7-
public class AsyncClientDataTest {
7+
public class ClientDataAsyncTest {
88

99
@Test
1010
public void retainedViewsSurviveLiveAndPackedHandoffs() {
@@ -18,7 +18,7 @@ public void retainedViewsSurviveLiveAndPackedHandoffs() {
1818
new FrameBuffer(new BWClientConfiguration.Builder().withAsyncFrameBufferCapacity(1).build())
1919
.copyBuffer(live, packed);
2020

21-
AsyncClientData data = new AsyncClientData(live);
21+
ClientDataAsync data = new ClientDataAsync(live);
2222
data.setBuffer(live);
2323
ClientData.Event event = data.gameData().getEvents(0);
2424
ClientData.Position position = data.gameData().getStartLocations(0);
@@ -61,7 +61,7 @@ byte getByte(int offset) {
6161
new FrameBuffer(new BWClientConfiguration.Builder().withAsyncFrameBufferCapacity(1).build())
6262
.copyBuffer(live, packed);
6363

64-
AsyncClientData data = new AsyncClientData(live);
64+
ClientDataAsync data = new ClientDataAsync(live);
6565
data.setBuffer(live);
6666
live.handoff = () -> data.setBuffer(packed);
6767
assertTrue(data.gameData().isVisible(0, 0));
@@ -84,7 +84,7 @@ public void frameBufferAllocatesReducedMemory() {
8484
}
8585

8686
@Test
87-
public void asyncClientDataReadsStaticDataFromStaticBuffer() {
87+
public void clientDataAsyncReadsStaticDataFromStaticBuffer() {
8888
WrappedBuffer mainBuffer = new WrappedBuffer(ClientData.GameData.SIZE);
8989
PackedWrappedBuffer dynamicBuffer = new PackedWrappedBuffer();
9090

@@ -106,8 +106,8 @@ public void asyncClientDataReadsStaticDataFromStaticBuffer() {
106106
mainData.gameData().getRegions(2).setIsAccessible(true);
107107
mainData.gameData().getRegions(2).setIsHigherGround(true);
108108

109-
// Configure AsyncClientData with mainBuffer as static and dynamicBuffer as active
110-
AsyncClientData asyncData = new AsyncClientData(mainBuffer);
109+
// Configure ClientDataAsync with mainBuffer as static and dynamicBuffer as active
110+
ClientDataAsync asyncData = new ClientDataAsync(mainBuffer);
111111
asyncData.setBuffer(dynamicBuffer);
112112

113113
assertEquals(2, asyncData.gameData().getGroundHeight(10, 20));
@@ -127,7 +127,7 @@ public void asyncClientDataReadsStaticDataFromStaticBuffer() {
127127
}
128128

129129
@Test
130-
public void asyncClientDataReadsDynamicDataWithPackedOffsets() {
130+
public void clientDataAsyncReadsDynamicDataWithPackedOffsets() {
131131
WrappedBuffer mainBuffer = new WrappedBuffer(ClientData.GameData.SIZE);
132132
PackedWrappedBuffer packedBuffer = new PackedWrappedBuffer();
133133

@@ -166,8 +166,8 @@ public void asyncClientDataReadsDynamicDataWithPackedOffsets() {
166166
FrameBuffer frameBuffer = new FrameBuffer(config);
167167
frameBuffer.copyBuffer(mainBuffer, packedBuffer);
168168

169-
// Verify AsyncClientData reads packed dynamic data accurately
170-
AsyncClientData asyncData = new AsyncClientData(mainBuffer);
169+
// Verify ClientDataAsync reads packed dynamic data accurately
170+
ClientDataAsync asyncData = new ClientDataAsync(mainBuffer);
171171
asyncData.setBuffer(packedBuffer);
172172

173173
// Range 1
@@ -199,7 +199,7 @@ public void asyncClientDataReadsDynamicDataWithPackedOffsets() {
199199
}
200200

201201
@Test
202-
public void asyncClientDataWorksWithFullUnpackedBuffer() {
202+
public void clientDataAsyncWorksWithFullUnpackedBuffer() {
203203
// Tests asyncUnsafe mode where bot is placed directly on the full 33MB liveData buffer
204204
WrappedBuffer fullBuffer = new WrappedBuffer(ClientData.GameData.SIZE);
205205

@@ -208,7 +208,7 @@ public void asyncClientDataWorksWithFullUnpackedBuffer() {
208208
syncData.gameData().setIsVisible(10, 20, true);
209209
syncData.gameData().setIsInGame(true);
210210

211-
AsyncClientData asyncData = new AsyncClientData(fullBuffer);
211+
ClientDataAsync asyncData = new ClientDataAsync(fullBuffer);
212212
asyncData.setBuffer(fullBuffer); // Unpacked full buffer
213213

214214
assertTrue(asyncData.gameData().isVisible(10, 20));
@@ -237,7 +237,7 @@ public void copyBufferTracksMaxUnitsAndOnlyCopiesActiveUnitsAndEvents() {
237237
new BWClientConfiguration.Builder().withAsyncFrameBufferCapacity(1).build());
238238
frameBuffer.copyBuffer(mainBuffer, packedBuffer);
239239

240-
AsyncClientData asyncData = new AsyncClientData(mainBuffer);
240+
ClientDataAsync asyncData = new ClientDataAsync(mainBuffer);
241241
asyncData.setBuffer(packedBuffer);
242242

243243
assertEquals(3, frameBuffer.getMaxUnitCount());

0 commit comments

Comments
 (0)