bwapi4 almost done

This commit is contained in:
vjurenka 2015-02-09 16:58:08 +01:00
parent dc4e7bc97d
commit 288d6b6c75
68 changed files with 1912 additions and 1079 deletions

View file

@ -1,136 +1,130 @@
package bwapi4; package bwapi4;
import bwapi4.*; import bwapi4.BWEventListener;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
/**
* This class receives all events from Broodwar.
* To process them, receive an AIModule's instance from {@link Mirror} and call {@link #setEventListener(bwapi.BWEventListener)}
* to set you own {@link BWEventListener listener}.
* There's also a stub class ({@link DefaultBWListener}) provided, so you don't have to implement all of the methods.
*/
public class AIModule { public class AIModule {
AIModule(){}
private BWEventListener eventListener;
public void setEventListener(BWEventListener eventListener) {
this.eventListener = eventListener;
}
public void onStart() { public void onStart() {
onStart_native(pointer); if (eventListener != null) {
eventListener.onStart();
}
} }
public void onEnd(boolean isWinner) { public void onEnd(boolean isWinner) {
onEnd_native(pointer, isWinner); if (eventListener != null) {
eventListener.onEnd(isWinner);
}
} }
public void onFrame() { public void onFrame() {
onFrame_native(pointer); if (eventListener != null) {
eventListener.onFrame();
}
} }
public void onSendText(String text) { public void onSendText(String text) {
onSendText_native(pointer, text); if (eventListener != null)
{
eventListener.onSendText(text);
}
} }
public void onReceiveText(Player player, String text) { public void onReceiveText(Player player, String text) {
onReceiveText_native(pointer, player, text); if (eventListener != null) {
eventListener.onReceiveText(player, text);
}
} }
public void onPlayerLeft(Player player) { public void onPlayerLeft(Player player) {
onPlayerLeft_native(pointer, player); if (eventListener != null) {
eventListener.onPlayerLeft(player);
}
} }
public void onNukeDetect(Position target) { public void onNukeDetect(Position target) {
onNukeDetect_native(pointer, target); if (eventListener != null) {
eventListener.onNukeDetect(target);
}
} }
public void onUnitDiscover(Unit unit) { public void onUnitDiscover(Unit unit) {
onUnitDiscover_native(pointer, unit); if (eventListener != null) {
eventListener.onUnitDiscover(unit);
}
} }
public void onUnitEvade(Unit unit) { public void onUnitEvade(Unit unit) {
onUnitEvade_native(pointer, unit); if (eventListener != null) {
eventListener.onUnitEvade(unit);
}
} }
public void onUnitShow(Unit unit) { public void onUnitShow(Unit unit) {
onUnitShow_native(pointer, unit); if (eventListener != null) {
eventListener.onUnitShow(unit);
}
} }
public void onUnitHide(Unit unit) { public void onUnitHide(Unit unit) {
onUnitHide_native(pointer, unit); if (eventListener != null) {
eventListener.onUnitHide(unit);
}
} }
public void onUnitCreate(Unit unit) { public void onUnitCreate(Unit unit) {
onUnitCreate_native(pointer, unit); if (eventListener != null) {
eventListener.onUnitCreate(unit);
}
} }
public void onUnitDestroy(Unit unit) { public void onUnitDestroy(Unit unit) {
onUnitDestroy_native(pointer, unit); if (eventListener != null) {
eventListener.onUnitDestroy(unit);
}
} }
public void onUnitMorph(Unit unit) { public void onUnitMorph(Unit unit) {
onUnitMorph_native(pointer, unit); if (eventListener != null) {
eventListener.onUnitMorph(unit);
}
} }
public void onUnitRenegade(Unit unit) { public void onUnitRenegade(Unit unit) {
onUnitRenegade_native(pointer, unit); if (eventListener != null) {
eventListener.onUnitRenegade(unit);
}
} }
public void onSaveGame(String gameName) { public void onSaveGame(String gameName) {
onSaveGame_native(pointer, gameName); if (eventListener != null) {
eventListener.onSaveGame(gameName);
}
} }
public void onUnitComplete(Unit unit) { public void onUnitComplete(Unit unit) {
onUnitComplete_native(pointer, unit); if (eventListener != null) {
} eventListener.onUnitComplete(unit);
private static Map<Long, AIModule> instances = new HashMap<Long, AIModule>();
private AIModule(long pointer) {
this.pointer = pointer;
}
private static AIModule get(long pointer) {
if (pointer == 0 ) {
return null;
} }
AIModule instance = instances.get(pointer);
if (instance == null ) {
instance = new AIModule(pointer);
instances.put(pointer, instance);
}
return instance;
} }
private long pointer; public void onPlayerDropped(Player player) {
if (eventListener != null) {
private native void onStart_native(long pointer); eventListener.onPlayerDropped(player);
}
private native void onEnd_native(long pointer, boolean isWinner); }
private native void onFrame_native(long pointer);
private native void onSendText_native(long pointer, String text);
private native void onReceiveText_native(long pointer, Player player, String text);
private native void onPlayerLeft_native(long pointer, Player player);
private native void onNukeDetect_native(long pointer, Position target);
private native void onUnitDiscover_native(long pointer, Unit unit);
private native void onUnitEvade_native(long pointer, Unit unit);
private native void onUnitShow_native(long pointer, Unit unit);
private native void onUnitHide_native(long pointer, Unit unit);
private native void onUnitCreate_native(long pointer, Unit unit);
private native void onUnitDestroy_native(long pointer, Unit unit);
private native void onUnitMorph_native(long pointer, Unit unit);
private native void onUnitRenegade_native(long pointer, Unit unit);
private native void onSaveGame_native(long pointer, String gameName);
private native void onUnitComplete_native(long pointer, Unit unit);
} }

View file

@ -0,0 +1,53 @@
package bwapi4;
import bwapi4.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
/**
* Implement this interface and call {@link AIModule#setEventListener(bwapi.BWEventListener)} to receive all of the in game events.
*/
public interface BWEventListener {
public void onStart();
public void onEnd(boolean isWinner);
public void onFrame();
public void onSendText(String text);
public void onReceiveText(Player player, String text);
public void onPlayerLeft(Player player);
public void onNukeDetect(Position target);
public void onUnitDiscover(Unit unit);
public void onUnitEvade(Unit unit);
public void onUnitShow(Unit unit);
public void onUnitHide(Unit unit);
public void onUnitCreate(Unit unit);
public void onUnitDestroy(Unit unit);
public void onUnitMorph(Unit unit);
public void onUnitRenegade(Unit unit);
public void onSaveGame(String gameName);
public void onUnitComplete(Unit unit);
public void onPlayerDropped(Player player);
}

View file

@ -1,24 +1,28 @@
package bwapi4; package bwapi4;
import bwapi4.*; import java.lang.Override;
import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Collection; import java.util.Map;
import java.util.List;
/**
* Starcraft uses a 256 color palette to render everything,
* so the colors available for draw shapes using BWAPI is limited to the colors available in the <a href="http://bwapi.googlecode.com/svn/wiki/colorPalette.gif" target="_blank">Pallete</a>.
* Several predefined colors from the pallete are provided.
*/
public class Color { public class Color {
public int red() { private int r, g, b;
return red_native(pointer);
}
public int green() { /**
return green_native(pointer); * Create a color using the color in the palette that is closest to the RGB color specified. This will check a number of colors in the pallet to see which is closest to the specified color so this function is relatively slow.
} * @param r
* @param g
public int blue() { * @param b
return blue_native(pointer); */
public Color(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
} }
public static Color Red; public static Color Red;
@ -45,32 +49,25 @@ public class Color {
public static Color Grey; public static Color Grey;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Color)) return false;
private static Map<Long, Color> instances = new HashMap<Long, Color>(); Color color = (Color) o;
private Color(long pointer) { if (b != color.b) return false;
this.pointer = pointer; if (g != color.g) return false;
if (r != color.r) return false;
return true;
} }
private static Color get(long pointer) { @Override
if (pointer == 0 ) { public int hashCode() {
return null; int result = r;
} result = 31 * result + g;
Color instance = instances.get(pointer); result = 31 * result + b;
if (instance == null ) { return result;
instance = new Color(pointer);
instances.put(pointer, instance);
}
return instance;
} }
private long pointer;
private native int red_native(long pointer);
private native int green_native(long pointer);
private native int blue_native(long pointer);
} }

View file

@ -0,0 +1,103 @@
package bwapi4;
import bwapi4.BWEventListener;
import bwapi4.Player;
import bwapi4.Position;
import bwapi4.Unit;
/**
* A utility stub class providing a default implementation of {@link BWEventListener},
* override it's methods if you want to handle only some events.
*/
public class DefaultBWListener implements BWEventListener {
@Override
public void onStart() {
}
@Override
public void onEnd(boolean b) {
}
@Override
public void onFrame() {
}
@Override
public void onSendText(String s) {
}
@Override
public void onReceiveText(Player player, String s) {
}
@Override
public void onPlayerLeft(Player player) {
}
@Override
public void onNukeDetect(Position position) {
}
@Override
public void onUnitDiscover(Unit unit) {
}
@Override
public void onUnitEvade(Unit unit) {
}
@Override
public void onUnitShow(Unit unit) {
}
@Override
public void onUnitHide(Unit unit) {
}
@Override
public void onUnitCreate(Unit unit) {
}
@Override
public void onUnitDestroy(Unit unit) {
}
@Override
public void onUnitMorph(Unit unit) {
}
@Override
public void onUnitRenegade(Unit unit) {
}
@Override
public void onSaveGame(String s) {
}
@Override
public void onUnitComplete(Unit unit) {
}
@Override
public void onPlayerDropped(Player player) {
}
}

View file

@ -377,26 +377,14 @@ public class Game {
printf_native(pointer, cstr_format); printf_native(pointer, cstr_format);
} }
public void vPrintf(String cstr_format, Object ... args) {
vPrintf_native(pointer, cstr_format, args);
}
public void sendText(String cstr_format) { public void sendText(String cstr_format) {
sendText_native(pointer, cstr_format); sendText_native(pointer, cstr_format);
} }
public void vSendText(String cstr_format, Object ... args) {
vSendText_native(pointer, cstr_format, args);
}
public void sendTextEx(boolean toAllies, String cstr_format) { public void sendTextEx(boolean toAllies, String cstr_format) {
sendTextEx_native(pointer, toAllies, cstr_format); sendTextEx_native(pointer, toAllies, cstr_format);
} }
public void vSendTextEx(boolean toAllies, String cstr_format, Object ... args) {
vSendTextEx_native(pointer, toAllies, cstr_format, args);
}
public boolean isInGame() { public boolean isInGame() {
return isInGame_native(pointer); return isInGame_native(pointer);
} }
@ -477,10 +465,6 @@ public class Game {
setTextSize_native(pointer, size); setTextSize_native(pointer, size);
} }
public void vDrawText(bwapi4.CoordinateType.Enum ctype, int x, int y, String cstr_format, Object ... arg) {
vDrawText_native(pointer, ctype, x, y, cstr_format, arg);
}
public void drawText(bwapi4.CoordinateType.Enum ctype, int x, int y, String cstr_format) { public void drawText(bwapi4.CoordinateType.Enum ctype, int x, int y, String cstr_format) {
drawText_native(pointer, ctype, x, y, cstr_format); drawText_native(pointer, ctype, x, y, cstr_format);
} }
@ -1142,16 +1126,10 @@ public class Game {
private native void printf_native(long pointer, String cstr_format); private native void printf_native(long pointer, String cstr_format);
private native void vPrintf_native(long pointer, String cstr_format, Object ... args);
private native void sendText_native(long pointer, String cstr_format); private native void sendText_native(long pointer, String cstr_format);
private native void vSendText_native(long pointer, String cstr_format, Object ... args);
private native void sendTextEx_native(long pointer, boolean toAllies, String cstr_format); private native void sendTextEx_native(long pointer, boolean toAllies, String cstr_format);
private native void vSendTextEx_native(long pointer, boolean toAllies, String cstr_format, Object ... args);
private native boolean isInGame_native(long pointer); private native boolean isInGame_native(long pointer);
private native boolean isMultiplayer_native(long pointer); private native boolean isMultiplayer_native(long pointer);
@ -1192,8 +1170,6 @@ public class Game {
private native void setTextSize_native(long pointer, bwapi4.Text.Size.Enum size); private native void setTextSize_native(long pointer, bwapi4.Text.Size.Enum size);
private native void vDrawText_native(long pointer, bwapi4.CoordinateType.Enum ctype, int x, int y, String cstr_format, Object ... arg);
private native void drawText_native(long pointer, bwapi4.CoordinateType.Enum ctype, int x, int y, String cstr_format); private native void drawText_native(long pointer, bwapi4.CoordinateType.Enum ctype, int x, int y, String cstr_format);
private native void drawTextMap_native(long pointer, int x, int y, String cstr_format); private native void drawTextMap_native(long pointer, int x, int y, String cstr_format);

262
bwapi4/Mirror.java Normal file
View file

@ -0,0 +1,262 @@
package bwapi4;
import bwapi4.AIModule;
import bwapi4.BWEventListener;
import java.io.*;
import java.io.File;
import java.lang.Exception;
import java.lang.UnsupportedOperationException;
import java.util.*;
import java.util.zip.*;
/**
* <p>The API entry point. Standard use case:</p>
* <ul>
* <li>Create a Mirror object and use {@link #getModule()} and then set an {@link AIModule}'s {@link BWEventListener}<br/>
* <li>Call {@link #startGame()} to init the API and connect to Broodwar, then launch Broodwar from ChaosLauncher.</li>
* <li>In you {@link BWEventListener#onStart()} method, receive the Game object by calling {@link #getGame()}</li>
* </ul>
* <br/>
* <b>Example</b>
* <pre>
* {@code
*
* mirror.getModule().setEventListener(new DefaultBWListener()
* {
* public void onStart() {
* game = mirror.getGame();
* self = game.self();
* //initialization
* ....
* }
*
* public void onUpdate() {
* for (Unit myUnit : self.getUnits()) {
* //give orders to unit
* ...
* }
* }
* });
* }
* mirror.startGame();
* </pre>
* <p><b>Note:</b> The Game object is initialized during the {@link #startGame()} as well as other BWMirror API's constants.
* Do not use any API releated methods/fields prior to {@link #startGame()}.</p>
*/
public class Mirror {
private Game game;
private AIModule module = new AIModule();
private FrameCallback frameCallback;
private static final boolean EXTRACT_JAR = true;
private static final String VERSION = "2_0";
static {
String arch = System.getProperty("os.arch");
String dllNames[] = {"bwapi_bridge" + VERSION, "gmp-vc90-mt", "mpfr-vc90-mt"};
if(!arch.equals("x86")){
throw new UnsupportedOperationException("BWMirror API supports only x86 architecture.");
}
try {
if (EXTRACT_JAR) {
System.setProperty("java.library.path", ".");
java.lang.reflect.Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
fieldSysPath.setAccessible(true);
fieldSysPath.set(null, null);
String path = Mirror.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = java.net.URLDecoder.decode(path, "UTF-8");
for (String dllName : dllNames) {
String dllNameExt = dllName + ".dll";
if (!new File(dllNameExt).exists()) {
JarResources jar = new JarResources(path);
byte[] correctDllData = jar.getResource(dllNameExt);
FileOutputStream funnyStream = new FileOutputStream(dllNameExt);
funnyStream.write(correctDllData);
funnyStream.close();
}
}
}
} catch (Exception e) {
System.err.println("Failed to extract native libraries.\n" + e);
}
System.loadLibrary(dllNames[0]);
File dataDir = new File("bwapi-data/BWTA");
if(!dataDir.exists()){
try {
dataDir.mkdirs();
} catch (Exception e) {
System.err.println("Unable to create /bwapi-data/BWTA folder, BWTA analysis will not be saved.");
}
}
}
public Game getGame() {
return game;
}
public AIModule getModule() {
return module;
}
/**
* Starts the API, initializes all constants ( {@link UnitType}, {@link WeaponType} ) and the {@link Game} object.
* This method blocks until the end of game.
*/
public native void startGame();
private void update() {
if (frameCallback != null) {
frameCallback.update();
}
}
/*public void setFrameCallback(bwapi.Mirror.FrameCallback frameCallback) {
this.frameCallback = frameCallback;
} */
/**
* The simplest interface to receive update event from Broodwar. The {@link #update()} method is called once each frame.
* For a simple bot and implementation of this interface is enough, to receive all in game events, implement {@link BWEventListener}.
*/
/*public*/ private interface FrameCallback {
public void update();
}
@SuppressWarnings({"unchecked"})
private static class JarResources {
// external debug flag
public boolean debugOn = false;
// jar resource mapping tables
private Hashtable htSizes = new Hashtable();
private Hashtable htJarContents = new Hashtable();
// a jar file
private String jarFileName;
/**
* creates a javabot.JarResources. It extracts all resources from a Jar
* into an internal hashtable, keyed by resource names.
*
* @param jarFileName a jar or zip file
*/
public JarResources(String jarFileName) {
this.jarFileName = jarFileName;
init();
}
/**
* Extracts a jar resource as a blob.
*
* @param name a resource name.
*/
public byte[] getResource(String name) {
return (byte[]) htJarContents.get(name);
}
/**
* initializes internal hash tables with Jar file resources.
*/
private void init() {
try {
// extracts just sizes only.
ZipFile zf = new ZipFile(jarFileName);
Enumeration e = zf.entries();
while (e.hasMoreElements()) {
ZipEntry ze = (ZipEntry) e.nextElement();
if (debugOn) {
System.out.println(dumpZipEntry(ze));
}
htSizes.put(ze.getName(), new Integer((int) ze.getSize()));
}
zf.close();
// extract resources and put them into the hashtable.
FileInputStream fis = new FileInputStream(jarFileName);
BufferedInputStream bis = new BufferedInputStream(fis);
ZipInputStream zis = new ZipInputStream(bis);
ZipEntry ze = null;
while ((ze = zis.getNextEntry()) != null) {
if (ze.isDirectory()) {
continue;
}
if (debugOn) {
System.out.println(
"ze.getName()=" + ze.getName() + "," + "getSize()=" + ze.getSize()
);
}
int size = (int) ze.getSize();
// -1 means unknown size.
if (size == -1) {
size = ((Integer) htSizes.get(ze.getName())).intValue();
}
byte[] b = new byte[(int) size];
int rb = 0;
int chunk = 0;
while (((int) size - rb) > 0) {
chunk = zis.read(b, rb, (int) size - rb);
if (chunk == -1) {
break;
}
rb += chunk;
}
// add to internal resource hashtable
htJarContents.put(ze.getName(), b);
if (debugOn) {
System.out.println(
ze.getName() + " rb=" + rb +
",size=" + size +
",csize=" + ze.getCompressedSize()
);
}
}
} catch (NullPointerException e) {
System.out.println("done.");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Dumps a zip entry into a string.
*
* @param ze a ZipEntry
*/
private String dumpZipEntry(ZipEntry ze) {
StringBuffer sb = new StringBuffer();
if (ze.isDirectory()) {
sb.append("d ");
} else {
sb.append("f ");
}
if (ze.getMethod() == ZipEntry.STORED) {
sb.append("stored ");
} else {
sb.append("defalted ");
}
sb.append(ze.getName());
sb.append("\t");
sb.append("" + ze.getSize());
if (ze.getMethod() == ZipEntry.DEFLATED) {
sb.append("/" + ze.getCompressedSize());
}
return (sb.toString());
}
}
}

View file

@ -30,8 +30,6 @@ public class Position extends AbstractPoint<Position>{
public native double getLength(); public native double getLength();
public native boolean hasPath(Position position);
public int getX() { public int getX() {
return x; return x;
} }

View file

@ -1,58 +1,55 @@
package bwapi4; package bwapi4;
import bwapi4.*; import java.lang.IllegalArgumentException;
import java.lang.Object;
import java.util.Map; import java.lang.Override;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
public class PositionOrUnit { public class PositionOrUnit {
public boolean isUnit() { private Unit unit;
return isUnit_native(pointer);
private Position position;
public PositionOrUnit(Unit unit){
if(unit == null){
throw new IllegalArgumentException("PositionOrUnit must not reference null!");
};
this.unit = unit;
} }
public Unit getUnit() { public PositionOrUnit(Position position){
return getUnit_native(pointer); if(position == null){
throw new IllegalArgumentException("PositionOrUnit must not reference null!");
};
this.position = position;
} }
public boolean isPosition() { public Unit getUnit(){
return isPosition_native(pointer); return unit;
} }
public Position getPosition() { public Position getPosition() {
return getPosition_native(pointer); return position;
} }
public boolean isUnit(){
private static Map<Long, PositionOrUnit> instances = new HashMap<Long, PositionOrUnit>(); return unit != null;
private PositionOrUnit(long pointer) {
this.pointer = pointer;
} }
private static PositionOrUnit get(long pointer) { public boolean isPosition(){
if (pointer == 0 ) { return position != null;
return null;
}
PositionOrUnit instance = instances.get(pointer);
if (instance == null ) {
instance = new PositionOrUnit(pointer);
instances.put(pointer, instance);
}
return instance;
} }
private long pointer; @Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PositionOrUnit)) return false;
private native boolean isUnit_native(long pointer); PositionOrUnit that = (PositionOrUnit) o;
private native Unit getUnit_native(long pointer); if (position != null ? !position.equals(that.position) : that.position != null) return false;
if (unit != null ? !unit.equals(that.unit) : that.unit != null) return false;
private native boolean isPosition_native(long pointer); return true;
}
private native Position getPosition_native(long pointer); }
}

View file

@ -9,7 +9,7 @@ import java.util.Map;
* These are called build tiles because buildability data is available at this resolution, and correspond to the tiles seen in game. * These are called build tiles because buildability data is available at this resolution, and correspond to the tiles seen in game.
* For example, a Command Center occupies an area of 4x3 build tiles. * For example, a Command Center occupies an area of 4x3 build tiles.
*/ */
public class TilePosition { public class TilePosition extends AbstractPoint<TilePosition>{
private int x, y; private int x, y;
public TilePosition(int x, int y) { public TilePosition(int x, int y) {
@ -21,8 +21,6 @@ public class TilePosition {
return "[" + x + ", " + y + "]"; return "[" + x + ", " + y + "]";
} }
public native boolean hasPath(TilePosition position);
public native boolean isValid(); public native boolean isValid();
public native TilePosition makeValid(); public native TilePosition makeValid();
@ -82,4 +80,8 @@ public class TilePosition {
result = 31 * result + y; result = 31 * result + y;
return result; return result;
} }
public TilePosition getPoint(){
return this;
}
} }

View file

@ -25,18 +25,6 @@ public class Unitset {
return getLarva_native(pointer); return getLarva_native(pointer);
} }
public void setClientInfo(int clientInfo) {
setClientInfo_native(pointer, clientInfo);
}
public void setClientInfo() {
setClientInfo_native(pointer);
}
public void setClientInfo(int clientInfo, int index) {
setClientInfo_native(pointer, clientInfo, index);
}
public List<Unit> getUnitsInRadius(int radius, UnitFilter pred) { public List<Unit> getUnitsInRadius(int radius, UnitFilter pred) {
return getUnitsInRadius_native(pointer, radius, pred); return getUnitsInRadius_native(pointer, radius, pred);
} }
@ -278,12 +266,6 @@ public class Unitset {
private native List<Unit> getLarva_native(long pointer); private native List<Unit> getLarva_native(long pointer);
private native void setClientInfo_native(long pointer, int clientInfo);
private native void setClientInfo_native(long pointer);
private native void setClientInfo_native(long pointer, int clientInfo, int index);
private native List<Unit> getUnitsInRadius_native(long pointer, int radius, UnitFilter pred); private native List<Unit> getUnitsInRadius_native(long pointer, int radius, UnitFilter pred);
private native Unit getClosestUnit_native(long pointer, UnitFilter pred); private native Unit getClosestUnit_native(long pointer, UnitFilter pred);

52
bwapi4/Utils.java Normal file
View file

@ -0,0 +1,52 @@
package bwapi4;
import java.lang.String;
import java.lang.System;
/**
*
*/
public class Utils {
public static final byte Previous = 0x01;
public static final byte Cyan = 0x02;
public static final byte Yellow = 0x03;
public static final byte White = 0x04;
public static final byte Grey = 0x05;
public static final byte Red = 0x06;
public static final byte Green = 0x07;
public static final byte Red_P1 = 0x08;
public static final byte Tab = 0x09;
public static final byte Newline = 0x0A;
public static final byte Invisible_no_override = 0x0B;
public static final byte Remove_beyond = 0x0C;
public static final byte Clear_formatting = 0x0D;
public static final byte Blue = 0x0E;
public static final byte Teal = 0x0F;
public static final byte Purple = 0x10;
public static final byte Orange = 0x11;
public static final byte Right_Align = 0x12;
public static final byte Center_Align = 0x13;
public static final byte Invisible = 0x14;
public static final byte Brown = 0x15;
public static final byte White_p7 = 0x16;
public static final byte Yellow_p8 = 0x17;
public static final byte Green_p9 = 0x18;
public static final byte Brighter_Yellow = 0x19;
public static final byte Cyan_default = 0x1A;
public static final byte Pinkish = 0x1B;
public static final byte Dark_Cyan = 0x1C;
public static final byte Greygreen = 0x1D;
public static final byte Bluegrey = 0x1E;
public static final byte Turquoise = 0x1F;
public static String formatText(String text, byte format){
byte[] textData = text.getBytes();
int textDataLength = text.length();
byte[] newTextData = new byte[textDataLength + 1];
newTextData[0] = format;
System.arraycopy(textData, 0, newTextData, 1, textDataLength);
return new String(newTextData);
}
}

View file

@ -4,7 +4,7 @@ import java.lang.Override;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class WalkPosition { public class WalkPosition extends AbstractPoint<WalkPosition>{
private int x, y; private int x, y;
@ -27,8 +27,6 @@ public class WalkPosition {
public native double getLength(); public native double getLength();
public native boolean hasPath(WalkPosition position);
public int getX() { public int getX() {
return x; return x;
} }
@ -80,4 +78,8 @@ public class WalkPosition {
} }
private long pointer; private long pointer;
public WalkPosition getPoint(){
return this;
}
} }

View file

@ -1,6 +1,8 @@
#include "../concat_header.h" #include "../concat_header.h"
#include <BWAPI.h> #include <BWAPI.h>
#include <BWAPI/Client.h> #include <BWAPI/Client.h>
#include <thread>
#include <chrono>
#include <jni.h> #include <jni.h>
#include <cstring> #include <cstring>
#include "../BWTA_Result.h" #include "../BWTA_Result.h"
@ -63,86 +65,21 @@ jfieldID FindCachedField(JNIEnv * env, jclass clz, string name, string signature
using namespace BWAPI; using namespace BWAPI;
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onStart_1native(JNIEnv * env, jobject obj, jlong pointer){ PositionOrUnit convertPositionOrUnit(JNIEnv * env, jobject obj){
AIModule* x_aIModule = (AIModule*)pointer; jclass clz = FindCachedClass(env, "PositionOrUnit");
x_aIModule->onStart(); jmethodID typeMethodId = FindCachedMethod(env, clz, "isUnit", "()Z");
} bool isUnit = (bool)env->CallBooleanMethod(obj, typeMethodId);
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onEnd_1native(JNIEnv * env, jobject obj, jlong pointer, jboolean isWinner){ if(isUnit){
AIModule* x_aIModule = (AIModule*)pointer; jobject unitObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, "getUnit", "()Lbwapi4/Unit;"));
x_aIModule->onEnd((bool)isWinner); Unit unit = (Unit)env->GetLongField(unitObj, FindCachedField(env, env->GetObjectClass(unitObj), "unitObj", "J"));
} return PositionOrUnit(unit);
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onFrame_1native(JNIEnv * env, jobject obj, jlong pointer){ }
AIModule* x_aIModule = (AIModule*)pointer; jobject posObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, "getPosition", "()Lbwapi4/Position;"));
x_aIModule->onFrame(); Position position((int)env->GetIntField(posObj, FindCachedField(env, env->GetObjectClass(posObj), "x", "I")), (int)env->GetIntField(posObj, FindCachedField(env, env->GetObjectClass(posObj), "y", "I")));
} return PositionOrUnit(position);
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onSendText_1native(JNIEnv * env, jobject obj, jlong pointer, jstring text){
AIModule* x_aIModule = (AIModule*)pointer;
x_aIModule->onSendText(std::string(env->GetStringUTFChars(text, NULL)));
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onReceiveText_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_player, jstring text){
AIModule* x_aIModule = (AIModule*)pointer;
Player player = (Player)env->GetLongField(p_player, FindCachedField(env, env->GetObjectClass(p_player), "pointer", "J"));
x_aIModule->onReceiveText(player, std::string(env->GetStringUTFChars(text, NULL)));
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onPlayerLeft_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_player){
AIModule* x_aIModule = (AIModule*)pointer;
Player player = (Player)env->GetLongField(p_player, FindCachedField(env, env->GetObjectClass(p_player), "pointer", "J"));
x_aIModule->onPlayerLeft(player);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onNukeDetect_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
AIModule* x_aIModule = (AIModule*)pointer;
Position target((int)env->GetIntField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "x", "I")), (int)env->GetIntField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "y", "I")));
x_aIModule->onNukeDetect(target);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitDiscover_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_unit){
AIModule* x_aIModule = (AIModule*)pointer;
Unit unit = (Unit)env->GetLongField(p_unit, FindCachedField(env, env->GetObjectClass(p_unit), "pointer", "J"));
x_aIModule->onUnitDiscover(unit);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitEvade_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_unit){
AIModule* x_aIModule = (AIModule*)pointer;
Unit unit = (Unit)env->GetLongField(p_unit, FindCachedField(env, env->GetObjectClass(p_unit), "pointer", "J"));
x_aIModule->onUnitEvade(unit);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitShow_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_unit){
AIModule* x_aIModule = (AIModule*)pointer;
Unit unit = (Unit)env->GetLongField(p_unit, FindCachedField(env, env->GetObjectClass(p_unit), "pointer", "J"));
x_aIModule->onUnitShow(unit);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitHide_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_unit){
AIModule* x_aIModule = (AIModule*)pointer;
Unit unit = (Unit)env->GetLongField(p_unit, FindCachedField(env, env->GetObjectClass(p_unit), "pointer", "J"));
x_aIModule->onUnitHide(unit);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitCreate_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_unit){
AIModule* x_aIModule = (AIModule*)pointer;
Unit unit = (Unit)env->GetLongField(p_unit, FindCachedField(env, env->GetObjectClass(p_unit), "pointer", "J"));
x_aIModule->onUnitCreate(unit);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitDestroy_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_unit){
AIModule* x_aIModule = (AIModule*)pointer;
Unit unit = (Unit)env->GetLongField(p_unit, FindCachedField(env, env->GetObjectClass(p_unit), "pointer", "J"));
x_aIModule->onUnitDestroy(unit);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitMorph_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_unit){
AIModule* x_aIModule = (AIModule*)pointer;
Unit unit = (Unit)env->GetLongField(p_unit, FindCachedField(env, env->GetObjectClass(p_unit), "pointer", "J"));
x_aIModule->onUnitMorph(unit);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitRenegade_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_unit){
AIModule* x_aIModule = (AIModule*)pointer;
Unit unit = (Unit)env->GetLongField(p_unit, FindCachedField(env, env->GetObjectClass(p_unit), "pointer", "J"));
x_aIModule->onUnitRenegade(unit);
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onSaveGame_1native(JNIEnv * env, jobject obj, jlong pointer, jstring gameName){
AIModule* x_aIModule = (AIModule*)pointer;
x_aIModule->onSaveGame(std::string(env->GetStringUTFChars(gameName, NULL)));
}
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitComplete_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_unit){
AIModule* x_aIModule = (AIModule*)pointer;
Unit unit = (Unit)env->GetLongField(p_unit, FindCachedField(env, env->GetObjectClass(p_unit), "pointer", "J"));
x_aIModule->onUnitComplete(unit);
} }
JNIEXPORT jint JNICALL Java_bwapi4_Bullet_getID_1native(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jint JNICALL Java_bwapi4_Bullet_getID_1native(JNIEnv * env, jobject obj, jlong pointer){
Bullet x_bullet = (Bullet)pointer; Bullet x_bullet = (Bullet)pointer;
return x_bullet->getID(); return x_bullet->getID();
@ -236,18 +173,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Client_update_1native(JNIEnv * env, jobject o
Client* x_client = (Client*)pointer; Client* x_client = (Client*)pointer;
x_client->update(); x_client->update();
} }
JNIEXPORT jint JNICALL Java_bwapi4_Color_red_1native(JNIEnv * env, jobject obj, jlong pointer){
Color x_color((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "r", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "g", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "b", "I")));
return x_color.red();
}
JNIEXPORT jint JNICALL Java_bwapi4_Color_green_1native(JNIEnv * env, jobject obj, jlong pointer){
Color x_color((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "r", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "g", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "b", "I")));
return x_color.green();
}
JNIEXPORT jint JNICALL Java_bwapi4_Color_blue_1native(JNIEnv * env, jobject obj, jlong pointer){
Color x_color((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "r", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "g", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "b", "I")));
return x_color.blue();
}
JNIEXPORT jobject JNICALL Java_bwapi4_Event_getPosition_1native(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jobject JNICALL Java_bwapi4_Event_getPosition_1native(JNIEnv * env, jobject obj, jlong pointer){
Event* x_evt = (Event*)pointer; Event* x_evt = (Event*)pointer;
Position cresult = x_evt->getPosition(); Position cresult = x_evt->getPosition();
@ -818,7 +743,7 @@ return x_game->isWalkable(walkX, walkY);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isWalkable_1native__JLbwapi4_WalkPosition_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_position){ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isWalkable_1native__JLbwapi4_WalkPosition_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_position){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
WalkPosition position = (WalkPosition)env->GetLongField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "pointer", "J")); WalkPosition position((int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "x", "I")), (int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "y", "I")));
return x_game->isWalkable(position); return x_game->isWalkable(position);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isBuildable_1native__JII(JNIEnv * env, jobject obj, jlong pointer, jint tileX, jint tileY){ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isBuildable_1native__JII(JNIEnv * env, jobject obj, jlong pointer, jint tileX, jint tileY){
@ -995,29 +920,14 @@ JNIEXPORT void JNICALL Java_bwapi4_Game_printf_1native(JNIEnv * env, jobject obj
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
x_game->printf(std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str()); x_game->printf(std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str());
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_vPrintf_1native(JNIEnv * env, jobject obj, jlong pointer, jstring cstr_format, jobject p_...){
Game* x_game = (Game*)pointer;
Object ... = (Object)env->GetLongField(p_..., FindCachedField(env, env->GetObjectClass(p_...), "pointer", "J"));
x_game->vPrintf(std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str(), ...);
}
JNIEXPORT void JNICALL Java_bwapi4_Game_sendText_1native(JNIEnv * env, jobject obj, jlong pointer, jstring cstr_format){ JNIEXPORT void JNICALL Java_bwapi4_Game_sendText_1native(JNIEnv * env, jobject obj, jlong pointer, jstring cstr_format){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
x_game->sendText(std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str()); x_game->sendText(std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str());
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_vSendText_1native(JNIEnv * env, jobject obj, jlong pointer, jstring cstr_format, jobject p_...){
Game* x_game = (Game*)pointer;
Object ... = (Object)env->GetLongField(p_..., FindCachedField(env, env->GetObjectClass(p_...), "pointer", "J"));
x_game->vSendText(std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str(), ...);
}
JNIEXPORT void JNICALL Java_bwapi4_Game_sendTextEx_1native(JNIEnv * env, jobject obj, jlong pointer, jboolean toAllies, jstring cstr_format){ JNIEXPORT void JNICALL Java_bwapi4_Game_sendTextEx_1native(JNIEnv * env, jobject obj, jlong pointer, jboolean toAllies, jstring cstr_format){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
x_game->sendTextEx((bool)toAllies, std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str()); x_game->sendTextEx((bool)toAllies, std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str());
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_vSendTextEx_1native(JNIEnv * env, jobject obj, jlong pointer, jboolean toAllies, jstring cstr_format, jobject p_...){
Game* x_game = (Game*)pointer;
Object ... = (Object)env->GetLongField(p_..., FindCachedField(env, env->GetObjectClass(p_...), "pointer", "J"));
x_game->vSendTextEx((bool)toAllies, std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str(), ...);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isInGame_1native(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isInGame_1native(JNIEnv * env, jobject obj, jlong pointer){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
return x_game->isInGame(); return x_game->isInGame();
@ -1159,18 +1069,12 @@ x_game->setTextSize();
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_setTextSize_1native__JLbwapi4_Text_Size_Enum_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_size){ JNIEXPORT void JNICALL Java_bwapi4_Game_setTextSize_1native__JLbwapi4_Text_Size_Enum_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_size){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.Text.Size.Enum size = (bwapi4.Text.Size.Enum)env->GetLongField(p_size, FindCachedField(env, env->GetObjectClass(p_size), "pointer", "J")); Text::Size::Enum size;
x_game->setTextSize(size); x_game->setTextSize(size);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_vDrawText_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jstring cstr_format, jobject p_...){
Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J"));
Object ... = (Object)env->GetLongField(p_..., FindCachedField(env, env->GetObjectClass(p_...), "pointer", "J"));
x_game->vDrawText(ctype, x, y, std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str(), ...);
}
JNIEXPORT void JNICALL Java_bwapi4_Game_drawText_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jstring cstr_format){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawText_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jstring cstr_format){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
x_game->drawText(ctype, x, y, std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str()); x_game->drawText(ctype, x, y, std::string(env->GetStringUTFChars(cstr_format, NULL)).c_str());
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawTextMap_1native__JIILjava_lang_String_2(JNIEnv * env, jobject obj, jlong pointer, jint x, jint y, jstring cstr_format){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawTextMap_1native__JIILjava_lang_String_2(JNIEnv * env, jobject obj, jlong pointer, jint x, jint y, jstring cstr_format){
@ -1202,13 +1106,13 @@ x_game->drawTextScreen(p, std::string(env->GetStringUTFChars(cstr_format, NULL))
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawBox_1native__JLbwapi4_CoordinateType_Enum_2IIIILbwapi4_Color_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint left, jint top, jint right, jint bottom, jobject p_color){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawBox_1native__JLbwapi4_CoordinateType_Enum_2IIIILbwapi4_Color_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint left, jint top, jint right, jint bottom, jobject p_color){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawBox(ctype, left, top, right, bottom, color); x_game->drawBox(ctype, left, top, right, bottom, color);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawBox_1native__JLbwapi4_CoordinateType_Enum_2IIIILbwapi4_Color_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint left, jint top, jint right, jint bottom, jobject p_color, jboolean isSolid){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawBox_1native__JLbwapi4_CoordinateType_Enum_2IIIILbwapi4_Color_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint left, jint top, jint right, jint bottom, jobject p_color, jboolean isSolid){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawBox(ctype, left, top, right, bottom, color, (bool)isSolid); x_game->drawBox(ctype, left, top, right, bottom, color, (bool)isSolid);
} }
@ -1286,13 +1190,13 @@ x_game->drawBoxScreen(leftTop, rightBottom, color, (bool)isSolid);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawTriangle_1native__JLbwapi4_CoordinateType_Enum_2IIIIIILbwapi4_Color_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint ax, jint ay, jint bx, jint by, jint cx, jint cy, jobject p_color){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawTriangle_1native__JLbwapi4_CoordinateType_Enum_2IIIIIILbwapi4_Color_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint ax, jint ay, jint bx, jint by, jint cx, jint cy, jobject p_color){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawTriangle(ctype, ax, ay, bx, by, cx, cy, color); x_game->drawTriangle(ctype, ax, ay, bx, by, cx, cy, color);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawTriangle_1native__JLbwapi4_CoordinateType_Enum_2IIIIIILbwapi4_Color_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint ax, jint ay, jint bx, jint by, jint cx, jint cy, jobject p_color, jboolean isSolid){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawTriangle_1native__JLbwapi4_CoordinateType_Enum_2IIIIIILbwapi4_Color_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint ax, jint ay, jint bx, jint by, jint cx, jint cy, jobject p_color, jboolean isSolid){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawTriangle(ctype, ax, ay, bx, by, cx, cy, color, (bool)isSolid); x_game->drawTriangle(ctype, ax, ay, bx, by, cx, cy, color, (bool)isSolid);
} }
@ -1376,13 +1280,13 @@ x_game->drawTriangleScreen(a, b, c, color, (bool)isSolid);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawCircle_1native__JLbwapi4_CoordinateType_Enum_2IIILbwapi4_Color_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jint radius, jobject p_color){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawCircle_1native__JLbwapi4_CoordinateType_Enum_2IIILbwapi4_Color_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jint radius, jobject p_color){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawCircle(ctype, x, y, radius, color); x_game->drawCircle(ctype, x, y, radius, color);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawCircle_1native__JLbwapi4_CoordinateType_Enum_2IIILbwapi4_Color_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jint radius, jobject p_color, jboolean isSolid){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawCircle_1native__JLbwapi4_CoordinateType_Enum_2IIILbwapi4_Color_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jint radius, jobject p_color, jboolean isSolid){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawCircle(ctype, x, y, radius, color, (bool)isSolid); x_game->drawCircle(ctype, x, y, radius, color, (bool)isSolid);
} }
@ -1454,13 +1358,13 @@ x_game->drawCircleScreen(p, radius, color, (bool)isSolid);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawEllipse_1native__JLbwapi4_CoordinateType_Enum_2IIIILbwapi4_Color_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jint xrad, jint yrad, jobject p_color){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawEllipse_1native__JLbwapi4_CoordinateType_Enum_2IIIILbwapi4_Color_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jint xrad, jint yrad, jobject p_color){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawEllipse(ctype, x, y, xrad, yrad, color); x_game->drawEllipse(ctype, x, y, xrad, yrad, color);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawEllipse_1native__JLbwapi4_CoordinateType_Enum_2IIIILbwapi4_Color_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jint xrad, jint yrad, jobject p_color, jboolean isSolid){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawEllipse_1native__JLbwapi4_CoordinateType_Enum_2IIIILbwapi4_Color_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jint xrad, jint yrad, jobject p_color, jboolean isSolid){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawEllipse(ctype, x, y, xrad, yrad, color, (bool)isSolid); x_game->drawEllipse(ctype, x, y, xrad, yrad, color, (bool)isSolid);
} }
@ -1532,7 +1436,7 @@ x_game->drawEllipseScreen(p, xrad, yrad, color, (bool)isSolid);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawDot_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jobject p_color){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawDot_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x, jint y, jobject p_color){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawDot(ctype, x, y, color); x_game->drawDot(ctype, x, y, color);
} }
@ -1571,7 +1475,7 @@ x_game->drawDotScreen(p, color);
} }
JNIEXPORT void JNICALL Java_bwapi4_Game_drawLine_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x1, jint y1, jint x2, jint y2, jobject p_color){ JNIEXPORT void JNICALL Java_bwapi4_Game_drawLine_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_ctype, jint x1, jint y1, jint x2, jint y2, jobject p_color){
Game* x_game = (Game*)pointer; Game* x_game = (Game*)pointer;
bwapi4.CoordinateType.Enum ctype = (bwapi4.CoordinateType.Enum)env->GetLongField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "pointer", "J")); CoordinateType::Enum ctype;
Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I"))); Color color((int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "r", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "g", "I")), (int)env->GetIntField(p_color, FindCachedField(env, env->GetObjectClass(p_color), "b", "I")));
x_game->drawLine(ctype, x1, y1, x2, y2, color); x_game->drawLine(ctype, x1, y1, x2, y2, color);
} }
@ -1809,10 +1713,6 @@ Player toPlayer = (Player)env->GetLongField(p_toPlayer, FindCachedField(env, env
Player fromPlayer = (Player)env->GetLongField(p_fromPlayer, FindCachedField(env, env->GetObjectClass(p_fromPlayer), "pointer", "J")); Player fromPlayer = (Player)env->GetLongField(p_fromPlayer, FindCachedField(env, env->GetObjectClass(p_fromPlayer), "pointer", "J"));
return x_game->getDamageTo(toType, fromType, toPlayer, fromPlayer); return x_game->getDamageTo(toType, fromType, toPlayer, fromPlayer);
} }
JNIEXPORT void JNICALL Java_bwapi4_GameWrapper_flush_1native(JNIEnv * env, jobject obj, jlong pointer){
GameWrapper x_gameWrapper = (GameWrapper)pointer;
x_gameWrapper->flush();
}
JNIEXPORT jint JNICALL Java_bwapi4_Player_getID_1native(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jint JNICALL Java_bwapi4_Player_getID_1native(JNIEnv * env, jobject obj, jlong pointer){
Player x_player = (Player)pointer; Player x_player = (Player)pointer;
return x_player->getID(); return x_player->getID();
@ -2121,14 +2021,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Playerset_setAlliance_1native__JZZ(JNIEnv * e
Playerset* x_playerset = (Playerset*)pointer; Playerset* x_playerset = (Playerset*)pointer;
x_playerset->setAlliance((bool)allies, (bool)alliedVictory); x_playerset->setAlliance((bool)allies, (bool)alliedVictory);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Point_isValid_1native(JNIEnv * env, jobject obj, jlong pointer){
Point x_point = (Point)pointer;
return x_point->isValid();
}
JNIEXPORT jdouble JNICALL Java_bwapi4_Point_getLength_1native(JNIEnv * env, jobject obj, jlong pointer){
Point x_point = (Point)pointer;
return x_point->getLength();
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Position_isValid(JNIEnv * env, jobject obj){ JNIEXPORT jboolean JNICALL Java_bwapi4_Position_isValid(JNIEnv * env, jobject obj){
Position x_position((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I"))); Position x_position((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
return x_position.isValid(); return x_position.isValid();
@ -2155,34 +2047,6 @@ JNIEXPORT jdouble JNICALL Java_bwapi4_Position_getLength(JNIEnv * env, jobject o
Position x_position((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I"))); Position x_position((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
return x_position.getLength(); return x_position.getLength();
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Position_hasPath(JNIEnv * env, jobject obj, jobject p_position){
Position x_position((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
Position position((int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "x", "I")), (int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "y", "I")));
return x_position.hasPath(position);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_PositionOrUnit_isUnit_1native(JNIEnv * env, jobject obj, jlong pointer){
PositionOrUnit x_positionOrUnit = (PositionOrUnit)pointer;
return x_positionOrUnit->isUnit();
}
JNIEXPORT jobject JNICALL Java_bwapi4_PositionOrUnit_getUnit_1native(JNIEnv * env, jobject obj, jlong pointer){
PositionOrUnit x_positionOrUnit = (PositionOrUnit)pointer;
jlong resptr = (jlong)x_positionOrUnit->getUnit();
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_PositionOrUnit_isPosition_1native(JNIEnv * env, jobject obj, jlong pointer){
PositionOrUnit x_positionOrUnit = (PositionOrUnit)pointer;
return x_positionOrUnit->isPosition();
}
JNIEXPORT jobject JNICALL Java_bwapi4_PositionOrUnit_getPosition_1native(JNIEnv * env, jobject obj, jlong pointer){
PositionOrUnit x_positionOrUnit = (PositionOrUnit)pointer;
Position cresult = x_positionOrUnit->getPosition();
jclass retcls = FindCachedClass(env, "bwapi/Position");
jmethodID retConsID = FindCachedMethod(env, retcls, "<init>", "(II)V");
jobject result = env->NewObject(retcls, retConsID, cresult.x, cresult.y);
return result;
}
JNIEXPORT jint JNICALL Java_bwapi4_Region_getID_1native(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jint JNICALL Java_bwapi4_Region_getID_1native(JNIEnv * env, jobject obj, jlong pointer){
Region x_region = (Region)pointer; Region x_region = (Region)pointer;
return x_region->getID(); return x_region->getID();
@ -2286,11 +2150,6 @@ env->CallVoidMethod(result, addMethodID, elem);
} }
return result; return result;
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_TilePosition_hasPath(JNIEnv * env, jobject obj, jobject p_position){
TilePosition x_tilePosition((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
TilePosition position((int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "x", "I")), (int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "y", "I")));
return x_tilePosition.hasPath(position);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_TilePosition_isValid(JNIEnv * env, jobject obj){ JNIEXPORT jboolean JNICALL Java_bwapi4_TilePosition_isValid(JNIEnv * env, jobject obj){
TilePosition x_tilePosition((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I"))); TilePosition x_tilePosition((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
return x_tilePosition.isValid(); return x_tilePosition.isValid();
@ -2411,12 +2270,12 @@ return x_unit->getResourceGroup();
} }
JNIEXPORT jint JNICALL Java_bwapi4_Unit_getDistance_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jint JNICALL Java_bwapi4_Unit_getDistance_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->getDistance(target); return x_unit->getDistance(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_hasPath_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_hasPath_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->hasPath(target); return x_unit->hasPath(target);
} }
JNIEXPORT jint JNICALL Java_bwapi4_Unit_getLastCommandFrame_1native(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jint JNICALL Java_bwapi4_Unit_getLastCommandFrame_1native(JNIEnv * env, jobject obj, jlong pointer){
@ -3013,12 +2872,12 @@ return x_unit->issueCommand(command);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_attack_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_attack_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->attack(target); return x_unit->attack(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_attack_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean shiftQueueCommand){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_attack_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean shiftQueueCommand){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->attack(target, (bool)shiftQueueCommand); return x_unit->attack(target, (bool)shiftQueueCommand);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_build_1native__JLbwapi4_UnitType_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_type){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_build_1native__JLbwapi4_UnitType_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_type){
@ -3063,7 +2922,7 @@ return x_unit->upgrade(upgrade);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_setRallyPoint_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_setRallyPoint_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->setRallyPoint(target); return x_unit->setRallyPoint(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_move_1native__JLbwapi4_Position_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_move_1native__JLbwapi4_Position_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
@ -3208,12 +3067,12 @@ return x_unit->unloadAll(target, (bool)shiftQueueCommand);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_rightClick_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_rightClick_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->rightClick(target); return x_unit->rightClick(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_rightClick_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean shiftQueueCommand){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_rightClick_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean shiftQueueCommand){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->rightClick(target, (bool)shiftQueueCommand); return x_unit->rightClick(target, (bool)shiftQueueCommand);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_haltConstruction_1native(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_haltConstruction_1native(JNIEnv * env, jobject obj, jlong pointer){
@ -3256,7 +3115,7 @@ return x_unit->useTech(tech);
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_useTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_useTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J")); TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J"));
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->useTech(tech, target); return x_unit->useTech(tech, target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_placeCOP_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_placeCOP_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
@ -3391,22 +3250,22 @@ return x_unit->canAttack((bool)checkCommandibility);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttack_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttack_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canAttack(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType); return x_unit->canAttack(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttack_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttack_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canAttack(target, (bool)checkCanTargetUnit); return x_unit->canAttack(target, (bool)checkCanTargetUnit);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttack_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttack_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canAttack(target); return x_unit->canAttack(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttack_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibility){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttack_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibility){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canAttack(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibility); return x_unit->canAttack(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibility);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JZ(JNIEnv * env, jobject obj, jlong pointer, jboolean checkCommandibilityGrouped){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JZ(JNIEnv * env, jobject obj, jlong pointer, jboolean checkCommandibilityGrouped){
@ -3423,27 +3282,27 @@ return x_unit->canAttackGrouped((bool)checkCommandibilityGrouped, (bool)checkCom
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canAttackGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped); return x_unit->canAttackGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canAttackGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType); return x_unit->canAttackGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canAttackGrouped(target, (bool)checkCanTargetUnit); return x_unit->canAttackGrouped(target, (bool)checkCanTargetUnit);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canAttackGrouped(target); return x_unit->canAttackGrouped(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2ZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped, jboolean checkCommandibility){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackGrouped_1native__JLbwapi4_PositionOrUnit_2ZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped, jboolean checkCommandibility){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canAttackGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped, (bool)checkCommandibility); return x_unit->canAttackGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped, (bool)checkCommandibility);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackMove_1native__J(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canAttackMove_1native__J(JNIEnv * env, jobject obj, jlong pointer){
@ -3693,22 +3552,22 @@ return x_unit->canSetRallyPoint((bool)checkCommandibility);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPoint_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPoint_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canSetRallyPoint(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType); return x_unit->canSetRallyPoint(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPoint_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPoint_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canSetRallyPoint(target, (bool)checkCanTargetUnit); return x_unit->canSetRallyPoint(target, (bool)checkCanTargetUnit);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPoint_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPoint_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canSetRallyPoint(target); return x_unit->canSetRallyPoint(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPoint_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibility){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPoint_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibility){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canSetRallyPoint(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibility); return x_unit->canSetRallyPoint(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibility);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPosition_1native__J(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canSetRallyPosition_1native__J(JNIEnv * env, jobject obj, jlong pointer){
@ -4099,22 +3958,22 @@ return x_unit->canRightClick((bool)checkCommandibility);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClick_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClick_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canRightClick(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType); return x_unit->canRightClick(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClick_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClick_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canRightClick(target, (bool)checkCanTargetUnit); return x_unit->canRightClick(target, (bool)checkCanTargetUnit);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClick_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClick_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canRightClick(target); return x_unit->canRightClick(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClick_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibility){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClick_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibility){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canRightClick(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibility); return x_unit->canRightClick(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibility);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JZ(JNIEnv * env, jobject obj, jlong pointer, jboolean checkCommandibilityGrouped){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JZ(JNIEnv * env, jobject obj, jlong pointer, jboolean checkCommandibilityGrouped){
@ -4131,27 +3990,27 @@ return x_unit->canRightClickGrouped((bool)checkCommandibilityGrouped, (bool)chec
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canRightClickGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped); return x_unit->canRightClickGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canRightClickGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType); return x_unit->canRightClickGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canRightClickGrouped(target, (bool)checkCanTargetUnit); return x_unit->canRightClickGrouped(target, (bool)checkCanTargetUnit);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canRightClickGrouped(target); return x_unit->canRightClickGrouped(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2ZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped, jboolean checkCommandibility){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickGrouped_1native__JLbwapi4_PositionOrUnit_2ZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped, jboolean checkCommandibility){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canRightClickGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped, (bool)checkCommandibility); return x_unit->canRightClickGrouped(target, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped, (bool)checkCommandibility);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickPosition_1native__J(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canRightClickPosition_1native__J(JNIEnv * env, jobject obj, jlong pointer){
@ -4341,25 +4200,25 @@ return x_unit->canUseTechWithOrWithoutTarget(tech, (bool)checkCanIssueCommandTyp
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target, jboolean checkCanTargetUnit, jboolean checkTargetsType, jboolean checkCanIssueCommandType){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target, jboolean checkCanTargetUnit, jboolean checkTargetsType, jboolean checkCanIssueCommandType){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J")); TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J"));
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canUseTech(tech, target, (bool)checkCanTargetUnit, (bool)checkTargetsType, (bool)checkCanIssueCommandType); return x_unit->canUseTech(tech, target, (bool)checkCanTargetUnit, (bool)checkTargetsType, (bool)checkCanIssueCommandType);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target, jboolean checkCanTargetUnit, jboolean checkTargetsType){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target, jboolean checkCanTargetUnit, jboolean checkTargetsType){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J")); TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J"));
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canUseTech(tech, target, (bool)checkCanTargetUnit, (bool)checkTargetsType); return x_unit->canUseTech(tech, target, (bool)checkCanTargetUnit, (bool)checkTargetsType);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target, jboolean checkCanTargetUnit){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target, jboolean checkCanTargetUnit){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J")); TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J"));
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canUseTech(tech, target, (bool)checkCanTargetUnit); return x_unit->canUseTech(tech, target, (bool)checkCanTargetUnit);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J")); TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J"));
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canUseTech(tech, target); return x_unit->canUseTech(tech, target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech){
@ -4370,7 +4229,7 @@ return x_unit->canUseTech(tech);
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2ZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target, jboolean checkCanTargetUnit, jboolean checkTargetsType, jboolean checkCanIssueCommandType, jboolean checkCommandibility){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2ZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target, jboolean checkCanTargetUnit, jboolean checkTargetsType, jboolean checkCanIssueCommandType, jboolean checkCommandibility){
Unit x_unit = (Unit)pointer; Unit x_unit = (Unit)pointer;
TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J")); TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J"));
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unit->canUseTech(tech, target, (bool)checkCanTargetUnit, (bool)checkTargetsType, (bool)checkCanIssueCommandType, (bool)checkCommandibility); return x_unit->canUseTech(tech, target, (bool)checkCanTargetUnit, (bool)checkTargetsType, (bool)checkCanIssueCommandType, (bool)checkCommandibility);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTechWithoutTarget_1native__JLbwapi4_TechType_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jboolean checkCanIssueCommandType){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canUseTechWithoutTarget_1native__JLbwapi4_TechType_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jboolean checkCanIssueCommandType){
@ -4555,18 +4414,6 @@ env->CallVoidMethod(result, addMethodID, elem);
} }
return result; return result;
} }
JNIEXPORT void JNICALL Java_bwapi4_Unitset_setClientInfo_1native__JI(JNIEnv * env, jobject obj, jlong pointer, jint clientInfo){
Unitset* x_unitset = (Unitset*)pointer;
x_unitset->setClientInfo(clientInfo);
}
JNIEXPORT void JNICALL Java_bwapi4_Unitset_setClientInfo_1native__J(JNIEnv * env, jobject obj, jlong pointer){
Unitset* x_unitset = (Unitset*)pointer;
x_unitset->setClientInfo();
}
JNIEXPORT void JNICALL Java_bwapi4_Unitset_setClientInfo_1native__JII(JNIEnv * env, jobject obj, jlong pointer, jint clientInfo, jint index){
Unitset* x_unitset = (Unitset*)pointer;
x_unitset->setClientInfo(clientInfo, index);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getUnitsInRadius_1native(JNIEnv * env, jobject obj, jlong pointer, jint radius, jobject p_pred){ JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getUnitsInRadius_1native(JNIEnv * env, jobject obj, jlong pointer, jint radius, jobject p_pred){
Unitset* x_unitset = (Unitset*)pointer; Unitset* x_unitset = (Unitset*)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J")); UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
@ -4606,12 +4453,12 @@ return x_unitset->issueCommand(command);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_attack_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_attack_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unitset* x_unitset = (Unitset*)pointer; Unitset* x_unitset = (Unitset*)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unitset->attack(target); return x_unitset->attack(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_attack_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean shiftQueueCommand){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_attack_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean shiftQueueCommand){
Unitset* x_unitset = (Unitset*)pointer; Unitset* x_unitset = (Unitset*)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unitset->attack(target, (bool)shiftQueueCommand); return x_unitset->attack(target, (bool)shiftQueueCommand);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_build_1native__JLbwapi4_UnitType_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_type){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_build_1native__JLbwapi4_UnitType_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_type){
@ -4642,7 +4489,7 @@ return x_unitset->morph(type);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_setRallyPoint_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_setRallyPoint_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unitset* x_unitset = (Unitset*)pointer; Unitset* x_unitset = (Unitset*)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unitset->setRallyPoint(target); return x_unitset->setRallyPoint(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_move_1native__JLbwapi4_Position_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_move_1native__JLbwapi4_Position_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
@ -4777,12 +4624,12 @@ return x_unitset->unloadAll(target, (bool)shiftQueueCommand);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_rightClick_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_rightClick_1native__JLbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_target){
Unitset* x_unitset = (Unitset*)pointer; Unitset* x_unitset = (Unitset*)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unitset->rightClick(target); return x_unitset->rightClick(target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_rightClick_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean shiftQueueCommand){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_rightClick_1native__JLbwapi4_PositionOrUnit_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_target, jboolean shiftQueueCommand){
Unitset* x_unitset = (Unitset*)pointer; Unitset* x_unitset = (Unitset*)pointer;
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unitset->rightClick(target, (bool)shiftQueueCommand); return x_unitset->rightClick(target, (bool)shiftQueueCommand);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_haltConstruction_1native(JNIEnv * env, jobject obj, jlong pointer){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_haltConstruction_1native(JNIEnv * env, jobject obj, jlong pointer){
@ -4825,43 +4672,39 @@ return x_unitset->useTech(tech);
JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_useTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target){ JNIEXPORT jboolean JNICALL Java_bwapi4_Unitset_useTech_1native__JLbwapi4_TechType_2Lbwapi4_PositionOrUnit_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_tech, jobject p_target){
Unitset* x_unitset = (Unitset*)pointer; Unitset* x_unitset = (Unitset*)pointer;
TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J")); TechType tech = (TechType)env->GetLongField(p_tech, FindCachedField(env, env->GetObjectClass(p_tech), "pointer", "J"));
PositionOrUnit target = (PositionOrUnit)env->GetLongField(p_target, FindCachedField(env, env->GetObjectClass(p_target), "pointer", "J")); PositionOrUnit target(convertPositionOrUnit(env, p_target ));
return x_unitset->useTech(tech, target); return x_unitset->useTech(tech, target);
} }
JNIEXPORT jboolean JNICALL Java_bwapi4_WalkPosition_isValid(JNIEnv * env, jobject obj){ JNIEXPORT jboolean JNICALL Java_bwapi4_WalkPosition_isValid(JNIEnv * env, jobject obj){
WalkPosition x_walkPosition = (WalkPosition)pointer; WalkPosition x_walkPosition((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
return x_walkPosition->isValid(); return x_walkPosition.isValid();
} }
JNIEXPORT jobject JNICALL Java_bwapi4_WalkPosition_makeValid(JNIEnv * env, jobject obj){ JNIEXPORT jobject JNICALL Java_bwapi4_WalkPosition_makeValid(JNIEnv * env, jobject obj){
WalkPosition x_walkPosition = (WalkPosition)pointer; WalkPosition x_walkPosition((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
jlong resptr = (jlong)x_walkPosition->makeValid(); WalkPosition cresult = x_walkPosition.makeValid();
jclass retcls = FindCachedClass(env, "bwapi4/WalkPosition"); jclass retcls = FindCachedClass(env, "bwapi4/WalkPosition");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/WalkPosition;"); jmethodID retConsID = FindCachedMethod(env, retcls, "<init>", "(II)V");
return env->CallStaticObjectMethod(retcls, mid, resptr); jobject result = env->NewObject(retcls, retConsID, cresult.x, cresult.y);
return result;
} }
JNIEXPORT jdouble JNICALL Java_bwapi4_WalkPosition_getDistance(JNIEnv * env, jobject obj, jobject p_position){ JNIEXPORT jdouble JNICALL Java_bwapi4_WalkPosition_getDistance(JNIEnv * env, jobject obj, jobject p_position){
WalkPosition x_walkPosition = (WalkPosition)pointer; WalkPosition x_walkPosition((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
WalkPosition position = (WalkPosition)env->GetLongField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "pointer", "J")); WalkPosition position((int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "x", "I")), (int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "y", "I")));
return x_walkPosition->getDistance(position); return x_walkPosition.getDistance(position);
} }
JNIEXPORT jint JNICALL Java_bwapi4_WalkPosition_getApproxDistance(JNIEnv * env, jobject obj, jobject p_position){ JNIEXPORT jint JNICALL Java_bwapi4_WalkPosition_getApproxDistance(JNIEnv * env, jobject obj, jobject p_position){
WalkPosition x_walkPosition = (WalkPosition)pointer; WalkPosition x_walkPosition((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
WalkPosition position = (WalkPosition)env->GetLongField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "pointer", "J")); WalkPosition position((int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "x", "I")), (int)env->GetIntField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "y", "I")));
return x_walkPosition->getApproxDistance(position); return x_walkPosition.getApproxDistance(position);
} }
JNIEXPORT jdouble JNICALL Java_bwapi4_WalkPosition_getLength(JNIEnv * env, jobject obj){ JNIEXPORT jdouble JNICALL Java_bwapi4_WalkPosition_getLength(JNIEnv * env, jobject obj){
WalkPosition x_walkPosition = (WalkPosition)pointer; WalkPosition x_walkPosition((int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "x", "I")), (int)env->GetIntField(obj, FindCachedField(env, env->GetObjectClass(obj), "y", "I")));
return x_walkPosition->getLength(); return x_walkPosition.getLength();
}
JNIEXPORT jboolean JNICALL Java_bwapi4_WalkPosition_hasPath(JNIEnv * env, jobject obj, jobject p_position){
WalkPosition x_walkPosition = (WalkPosition)pointer;
WalkPosition position = (WalkPosition)env->GetLongField(p_position, FindCachedField(env, env->GetObjectClass(p_position), "pointer", "J"));
return x_walkPosition->hasPath(position);
} }
void reconnect() void reconnect()
{ {
while (!BWAPIClient.connect()) { while (!BWAPIClient.connect()) {
Sleep(1000); std::this_thread::sleep_for(std::chrono::milliseconds{ 1000 });
} }
} }
@ -4878,9 +4721,6 @@ void println(const char * text){
} }
JNIEXPORT void JNICALL Java_bwapi_Mirror_startGame(JNIEnv * env, jobject obj){ JNIEXPORT void JNICALL Java_bwapi_Mirror_startGame(JNIEnv * env, jobject obj){
println("Attempting to init BWAPI...");
BWAPI_init();
println("BWAPI ready.");
jclass cls; jclass cls;
jmethodID getId; jmethodID getId;
cls = env->FindClass("Lbwapi/BulletType;"); cls = env->FindClass("Lbwapi/BulletType;");
@ -6414,7 +6254,7 @@ println("Connecting to Broodwar...");
jclass posCls = env->FindClass("Lbwapi/Position;"); jclass posCls = env->FindClass("Lbwapi/Position;");
jobject moduleObj = env->GetObjectField(obj, env->GetFieldID(cls, "module", "Lbwapi/AIModule;")); jobject moduleObj = env->GetObjectField(obj, env->GetFieldID(cls, "module", "Lbwapi/AIModule;"));
jclass moduleCls = env->GetObjectClass(moduleObj); jclass moduleCls = env->GetObjectClass(moduleObj);
env->SetObjectField(obj, env->GetFieldID(cls, "game", "Lbwapi/Game;"), env->CallStaticObjectMethod(gamecls, env->GetStaticMethodID(gamecls, "get", "(J)Lbwapi/Game;"), (long)Broodwarptr)); env->SetObjectField(obj, env->GetFieldID(cls, "game", "Lbwapi/Game;"), env->CallStaticObjectMethod(gamecls, env->GetStaticMethodID(gamecls, "get", "(J)Lbwapi/Game;"), (long)&Broodwar));
jmethodID updateMethodID = env->GetMethodID(env->GetObjectClass(obj), "update", "()V"); jmethodID updateMethodID = env->GetMethodID(env->GetObjectClass(obj), "update", "()V");
jmethodID matchStartCallback = env->GetMethodID(moduleCls, "onStart", "()V"); jmethodID matchStartCallback = env->GetMethodID(moduleCls, "onStart", "()V");
@ -6436,17 +6276,16 @@ println("Connecting to Broodwar...");
jmethodID unitCompleteCallback = env->GetMethodID(moduleCls, "onUnitComplete", "(Lbwapi/Unit;)V"); jmethodID unitCompleteCallback = env->GetMethodID(moduleCls, "onUnitComplete", "(Lbwapi/Unit;)V");
jmethodID playerDroppedCallback = env->GetMethodID(moduleCls, "onPlayerDropped", "(Lbwapi/Player;)V"); jmethodID playerDroppedCallback = env->GetMethodID(moduleCls, "onPlayerDropped", "(Lbwapi/Player;)V");
while (true) { while (true) {
if (Broodwarptr != NULL) {
println("Waiting...");
while (!Broodwarptr->isInGame()) {
BWAPIClient.update();
if (Broodwarptr == NULL) {
println("Match ended.");
return;
}
}
}
println("Waiting...");while ( !Broodwar->isInGame() )
{
BWAPI::BWAPIClient.update();
if (!BWAPI::BWAPIClient.isConnected())
{
println("Reconnecting...");
reconnect();
}
}
println("Game ready!!!"); println("Game ready!!!");
while (Broodwar->isInGame()) { while (Broodwar->isInGame()) {
@ -6521,7 +6360,7 @@ println("Connecting to Broodwar...");
println("Reconnecting..."); println("Reconnecting...");
reconnect(); reconnect();
} }
} println("Match ended."); }
} }
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -18,142 +18,6 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*
* Class: bwapi4_AIModule
* Method: onStart_native
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onStart_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_AIModule
* Method: onEnd_native
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onEnd_1native
(JNIEnv *, jobject, jlong, jboolean);
/*
* Class: bwapi4_AIModule
* Method: onFrame_native
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onFrame_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_AIModule
* Method: onSendText_native
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onSendText_1native
(JNIEnv *, jobject, jlong, jstring);
/*
* Class: bwapi4_AIModule
* Method: onReceiveText_native
* Signature: (JLbwapi4/Player;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onReceiveText_1native
(JNIEnv *, jobject, jlong, jobject, jstring);
/*
* Class: bwapi4_AIModule
* Method: onPlayerLeft_native
* Signature: (JLbwapi4/Player;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onPlayerLeft_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onNukeDetect_native
* Signature: (JLbwapi4/Position;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onNukeDetect_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitDiscover_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitDiscover_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitEvade_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitEvade_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitShow_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitShow_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitHide_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitHide_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitCreate_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitCreate_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitDestroy_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitDestroy_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitMorph_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitMorph_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitRenegade_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitRenegade_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onSaveGame_native
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onSaveGame_1native
(JNIEnv *, jobject, jlong, jstring);
/*
* Class: bwapi4_AIModule
* Method: onUnitComplete_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitComplete_1native
(JNIEnv *, jobject, jlong, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -325,6 +189,17 @@ extern "C" {
} }
#endif #endif
#endif #endif
/* Header for class bwapi4_BWEventListener */
#ifndef _Included_bwapi4_BWEventListener
#define _Included_bwapi4_BWEventListener
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif
/* Header for class bwapi4_CenteredObject */ /* Header for class bwapi4_CenteredObject */
#ifndef _Included_bwapi4_CenteredObject #ifndef _Included_bwapi4_CenteredObject
@ -386,30 +261,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Client_update_1native
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*
* Class: bwapi4_Color
* Method: red_native
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Color_red_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Color
* Method: green_native
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Color_green_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Color
* Method: blue_native
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Color_blue_1native
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -436,6 +287,17 @@ extern "C" {
} }
#endif #endif
#endif #endif
/* Header for class bwapi4_DefaultBWListener */
#ifndef _Included_bwapi4_DefaultBWListener
#define _Included_bwapi4_DefaultBWListener
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif
/* Header for class bwapi4_Error */ /* Header for class bwapi4_Error */
#ifndef _Included_bwapi4_Error #ifndef _Included_bwapi4_Error
@ -1306,14 +1168,6 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_canUpgrade_1native__JLbwapi4_Upgrade
JNIEXPORT void JNICALL Java_bwapi4_Game_printf_1native JNIEXPORT void JNICALL Java_bwapi4_Game_printf_1native
(JNIEnv *, jobject, jlong, jstring); (JNIEnv *, jobject, jlong, jstring);
/*
* Class: bwapi4_Game
* Method: vPrintf_native
* Signature: (JLjava/lang/String;[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Game_vPrintf_1native
(JNIEnv *, jobject, jlong, jstring, jobjectArray);
/* /*
* Class: bwapi4_Game * Class: bwapi4_Game
* Method: sendText_native * Method: sendText_native
@ -1322,14 +1176,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Game_vPrintf_1native
JNIEXPORT void JNICALL Java_bwapi4_Game_sendText_1native JNIEXPORT void JNICALL Java_bwapi4_Game_sendText_1native
(JNIEnv *, jobject, jlong, jstring); (JNIEnv *, jobject, jlong, jstring);
/*
* Class: bwapi4_Game
* Method: vSendText_native
* Signature: (JLjava/lang/String;[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Game_vSendText_1native
(JNIEnv *, jobject, jlong, jstring, jobjectArray);
/* /*
* Class: bwapi4_Game * Class: bwapi4_Game
* Method: sendTextEx_native * Method: sendTextEx_native
@ -1338,14 +1184,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Game_vSendText_1native
JNIEXPORT void JNICALL Java_bwapi4_Game_sendTextEx_1native JNIEXPORT void JNICALL Java_bwapi4_Game_sendTextEx_1native
(JNIEnv *, jobject, jlong, jboolean, jstring); (JNIEnv *, jobject, jlong, jboolean, jstring);
/*
* Class: bwapi4_Game
* Method: vSendTextEx_native
* Signature: (JZLjava/lang/String;[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Game_vSendTextEx_1native
(JNIEnv *, jobject, jlong, jboolean, jstring, jobjectArray);
/* /*
* Class: bwapi4_Game * Class: bwapi4_Game
* Method: isInGame_native * Method: isInGame_native
@ -1506,14 +1344,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Game_setTextSize_1native__J
JNIEXPORT void JNICALL Java_bwapi4_Game_setTextSize_1native__JLbwapi4_Text_Size_Enum_2 JNIEXPORT void JNICALL Java_bwapi4_Game_setTextSize_1native__JLbwapi4_Text_Size_Enum_2
(JNIEnv *, jobject, jlong, jobject); (JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Game
* Method: vDrawText_native
* Signature: (JLbwapi4/CoordinateType/Enum;IILjava/lang/String;[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Game_vDrawText_1native
(JNIEnv *, jobject, jlong, jobject, jint, jint, jstring, jobjectArray);
/* /*
* Class: bwapi4_Game * Class: bwapi4_Game
* Method: drawText_native * Method: drawText_native
@ -2494,6 +2324,49 @@ JNIEXPORT void JNICALL Java_bwapi4_InterfaceEvent_removeEvent_1native
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef __cplusplus
}
#endif
#endif
/* Header for class bwapi4_Mirror_FrameCallback */
#ifndef _Included_bwapi4_Mirror_FrameCallback
#define _Included_bwapi4_Mirror_FrameCallback
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif
/* Header for class bwapi4_Mirror_JarResources */
#ifndef _Included_bwapi4_Mirror_JarResources
#define _Included_bwapi4_Mirror_JarResources
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif
/* Header for class bwapi4_Mirror */
#ifndef _Included_bwapi4_Mirror
#define _Included_bwapi4_Mirror
#ifdef __cplusplus
extern "C" {
#endif
#undef bwapi4_Mirror_EXTRACT_JAR
#define bwapi4_Mirror_EXTRACT_JAR 1L
/*
* Class: bwapi4_Mirror
* Method: startGame
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_bwapi4_Mirror_startGame
(JNIEnv *, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -3074,19 +2947,35 @@ extern "C" {
#endif #endif
/* /*
* Class: bwapi4_Point * Class: bwapi4_Point
* Method: isValid_native * Method: isValid
* Signature: (J)Z * Signature: ()Z
*/ */
JNIEXPORT jboolean JNICALL Java_bwapi4_Point_isValid_1native JNIEXPORT jboolean JNICALL Java_bwapi4_Point_isValid
(JNIEnv *, jobject, jlong); (JNIEnv *, jobject);
/* /*
* Class: bwapi4_Point * Class: bwapi4_Point
* Method: getLength_native * Method: makeValid
* Signature: (J)D * Signature: ()Lbwapi4/Point;
*/ */
JNIEXPORT jdouble JNICALL Java_bwapi4_Point_getLength_1native JNIEXPORT jobject JNICALL Java_bwapi4_Point_makeValid
(JNIEnv *, jobject, jlong); (JNIEnv *, jobject);
/*
* Class: bwapi4_Point
* Method: getDistance
* Signature: (Lbwapi4/Point;)D
*/
JNIEXPORT jdouble JNICALL Java_bwapi4_Point_getDistance
(JNIEnv *, jobject, jobject);
/*
* Class: bwapi4_Point
* Method: getLength
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL Java_bwapi4_Point_getLength
(JNIEnv *, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }
@ -3139,14 +3028,6 @@ JNIEXPORT jint JNICALL Java_bwapi4_Position_getApproxDistance
JNIEXPORT jdouble JNICALL Java_bwapi4_Position_getLength JNIEXPORT jdouble JNICALL Java_bwapi4_Position_getLength
(JNIEnv *, jobject); (JNIEnv *, jobject);
/*
* Class: bwapi4_Position
* Method: hasPath
* Signature: (Lbwapi4/Position;)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_Position_hasPath
(JNIEnv *, jobject, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -3169,38 +3050,6 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*
* Class: bwapi4_PositionOrUnit
* Method: isUnit_native
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_PositionOrUnit_isUnit_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_PositionOrUnit
* Method: getUnit_native
* Signature: (J)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_PositionOrUnit_getUnit_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_PositionOrUnit
* Method: isPosition_native
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_PositionOrUnit_isPosition_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_PositionOrUnit
* Method: getPosition_native
* Signature: (J)Lbwapi4/Position;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_PositionOrUnit_getPosition_1native
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -3384,14 +3233,6 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*
* Class: bwapi4_TilePosition
* Method: hasPath
* Signature: (Lbwapi4/TilePosition;)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_TilePosition_hasPath
(JNIEnv *, jobject, jobject);
/* /*
* Class: bwapi4_TilePosition * Class: bwapi4_TilePosition
* Method: isValid * Method: isValid
@ -7186,30 +7027,6 @@ JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getInterceptors_1native
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getLarva_1native JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getLarva_1native
(JNIEnv *, jobject, jlong); (JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unitset
* Method: setClientInfo_native
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Unitset_setClientInfo_1native__JI
(JNIEnv *, jobject, jlong, jint);
/*
* Class: bwapi4_Unitset
* Method: setClientInfo_native
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Unitset_setClientInfo_1native__J
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unitset
* Method: setClientInfo_native
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Unitset_setClientInfo_1native__JII
(JNIEnv *, jobject, jlong, jint, jint);
/* /*
* Class: bwapi4_Unitset * Class: bwapi4_Unitset
* Method: getUnitsInRadius_native * Method: getUnitsInRadius_native
@ -7671,6 +7488,79 @@ extern "C" {
} }
#endif #endif
#endif #endif
/* Header for class bwapi4_Utils */
#ifndef _Included_bwapi4_Utils
#define _Included_bwapi4_Utils
#ifdef __cplusplus
extern "C" {
#endif
#undef bwapi4_Utils_Previous
#define bwapi4_Utils_Previous 1L
#undef bwapi4_Utils_Cyan
#define bwapi4_Utils_Cyan 2L
#undef bwapi4_Utils_Yellow
#define bwapi4_Utils_Yellow 3L
#undef bwapi4_Utils_White
#define bwapi4_Utils_White 4L
#undef bwapi4_Utils_Grey
#define bwapi4_Utils_Grey 5L
#undef bwapi4_Utils_Red
#define bwapi4_Utils_Red 6L
#undef bwapi4_Utils_Green
#define bwapi4_Utils_Green 7L
#undef bwapi4_Utils_Red_P1
#define bwapi4_Utils_Red_P1 8L
#undef bwapi4_Utils_Tab
#define bwapi4_Utils_Tab 9L
#undef bwapi4_Utils_Newline
#define bwapi4_Utils_Newline 10L
#undef bwapi4_Utils_Invisible_no_override
#define bwapi4_Utils_Invisible_no_override 11L
#undef bwapi4_Utils_Remove_beyond
#define bwapi4_Utils_Remove_beyond 12L
#undef bwapi4_Utils_Clear_formatting
#define bwapi4_Utils_Clear_formatting 13L
#undef bwapi4_Utils_Blue
#define bwapi4_Utils_Blue 14L
#undef bwapi4_Utils_Teal
#define bwapi4_Utils_Teal 15L
#undef bwapi4_Utils_Purple
#define bwapi4_Utils_Purple 16L
#undef bwapi4_Utils_Orange
#define bwapi4_Utils_Orange 17L
#undef bwapi4_Utils_Right_Align
#define bwapi4_Utils_Right_Align 18L
#undef bwapi4_Utils_Center_Align
#define bwapi4_Utils_Center_Align 19L
#undef bwapi4_Utils_Invisible
#define bwapi4_Utils_Invisible 20L
#undef bwapi4_Utils_Brown
#define bwapi4_Utils_Brown 21L
#undef bwapi4_Utils_White_p7
#define bwapi4_Utils_White_p7 22L
#undef bwapi4_Utils_Yellow_p8
#define bwapi4_Utils_Yellow_p8 23L
#undef bwapi4_Utils_Green_p9
#define bwapi4_Utils_Green_p9 24L
#undef bwapi4_Utils_Brighter_Yellow
#define bwapi4_Utils_Brighter_Yellow 25L
#undef bwapi4_Utils_Cyan_default
#define bwapi4_Utils_Cyan_default 26L
#undef bwapi4_Utils_Pinkish
#define bwapi4_Utils_Pinkish 27L
#undef bwapi4_Utils_Dark_Cyan
#define bwapi4_Utils_Dark_Cyan 28L
#undef bwapi4_Utils_Greygreen
#define bwapi4_Utils_Greygreen 29L
#undef bwapi4_Utils_Bluegrey
#define bwapi4_Utils_Bluegrey 30L
#undef bwapi4_Utils_Turquoise
#define bwapi4_Utils_Turquoise 31L
#ifdef __cplusplus
}
#endif
#endif
/* Header for class bwapi4_WalkPosition */ /* Header for class bwapi4_WalkPosition */
#ifndef _Included_bwapi4_WalkPosition #ifndef _Included_bwapi4_WalkPosition
@ -7718,14 +7608,6 @@ JNIEXPORT jint JNICALL Java_bwapi4_WalkPosition_getApproxDistance
JNIEXPORT jdouble JNICALL Java_bwapi4_WalkPosition_getLength JNIEXPORT jdouble JNICALL Java_bwapi4_WalkPosition_getLength
(JNIEnv *, jobject); (JNIEnv *, jobject);
/*
* Class: bwapi4_WalkPosition
* Method: hasPath
* Signature: (Lbwapi4/WalkPosition;)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_WalkPosition_hasPath
(JNIEnv *, jobject, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -7,142 +7,6 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*
* Class: bwapi4_AIModule
* Method: onStart_native
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onStart_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_AIModule
* Method: onEnd_native
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onEnd_1native
(JNIEnv *, jobject, jlong, jboolean);
/*
* Class: bwapi4_AIModule
* Method: onFrame_native
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onFrame_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_AIModule
* Method: onSendText_native
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onSendText_1native
(JNIEnv *, jobject, jlong, jstring);
/*
* Class: bwapi4_AIModule
* Method: onReceiveText_native
* Signature: (JLbwapi4/Player;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onReceiveText_1native
(JNIEnv *, jobject, jlong, jobject, jstring);
/*
* Class: bwapi4_AIModule
* Method: onPlayerLeft_native
* Signature: (JLbwapi4/Player;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onPlayerLeft_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onNukeDetect_native
* Signature: (JLbwapi4/Position;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onNukeDetect_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitDiscover_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitDiscover_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitEvade_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitEvade_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitShow_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitShow_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitHide_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitHide_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitCreate_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitCreate_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitDestroy_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitDestroy_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitMorph_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitMorph_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onUnitRenegade_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitRenegade_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_AIModule
* Method: onSaveGame_native
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onSaveGame_1native
(JNIEnv *, jobject, jlong, jstring);
/*
* Class: bwapi4_AIModule
* Method: onUnitComplete_native
* Signature: (JLbwapi4/Unit;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_AIModule_onUnitComplete_1native
(JNIEnv *, jobject, jlong, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -0,0 +1,13 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class bwapi4_BWEventListener */
#ifndef _Included_bwapi4_BWEventListener
#define _Included_bwapi4_BWEventListener
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -7,30 +7,6 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*
* Class: bwapi4_Color
* Method: red_native
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Color_red_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Color
* Method: green_native
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Color_green_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Color
* Method: blue_native
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Color_blue_1native
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -0,0 +1,13 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class bwapi4_DefaultBWListener */
#ifndef _Included_bwapi4_DefaultBWListener
#define _Included_bwapi4_DefaultBWListener
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -743,14 +743,6 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_canUpgrade_1native__JLbwapi4_Upgrade
JNIEXPORT void JNICALL Java_bwapi4_Game_printf_1native JNIEXPORT void JNICALL Java_bwapi4_Game_printf_1native
(JNIEnv *, jobject, jlong, jstring); (JNIEnv *, jobject, jlong, jstring);
/*
* Class: bwapi4_Game
* Method: vPrintf_native
* Signature: (JLjava/lang/String;[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Game_vPrintf_1native
(JNIEnv *, jobject, jlong, jstring, jobjectArray);
/* /*
* Class: bwapi4_Game * Class: bwapi4_Game
* Method: sendText_native * Method: sendText_native
@ -759,14 +751,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Game_vPrintf_1native
JNIEXPORT void JNICALL Java_bwapi4_Game_sendText_1native JNIEXPORT void JNICALL Java_bwapi4_Game_sendText_1native
(JNIEnv *, jobject, jlong, jstring); (JNIEnv *, jobject, jlong, jstring);
/*
* Class: bwapi4_Game
* Method: vSendText_native
* Signature: (JLjava/lang/String;[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Game_vSendText_1native
(JNIEnv *, jobject, jlong, jstring, jobjectArray);
/* /*
* Class: bwapi4_Game * Class: bwapi4_Game
* Method: sendTextEx_native * Method: sendTextEx_native
@ -775,14 +759,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Game_vSendText_1native
JNIEXPORT void JNICALL Java_bwapi4_Game_sendTextEx_1native JNIEXPORT void JNICALL Java_bwapi4_Game_sendTextEx_1native
(JNIEnv *, jobject, jlong, jboolean, jstring); (JNIEnv *, jobject, jlong, jboolean, jstring);
/*
* Class: bwapi4_Game
* Method: vSendTextEx_native
* Signature: (JZLjava/lang/String;[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Game_vSendTextEx_1native
(JNIEnv *, jobject, jlong, jboolean, jstring, jobjectArray);
/* /*
* Class: bwapi4_Game * Class: bwapi4_Game
* Method: isInGame_native * Method: isInGame_native
@ -943,14 +919,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Game_setTextSize_1native__J
JNIEXPORT void JNICALL Java_bwapi4_Game_setTextSize_1native__JLbwapi4_Text_Size_Enum_2 JNIEXPORT void JNICALL Java_bwapi4_Game_setTextSize_1native__JLbwapi4_Text_Size_Enum_2
(JNIEnv *, jobject, jlong, jobject); (JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Game
* Method: vDrawText_native
* Signature: (JLbwapi4/CoordinateType/Enum;IILjava/lang/String;[Ljava/lang/Object;)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Game_vDrawText_1native
(JNIEnv *, jobject, jlong, jobject, jint, jint, jstring, jobjectArray);
/* /*
* Class: bwapi4_Game * Class: bwapi4_Game
* Method: drawText_native * Method: drawText_native

23
headers4/bwapi4_Mirror.h Normal file
View file

@ -0,0 +1,23 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class bwapi4_Mirror */
#ifndef _Included_bwapi4_Mirror
#define _Included_bwapi4_Mirror
#ifdef __cplusplus
extern "C" {
#endif
#undef bwapi4_Mirror_EXTRACT_JAR
#define bwapi4_Mirror_EXTRACT_JAR 1L
/*
* Class: bwapi4_Mirror
* Method: startGame
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_bwapi4_Mirror_startGame
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,13 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class bwapi4_Mirror_FrameCallback */
#ifndef _Included_bwapi4_Mirror_FrameCallback
#define _Included_bwapi4_Mirror_FrameCallback
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,13 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class bwapi4_Mirror_JarResources */
#ifndef _Included_bwapi4_Mirror_JarResources
#define _Included_bwapi4_Mirror_JarResources
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -9,19 +9,35 @@ extern "C" {
#endif #endif
/* /*
* Class: bwapi4_Point * Class: bwapi4_Point
* Method: isValid_native * Method: isValid
* Signature: (J)Z * Signature: ()Z
*/ */
JNIEXPORT jboolean JNICALL Java_bwapi4_Point_isValid_1native JNIEXPORT jboolean JNICALL Java_bwapi4_Point_isValid
(JNIEnv *, jobject, jlong); (JNIEnv *, jobject);
/* /*
* Class: bwapi4_Point * Class: bwapi4_Point
* Method: getLength_native * Method: makeValid
* Signature: (J)D * Signature: ()Lbwapi4/Point;
*/ */
JNIEXPORT jdouble JNICALL Java_bwapi4_Point_getLength_1native JNIEXPORT jobject JNICALL Java_bwapi4_Point_makeValid
(JNIEnv *, jobject, jlong); (JNIEnv *, jobject);
/*
* Class: bwapi4_Point
* Method: getDistance
* Signature: (Lbwapi4/Point;)D
*/
JNIEXPORT jdouble JNICALL Java_bwapi4_Point_getDistance
(JNIEnv *, jobject, jobject);
/*
* Class: bwapi4_Point
* Method: getLength
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL Java_bwapi4_Point_getLength
(JNIEnv *, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -47,14 +47,6 @@ JNIEXPORT jint JNICALL Java_bwapi4_Position_getApproxDistance
JNIEXPORT jdouble JNICALL Java_bwapi4_Position_getLength JNIEXPORT jdouble JNICALL Java_bwapi4_Position_getLength
(JNIEnv *, jobject); (JNIEnv *, jobject);
/*
* Class: bwapi4_Position
* Method: hasPath
* Signature: (Lbwapi4/Position;)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_Position_hasPath
(JNIEnv *, jobject, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -7,38 +7,6 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*
* Class: bwapi4_PositionOrUnit
* Method: isUnit_native
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_PositionOrUnit_isUnit_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_PositionOrUnit
* Method: getUnit_native
* Signature: (J)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_PositionOrUnit_getUnit_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_PositionOrUnit
* Method: isPosition_native
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_PositionOrUnit_isPosition_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_PositionOrUnit
* Method: getPosition_native
* Signature: (J)Lbwapi4/Position;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_PositionOrUnit_getPosition_1native
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -7,14 +7,6 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/*
* Class: bwapi4_TilePosition
* Method: hasPath
* Signature: (Lbwapi4/TilePosition;)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_TilePosition_hasPath
(JNIEnv *, jobject, jobject);
/* /*
* Class: bwapi4_TilePosition * Class: bwapi4_TilePosition
* Method: isValid * Method: isValid

View file

@ -39,30 +39,6 @@ JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getInterceptors_1native
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getLarva_1native JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getLarva_1native
(JNIEnv *, jobject, jlong); (JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unitset
* Method: setClientInfo_native
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Unitset_setClientInfo_1native__JI
(JNIEnv *, jobject, jlong, jint);
/*
* Class: bwapi4_Unitset
* Method: setClientInfo_native
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Unitset_setClientInfo_1native__J
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unitset
* Method: setClientInfo_native
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_bwapi4_Unitset_setClientInfo_1native__JII
(JNIEnv *, jobject, jlong, jint, jint);
/* /*
* Class: bwapi4_Unitset * Class: bwapi4_Unitset
* Method: getUnitsInRadius_native * Method: getUnitsInRadius_native

75
headers4/bwapi4_Utils.h Normal file
View file

@ -0,0 +1,75 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class bwapi4_Utils */
#ifndef _Included_bwapi4_Utils
#define _Included_bwapi4_Utils
#ifdef __cplusplus
extern "C" {
#endif
#undef bwapi4_Utils_Previous
#define bwapi4_Utils_Previous 1L
#undef bwapi4_Utils_Cyan
#define bwapi4_Utils_Cyan 2L
#undef bwapi4_Utils_Yellow
#define bwapi4_Utils_Yellow 3L
#undef bwapi4_Utils_White
#define bwapi4_Utils_White 4L
#undef bwapi4_Utils_Grey
#define bwapi4_Utils_Grey 5L
#undef bwapi4_Utils_Red
#define bwapi4_Utils_Red 6L
#undef bwapi4_Utils_Green
#define bwapi4_Utils_Green 7L
#undef bwapi4_Utils_Red_P1
#define bwapi4_Utils_Red_P1 8L
#undef bwapi4_Utils_Tab
#define bwapi4_Utils_Tab 9L
#undef bwapi4_Utils_Newline
#define bwapi4_Utils_Newline 10L
#undef bwapi4_Utils_Invisible_no_override
#define bwapi4_Utils_Invisible_no_override 11L
#undef bwapi4_Utils_Remove_beyond
#define bwapi4_Utils_Remove_beyond 12L
#undef bwapi4_Utils_Clear_formatting
#define bwapi4_Utils_Clear_formatting 13L
#undef bwapi4_Utils_Blue
#define bwapi4_Utils_Blue 14L
#undef bwapi4_Utils_Teal
#define bwapi4_Utils_Teal 15L
#undef bwapi4_Utils_Purple
#define bwapi4_Utils_Purple 16L
#undef bwapi4_Utils_Orange
#define bwapi4_Utils_Orange 17L
#undef bwapi4_Utils_Right_Align
#define bwapi4_Utils_Right_Align 18L
#undef bwapi4_Utils_Center_Align
#define bwapi4_Utils_Center_Align 19L
#undef bwapi4_Utils_Invisible
#define bwapi4_Utils_Invisible 20L
#undef bwapi4_Utils_Brown
#define bwapi4_Utils_Brown 21L
#undef bwapi4_Utils_White_p7
#define bwapi4_Utils_White_p7 22L
#undef bwapi4_Utils_Yellow_p8
#define bwapi4_Utils_Yellow_p8 23L
#undef bwapi4_Utils_Green_p9
#define bwapi4_Utils_Green_p9 24L
#undef bwapi4_Utils_Brighter_Yellow
#define bwapi4_Utils_Brighter_Yellow 25L
#undef bwapi4_Utils_Cyan_default
#define bwapi4_Utils_Cyan_default 26L
#undef bwapi4_Utils_Pinkish
#define bwapi4_Utils_Pinkish 27L
#undef bwapi4_Utils_Dark_Cyan
#define bwapi4_Utils_Dark_Cyan 28L
#undef bwapi4_Utils_Greygreen
#define bwapi4_Utils_Greygreen 29L
#undef bwapi4_Utils_Bluegrey
#define bwapi4_Utils_Bluegrey 30L
#undef bwapi4_Utils_Turquoise
#define bwapi4_Utils_Turquoise 31L
#ifdef __cplusplus
}
#endif
#endif

View file

@ -47,14 +47,6 @@ JNIEXPORT jint JNICALL Java_bwapi4_WalkPosition_getApproxDistance
JNIEXPORT jdouble JNICALL Java_bwapi4_WalkPosition_getLength JNIEXPORT jdouble JNICALL Java_bwapi4_WalkPosition_getLength
(JNIEnv *, jobject); (JNIEnv *, jobject);
/*
* Class: bwapi4_WalkPosition
* Method: hasPath
* Signature: (Lbwapi4/WalkPosition;)Z
*/
JNIEXPORT jboolean JNICALL Java_bwapi4_WalkPosition_hasPath
(JNIEnv *, jobject, jobject);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

130
manual-bwapi4/AIModule.java Normal file
View file

@ -0,0 +1,130 @@
package bwapi4;
import bwapi4.BWEventListener;
/**
* This class receives all events from Broodwar.
* To process them, receive an AIModule's instance from {@link Mirror} and call {@link #setEventListener(bwapi.BWEventListener)}
* to set you own {@link BWEventListener listener}.
* There's also a stub class ({@link DefaultBWListener}) provided, so you don't have to implement all of the methods.
*/
public class AIModule {
AIModule(){}
private BWEventListener eventListener;
public void setEventListener(BWEventListener eventListener) {
this.eventListener = eventListener;
}
public void onStart() {
if (eventListener != null) {
eventListener.onStart();
}
}
public void onEnd(boolean isWinner) {
if (eventListener != null) {
eventListener.onEnd(isWinner);
}
}
public void onFrame() {
if (eventListener != null) {
eventListener.onFrame();
}
}
public void onSendText(String text) {
if (eventListener != null)
{
eventListener.onSendText(text);
}
}
public void onReceiveText(Player player, String text) {
if (eventListener != null) {
eventListener.onReceiveText(player, text);
}
}
public void onPlayerLeft(Player player) {
if (eventListener != null) {
eventListener.onPlayerLeft(player);
}
}
public void onNukeDetect(Position target) {
if (eventListener != null) {
eventListener.onNukeDetect(target);
}
}
public void onUnitDiscover(Unit unit) {
if (eventListener != null) {
eventListener.onUnitDiscover(unit);
}
}
public void onUnitEvade(Unit unit) {
if (eventListener != null) {
eventListener.onUnitEvade(unit);
}
}
public void onUnitShow(Unit unit) {
if (eventListener != null) {
eventListener.onUnitShow(unit);
}
}
public void onUnitHide(Unit unit) {
if (eventListener != null) {
eventListener.onUnitHide(unit);
}
}
public void onUnitCreate(Unit unit) {
if (eventListener != null) {
eventListener.onUnitCreate(unit);
}
}
public void onUnitDestroy(Unit unit) {
if (eventListener != null) {
eventListener.onUnitDestroy(unit);
}
}
public void onUnitMorph(Unit unit) {
if (eventListener != null) {
eventListener.onUnitMorph(unit);
}
}
public void onUnitRenegade(Unit unit) {
if (eventListener != null) {
eventListener.onUnitRenegade(unit);
}
}
public void onSaveGame(String gameName) {
if (eventListener != null) {
eventListener.onSaveGame(gameName);
}
}
public void onUnitComplete(Unit unit) {
if (eventListener != null) {
eventListener.onUnitComplete(unit);
}
}
public void onPlayerDropped(Player player) {
if (eventListener != null) {
eventListener.onPlayerDropped(player);
}
}
}

View file

@ -0,0 +1,53 @@
package bwapi4;
import bwapi4.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
/**
* Implement this interface and call {@link AIModule#setEventListener(bwapi.BWEventListener)} to receive all of the in game events.
*/
public interface BWEventListener {
public void onStart();
public void onEnd(boolean isWinner);
public void onFrame();
public void onSendText(String text);
public void onReceiveText(Player player, String text);
public void onPlayerLeft(Player player);
public void onNukeDetect(Position target);
public void onUnitDiscover(Unit unit);
public void onUnitEvade(Unit unit);
public void onUnitShow(Unit unit);
public void onUnitHide(Unit unit);
public void onUnitCreate(Unit unit);
public void onUnitDestroy(Unit unit);
public void onUnitMorph(Unit unit);
public void onUnitRenegade(Unit unit);
public void onSaveGame(String gameName);
public void onUnitComplete(Unit unit);
public void onPlayerDropped(Player player);
}

73
manual-bwapi4/Color.java Normal file
View file

@ -0,0 +1,73 @@
package bwapi4;
import java.lang.Override;
import java.util.HashMap;
import java.util.Map;
/**
* Starcraft uses a 256 color palette to render everything,
* so the colors available for draw shapes using BWAPI is limited to the colors available in the <a href="http://bwapi.googlecode.com/svn/wiki/colorPalette.gif" target="_blank">Pallete</a>.
* Several predefined colors from the pallete are provided.
*/
public class Color {
private int r, g, b;
/**
* Create a color using the color in the palette that is closest to the RGB color specified. This will check a number of colors in the pallet to see which is closest to the specified color so this function is relatively slow.
* @param r
* @param g
* @param b
*/
public Color(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
}
public static Color Red;
public static Color Blue;
public static Color Teal;
public static Color Purple;
public static Color Orange;
public static Color Brown;
public static Color White;
public static Color Yellow;
public static Color Green;
public static Color Cyan;
public static Color Black;
public static Color Grey;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Color)) return false;
Color color = (Color) o;
if (b != color.b) return false;
if (g != color.g) return false;
if (r != color.r) return false;
return true;
}
@Override
public int hashCode() {
int result = r;
result = 31 * result + g;
result = 31 * result + b;
return result;
}
}

View file

@ -0,0 +1,103 @@
package bwapi4;
import bwapi4.BWEventListener;
import bwapi4.Player;
import bwapi4.Position;
import bwapi4.Unit;
/**
* A utility stub class providing a default implementation of {@link BWEventListener},
* override it's methods if you want to handle only some events.
*/
public class DefaultBWListener implements BWEventListener {
@Override
public void onStart() {
}
@Override
public void onEnd(boolean b) {
}
@Override
public void onFrame() {
}
@Override
public void onSendText(String s) {
}
@Override
public void onReceiveText(Player player, String s) {
}
@Override
public void onPlayerLeft(Player player) {
}
@Override
public void onNukeDetect(Position position) {
}
@Override
public void onUnitDiscover(Unit unit) {
}
@Override
public void onUnitEvade(Unit unit) {
}
@Override
public void onUnitShow(Unit unit) {
}
@Override
public void onUnitHide(Unit unit) {
}
@Override
public void onUnitCreate(Unit unit) {
}
@Override
public void onUnitDestroy(Unit unit) {
}
@Override
public void onUnitMorph(Unit unit) {
}
@Override
public void onUnitRenegade(Unit unit) {
}
@Override
public void onSaveGame(String s) {
}
@Override
public void onUnitComplete(Unit unit) {
}
@Override
public void onPlayerDropped(Player player) {
}
}

262
manual-bwapi4/Mirror.java Normal file
View file

@ -0,0 +1,262 @@
package bwapi4;
import bwapi4.AIModule;
import bwapi4.BWEventListener;
import java.io.*;
import java.io.File;
import java.lang.Exception;
import java.lang.UnsupportedOperationException;
import java.util.*;
import java.util.zip.*;
/**
* <p>The API entry point. Standard use case:</p>
* <ul>
* <li>Create a Mirror object and use {@link #getModule()} and then set an {@link AIModule}'s {@link BWEventListener}<br/>
* <li>Call {@link #startGame()} to init the API and connect to Broodwar, then launch Broodwar from ChaosLauncher.</li>
* <li>In you {@link BWEventListener#onStart()} method, receive the Game object by calling {@link #getGame()}</li>
* </ul>
* <br/>
* <b>Example</b>
* <pre>
* {@code
*
* mirror.getModule().setEventListener(new DefaultBWListener()
* {
* public void onStart() {
* game = mirror.getGame();
* self = game.self();
* //initialization
* ....
* }
*
* public void onUpdate() {
* for (Unit myUnit : self.getUnits()) {
* //give orders to unit
* ...
* }
* }
* });
* }
* mirror.startGame();
* </pre>
* <p><b>Note:</b> The Game object is initialized during the {@link #startGame()} as well as other BWMirror API's constants.
* Do not use any API releated methods/fields prior to {@link #startGame()}.</p>
*/
public class Mirror {
private Game game;
private AIModule module = new AIModule();
private FrameCallback frameCallback;
private static final boolean EXTRACT_JAR = true;
private static final String VERSION = "2_0";
static {
String arch = System.getProperty("os.arch");
String dllNames[] = {"bwapi_bridge" + VERSION, "gmp-vc90-mt", "mpfr-vc90-mt"};
if(!arch.equals("x86")){
throw new UnsupportedOperationException("BWMirror API supports only x86 architecture.");
}
try {
if (EXTRACT_JAR) {
System.setProperty("java.library.path", ".");
java.lang.reflect.Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
fieldSysPath.setAccessible(true);
fieldSysPath.set(null, null);
String path = Mirror.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = java.net.URLDecoder.decode(path, "UTF-8");
for (String dllName : dllNames) {
String dllNameExt = dllName + ".dll";
if (!new File(dllNameExt).exists()) {
JarResources jar = new JarResources(path);
byte[] correctDllData = jar.getResource(dllNameExt);
FileOutputStream funnyStream = new FileOutputStream(dllNameExt);
funnyStream.write(correctDllData);
funnyStream.close();
}
}
}
} catch (Exception e) {
System.err.println("Failed to extract native libraries.\n" + e);
}
System.loadLibrary(dllNames[0]);
File dataDir = new File("bwapi-data/BWTA");
if(!dataDir.exists()){
try {
dataDir.mkdirs();
} catch (Exception e) {
System.err.println("Unable to create /bwapi-data/BWTA folder, BWTA analysis will not be saved.");
}
}
}
public Game getGame() {
return game;
}
public AIModule getModule() {
return module;
}
/**
* Starts the API, initializes all constants ( {@link UnitType}, {@link WeaponType} ) and the {@link Game} object.
* This method blocks until the end of game.
*/
public native void startGame();
private void update() {
if (frameCallback != null) {
frameCallback.update();
}
}
/*public void setFrameCallback(bwapi.Mirror.FrameCallback frameCallback) {
this.frameCallback = frameCallback;
} */
/**
* The simplest interface to receive update event from Broodwar. The {@link #update()} method is called once each frame.
* For a simple bot and implementation of this interface is enough, to receive all in game events, implement {@link BWEventListener}.
*/
/*public*/ private interface FrameCallback {
public void update();
}
@SuppressWarnings({"unchecked"})
private static class JarResources {
// external debug flag
public boolean debugOn = false;
// jar resource mapping tables
private Hashtable htSizes = new Hashtable();
private Hashtable htJarContents = new Hashtable();
// a jar file
private String jarFileName;
/**
* creates a javabot.JarResources. It extracts all resources from a Jar
* into an internal hashtable, keyed by resource names.
*
* @param jarFileName a jar or zip file
*/
public JarResources(String jarFileName) {
this.jarFileName = jarFileName;
init();
}
/**
* Extracts a jar resource as a blob.
*
* @param name a resource name.
*/
public byte[] getResource(String name) {
return (byte[]) htJarContents.get(name);
}
/**
* initializes internal hash tables with Jar file resources.
*/
private void init() {
try {
// extracts just sizes only.
ZipFile zf = new ZipFile(jarFileName);
Enumeration e = zf.entries();
while (e.hasMoreElements()) {
ZipEntry ze = (ZipEntry) e.nextElement();
if (debugOn) {
System.out.println(dumpZipEntry(ze));
}
htSizes.put(ze.getName(), new Integer((int) ze.getSize()));
}
zf.close();
// extract resources and put them into the hashtable.
FileInputStream fis = new FileInputStream(jarFileName);
BufferedInputStream bis = new BufferedInputStream(fis);
ZipInputStream zis = new ZipInputStream(bis);
ZipEntry ze = null;
while ((ze = zis.getNextEntry()) != null) {
if (ze.isDirectory()) {
continue;
}
if (debugOn) {
System.out.println(
"ze.getName()=" + ze.getName() + "," + "getSize()=" + ze.getSize()
);
}
int size = (int) ze.getSize();
// -1 means unknown size.
if (size == -1) {
size = ((Integer) htSizes.get(ze.getName())).intValue();
}
byte[] b = new byte[(int) size];
int rb = 0;
int chunk = 0;
while (((int) size - rb) > 0) {
chunk = zis.read(b, rb, (int) size - rb);
if (chunk == -1) {
break;
}
rb += chunk;
}
// add to internal resource hashtable
htJarContents.put(ze.getName(), b);
if (debugOn) {
System.out.println(
ze.getName() + " rb=" + rb +
",size=" + size +
",csize=" + ze.getCompressedSize()
);
}
}
} catch (NullPointerException e) {
System.out.println("done.");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Dumps a zip entry into a string.
*
* @param ze a ZipEntry
*/
private String dumpZipEntry(ZipEntry ze) {
StringBuffer sb = new StringBuffer();
if (ze.isDirectory()) {
sb.append("d ");
} else {
sb.append("f ");
}
if (ze.getMethod() == ZipEntry.STORED) {
sb.append("stored ");
} else {
sb.append("defalted ");
}
sb.append(ze.getName());
sb.append("\t");
sb.append("" + ze.getSize());
if (ze.getMethod() == ZipEntry.DEFLATED) {
sb.append("/" + ze.getCompressedSize());
}
return (sb.toString());
}
}
}

View file

@ -30,8 +30,6 @@ public class Position extends AbstractPoint<Position>{
public native double getLength(); public native double getLength();
public native boolean hasPath(Position position);
public int getX() { public int getX() {
return x; return x;
} }

View file

@ -0,0 +1,55 @@
package bwapi4;
import java.lang.IllegalArgumentException;
import java.lang.Object;
import java.lang.Override;
public class PositionOrUnit {
private Unit unit;
private Position position;
public PositionOrUnit(Unit unit){
if(unit == null){
throw new IllegalArgumentException("PositionOrUnit must not reference null!");
};
this.unit = unit;
}
public PositionOrUnit(Position position){
if(position == null){
throw new IllegalArgumentException("PositionOrUnit must not reference null!");
};
this.position = position;
}
public Unit getUnit(){
return unit;
}
public Position getPosition() {
return position;
}
public boolean isUnit(){
return unit != null;
}
public boolean isPosition(){
return position != null;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PositionOrUnit)) return false;
PositionOrUnit that = (PositionOrUnit) o;
if (position != null ? !position.equals(that.position) : that.position != null) return false;
if (unit != null ? !unit.equals(that.unit) : that.unit != null) return false;
return true;
}
}

View file

@ -9,7 +9,7 @@ import java.util.Map;
* These are called build tiles because buildability data is available at this resolution, and correspond to the tiles seen in game. * These are called build tiles because buildability data is available at this resolution, and correspond to the tiles seen in game.
* For example, a Command Center occupies an area of 4x3 build tiles. * For example, a Command Center occupies an area of 4x3 build tiles.
*/ */
public class TilePosition { public class TilePosition extends AbstractPoint<TilePosition>{
private int x, y; private int x, y;
public TilePosition(int x, int y) { public TilePosition(int x, int y) {
@ -21,8 +21,6 @@ public class TilePosition {
return "[" + x + ", " + y + "]"; return "[" + x + ", " + y + "]";
} }
public native boolean hasPath(TilePosition position);
public native boolean isValid(); public native boolean isValid();
public native TilePosition makeValid(); public native TilePosition makeValid();
@ -82,4 +80,8 @@ public class TilePosition {
result = 31 * result + y; result = 31 * result + y;
return result; return result;
} }
public TilePosition getPoint(){
return this;
}
} }

52
manual-bwapi4/Utils.java Normal file
View file

@ -0,0 +1,52 @@
package bwapi4;
import java.lang.String;
import java.lang.System;
/**
*
*/
public class Utils {
public static final byte Previous = 0x01;
public static final byte Cyan = 0x02;
public static final byte Yellow = 0x03;
public static final byte White = 0x04;
public static final byte Grey = 0x05;
public static final byte Red = 0x06;
public static final byte Green = 0x07;
public static final byte Red_P1 = 0x08;
public static final byte Tab = 0x09;
public static final byte Newline = 0x0A;
public static final byte Invisible_no_override = 0x0B;
public static final byte Remove_beyond = 0x0C;
public static final byte Clear_formatting = 0x0D;
public static final byte Blue = 0x0E;
public static final byte Teal = 0x0F;
public static final byte Purple = 0x10;
public static final byte Orange = 0x11;
public static final byte Right_Align = 0x12;
public static final byte Center_Align = 0x13;
public static final byte Invisible = 0x14;
public static final byte Brown = 0x15;
public static final byte White_p7 = 0x16;
public static final byte Yellow_p8 = 0x17;
public static final byte Green_p9 = 0x18;
public static final byte Brighter_Yellow = 0x19;
public static final byte Cyan_default = 0x1A;
public static final byte Pinkish = 0x1B;
public static final byte Dark_Cyan = 0x1C;
public static final byte Greygreen = 0x1D;
public static final byte Bluegrey = 0x1E;
public static final byte Turquoise = 0x1F;
public static String formatText(String text, byte format){
byte[] textData = text.getBytes();
int textDataLength = text.length();
byte[] newTextData = new byte[textDataLength + 1];
newTextData[0] = format;
System.arraycopy(textData, 0, newTextData, 1, textDataLength);
return new String(newTextData);
}
}

View file

@ -4,7 +4,7 @@ import java.lang.Override;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class WalkPosition { public class WalkPosition extends AbstractPoint<WalkPosition>{
private int x, y; private int x, y;
@ -27,8 +27,6 @@ public class WalkPosition {
public native double getLength(); public native double getLength();
public native boolean hasPath(WalkPosition position);
public int getX() { public int getX() {
return x; return x;
} }
@ -80,4 +78,8 @@ public class WalkPosition {
} }
private long pointer; private long pointer;
public WalkPosition getPoint(){
return this;
}
} }

View file

@ -39,8 +39,8 @@ public class CJavaPipeline {
* Classes from BWAPI 4 that don't need mirroring * Classes from BWAPI 4 that don't need mirroring
* Not used in mirroring BWAPI 3 * Not used in mirroring BWAPI 3
*/ */
private static final List<String> ignoredClasses = new ArrayList<>(Arrays.asList("Vectorset", "ConstVectorset", "VSetIterator", private static final List<String> ignoredClasses = new ArrayList<>(Arrays.asList("Vectorset", "ConstVectorset", "VSetIterator", "GameWrapper",
"Interface", "RectangleArray", "UnitImpl", "PlayerImpl", "GameImpl", "BulletImpl", "ForceImpl", "TournamentModule", "RegionImpl", "SetContainer", "InterfaceEvent")); "Interface", "RectangleArray", "UnitImpl", "PlayerImpl", "GameImpl", "BulletImpl", "ForceImpl", "TournamentModule", "RegionImpl", "SetContainer", "InterfaceEvent", "PositionOrUnit", "Point"));
private static final HashMap<String, String> superClasses = new HashMap<>(); private static final HashMap<String, String> superClasses = new HashMap<>();
@ -187,6 +187,8 @@ public class CJavaPipeline {
callImplementer.setBwtaMode(pkg.packageName.equals("bwta")); callImplementer.setBwtaMode(pkg.packageName.equals("bwta"));
javaContext.setPackageName(pkg.packageName); javaContext.setPackageName(pkg.packageName);
callImplementer.notifyPackageStart();
for (File file : new File(pkg.packageName).listFiles(new FilenameFilter() { for (File file : new File(pkg.packageName).listFiles(new FilenameFilter() {
@Override @Override
public boolean accept(File dir, String name) { public boolean accept(File dir, String name) {

View file

@ -14,11 +14,11 @@ public class JavaContext {
private HashMap<String, String> javaToCType = new HashMap<>(); private HashMap<String, String> javaToCType = new HashMap<>();
private List<String> valueTypes = Arrays.asList("Position", "TilePosition", "Color", "BWTA::RectangleArray<double>"); private List<String> valueTypes = Arrays.asList("Position", "TilePosition", "WalkPosition", "Color", "BWTA::RectangleArray<double>", "PositionOrUnit", "Point");
private List<String> constantTypes = Arrays.asList("UnitType", "TechType", "UpgradeType", "Race", "UnitCommand", "WeaponType", "Order", "GameType", "Error"); private List<String> constantTypes = Arrays.asList("UnitType", "TechType", "UpgradeType", "Race", "UnitCommand", "WeaponType", "Order", "GameType", "Error");
private List<String> enumTypes = Arrays.asList("MouseButton", "Key"); private List<String> enumTypes = Arrays.asList("MouseButton", "Key", "bwapi4.Text.Size.Enum", "bwapi4.CoordinateType.Enum");
private List<String> valueReturnTypes = Arrays.asList("UnitCommand", "Event"); private List<String> valueReturnTypes = Arrays.asList("UnitCommand", "Event");
@ -85,7 +85,9 @@ public class JavaContext {
} }
switch (variableType) { switch (variableType) {
case "Position": case "Position":
case "WalkPosition":
case "TilePosition": case "TilePosition":
case "Point":
return "(" + return "(" +
"(int)env->GetIntField(" + rawName + ", FindCachedField(env, env->GetObjectClass(" + rawName + "), \"x\", \"I\")), " + "(int)env->GetIntField(" + rawName + ", FindCachedField(env, env->GetObjectClass(" + rawName + "), \"x\", \"I\")), " +
"(int)env->GetIntField(" + rawName + ", FindCachedField(env, env->GetObjectClass(" + rawName + "), \"y\", \"I\"))" + "(int)env->GetIntField(" + rawName + ", FindCachedField(env, env->GetObjectClass(" + rawName + "), \"y\", \"I\"))" +
@ -100,12 +102,20 @@ public class JavaContext {
"(int)env->GetIntField(" + rawName + ", FindCachedField(env, env->GetObjectClass(" + rawName + "), \"g\", \"I\")), " + "(int)env->GetIntField(" + rawName + ", FindCachedField(env, env->GetObjectClass(" + rawName + "), \"g\", \"I\")), " +
"(int)env->GetIntField(" + rawName + ", FindCachedField(env, env->GetObjectClass(" + rawName + "), \"b\", \"I\"))" + "(int)env->GetIntField(" + rawName + ", FindCachedField(env, env->GetObjectClass(" + rawName + "), \"b\", \"I\"))" +
");"; ");";
case "PositionOrUnit":
return "(convertPositionOrUnit(env, " + rawName + " ));";
} }
return ";"; return ";";
} }
public String copyJavaObjectToC(String variableType, String variableName, String rawName) { public String copyJavaObjectToC(String variableType, String variableName, String rawName) {
return (variableType + " " + variableName) + copyFields(variableType, variableName, rawName); String packageStrippedType = variableType;
if(packageStrippedType.startsWith("bwapi")){
packageStrippedType = packageStrippedType.substring(packageStrippedType.indexOf(".") + 1);
}
packageStrippedType = packageStrippedType.replaceAll("\\.","::");
return (packageStrippedType + " " + variableName) + copyFields(packageStrippedType, variableName, rawName);
} }
public String copyJavaObjectToC(String variableType, String variableName) { public String copyJavaObjectToC(String variableType, String variableName) {
@ -133,14 +143,16 @@ public class JavaContext {
public String copyConstructor(String javaType) { public String copyConstructor(String javaType) {
switch (javaType) { switch (javaType) {
case "TilePosition": case "TilePosition":
case "WalkPosition":
case "Position": case "Position":
case "Point":
return "II"; return "II";
case "Color": case "Color":
return "III"; return "III";
case "Error": case "Error":
return "I"; return "I";
default: default:
return ""; throw new UnsupportedOperationException();
} }
} }
@ -158,9 +170,9 @@ public class JavaContext {
public String implementCopyReturn(String javaType, String fieldName) { public String implementCopyReturn(String javaType, String fieldName) {
switch (javaType) { switch (javaType) {
case "TilePosition": case "TilePosition":
return ", "+fieldName+".x" + checkBWAPI3brackets() +
", "+fieldName+".y" + checkBWAPI3brackets() ;
case "Position": case "Position":
case "WalkPosition":
case "Point":
return ", "+fieldName+".x" + checkBWAPI3brackets() + return ", "+fieldName+".x" + checkBWAPI3brackets() +
", "+fieldName+".y" + checkBWAPI3brackets() ; ", "+fieldName+".y" + checkBWAPI3brackets() ;
case "Color": case "Color":

View file

@ -5,6 +5,7 @@ import c.CDeclaration;
import c.DeclarationType; import c.DeclarationType;
import c.Field; import c.Field;
import generator.CJavaPipeline; import generator.CJavaPipeline;
import generator.JavaContext;
import impl.ClassVariable; import impl.ClassVariable;
import java.io.PrintStream; import java.io.PrintStream;
@ -21,6 +22,7 @@ public class Bind {
private PrintStream out; private PrintStream out;
public void setOut(PrintStream out) { public void setOut(PrintStream out) {
this.out = out; this.out = out;
} }
@ -31,13 +33,35 @@ public class Bind {
out.println("\t\tprintln(\"BWAPI ready.\");"); out.println("\t\tprintln(\"BWAPI ready.\");");
} }
private String broodwarPtrSuffix() {
if (!CJavaPipeline.isBWAPI3()) { private void implementConnectionRoutine() {
return "ptr"; if (CJavaPipeline.isBWAPI3()) {
out.println(" if (Broodwar != NULL) {\n" +
"\t\t\t\tprintln(\"Waiting...\");\n" +
" while (!Broodwar->isInGame()) {\n" +
" BWAPIClient.update();\n" +
"\t\t\t\t\tif (Broodwar == NULL) {\n" +
" println(\"Match ended.\");\n" +
" return;\n" +
" }\n" +
" }\n" +
" }\n" +
"\n");
} else {
out.println("\t\t\t\tprintln(\"Waiting...\");" +
"while ( !Broodwar->isInGame() )\n" +
" {\n" +
" BWAPI::BWAPIClient.update();\n" +
" if (!BWAPI::BWAPIClient.isConnected())\n" +
" {\n" +
" println(\"Reconnecting...\");\n" +
" reconnect();\n" +
" }\n" +
" }");
} }
return "";
} }
private void implementGameStart() { private void implementGameStart() {
out.println("println(\"Connecting to Broodwar...\");\n" + out.println("println(\"Connecting to Broodwar...\");\n" +
"\t\treconnect();\n" + "\t\treconnect();\n" +
@ -51,7 +75,7 @@ public class Bind {
"\t\tjobject moduleObj = env->GetObjectField(obj, env->GetFieldID(cls, \"module\", \"Lbwapi/AIModule;\"));\n" + "\t\tjobject moduleObj = env->GetObjectField(obj, env->GetFieldID(cls, \"module\", \"Lbwapi/AIModule;\"));\n" +
"\t\tjclass moduleCls = env->GetObjectClass(moduleObj);\n" + "\t\tjclass moduleCls = env->GetObjectClass(moduleObj);\n" +
"\t\tenv->SetObjectField(obj, env->GetFieldID(cls, \"game\", \"Lbwapi/Game;\"), " + "\t\tenv->SetObjectField(obj, env->GetFieldID(cls, \"game\", \"Lbwapi/Game;\"), " +
"env->CallStaticObjectMethod(gamecls, env->GetStaticMethodID(gamecls, \"get\", \"(J)Lbwapi/Game;\"), (long)Broodwar" + broodwarPtrSuffix() + "));\n" + "env->CallStaticObjectMethod(gamecls, env->GetStaticMethodID(gamecls, \"get\", \"(J)Lbwapi/Game;\"), (long)" + (CJavaPipeline.isBWAPI3() ? "" : "&") + "Broodwar));\n" +
"\n" + "\n" +
"\t\tjmethodID updateMethodID = env->GetMethodID(env->GetObjectClass(obj), \"update\", \"()V\");"); "\t\tjmethodID updateMethodID = env->GetMethodID(env->GetObjectClass(obj), \"update\", \"()V\");");
@ -74,24 +98,13 @@ public class Bind {
"\t\tjmethodID unitCompleteCallback = env->GetMethodID(moduleCls, \"onUnitComplete\", \"(Lbwapi/Unit;)V\");\n" + "\t\tjmethodID unitCompleteCallback = env->GetMethodID(moduleCls, \"onUnitComplete\", \"(Lbwapi/Unit;)V\");\n" +
"\t\tjmethodID playerDroppedCallback = env->GetMethodID(moduleCls, \"onPlayerDropped\", \"(Lbwapi/Player;)V\");"); "\t\tjmethodID playerDroppedCallback = env->GetMethodID(moduleCls, \"onPlayerDropped\", \"(Lbwapi/Player;)V\");");
out.println( out.println("\t\twhile (true) {\n");
"\t\twhile (true) {\n" + implementConnectionRoutine();
" if (Broodwar" + broodwarPtrSuffix() + " != NULL) {\n" + out.println("\t\t\tprintln(\"Game ready!!!\");\n" +
"\t\t\t\tprintln(\"Waiting...\");\n" + "\n" +
" while (!Broodwar" + broodwarPtrSuffix() + "->isInGame()) {\n" + "\t\t\twhile (Broodwar->isInGame()) {\n" +
" BWAPIClient.update();\n" + "\t\t\t\t\n" +
"\t\t\t\t\tif (Broodwar" + broodwarPtrSuffix() + " == NULL) {\n" + "\t\t\t\tenv->CallVoidMethod(obj, updateMethodID);\n");
" println(\"Match ended.\");\n" +
" return;\n" +
" }\n" +
" }\n" +
" }\n" +
"\n" +
"\t\t\tprintln(\"Game ready!!!\");\n" +
"\n" +
"\t\t\twhile (Broodwar->isInGame()) {\n" +
"\t\t\t\t\n" +
"\t\t\t\tenv->CallVoidMethod(obj, updateMethodID);\n");
out.println("\n" + out.println("\n" +
"\t\t\t\tfor(std::list<Event>::const_iterator it = Broodwar->getEvents().begin(); it!=Broodwar->getEvents().end(); it++)\n" + "\t\t\t\tfor(std::list<Event>::const_iterator it = Broodwar->getEvents().begin(); it!=Broodwar->getEvents().end(); it++)\n" +
"\t\t\t\t {\n" + "\t\t\t\t {\n" +
@ -166,35 +179,51 @@ public class Bind {
"\t\t\t\t\t\tprintln(\"Reconnecting...\");\n" + "\t\t\t\t\t\tprintln(\"Reconnecting...\");\n" +
"\t\t\t\t\t\treconnect();\n" + "\t\t\t\t\t\treconnect();\n" +
"\t\t\t\t}\n" + "\t\t\t\t}\n" +
(CJavaPipeline.isBWAPI3() ? "" : "println(\"Match ended.\");") +
"\t\t\t}\n" + "\t\t\t}\n" +
"\t\t}"); "\t\t}");
} }
private void implementHelpers() { private void implementHelpers() {
out.println("void reconnect()\n" + if (CJavaPipeline.isBWAPI3()) {
"{\n" + out.println("void reconnect()\n" +
"\twhile (!BWAPIClient.connect()) {\n" + "{\n" +
" Sleep(1000);\n" + "\twhile (!BWAPIClient.connect()) {\n" +
" }\n" + " Sleep(1000);\n" +
"}\n" + " }\n" +
"\n" + "}\n" +
"\n" + "\n" +
"\n" + "\n");
} else {
out.println("void reconnect()\n" +
"{\n" +
"\twhile (!BWAPIClient.connect()) {\n" +
" std::this_thread::sleep_for(std::chrono::milliseconds{ 1000 });\n" +
" }\n" +
"}\n" +
"\n" +
"\n");
}
out.println(
"void flushPrint(const char * text){\n" + "void flushPrint(const char * text){\n" +
"\tprintf(text);\n" + "\tprintf(text);\n" +
"\tfflush(stdout); \n" + "\tfflush(stdout); \n" +
"}\n" + "}\n" +
"\n" + "\n" +
"void println(const char * text){\n" + "void println(const char * text){\n" +
"\tprintf(text);\n" + "\tprintf(text);\n" +
"\tflushPrint(\"\\n\");\n" + "\tflushPrint(\"\\n\");\n" +
"}\n"); "}\n");
} }
private void implementMirrorInit(List<CDeclaration> declarationList) { private void implementMirrorInit(List<CDeclaration> declarationList) {
implementHelpers(); implementHelpers();
out.println("JNIEXPORT void JNICALL Java_bwapi_Mirror_startGame(JNIEnv * env, jobject obj){"); out.println("JNIEXPORT void JNICALL Java_bwapi_Mirror_startGame(JNIEnv * env, jobject obj){");
implementBWAPIInit(); if (CJavaPipeline.isBWAPI3()) {
implementBWAPIInit();
}
implementVariablesBind(declarationList); implementVariablesBind(declarationList);
implementGameStart(); implementGameStart();
out.println("}"); out.println("}");
@ -246,7 +275,7 @@ public class Bind {
"env->GetStaticFieldID(cls, \"" + classVariable.getName() + "\", \"Lbwapi/" + classVariable.getType() + ";\"), " + "env->GetStaticFieldID(cls, \"" + classVariable.getName() + "\", \"Lbwapi/" + classVariable.getType() + ";\"), " +
"env->CallStaticObjectMethod(cls, getId, (jlong)&" + cValue + ")" + "env->CallStaticObjectMethod(cls, getId, (jlong)&" + cValue + ")" +
");"); ");");
if (cClass.getName().equals("Position") || cClass.getName().equals("TilePosition")) { if (cClass.getName().equals("Position") || cClass.getName().equals("TilePosition") || cClass.getName().equals("WalkPosition") || cClass.getName().equals("Point")) {
return; return;
} }
out.println("table" + cClass.getName() + ".insert(std::pair<int, const " + cClass.getName() + "*>(" + cValue + ".getID(), &" + cValue + "));"); out.println("table" + cClass.getName() + ".insert(std::pair<int, const " + cClass.getName() + "*>(" + cValue + ".getID(), &" + cValue + "));");

View file

@ -33,7 +33,7 @@ public class TypeTable {
} }
private void checkTypeTable(CClass cClass) { private void checkTypeTable(CClass cClass) {
if(cClass.getName().equals("Position") || cClass.getName().equals("TilePosition")){ if(cClass.getName().equals("Position") || cClass.getName().equals("TilePosition") || cClass.getName().equals("WalkPosition") || cClass.getName().equals("Point")){
return; return;
} }
for (Field field : cClass.getFields()) { for (Field field : cClass.getFields()) {

View file

@ -53,7 +53,7 @@ public class CallImplementer {
out.print("#include \"../concat_header.h\"\n" + out.print("#include \"../concat_header.h\"\n" +
"#include <BWAPI.h>\n" + "#include <BWAPI.h>\n" +
"#include <BWAPI/Client.h>\n" + "#include <BWAPI/Client.h>\n" +
(CJavaPipeline.isBWAPI3() ? "#include <BWTA.h>\n" : "") + (CJavaPipeline.isBWAPI3() ? "#include <BWTA.h>\n" : "#include <thread>\n" + "#include <chrono>\n") +
"#include <jni.h>\n" + "#include <jni.h>\n" +
"#include <cstring>\n" + "#include <cstring>\n" +
"#include \"../BWTA_Result.h\"" + "#include \"../BWTA_Result.h\"" +
@ -390,4 +390,20 @@ public class CallImplementer {
public void setBwtaMode(boolean bwtaMode) { public void setBwtaMode(boolean bwtaMode) {
this.bwtaMode = bwtaMode; this.bwtaMode = bwtaMode;
} }
public void notifyPackageStart(){
out.println("PositionOrUnit convertPositionOrUnit(JNIEnv * env, jobject obj){ \n" +
"\tjclass clz = FindCachedClass(env, \"PositionOrUnit\");\n" +
"\tjmethodID typeMethodId = FindCachedMethod(env, clz, \"isUnit\", \"()Z\");\n" +
"\tbool isUnit = (bool)env->CallBooleanMethod(obj, typeMethodId);\n" +
"\tif(isUnit){\n" +
"\t\tjobject unitObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, \"getUnit\", \"()L" + javaContext.getPackageName() + "/Unit;\"));\n" +
"\t\tUnit unit = (Unit)env->GetLongField(unitObj, FindCachedField(env, env->GetObjectClass(unitObj), \"unitObj\", \"J\"));\n" +
"\t\treturn PositionOrUnit(unit);\n" +
"\t}\n" +
"\tjobject posObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, \"getPosition\", \"()L" + javaContext.getPackageName() + "/Position;\"));\n" +
"\t" + javaContext.copyJavaObjectToC("Position", "position", "posObj") + "\n" +
"\treturn PositionOrUnit(position);\n" +
"}\n\n");
}
} }

View file

@ -261,6 +261,11 @@ public class CApiParser {
} }
} }
if(function.name.equals("setClientInfo")){
System.err.println("function skipped - BWAPI4 set client info return (" + function.name + ")");
return null;
}
if (matcher.group(F_REGEX_PARAMS) != null) { if (matcher.group(F_REGEX_PARAMS) != null) {
String paramsString = matcher.group(F_REGEX_PARAMS); String paramsString = matcher.group(F_REGEX_PARAMS);
String paramStrings[] = paramsString.split("\\,"); String paramStrings[] = paramsString.split("\\,");
@ -325,7 +330,12 @@ public class CApiParser {
} }
// //
if (argType.equals("va_list")) { if (argType.equals("va_list")) {
if(function.name.startsWith("v")){
System.err.println("BWAPI4 va_list function skipped : " + function.name);
return null;
}
argType = "Object ..."; argType = "Object ...";
continue;
} }
@ -381,6 +391,7 @@ public class CApiParser {
return null; return null;
} }
if (arg.length > 2 && arg[2].equals("=")) { if (arg.length > 2 && arg[2].equals("=")) {
function.args.add(new Param(argType, argName, arg[3])); function.args.add(new Param(argType, argName, arg[3]));
} else { } else {