Skip to content

Commit 00b1266

Browse files
committed
Fixed use case of copying frames via ByteBuffer API
1 parent 4bbef45 commit 00b1266

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/main/java/bwapi/FrameBuffer.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,6 @@ && tryMemcpyBuffer(source, destination, STRINGSHAPES_END, UNITFINDER_START - STR
219219
// There's no specific case where we expect to fail above,
220220
// but this is a safe fallback regardless,
221221
// and serves to document the known-good (and cross-platform, for BWAPI 5) way to executing the copy.
222-
223-
// TODO: This part was written for ByteBuffer.
224-
// Adapt it for WrappedBuffer
225-
/*
226-
source.rewind();
227-
destination.rewind();
228-
destination.put(liveData);
229-
*/
222+
destination.copyFrom(source);
230223
}
231224
}

src/main/java/bwapi/WrappedBuffer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ class WrappedBuffer {
3737
this.address = Pointer.nativeValue(pointer);
3838
}
3939

40+
void copyFrom(WrappedBuffer source) {
41+
source.buffer.rewind();
42+
buffer.rewind();
43+
buffer.put(source.buffer);
44+
}
45+
4046
byte getByte(final int offset) {
4147
return unsafe.getByte(address + offset);
4248
}

0 commit comments

Comments
 (0)