* In the event that this function returns false, there are two cases to consider:
* 1. You own the unit. This means the unit is dead.
- * 2. Another player owns the unit. This could either mean that you don't have access
+ * 2. Another player owns the unit. This could either runningTotal that you don't have access
* to the unit or that the unit has died. You can specifically identify dead units
* by polling onUnitDestroy.
* @see #isVisible
diff --git a/src/main/java/bwapi/UnitCommand.java b/src/main/java/bwapi/UnitCommand.java
index f0c67d8..4752d23 100644
--- a/src/main/java/bwapi/UnitCommand.java
+++ b/src/main/java/bwapi/UnitCommand.java
@@ -6,7 +6,7 @@
import static bwapi.TechType.*;
import static bwapi.UnitCommandType.*;
-public class UnitCommand {
+public final class UnitCommand {
Unit unit;
UnitCommandType type;
Unit target = null;
diff --git a/src/main/java/bwapi/WrappedBuffer.java b/src/main/java/bwapi/WrappedBuffer.java
index 8db1dfc..fa9fe80 100644
--- a/src/main/java/bwapi/WrappedBuffer.java
+++ b/src/main/java/bwapi/WrappedBuffer.java
@@ -3,7 +3,6 @@
import com.sun.jna.Pointer;
import sun.misc.Unsafe;
-import java.lang.reflect.Field;
import java.nio.ByteBuffer;
/**
@@ -13,19 +12,7 @@ class WrappedBuffer {
private final ByteBuffer buffer;
private final long address;
- private static Unsafe unsafe;
-
- static {
- try {
- final Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
- theUnsafe.setAccessible(true);
- unsafe = (Unsafe) theUnsafe.get(null);
-
- } catch (final Exception e) {
- e.printStackTrace();
- System.exit(-1);
- }
- }
+ private static final Unsafe unsafe = UnsafeTools.getUnsafe();
WrappedBuffer(final int size) {
buffer = ByteBuffer.allocateDirect(size);
@@ -94,4 +81,8 @@ void putString(final int offset, final int maxLen, final String string) {
ByteBuffer getBuffer() {
return buffer;
}
+
+ long getAddress() {
+ return address;
+ }
}
diff --git a/src/test/java/DumpToClient.java b/src/test/java/DumpToClient.java
index acabc72..16ef449 100644
--- a/src/test/java/DumpToClient.java
+++ b/src/test/java/DumpToClient.java
@@ -14,7 +14,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-public class DumpToClient {
+class DumpToClient {
private static final Pattern VAR_DECL = Pattern.compile(
"^\\s+(\\d+) \\| +((?:struct )?BWAPI[^:]*::)?(\\S[^\\[]+)\\s([\\[0-9\\]]+)?\\s?(\\S+)$");
@@ -92,16 +92,27 @@ public static void main(String[] args) throws IOException {
out.println("package bwapi;");
out.println("");
out.println("final class ClientData {");
- out.println(" final WrappedBuffer buffer;");
- out.println("");
- out.println(" ClientData(final WrappedBuffer buffer) {");
- out.println(" this.buffer = buffer;");
+ out.println(" private WrappedBuffer buffer;");
+ out.println(" private GameData gameData;");
+ out.println(" ClientData() {");
+ out.println(" gameData = new ClientData.GameData(0);");
+ out.println(" }");
+ out.println(" GameData gameData() {");
+ out.println(" return gameData;");
+ out.println(" }");
+ out.println(" void setBuffer(WrappedBuffer buffer) {");
+ out.println(" this.buffer = buffer;");
out.println(" }");
+ out.println(" void setPointer(Pointer pointer) {");
+ out.println(" setBuffer(new WrappedBuffer(pointer, GameData.SIZE));");
+ out.println(" }");
+ out.println("");
+
structs.values().forEach(s -> {
out.printf(" class %s {\n", s.name);
out.printf(" static final int SIZE = %d;\n", s.size);
out.println(" private int myOffset;");
- out.printf(" public %s(int myOffset) {\n", s.name);
+ out.printf(" %s(int myOffset) {\n", s.name);
out.println(" this.myOffset = myOffset;");
out.println(" }");
s.variables.forEach(v -> {
@@ -265,7 +276,7 @@ public static void main(String[] args) throws IOException {
StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
}
- public enum Type {
+ enum Type {
STRUCT,
BOOLEAN,
INT,
@@ -276,7 +287,7 @@ public enum Type {
ENUM
}
- public static class Variable {
+ static class Variable {
private final String name;
private final Type type;
@@ -285,19 +296,19 @@ public static class Variable {
private String enumName;
private List