@@ -29,6 +29,7 @@ of this software and associated documentation files (the "Software"), to deal
2929import bwapi .ClientData .GameData ;
3030import bwapi .ClientData .Shape ;
3131import com .sun .jna .Native ;
32+ import com .sun .jna .Pointer ;
3233import com .sun .jna .platform .win32 .Kernel32 ;
3334import com .sun .jna .win32 .W32APIOptions ;
3435
@@ -57,7 +58,7 @@ public interface EventHandler {
5758 private ClientData .GameData gameData ;
5859 private boolean connected = false ;
5960 private RandomAccessFile pipeObjectHandle = null ;
60- private ByteBuffer mapFileHandle = null ;
61+ private WrappedBuffer mapFileHandle = null ;
6162 private ByteBuffer gameTableFileHandle = null ;
6263
6364 private boolean debugConnection = false ;
@@ -69,8 +70,8 @@ public interface EventHandler {
6970 /**
7071 * For test purposes only
7172 */
72- Client (ByteBuffer buffer ) {
73- clientData = new ClientData (buffer );
73+ Client (final WrappedBuffer memory ) {
74+ clientData = new ClientData (memory );
7475 gameData = clientData .new GameData (0 );
7576 }
7677
@@ -130,7 +131,6 @@ boolean connect() {
130131 gameTableFileHandle = Kernel32 .INSTANCE .MapViewOfFile (
131132 MappingKernel .INSTANCE .OpenFileMapping (READ_WRITE , false , "Local\\ bwapi_shared_memory_game_list" ), READ_WRITE , 0 , 0 , GameTable .SIZE )
132133 .getByteBuffer (0 , GameTable .SIZE );
133- gameTableFileHandle .order (ByteOrder .LITTLE_ENDIAN );
134134 }
135135 catch (Exception e ) {
136136 System .err .println ("Game table mapping not found." );
@@ -186,9 +186,10 @@ boolean connect() {
186186 System .out .println ("Connected" );
187187
188188 try {
189- mapFileHandle = Kernel32 .INSTANCE .MapViewOfFile (MappingKernel .INSTANCE
189+ final Pointer mapFileView = Kernel32 .INSTANCE .MapViewOfFile (MappingKernel .INSTANCE
190190 .OpenFileMapping (READ_WRITE , false , sharedMemoryName ), READ_WRITE ,
191- 0 , 0 , GameData .SIZE ).getByteBuffer (0 , GameData .SIZE );
191+ 0 , 0 , GameData .SIZE );
192+ mapFileHandle = new WrappedBuffer (mapFileView , GameData .SIZE );
192193 }
193194 catch (Exception e ) {
194195 System .err .println ("Unable to open shared memory mapping: " + sharedMemoryName );
0 commit comments