@@ -36,7 +36,7 @@ void startNewGame(ByteBuffer liveData, PerformanceMetrics performanceMetrics) {
36
36
}
37
37
this .performanceMetrics = performanceMetrics ;
38
38
botGame = new Game ();
39
- botGame .clientData ().setBuffer (liveData );
39
+ botGame .botClientData ().setBuffer (liveData );
40
40
liveClientData .setBuffer (liveData );
41
41
this .liveData = liveData ;
42
42
botThread = null ;
@@ -76,7 +76,7 @@ void onFrame() {
76
76
if (configuration .getAsync ()) {
77
77
configuration .log ("Main: onFrame asynchronous start" );
78
78
long startNanos = System .nanoTime ();
79
- long endNanos = startNanos + configuration .getMaxFrameDurationMs () * 1000000 ;
79
+ long endNanos = startNanos + ( long ) configuration .getMaxFrameDurationMs () * 1000000 ;
80
80
if (botThread == null ) {
81
81
configuration .log ("Main: Starting bot thread" );
82
82
botThread = createBotThread ();
@@ -94,7 +94,7 @@ void onFrame() {
94
94
try {
95
95
if (frameBuffer .empty ()) {
96
96
configuration .log ("Main: Putting bot on live data" );
97
- botGame .clientData ().setBuffer (liveData );
97
+ botGame .botClientData ().setBuffer (liveData );
98
98
setUnsafeReadReady (true );
99
99
} else {
100
100
setUnsafeReadReady (false );
@@ -125,7 +125,7 @@ void onFrame() {
125
125
// so there's no guarantee of safety here.
126
126
if (configuration .getAsyncUnsafe () && frameBuffer .size () == 1 ) {
127
127
configuration .log ("Main: Weaning bot off live data" );
128
- botGame .clientData ().setBuffer (frameBuffer .peek ());
128
+ botGame .botClientData ().setBuffer (frameBuffer .peek ());
129
129
}
130
130
131
131
// Make bot exceptions fall through to the main thread.
@@ -209,7 +209,7 @@ private Thread createBotThread() {
209
209
// TODO: Maybe we should point it at live data from here?
210
210
} else {
211
211
configuration .log ("Bot: Peeking next frame from buffer" );
212
- botGame .clientData ().setBuffer (frameBuffer .peek ());
212
+ botGame .botClientData ().setBuffer (frameBuffer .peek ());
213
213
}
214
214
215
215
configuration .log ("Bot: Handling events on frame #" + botGame .getFrameCount ());
@@ -235,22 +235,22 @@ private Thread createBotThread() {
235
235
}
236
236
237
237
private void handleEvents () {
238
- ClientData .GameData gameData = botGame .clientData ().gameData ();
238
+ ClientData .GameData botGameData = botGame .botClientData ().gameData ();
239
239
240
240
// Populate gameOver before invoking event handlers (in case the bot throws)
241
- for (int i = 0 ; i < gameData .getEventCount (); i ++) {
242
- gameOver = gameOver || gameData .getEvents (i ).getType () == EventType .MatchEnd ;
241
+ for (int i = 0 ; i < botGameData .getEventCount (); i ++) {
242
+ gameOver = gameOver || botGameData .getEvents (i ).getType () == EventType .MatchEnd ;
243
243
}
244
244
245
245
if (configuration .getAsync ()) {
246
246
performanceMetrics .getFramesBehind ().record (Math .max (1 , frameBuffer .framesBuffered ()) - 1 );
247
247
}
248
248
249
249
performanceMetrics .getBotResponse ().timeIf (
250
- ! gameOver && (gameData .getFrameCount () > 0 || ! configuration .getUnlimitedFrameZero ()),
250
+ ! gameOver && (botGameData .getFrameCount () > 0 || ! configuration .getUnlimitedFrameZero ()),
251
251
() -> {
252
- for (int i = 0 ; i < gameData .getEventCount (); i ++) {
253
- EventHandler .operation (eventListener , botGame , gameData .getEvents (i ));
252
+ for (int i = 0 ; i < botGameData .getEventCount (); i ++) {
253
+ EventHandler .operation (eventListener , botGame , botGameData .getEvents (i ));
254
254
}
255
255
});
256
256
}
0 commit comments