bwapi4 testing begins!

This commit is contained in:
vjurenka 2015-02-09 19:16:11 +01:00
parent 288d6b6c75
commit 14e4e5aaef
42 changed files with 504 additions and 982 deletions

View file

@ -133,70 +133,6 @@ public class Game {
enableFlag_native(pointer, flag);
}
public List<Unit> getUnitsOnTile(int tileX, int tileY, UnitFilter pred) {
return getUnitsOnTile_native(pointer, tileX, tileY, pred);
}
public List<Unit> getUnitsOnTile(TilePosition tile, UnitFilter pred) {
return getUnitsOnTile_native(pointer, tile, pred);
}
public List<Unit> getUnitsInRectangle(int left, int top, int right, int bottom, UnitFilter pred) {
return getUnitsInRectangle_native(pointer, left, top, right, bottom, pred);
}
public List<Unit> getUnitsInRectangle(Position topLeft, Position bottomRight, UnitFilter pred) {
return getUnitsInRectangle_native(pointer, topLeft, bottomRight, pred);
}
public List<Unit> getUnitsInRadius(int x, int y, int radius, UnitFilter pred) {
return getUnitsInRadius_native(pointer, x, y, radius, pred);
}
public List<Unit> getUnitsInRadius(Position center, int radius, UnitFilter pred) {
return getUnitsInRadius_native(pointer, center, radius, pred);
}
public Unit getClosestUnit(Position center, UnitFilter pred) {
return getClosestUnit_native(pointer, center, pred);
}
public Unit getClosestUnit(Position center, UnitFilter pred, int radius) {
return getClosestUnit_native(pointer, center, pred, radius);
}
public Unit getClosestUnitInRectangle(Position center, UnitFilter pred, int left, int top, int right) {
return getClosestUnitInRectangle_native(pointer, center, pred, left, top, right);
}
public Unit getClosestUnitInRectangle(Position center, UnitFilter pred, int left, int top) {
return getClosestUnitInRectangle_native(pointer, center, pred, left, top);
}
public Unit getClosestUnitInRectangle(Position center, UnitFilter pred, int left) {
return getClosestUnitInRectangle_native(pointer, center, pred, left);
}
public Unit getClosestUnitInRectangle(Position center, UnitFilter pred) {
return getClosestUnitInRectangle_native(pointer, center, pred);
}
public Unit getClosestUnitInRectangle(Position center, UnitFilter pred, int left, int top, int right, int bottom) {
return getClosestUnitInRectangle_native(pointer, center, pred, left, top, right, bottom);
}
public Unit getBestUnit(BestUnitFilter best, UnitFilter pred, Position center) {
return getBestUnit_native(pointer, best, pred, center);
}
public Unit getBestUnit(BestUnitFilter best, UnitFilter pred) {
return getBestUnit_native(pointer, best, pred);
}
public Unit getBestUnit(BestUnitFilter best, UnitFilter pred, Position center, int radius) {
return getBestUnit_native(pointer, best, pred, center, radius);
}
public Error getLastError() {
return getLastError_native(pointer);
}
@ -241,6 +177,14 @@ public class Game {
return isWalkable_native(pointer, position);
}
public int getGroundHeight(int tileX, int tileY) {
return getGroundHeight_native(pointer, tileX, tileY);
}
public int getGroundHeight(TilePosition position) {
return getGroundHeight_native(pointer, position);
}
public boolean isBuildable(int tileX, int tileY) {
return isBuildable_native(pointer, tileX, tileY);
}
@ -857,6 +801,10 @@ public class Game {
return setVision_native(pointer, player, enabled);
}
public int elapsedTime() {
return elapsedTime_native(pointer);
}
public void setCommandOptimizationLevel(int level) {
setCommandOptimizationLevel_native(pointer, level);
}
@ -1004,38 +952,6 @@ public class Game {
private native void enableFlag_native(long pointer, int flag);
private native List<Unit> getUnitsOnTile_native(long pointer, int tileX, int tileY, UnitFilter pred);
private native List<Unit> getUnitsOnTile_native(long pointer, TilePosition tile, UnitFilter pred);
private native List<Unit> getUnitsInRectangle_native(long pointer, int left, int top, int right, int bottom, UnitFilter pred);
private native List<Unit> getUnitsInRectangle_native(long pointer, Position topLeft, Position bottomRight, UnitFilter pred);
private native List<Unit> getUnitsInRadius_native(long pointer, int x, int y, int radius, UnitFilter pred);
private native List<Unit> getUnitsInRadius_native(long pointer, Position center, int radius, UnitFilter pred);
private native Unit getClosestUnit_native(long pointer, Position center, UnitFilter pred);
private native Unit getClosestUnit_native(long pointer, Position center, UnitFilter pred, int radius);
private native Unit getClosestUnitInRectangle_native(long pointer, Position center, UnitFilter pred, int left, int top, int right);
private native Unit getClosestUnitInRectangle_native(long pointer, Position center, UnitFilter pred, int left, int top);
private native Unit getClosestUnitInRectangle_native(long pointer, Position center, UnitFilter pred, int left);
private native Unit getClosestUnitInRectangle_native(long pointer, Position center, UnitFilter pred);
private native Unit getClosestUnitInRectangle_native(long pointer, Position center, UnitFilter pred, int left, int top, int right, int bottom);
private native Unit getBestUnit_native(long pointer, BestUnitFilter best, UnitFilter pred, Position center);
private native Unit getBestUnit_native(long pointer, BestUnitFilter best, UnitFilter pred);
private native Unit getBestUnit_native(long pointer, BestUnitFilter best, UnitFilter pred, Position center, int radius);
private native Error getLastError_native(long pointer);
private native boolean setLastError_native(long pointer);
@ -1058,6 +974,10 @@ public class Game {
private native boolean isWalkable_native(long pointer, WalkPosition position);
private native int getGroundHeight_native(long pointer, int tileX, int tileY);
private native int getGroundHeight_native(long pointer, TilePosition position);
private native boolean isBuildable_native(long pointer, int tileX, int tileY);
private native boolean isBuildable_native(long pointer, int tileX, int tileY, boolean includeBuildings);
@ -1366,6 +1286,8 @@ public class Game {
private native boolean setVision_native(long pointer, Player player, boolean enabled);
private native int elapsedTime_native(long pointer);
private native void setCommandOptimizationLevel_native(long pointer, int level);
private native int countdownTimer_native(long pointer);

View file

@ -60,7 +60,7 @@ public class Mirror {
static {
String arch = System.getProperty("os.arch");
String dllNames[] = {"bwapi_bridge" + VERSION, "gmp-vc90-mt", "mpfr-vc90-mt"};
String dllNames[] = {"BWAPI4.dll", "gmp-vc90-mt", "mpfr-vc90-mt"};
if(!arch.equals("x86")){
throw new UnsupportedOperationException("BWMirror API supports only x86 architecture.");
}

View file

@ -63,10 +63,6 @@ public class Region extends CenteredObject
return getDistance_native(pointer, other);
}
public List<Unit> getUnits(UnitFilter pred) {
return getUnits_native(pointer, pred);
}
private static Map<Long, Region> instances = new HashMap<Long, Region>();
@ -114,7 +110,5 @@ public class Region extends CenteredObject
private native int getDistance_native(long pointer, Region other);
private native List<Unit> getUnits_native(long pointer, UnitFilter pred);
}

View file

@ -13,10 +13,6 @@ public class Regionset {
return getCenter_native(pointer);
}
public List<Unit> getUnits(UnitFilter pred) {
return getUnits_native(pointer, pred);
}
private static Map<Long, Regionset> instances = new HashMap<Long, Regionset>();
@ -40,7 +36,5 @@ public class Regionset {
private native Position getCenter_native(long pointer);
private native List<Unit> getUnits_native(long pointer, UnitFilter pred);
}

View file

@ -103,6 +103,10 @@ public class Unit extends PositionedObject
return getLastCommandFrame_native(pointer);
}
public UnitCommand getLastCommand() {
return getLastCommand_native(pointer);
}
public Player getLastAttackingPlayer() {
return getLastAttackingPlayer_native(pointer);
}
@ -307,22 +311,6 @@ public class Unit extends PositionedObject
return getLarva_native(pointer);
}
public List<Unit> getUnitsInRadius(int radius, UnitFilter pred) {
return getUnitsInRadius_native(pointer, radius, pred);
}
public List<Unit> getUnitsInWeaponRange(WeaponType weapon, UnitFilter pred) {
return getUnitsInWeaponRange_native(pointer, weapon, pred);
}
public Unit getClosestUnit(UnitFilter pred) {
return getClosestUnit_native(pointer, pred);
}
public Unit getClosestUnit(UnitFilter pred, int radius) {
return getClosestUnit_native(pointer, pred, radius);
}
public boolean hasNuke() {
return hasNuke_native(pointer);
}
@ -1906,6 +1894,8 @@ public class Unit extends PositionedObject
private native int getLastCommandFrame_native(long pointer);
private native UnitCommand getLastCommand_native(long pointer);
private native Player getLastAttackingPlayer_native(long pointer);
private native UnitType getInitialType_native(long pointer);
@ -2008,14 +1998,6 @@ public class Unit extends PositionedObject
private native List<Unit> getLarva_native(long pointer);
private native List<Unit> getUnitsInRadius_native(long pointer, int radius, UnitFilter pred);
private native List<Unit> getUnitsInWeaponRange_native(long pointer, WeaponType weapon, UnitFilter pred);
private native Unit getClosestUnit_native(long pointer, UnitFilter pred);
private native Unit getClosestUnit_native(long pointer, UnitFilter pred, int radius);
private native boolean hasNuke_native(long pointer);
private native boolean isAccelerating_native(long pointer);

View file

@ -1,40 +1,116 @@
package bwapi4;
import bwapi4.*;
import bwapi.UnitCommandType;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.util.List;
import java.lang.Override;
public class UnitCommand {
public UnitCommandType getType() {
return getType_native(pointer);
private Unit unit;
private UnitCommandType unitCommandType;
private Unit target;
private int x, y;
private int extra;
public UnitCommand(Unit unit, UnitCommandType unitCommandType, Unit target, int x, int y, int extra) {
this.unit = unit;
this.unitCommandType = unitCommandType;
this.target = target;
this.x = x;
this.y = y;
this.extra = extra;
}
public Unit getUnit() {
return unit;
}
public UnitCommandType getUnitCommandType() {
return unitCommandType;
}
public Unit getTarget() {
return target;
}
private static Map<Long, UnitCommand> instances = new HashMap<Long, UnitCommand>();
private UnitCommand(long pointer) {
this.pointer = pointer;
}
private static UnitCommand get(long pointer) {
if (pointer == 0 ) {
return null;
public int getSlot() {
if (unitCommandType == UnitCommandType.None) {
return extra;
}
UnitCommand instance = instances.get(pointer);
if (instance == null ) {
instance = new UnitCommand(pointer);
instances.put(pointer, instance);
}
return instance;
return -1;
}
private long pointer;
public Position getTargetPosition() {
if (unitCommandType == UnitCommandType.Build ||
unitCommandType == UnitCommandType.Land ||
unitCommandType == UnitCommandType.Place_COP) {
return new Position(x * 32, y * 32);
}
return new Position(x, y);
}
private native UnitCommandType getType_native(long pointer);
public TilePosition getTargetTilePosition() {
if (unitCommandType == UnitCommandType.Build ||
unitCommandType == UnitCommandType.Land ||
unitCommandType == UnitCommandType.Place_COP) {
return new TilePosition(x, y);
}
return new TilePosition(x / 32, y / 32);
}
public boolean isQueued() {
if (unitCommandType == UnitCommandType.Attack_Move ||
unitCommandType == UnitCommandType.Attack_Unit ||
unitCommandType == UnitCommandType.Move ||
unitCommandType == UnitCommandType.Patrol ||
unitCommandType == UnitCommandType.Hold_Position ||
unitCommandType == UnitCommandType.Stop ||
unitCommandType == UnitCommandType.Follow ||
unitCommandType == UnitCommandType.Gather ||
unitCommandType == UnitCommandType.Return_Cargo ||
unitCommandType == UnitCommandType.Repair ||
unitCommandType == UnitCommandType.Load ||
unitCommandType == UnitCommandType.Unload_All ||
unitCommandType == UnitCommandType.Unload_All_Position ||
unitCommandType == UnitCommandType.Right_Click_Position ||
unitCommandType == UnitCommandType.Right_Click_Unit) {
return extra != 0;
}
return false;
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof UnitCommand)) return false;
UnitCommand that = (UnitCommand) o;
if (extra != that.extra) return false;
if (x != that.x) return false;
if (y != that.y) return false;
if (target != null ? !target.equals(that.target) : that.target != null) return false;
if (unit != null ? !unit.equals(that.unit) : that.unit != null) return false;
if (unitCommandType != null ? !unitCommandType.equals(that.unitCommandType) : that.unitCommandType != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = unit != null ? unit.hashCode() : 0;
result = 31 * result + (unitCommandType != null ? unitCommandType.hashCode() : 0);
result = 31 * result + (target != null ? target.hashCode() : 0);
result = 31 * result + x;
result = 31 * result + y;
result = 31 * result + extra;
return result;
}
}

View file

@ -25,18 +25,6 @@ public class Unitset {
return getLarva_native(pointer);
}
public List<Unit> getUnitsInRadius(int radius, UnitFilter pred) {
return getUnitsInRadius_native(pointer, radius, pred);
}
public Unit getClosestUnit(UnitFilter pred) {
return getClosestUnit_native(pointer, pred);
}
public Unit getClosestUnit(UnitFilter pred, int radius) {
return getClosestUnit_native(pointer, pred, radius);
}
public boolean issueCommand(UnitCommand command) {
return issueCommand_native(pointer, command);
}
@ -266,12 +254,6 @@ public class Unitset {
private native List<Unit> getLarva_native(long pointer);
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, int radius);
private native boolean issueCommand_native(long pointer, UnitCommand command);
private native boolean attack_native(long pointer, PositionOrUnit target);

View file

@ -5,7 +5,7 @@
#include <chrono>
#include <jni.h>
#include <cstring>
#include "../BWTA_Result.h"
using namespace BWAPI;
std::map<int, const BulletType *> tableBulletType;
@ -66,12 +66,12 @@ jfieldID FindCachedField(JNIEnv * env, jclass clz, string name, string signature
using namespace BWAPI;
PositionOrUnit convertPositionOrUnit(JNIEnv * env, jobject obj){
jclass clz = FindCachedClass(env, "PositionOrUnit");
jclass clz = FindCachedClass(env, "bwapi4/PositionOrUnit");
jmethodID typeMethodId = FindCachedMethod(env, clz, "isUnit", "()Z");
bool isUnit = (bool)env->CallBooleanMethod(obj, typeMethodId);
if(isUnit){
jobject unitObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, "getUnit", "()Lbwapi4/Unit;"));
Unit unit = (Unit)env->GetLongField(unitObj, FindCachedField(env, env->GetObjectClass(unitObj), "unitObj", "J"));
Unit unit = (Unit)env->GetLongField(unitObj, FindCachedField(env, env->GetObjectClass(unitObj), "pointer", "J"));
return PositionOrUnit(unit);
}
jobject posObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, "getPosition", "()Lbwapi4/Position;"));
@ -80,6 +80,29 @@ PositionOrUnit convertPositionOrUnit(JNIEnv * env, jobject obj){
}
UnitCommand convertUnitCommand(JNIEnv * env, jobject obj){ jclass clz = FindCachedClass(env, "bwapi4/UnitCommand");
jobject unitObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, "getUnit", "()Lbwapi4/Unit;"));
Unit unit = (Unit)env->GetLongField(unitObj, FindCachedField(env, env->GetObjectClass(unitObj), "pointer", "J"));
jobject targetObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, "getTarget", "()Lbwapi4/Unit;"));
Unit target = (Unit)env->GetLongField(targetObj, FindCachedField(env, env->GetObjectClass(targetObj), "pointer", "J"));
jobject typeObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, "getType", "()Lbwapi4/UnitCommandType;"));
UnitCommandType type = (UnitCommandType)env->GetIntField(typeObj, FindCachedField(env, env->GetObjectClass(typeObj), "value", "I"));
int extra = (int)env->GetIntField(obj, FindCachedField(env, clz, "extra", "I"));
jobject posObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, "getPosition", "()Lbwapi4/Position;"));
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 UnitCommand(unit, UnitCommandType(type), target, position.x, position.y, extra);
}
int resolveUnitCommandExtra(UnitCommand& command){
if(command.getUnitType() != UnitTypes::None){ return command.getUnitType().getID();}
if(command.getTechType() != TechTypes::None){ return command.getTechType().getID();}
if(command.getUpgradeType() != UpgradeTypes::None){ return command.getUpgradeType().getID();}
if(command.getSlot() != -1){ return command.extra;}
return command.isQueued();
}
JNIEXPORT jint JNICALL Java_bwapi4_Bullet_getID_1native(JNIEnv * env, jobject obj, jlong pointer){
Bullet x_bullet = (Bullet)pointer;
return x_bullet->getID();
@ -505,198 +528,6 @@ JNIEXPORT void JNICALL Java_bwapi4_Game_enableFlag_1native(JNIEnv * env, jobject
Game* x_game = (Game*)pointer;
x_game->enableFlag(flag);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsOnTile_1native__JIILbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jint tileX, jint tileY, jobject p_pred){
Game* x_game = (Game*)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_game->getUnitsOnTile(tileX, tileY, pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsOnTile_1native__JLbwapi4_TilePosition_2Lbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_tile, jobject p_pred){
Game* x_game = (Game*)pointer;
TilePosition tile((int)env->GetIntField(p_tile, FindCachedField(env, env->GetObjectClass(p_tile), "x", "I")), (int)env->GetIntField(p_tile, FindCachedField(env, env->GetObjectClass(p_tile), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_game->getUnitsOnTile(tile, pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRectangle_1native__JIIIILbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jint left, jint top, jint right, jint bottom, jobject p_pred){
Game* x_game = (Game*)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_game->getUnitsInRectangle(left, top, right, bottom, pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRectangle_1native__JLbwapi4_Position_2Lbwapi4_Position_2Lbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_topLeft, jobject p_bottomRight, jobject p_pred){
Game* x_game = (Game*)pointer;
Position topLeft((int)env->GetIntField(p_topLeft, FindCachedField(env, env->GetObjectClass(p_topLeft), "x", "I")), (int)env->GetIntField(p_topLeft, FindCachedField(env, env->GetObjectClass(p_topLeft), "y", "I")));
Position bottomRight((int)env->GetIntField(p_bottomRight, FindCachedField(env, env->GetObjectClass(p_bottomRight), "x", "I")), (int)env->GetIntField(p_bottomRight, FindCachedField(env, env->GetObjectClass(p_bottomRight), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_game->getUnitsInRectangle(topLeft, bottomRight, pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRadius_1native__JIIILbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jint x, jint y, jint radius, jobject p_pred){
Game* x_game = (Game*)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_game->getUnitsInRadius(x, y, radius, pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRadius_1native__JLbwapi4_Position_2ILbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_center, jint radius, jobject p_pred){
Game* x_game = (Game*)pointer;
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_game->getUnitsInRadius(center, radius, pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnit_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_center, jobject p_pred){
Game* x_game = (Game*)pointer;
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_game->getClosestUnit(center, pred);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnit_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2I(JNIEnv * env, jobject obj, jlong pointer, jobject p_center, jobject p_pred, jint radius){
Game* x_game = (Game*)pointer;
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_game->getClosestUnit(center, pred, radius);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2III(JNIEnv * env, jobject obj, jlong pointer, jobject p_center, jobject p_pred, jint left, jint top, jint right){
Game* x_game = (Game*)pointer;
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_game->getClosestUnitInRectangle(center, pred, left, top, right);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2II(JNIEnv * env, jobject obj, jlong pointer, jobject p_center, jobject p_pred, jint left, jint top){
Game* x_game = (Game*)pointer;
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_game->getClosestUnitInRectangle(center, pred, left, top);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2I(JNIEnv * env, jobject obj, jlong pointer, jobject p_center, jobject p_pred, jint left){
Game* x_game = (Game*)pointer;
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_game->getClosestUnitInRectangle(center, pred, left);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_center, jobject p_pred){
Game* x_game = (Game*)pointer;
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_game->getClosestUnitInRectangle(center, pred);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2IIII(JNIEnv * env, jobject obj, jlong pointer, jobject p_center, jobject p_pred, jint left, jint top, jint right, jint bottom){
Game* x_game = (Game*)pointer;
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_game->getClosestUnitInRectangle(center, pred, left, top, right, bottom);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getBestUnit_1native__JLbwapi4_BestUnitFilter_2Lbwapi4_UnitFilter_2Lbwapi4_Position_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_best, jobject p_pred, jobject p_center){
Game* x_game = (Game*)pointer;
BestUnitFilter best = (BestUnitFilter)env->GetLongField(p_best, FindCachedField(env, env->GetObjectClass(p_best), "pointer", "J"));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
jlong resptr = (jlong)x_game->getBestUnit(best, pred, center);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getBestUnit_1native__JLbwapi4_BestUnitFilter_2Lbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_best, jobject p_pred){
Game* x_game = (Game*)pointer;
BestUnitFilter best = (BestUnitFilter)env->GetLongField(p_best, FindCachedField(env, env->GetObjectClass(p_best), "pointer", "J"));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_game->getBestUnit(best, pred);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getBestUnit_1native__JLbwapi4_BestUnitFilter_2Lbwapi4_UnitFilter_2Lbwapi4_Position_2I(JNIEnv * env, jobject obj, jlong pointer, jobject p_best, jobject p_pred, jobject p_center, jint radius){
Game* x_game = (Game*)pointer;
BestUnitFilter best = (BestUnitFilter)env->GetLongField(p_best, FindCachedField(env, env->GetObjectClass(p_best), "pointer", "J"));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Position center((int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "x", "I")), (int)env->GetIntField(p_center, FindCachedField(env, env->GetObjectClass(p_center), "y", "I")));
jlong resptr = (jlong)x_game->getBestUnit(best, pred, center, radius);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getLastError_1native(JNIEnv * env, jobject obj, jlong pointer){
Game* x_game = (Game*)pointer;
jlong resptr = (jlong)tableError.find(x_game->getLastError())->second;
@ -746,6 +577,15 @@ Game* x_game = (Game*)pointer;
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);
}
JNIEXPORT jint JNICALL Java_bwapi4_Game_getGroundHeight_1native__JII(JNIEnv * env, jobject obj, jlong pointer, jint tileX, jint tileY){
Game* x_game = (Game*)pointer;
return x_game->getGroundHeight(tileX, tileY);
}
JNIEXPORT jint JNICALL Java_bwapi4_Game_getGroundHeight_1native__JLbwapi4_TilePosition_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_position){
Game* x_game = (Game*)pointer;
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_game->getGroundHeight(position);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isBuildable_1native__JII(JNIEnv * env, jobject obj, jlong pointer, jint tileX, jint tileY){
Game* x_game = (Game*)pointer;
return x_game->isBuildable(tileX, tileY);
@ -970,7 +810,7 @@ x_game->setLocalSpeed(speed);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Game_issueCommand_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_units, jobject p_command){
Game* x_game = (Game*)pointer;
std::set<Unit> units;
Unitset units;
jclass colClass = env->GetObjectClass(p_units);
jmethodID sizeMethodId = FindCachedMethod(env, colClass, "size", "()I");
jmethodID getMethodId = FindCachedMethod(env, colClass, "get", "(I)Ljava/lang/Object;");
@ -979,7 +819,7 @@ for( int i = 0; i < size; i++ ) {
jobject jobj = env->CallObjectMethod(p_units,getMethodId);
units.insert((Unit)env->GetLongField(jobj, FindCachedField(env, env->GetObjectClass(jobj), "pointer", "J")));
}
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_game->issueCommand(units, command);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getSelectedUnits_1native(JNIEnv * env, jobject obj, jlong pointer){
@ -1069,12 +909,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){
Game* x_game = (Game*)pointer;
Text::Size::Enum size;
Text::Size::Enum size = (Text::Size::Enum)(int)env->GetIntField(p_size, FindCachedField(env, env->GetObjectClass(p_size), "value", "I"));
x_game->setTextSize(size);
}
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;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "I"));
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){
@ -1106,13 +946,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){
Game* x_game = (Game*)pointer;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
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;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
@ -1190,13 +1030,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){
Game* x_game = (Game*)pointer;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
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;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
@ -1280,13 +1120,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){
Game* x_game = (Game*)pointer;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
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;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
@ -1358,13 +1198,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){
Game* x_game = (Game*)pointer;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
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;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
@ -1436,7 +1276,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){
Game* x_game = (Game*)pointer;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
@ -1475,7 +1315,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){
Game* x_game = (Game*)pointer;
CoordinateType::Enum ctype;
CoordinateType::Enum ctype = (CoordinateType::Enum)(int)env->GetIntField(p_ctype, FindCachedField(env, env->GetObjectClass(p_ctype), "value", "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);
}
@ -1606,6 +1446,10 @@ Game* x_game = (Game*)pointer;
Player player = (Player)env->GetLongField(p_player, FindCachedField(env, env->GetObjectClass(p_player), "pointer", "J"));
return x_game->setVision(player, (bool)enabled);
}
JNIEXPORT jint JNICALL Java_bwapi4_Game_elapsedTime_1native(JNIEnv * env, jobject obj, jlong pointer){
Game* x_game = (Game*)pointer;
return x_game->elapsedTime();
}
JNIEXPORT void JNICALL Java_bwapi4_Game_setCommandOptimizationLevel_1native(JNIEnv * env, jobject obj, jlong pointer, jint level){
Game* x_game = (Game*)pointer;
x_game->setCommandOptimizationLevel(level);
@ -2110,22 +1954,6 @@ Region x_region = (Region)pointer;
Region other = (Region)env->GetLongField(p_other, FindCachedField(env, env->GetObjectClass(p_other), "pointer", "J"));
return x_region->getDistance(other);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Region_getUnits_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_pred){
Region x_region = (Region)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_region->getUnits(pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Regionset_getCenter_1native(JNIEnv * env, jobject obj, jlong pointer){
Regionset* x_regionset = (Regionset*)pointer;
Position cresult = x_regionset->getCenter();
@ -2134,22 +1962,6 @@ jmethodID retConsID = FindCachedMethod(env, retcls, "<init>", "(II)V");
jobject result = env->NewObject(retcls, retConsID, cresult.x, cresult.y);
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Regionset_getUnits_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_pred){
Regionset* x_regionset = (Regionset*)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_regionset->getUnits(pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
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")));
return x_tilePosition.isValid();
@ -2282,6 +2094,14 @@ JNIEXPORT jint JNICALL Java_bwapi4_Unit_getLastCommandFrame_1native(JNIEnv * env
Unit x_unit = (Unit)pointer;
return x_unit->getLastCommandFrame();
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getLastCommand_1native(JNIEnv * env, jobject obj, jlong pointer){
Unit x_unit = (Unit)pointer;
UnitCommand cresult = x_unit->getLastCommand();
jclass retcls = FindCachedClass(env, "bwapi4/UnitCommand");
jmethodID retConsID = FindCachedMethod(env, retcls, "<init>", "(Lbwapi4/Unit;Lbwapi4/UnitCommandType;Lbwapi4/Unit;III)V");
jobject result = env->NewObject(retcls, retConsID, env->CallStaticObjectMethod(FindCachedClass(env, "bwapi4/Unit"), FindCachedMethodStatic(env, FindCachedClass(env, "bwapi4/Unit"), "get", "(J)Lbwapi4/Unit;"), cresult.getUnit()), env->CallStaticObjectMethod(FindCachedClass(env, "bwapi4/UnitCommandType"), FindCachedMethodStatic(env, FindCachedClass(env, "bwapi4/UnitCommandType"), "get", "(J)Lbwapi4/UnitCommandType;"), cresult.getType()), env->CallStaticObjectMethod(FindCachedClass(env, "bwapi4/Unit"), FindCachedMethodStatic(env, FindCachedClass(env, "bwapi4/Unit"), "get", "(J)Lbwapi4/Unit;"), cresult.getTarget()), cresult.getTargetPosition().x , cresult.getTargetPosition().y , resolveUnitCommandExtra(cresult));
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getLastAttackingPlayer_1native(JNIEnv * env, jobject obj, jlong pointer){
Unit x_unit = (Unit)pointer;
jlong resptr = (jlong)x_unit->getLastAttackingPlayer();
@ -2590,55 +2410,6 @@ env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getUnitsInRadius_1native(JNIEnv * env, jobject obj, jlong pointer, jint radius, jobject p_pred){
Unit x_unit = (Unit)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_unit->getUnitsInRadius(radius, pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getUnitsInWeaponRange_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_weapon, jobject p_pred){
Unit x_unit = (Unit)pointer;
WeaponType weapon = (WeaponType)env->GetLongField(p_weapon, FindCachedField(env, env->GetObjectClass(p_weapon), "pointer", "J"));
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_unit->getUnitsInWeaponRange(weapon, pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getClosestUnit_1native__JLbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_pred){
Unit x_unit = (Unit)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_unit->getClosestUnit(pred);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getClosestUnit_1native__JLbwapi4_UnitFilter_2I(JNIEnv * env, jobject obj, jlong pointer, jobject p_pred, jint radius){
Unit x_unit = (Unit)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_unit->getClosestUnit(pred, radius);
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_Unit_hasNuke_1native(JNIEnv * env, jobject obj, jlong pointer){
Unit x_unit = (Unit)pointer;
return x_unit->hasNuke();
@ -2867,7 +2638,7 @@ return x_unit->isTargetable();
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_issueCommand_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_command){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
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){
@ -3125,72 +2896,72 @@ return x_unit->placeCOP(target);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommand_1native__JLbwapi4_UnitCommand_2ZZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits, jboolean checkCanBuildUnitType, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommand(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits, (bool)checkCanBuildUnitType, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommand_1native__JLbwapi4_UnitCommand_2ZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits, jboolean checkCanBuildUnitType, jboolean checkCanTargetUnit){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommand(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits, (bool)checkCanBuildUnitType, (bool)checkCanTargetUnit);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommand_1native__JLbwapi4_UnitCommand_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits, jboolean checkCanBuildUnitType){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommand(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits, (bool)checkCanBuildUnitType);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommand_1native__JLbwapi4_UnitCommand_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommand(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommand_1native__JLbwapi4_UnitCommand_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommand(command, (bool)checkCanUseTechPositionOnPositions);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommand_1native__JLbwapi4_UnitCommand_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_command){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommand(command);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommand_1native__JLbwapi4_UnitCommand_2ZZZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits, jboolean checkCanBuildUnitType, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibility){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommand(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits, (bool)checkCanBuildUnitType, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibility);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommandGrouped_1native__JLbwapi4_UnitCommand_2ZZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommandGrouped(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommandGrouped_1native__JLbwapi4_UnitCommand_2ZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommandGrouped(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommandGrouped_1native__JLbwapi4_UnitCommand_2ZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits, jboolean checkCanTargetUnit){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommandGrouped(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits, (bool)checkCanTargetUnit);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommandGrouped_1native__JLbwapi4_UnitCommand_2ZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommandGrouped(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommandGrouped_1native__JLbwapi4_UnitCommand_2Z(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommandGrouped(command, (bool)checkCanUseTechPositionOnPositions);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommandGrouped_1native__JLbwapi4_UnitCommand_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_command){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommandGrouped(command);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canIssueCommandGrouped_1native__JLbwapi4_UnitCommand_2ZZZZZZ(JNIEnv * env, jobject obj, jlong pointer, jobject p_command, jboolean checkCanUseTechPositionOnPositions, jboolean checkCanUseTechUnitOnUnits, jboolean checkCanTargetUnit, jboolean checkCanIssueCommandType, jboolean checkCommandibilityGrouped, jboolean checkCommandibility){
Unit x_unit = (Unit)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
return x_unit->canIssueCommandGrouped(command, (bool)checkCanUseTechPositionOnPositions, (bool)checkCanUseTechUnitOnUnits, (bool)checkCanTargetUnit, (bool)checkCanIssueCommandType, (bool)checkCommandibilityGrouped, (bool)checkCommandibility);
}
JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canCommand_1native(JNIEnv * env, jobject obj, jlong pointer){
@ -4354,13 +4125,6 @@ Unit x_unit = (Unit)pointer;
TilePosition 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")));
return x_unit->canPlaceCOP(target, (bool)checkCanIssueCommandType, (bool)checkCommandibility);
}
JNIEXPORT jobject JNICALL Java_bwapi4_UnitCommand_getType_1native(JNIEnv * env, jobject obj, jlong pointer){
UnitCommand x_unitCommand = (UnitCommand)pointer;
jlong resptr = (jlong)x_unitCommand->getType();
jclass retcls = FindCachedClass(env, "bwapi4/UnitCommandType");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/UnitCommandType;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getPosition_1native(JNIEnv * env, jobject obj, jlong pointer){
Unitset* x_unitset = (Unitset*)pointer;
Position cresult = x_unitset->getPosition();
@ -4414,41 +4178,9 @@ env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getUnitsInRadius_1native(JNIEnv * env, jobject obj, jlong pointer, jint radius, jobject p_pred){
Unitset* x_unitset = (Unitset*)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
Unitset cresult = x_unitset->getUnitsInRadius(radius, pred);
jclass listCls = FindCachedClass(env, "java/util/ArrayList");
jmethodID listConsID = FindCachedMethod(env, listCls, "<init>", "()V");
jobject result = env->NewObject(listCls, listConsID);
jmethodID addMethodID = FindCachedMethod(env, listCls, "add", "(Ljava/lang/Object;)Z");
jclass elemClass = FindCachedClass(env, "bwapi4/Unit");
jmethodID getMethodID = FindCachedMethodStatic(env, elemClass, "get", "(J)Lbwapi4/Unit;");
for(Unitset::const_iterator it = cresult.begin(); it != cresult.end(); it++ ){const Unit elem_ptr = *it;
jobject elem = env->CallStaticObjectMethod(elemClass, getMethodID, (long)elem_ptr) ;
env->CallVoidMethod(result, addMethodID, elem);
}
return result;
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getClosestUnit_1native__JLbwapi4_UnitFilter_2(JNIEnv * env, jobject obj, jlong pointer, jobject p_pred){
Unitset* x_unitset = (Unitset*)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_unitset->getClosestUnit(pred);
jclass retcls = FindCachedClass(env, "bwapi4/Unit");
jmethodID mid = FindCachedMethodStatic(env, retcls, "get", "(J)Lbwapi4/Unit;");
return env->CallStaticObjectMethod(retcls, mid, resptr);
}
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getClosestUnit_1native__JLbwapi4_UnitFilter_2I(JNIEnv * env, jobject obj, jlong pointer, jobject p_pred, jint radius){
Unitset* x_unitset = (Unitset*)pointer;
UnitFilter pred = (UnitFilter)env->GetLongField(p_pred, FindCachedField(env, env->GetObjectClass(p_pred), "pointer", "J"));
jlong resptr = (jlong)x_unitset->getClosestUnit(pred, radius);
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_Unitset_issueCommand_1native(JNIEnv * env, jobject obj, jlong pointer, jobject p_command){
Unitset* x_unitset = (Unitset*)pointer;
UnitCommand command = (UnitCommand)env->GetLongField(p_command, FindCachedField(env, env->GetObjectClass(p_command), "pointer", "J"));
UnitCommand command(convertUnitCommand(env, p_command ));
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){
@ -6297,11 +6029,6 @@ println("Connecting to Broodwar...");
{
switch (it->getType()) {
case EventType::MatchStart:
BWTA::BWTA_Result::regions.clear();
BWTA::BWTA_Result::baselocations.clear();
BWTA::BWTA_Result::startlocations.clear();
BWTA::BWTA_Result::chokepoints.clear();
BWTA::BWTA_Result::unwalkablePolygons.clear();
env->CallVoidMethod(moduleObj, matchStartCallback);
break;
case EventType::MatchEnd:

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

@ -680,134 +680,6 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isFlagEnabled_1native
JNIEXPORT void JNICALL Java_bwapi4_Game_enableFlag_1native
(JNIEnv *, jobject, jlong, jint);
/*
* Class: bwapi4_Game
* Method: getUnitsOnTile_native
* Signature: (JIILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsOnTile_1native__JIILbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jint, jint, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsOnTile_native
* Signature: (JLbwapi4/TilePosition;Lbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsOnTile_1native__JLbwapi4_TilePosition_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsInRectangle_native
* Signature: (JIIIILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRectangle_1native__JIIIILbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jint, jint, jint, jint, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/Position;Lbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRectangle_1native__JLbwapi4_Position_2Lbwapi4_Position_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsInRadius_native
* Signature: (JIIILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRadius_1native__JIIILbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jint, jint, jint, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsInRadius_native
* Signature: (JLbwapi4/Position;ILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRadius_1native__JLbwapi4_Position_2ILbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jint, jobject);
/*
* Class: bwapi4_Game
* Method: getClosestUnit_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnit_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getClosestUnit_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnit_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2I
(JNIEnv *, jobject, jlong, jobject, jobject, jint);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;III)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2III
(JNIEnv *, jobject, jlong, jobject, jobject, jint, jint, jint);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;II)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2II
(JNIEnv *, jobject, jlong, jobject, jobject, jint, jint);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2I
(JNIEnv *, jobject, jlong, jobject, jobject, jint);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;IIII)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2IIII
(JNIEnv *, jobject, jlong, jobject, jobject, jint, jint, jint, jint);
/*
* Class: bwapi4_Game
* Method: getBestUnit_native
* Signature: (JLbwapi4/BestUnitFilter;Lbwapi4/UnitFilter;Lbwapi4/Position;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getBestUnit_1native__JLbwapi4_BestUnitFilter_2Lbwapi4_UnitFilter_2Lbwapi4_Position_2
(JNIEnv *, jobject, jlong, jobject, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getBestUnit_native
* Signature: (JLbwapi4/BestUnitFilter;Lbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getBestUnit_1native__JLbwapi4_BestUnitFilter_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getBestUnit_native
* Signature: (JLbwapi4/BestUnitFilter;Lbwapi4/UnitFilter;Lbwapi4/Position;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getBestUnit_1native__JLbwapi4_BestUnitFilter_2Lbwapi4_UnitFilter_2Lbwapi4_Position_2I
(JNIEnv *, jobject, jlong, jobject, jobject, jobject, jint);
/*
* Class: bwapi4_Game
* Method: getLastError_native
@ -896,6 +768,22 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isWalkable_1native__JII
JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isWalkable_1native__JLbwapi4_WalkPosition_2
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Game
* Method: getGroundHeight_native
* Signature: (JII)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Game_getGroundHeight_1native__JII
(JNIEnv *, jobject, jlong, jint, jint);
/*
* Class: bwapi4_Game
* Method: getGroundHeight_native
* Signature: (JLbwapi4/TilePosition;)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Game_getGroundHeight_1native__JLbwapi4_TilePosition_2
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Game
* Method: isBuildable_native
@ -2128,6 +2016,14 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_setVision_1native__JLbwapi4_Player_2
JNIEXPORT jboolean JNICALL Java_bwapi4_Game_setVision_1native__JLbwapi4_Player_2Z
(JNIEnv *, jobject, jlong, jobject, jboolean);
/*
* Class: bwapi4_Game
* Method: elapsedTime_native
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Game_elapsedTime_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Game
* Method: setCommandOptimizationLevel_native
@ -3176,14 +3072,6 @@ JNIEXPORT jobject JNICALL Java_bwapi4_Region_getClosestInaccessibleRegion_1nativ
JNIEXPORT jint JNICALL Java_bwapi4_Region_getDistance_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Region
* Method: getUnits_native
* Signature: (JLbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Region_getUnits_1native
(JNIEnv *, jobject, jlong, jobject);
#ifdef __cplusplus
}
#endif
@ -3203,14 +3091,6 @@ extern "C" {
JNIEXPORT jobject JNICALL Java_bwapi4_Regionset_getCenter_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Regionset
* Method: getUnits_native
* Signature: (JLbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Regionset_getUnits_1native
(JNIEnv *, jobject, jlong, jobject);
#ifdef __cplusplus
}
#endif
@ -3471,6 +3351,14 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_hasPath_1native
JNIEXPORT jint JNICALL Java_bwapi4_Unit_getLastCommandFrame_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unit
* Method: getLastCommand_native
* Signature: (J)Lbwapi4/UnitCommand;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getLastCommand_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unit
* Method: getLastAttackingPlayer_native
@ -3879,38 +3767,6 @@ JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getHatchery_1native
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getLarva_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unit
* Method: getUnitsInRadius_native
* Signature: (JILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getUnitsInRadius_1native
(JNIEnv *, jobject, jlong, jint, jobject);
/*
* Class: bwapi4_Unit
* Method: getUnitsInWeaponRange_native
* Signature: (JLbwapi4/WeaponType;Lbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getUnitsInWeaponRange_1native
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Unit
* Method: getClosestUnit_native
* Signature: (JLbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getClosestUnit_1native__JLbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Unit
* Method: getClosestUnit_native
* Signature: (JLbwapi4/UnitFilter;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getClosestUnit_1native__JLbwapi4_UnitFilter_2I
(JNIEnv *, jobject, jlong, jobject, jint);
/*
* Class: bwapi4_Unit
* Method: hasNuke_native
@ -6954,14 +6810,6 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_canPlaceCOP_1native__JLbwapi4_TilePo
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: bwapi4_UnitCommand
* Method: getType_native
* Signature: (J)Lbwapi4/UnitCommandType;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_UnitCommand_getType_1native
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
}
#endif
@ -7027,30 +6875,6 @@ JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getInterceptors_1native
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getLarva_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unitset
* Method: getUnitsInRadius_native
* Signature: (JILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getUnitsInRadius_1native
(JNIEnv *, jobject, jlong, jint, jobject);
/*
* Class: bwapi4_Unitset
* Method: getClosestUnit_native
* Signature: (JLbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getClosestUnit_1native__JLbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Unitset
* Method: getClosestUnit_native
* Signature: (JLbwapi4/UnitFilter;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getClosestUnit_1native__JLbwapi4_UnitFilter_2I
(JNIEnv *, jobject, jlong, jobject, jint);
/*
* Class: bwapi4_Unitset
* Method: issueCommand_native

View file

@ -255,134 +255,6 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isFlagEnabled_1native
JNIEXPORT void JNICALL Java_bwapi4_Game_enableFlag_1native
(JNIEnv *, jobject, jlong, jint);
/*
* Class: bwapi4_Game
* Method: getUnitsOnTile_native
* Signature: (JIILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsOnTile_1native__JIILbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jint, jint, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsOnTile_native
* Signature: (JLbwapi4/TilePosition;Lbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsOnTile_1native__JLbwapi4_TilePosition_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsInRectangle_native
* Signature: (JIIIILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRectangle_1native__JIIIILbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jint, jint, jint, jint, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/Position;Lbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRectangle_1native__JLbwapi4_Position_2Lbwapi4_Position_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsInRadius_native
* Signature: (JIIILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRadius_1native__JIIILbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jint, jint, jint, jobject);
/*
* Class: bwapi4_Game
* Method: getUnitsInRadius_native
* Signature: (JLbwapi4/Position;ILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getUnitsInRadius_1native__JLbwapi4_Position_2ILbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jint, jobject);
/*
* Class: bwapi4_Game
* Method: getClosestUnit_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnit_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getClosestUnit_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnit_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2I
(JNIEnv *, jobject, jlong, jobject, jobject, jint);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;III)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2III
(JNIEnv *, jobject, jlong, jobject, jobject, jint, jint, jint);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;II)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2II
(JNIEnv *, jobject, jlong, jobject, jobject, jint, jint);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2I
(JNIEnv *, jobject, jlong, jobject, jobject, jint);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getClosestUnitInRectangle_native
* Signature: (JLbwapi4/Position;Lbwapi4/UnitFilter;IIII)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getClosestUnitInRectangle_1native__JLbwapi4_Position_2Lbwapi4_UnitFilter_2IIII
(JNIEnv *, jobject, jlong, jobject, jobject, jint, jint, jint, jint);
/*
* Class: bwapi4_Game
* Method: getBestUnit_native
* Signature: (JLbwapi4/BestUnitFilter;Lbwapi4/UnitFilter;Lbwapi4/Position;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getBestUnit_1native__JLbwapi4_BestUnitFilter_2Lbwapi4_UnitFilter_2Lbwapi4_Position_2
(JNIEnv *, jobject, jlong, jobject, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getBestUnit_native
* Signature: (JLbwapi4/BestUnitFilter;Lbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getBestUnit_1native__JLbwapi4_BestUnitFilter_2Lbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Game
* Method: getBestUnit_native
* Signature: (JLbwapi4/BestUnitFilter;Lbwapi4/UnitFilter;Lbwapi4/Position;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Game_getBestUnit_1native__JLbwapi4_BestUnitFilter_2Lbwapi4_UnitFilter_2Lbwapi4_Position_2I
(JNIEnv *, jobject, jlong, jobject, jobject, jobject, jint);
/*
* Class: bwapi4_Game
* Method: getLastError_native
@ -471,6 +343,22 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isWalkable_1native__JII
JNIEXPORT jboolean JNICALL Java_bwapi4_Game_isWalkable_1native__JLbwapi4_WalkPosition_2
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Game
* Method: getGroundHeight_native
* Signature: (JII)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Game_getGroundHeight_1native__JII
(JNIEnv *, jobject, jlong, jint, jint);
/*
* Class: bwapi4_Game
* Method: getGroundHeight_native
* Signature: (JLbwapi4/TilePosition;)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Game_getGroundHeight_1native__JLbwapi4_TilePosition_2
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Game
* Method: isBuildable_native
@ -1703,6 +1591,14 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Game_setVision_1native__JLbwapi4_Player_2
JNIEXPORT jboolean JNICALL Java_bwapi4_Game_setVision_1native__JLbwapi4_Player_2Z
(JNIEnv *, jobject, jlong, jobject, jboolean);
/*
* Class: bwapi4_Game
* Method: elapsedTime_native
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_bwapi4_Game_elapsedTime_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Game
* Method: setCommandOptimizationLevel_native

View file

@ -111,14 +111,6 @@ JNIEXPORT jobject JNICALL Java_bwapi4_Region_getClosestInaccessibleRegion_1nativ
JNIEXPORT jint JNICALL Java_bwapi4_Region_getDistance_1native
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Region
* Method: getUnits_native
* Signature: (JLbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Region_getUnits_1native
(JNIEnv *, jobject, jlong, jobject);
#ifdef __cplusplus
}
#endif

View file

@ -15,14 +15,6 @@ extern "C" {
JNIEXPORT jobject JNICALL Java_bwapi4_Regionset_getCenter_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Regionset
* Method: getUnits_native
* Signature: (JLbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Regionset_getUnits_1native
(JNIEnv *, jobject, jlong, jobject);
#ifdef __cplusplus
}
#endif

View file

@ -191,6 +191,14 @@ JNIEXPORT jboolean JNICALL Java_bwapi4_Unit_hasPath_1native
JNIEXPORT jint JNICALL Java_bwapi4_Unit_getLastCommandFrame_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unit
* Method: getLastCommand_native
* Signature: (J)Lbwapi4/UnitCommand;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getLastCommand_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unit
* Method: getLastAttackingPlayer_native
@ -599,38 +607,6 @@ JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getHatchery_1native
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getLarva_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unit
* Method: getUnitsInRadius_native
* Signature: (JILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getUnitsInRadius_1native
(JNIEnv *, jobject, jlong, jint, jobject);
/*
* Class: bwapi4_Unit
* Method: getUnitsInWeaponRange_native
* Signature: (JLbwapi4/WeaponType;Lbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getUnitsInWeaponRange_1native
(JNIEnv *, jobject, jlong, jobject, jobject);
/*
* Class: bwapi4_Unit
* Method: getClosestUnit_native
* Signature: (JLbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getClosestUnit_1native__JLbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Unit
* Method: getClosestUnit_native
* Signature: (JLbwapi4/UnitFilter;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unit_getClosestUnit_1native__JLbwapi4_UnitFilter_2I
(JNIEnv *, jobject, jlong, jobject, jint);
/*
* Class: bwapi4_Unit
* Method: hasNuke_native

View file

@ -7,14 +7,6 @@
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: bwapi4_UnitCommand
* Method: getType_native
* Signature: (J)Lbwapi4/UnitCommandType;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_UnitCommand_getType_1native
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
}
#endif

View file

@ -39,30 +39,6 @@ JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getInterceptors_1native
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getLarva_1native
(JNIEnv *, jobject, jlong);
/*
* Class: bwapi4_Unitset
* Method: getUnitsInRadius_native
* Signature: (JILbwapi4/UnitFilter;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getUnitsInRadius_1native
(JNIEnv *, jobject, jlong, jint, jobject);
/*
* Class: bwapi4_Unitset
* Method: getClosestUnit_native
* Signature: (JLbwapi4/UnitFilter;)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getClosestUnit_1native__JLbwapi4_UnitFilter_2
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: bwapi4_Unitset
* Method: getClosestUnit_native
* Signature: (JLbwapi4/UnitFilter;I)Lbwapi4/Unit;
*/
JNIEXPORT jobject JNICALL Java_bwapi4_Unitset_getClosestUnit_1native__JLbwapi4_UnitFilter_2I
(JNIEnv *, jobject, jlong, jobject, jint);
/*
* Class: bwapi4_Unitset
* Method: issueCommand_native

View file

@ -60,7 +60,7 @@ public class Mirror {
static {
String arch = System.getProperty("os.arch");
String dllNames[] = {"bwapi_bridge" + VERSION, "gmp-vc90-mt", "mpfr-vc90-mt"};
String dllNames[] = {"BWAPI4.dll", "gmp-vc90-mt", "mpfr-vc90-mt"};
if(!arch.equals("x86")){
throw new UnsupportedOperationException("BWMirror API supports only x86 architecture.");
}

View file

@ -0,0 +1,116 @@
package bwapi4;
import bwapi.UnitCommandType;
import java.lang.Override;
public class UnitCommand {
private Unit unit;
private UnitCommandType unitCommandType;
private Unit target;
private int x, y;
private int extra;
private UnitCommand(Unit unit, UnitCommandType unitCommandType, Unit target, int x, int y, int extra) {
this.unit = unit;
this.unitCommandType = unitCommandType;
this.target = target;
this.x = x;
this.y = y;
this.extra = extra;
}
public Unit getUnit() {
return unit;
}
public UnitCommandType getUnitCommandType() {
return unitCommandType;
}
public Unit getTarget() {
return target;
}
public int getSlot() {
if (unitCommandType == UnitCommandType.None) {
return extra;
}
return -1;
}
public Position getTargetPosition() {
if (unitCommandType == UnitCommandType.Build ||
unitCommandType == UnitCommandType.Land ||
unitCommandType == UnitCommandType.Place_COP) {
return new Position(x * 32, y * 32);
}
return new Position(x, y);
}
public TilePosition getTargetTilePosition() {
if (unitCommandType == UnitCommandType.Build ||
unitCommandType == UnitCommandType.Land ||
unitCommandType == UnitCommandType.Place_COP) {
return new TilePosition(x, y);
}
return new TilePosition(x / 32, y / 32);
}
public boolean isQueued() {
if (unitCommandType == UnitCommandType.Attack_Move ||
unitCommandType == UnitCommandType.Attack_Unit ||
unitCommandType == UnitCommandType.Move ||
unitCommandType == UnitCommandType.Patrol ||
unitCommandType == UnitCommandType.Hold_Position ||
unitCommandType == UnitCommandType.Stop ||
unitCommandType == UnitCommandType.Follow ||
unitCommandType == UnitCommandType.Gather ||
unitCommandType == UnitCommandType.Return_Cargo ||
unitCommandType == UnitCommandType.Repair ||
unitCommandType == UnitCommandType.Load ||
unitCommandType == UnitCommandType.Unload_All ||
unitCommandType == UnitCommandType.Unload_All_Position ||
unitCommandType == UnitCommandType.Right_Click_Position ||
unitCommandType == UnitCommandType.Right_Click_Unit) {
return extra != 0;
}
return false;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof UnitCommand)) return false;
UnitCommand that = (UnitCommand) o;
if (extra != that.extra) return false;
if (x != that.x) return false;
if (y != that.y) return false;
if (target != null ? !target.equals(that.target) : that.target != null) return false;
if (unit != null ? !unit.equals(that.unit) : that.unit != null) return false;
if (unitCommandType != null ? !unitCommandType.equals(that.unitCommandType) : that.unitCommandType != null)
return false;
return true;
}
@Override
public int hashCode() {
int result = unit != null ? unit.hashCode() : 0;
result = 31 * result + (unitCommandType != null ? unitCommandType.hashCode() : 0);
result = 31 * result + (target != null ? target.hashCode() : 0);
result = 31 * result + x;
result = 31 * result + y;
result = 31 * result + extra;
return result;
}
}

View file

@ -16,4 +16,6 @@ public interface Method extends Field{
public List<Param> getParams();
public Method clone();
public boolean isStatic();
}

View file

@ -14,13 +14,13 @@ public class JavaContext {
private HashMap<String, String> javaToCType = new HashMap<>();
private List<String> valueTypes = Arrays.asList("Position", "TilePosition", "WalkPosition", "Color", "BWTA::RectangleArray<double>", "PositionOrUnit", "Point");
private List<String> valueTypes = Arrays.asList("Position", "TilePosition", "WalkPosition", "Color", "BWTA::RectangleArray<double>", "PositionOrUnit", "Point", "UnitCommand");
private List<String> constantTypes = Arrays.asList("UnitType", "TechType", "UpgradeType", "Race", "UnitCommand", "WeaponType", "Order", "GameType", "Error");
private List<String> enumTypes = Arrays.asList("MouseButton", "Key", "bwapi4.Text.Size.Enum", "bwapi4.CoordinateType.Enum");
private List<String> enumTypes = Arrays.asList("MouseButton", "Key", "bwapi4.Text.Size.Enum", "bwapi4.CoordinateType.Enum", "Text::Size::Enum", "CoordinateType::Enum");
private List<String> valueReturnTypes = Arrays.asList("UnitCommand", "Event");
private List<String> valueReturnTypes = Arrays.asList("Event");
private List<String> bwtaClasses = Arrays.asList("Chokepoint", "Region", "RectangleArray", "Polygon", "BaseLocation");
@ -40,7 +40,7 @@ public class JavaContext {
}
public String getPackageName(String javaRetType) {
if(javaRetType.equals("Position") || javaRetType.equals("TilePosition")){
if (javaRetType.equals("Position") || javaRetType.equals("TilePosition")) {
return "bwapi";
}
return packageName;
@ -104,16 +104,18 @@ public class JavaContext {
");";
case "PositionOrUnit":
return "(convertPositionOrUnit(env, " + rawName + " ));";
case "UnitCommand":
return "(convertUnitCommand(env, " + rawName + " ));";
}
return ";";
}
public String copyJavaObjectToC(String variableType, String variableName, String rawName) {
String packageStrippedType = variableType;
if(packageStrippedType.startsWith("bwapi")){
if (packageStrippedType.startsWith("bwapi")) {
packageStrippedType = packageStrippedType.substring(packageStrippedType.indexOf(".") + 1);
}
packageStrippedType = packageStrippedType.replaceAll("\\.","::");
packageStrippedType = packageStrippedType.replaceAll("\\.", "::");
return (packageStrippedType + " " + variableName) + copyFields(packageStrippedType, variableName, rawName);
}
@ -151,6 +153,8 @@ public class JavaContext {
return "III";
case "Error":
return "I";
case "UnitCommand":
return "L" + packageName + "/Unit;L" + packageName + "/UnitCommandType;L" + packageName + "/Unit;III";
default:
throw new UnsupportedOperationException();
}
@ -160,8 +164,8 @@ public class JavaContext {
return implementCopyReturn(javaType, "cresult");
}
public static String checkBWAPI3brackets(){
if(CJavaPipeline.isBWAPI3()){
public static String checkBWAPI3brackets() {
if (CJavaPipeline.isBWAPI3()) {
return "()";
}
return "";
@ -173,18 +177,26 @@ public class JavaContext {
case "Position":
case "WalkPosition":
case "Point":
return ", "+fieldName+".x" + checkBWAPI3brackets() +
", "+fieldName+".y" + checkBWAPI3brackets() ;
return ", " + fieldName + ".x" + checkBWAPI3brackets() +
", " + fieldName + ".y" + checkBWAPI3brackets();
case "Color":
return ", "+fieldName+".red()" +
", "+fieldName+".green()" +
", "+fieldName+".blue()";
return ", " + fieldName + ".red()" +
", " + fieldName + ".green()" +
", " + fieldName + ".blue()";
case "UnitCommand":
return
", env->CallStaticObjectMethod(FindCachedClass(env, \"" + packageName + "/Unit\"), FindCachedMethodStatic(env, FindCachedClass(env, \"" + packageName + "/Unit\"), \"get\", \"(J)Lbwapi4/Unit;\"), " +fieldName+ ".getUnit())" +
", env->CallStaticObjectMethod(FindCachedClass(env, \"" + packageName + "/UnitCommandType\"), FindCachedMethodStatic(env, FindCachedClass(env, \"" + packageName + "/UnitCommandType\"), \"get\", \"(J)Lbwapi4/UnitCommandType;\"), "+fieldName+".getType())" +
", env->CallStaticObjectMethod(FindCachedClass(env, \"" + packageName + "/Unit\"), FindCachedMethodStatic(env, FindCachedClass(env, \"" + packageName + "/Unit\"), \"get\", \"(J)Lbwapi4/Unit;\"), "+fieldName+".getTarget())" +
", "+ fieldName +".getTargetPosition().x " +
", "+ fieldName +".getTargetPosition().y " +
", resolveUnitCommandExtra("+fieldName+")";
default:
throw new UnsupportedOperationException();
}
}
public boolean isBWTA(String cls){
public boolean isBWTA(String cls) {
return bwtaClasses.contains(cls);
}
}

View file

@ -109,12 +109,14 @@ public class Bind {
"\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\t switch (it->getType()) {\n" +
"\t\t\t\t\t\t case EventType::MatchStart:\n" +
( CJavaPipeline.isBWAPI3()?
"\t\t\t\t\t\t\t BWTA::BWTA_Result::regions.clear();\n" +
"\t\t\t\t\t\t\t BWTA::BWTA_Result::baselocations.clear();\n" +
"\t\t\t\t\t\t\t BWTA::BWTA_Result::startlocations.clear();\n" +
"\t\t\t\t\t\t\t BWTA::BWTA_Result::chokepoints.clear();\n" +
"\t\t\t\t\t\t\t BWTA::BWTA_Result::unwalkablePolygons.clear();\n" +
"\t\t\t\t\t\t\t BWTA::BWTA_Result::unwalkablePolygons.clear();\n" : "" ) +
"\t\t\t\t\t\t\t env->CallVoidMethod(moduleObj, matchStartCallback);\n" +
"\t\t\t\t\t\t break;\n" +
"\t\t\t\t\t\t case EventType::MatchEnd:\n" +

View file

@ -56,7 +56,7 @@ public class CallImplementer {
(CJavaPipeline.isBWAPI3() ? "#include <BWTA.h>\n" : "#include <thread>\n" + "#include <chrono>\n") +
"#include <jni.h>\n" +
"#include <cstring>\n" +
"#include \"../BWTA_Result.h\"" +
(CJavaPipeline.isBWAPI3() ? "#include \"../BWTA_Result.h\"" : "")+
"\n" +
"using namespace BWAPI;\n\n");
}
@ -82,7 +82,11 @@ public class CallImplementer {
if (javaContext.isCollection(param.third)) {
String genericType = Generic.extractGeneric(param.third);
out.println("std::set<" + PointerTest.test(genericType) + "> " + param.second + SEMICOLON);
if (CJavaPipeline.isBWAPI3()) {
out.println("std::set<" + PointerTest.test(genericType) + "> " + param.second + SEMICOLON);
} else {
out.println(genericType + "set " + param.second + SEMICOLON);
}
out.println("jclass colClass = env->GetObjectClass(" + paramName + ");");
out.println("jmethodID sizeMethodId = FindCachedMethod(env, colClass, \"size\", \"()I\");");
@ -391,19 +395,54 @@ public class CallImplementer {
this.bwtaMode = bwtaMode;
}
public void notifyPackageStart(){
public void notifyPackageStart() {
out.println("PositionOrUnit convertPositionOrUnit(JNIEnv * env, jobject obj){ \n" +
"\tjclass clz = FindCachedClass(env, \"PositionOrUnit\");\n" +
"\tjclass clz = FindCachedClass(env, \"" + javaContext.getPackageName() + "/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\tUnit unit = (Unit)env->GetLongField(unitObj, FindCachedField(env, env->GetObjectClass(unitObj), \"pointer\", \"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");
out.println("UnitCommand convertUnitCommand(JNIEnv * env, jobject obj){" +
"\tjclass clz = FindCachedClass(env, \"" + javaContext.getPackageName() + "/UnitCommand\");\n" +
"\tjobject unitObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, \"getUnit\", \"()L" + javaContext.getPackageName() + "/Unit;\"));\n" +
"\tUnit unit = (Unit)env->GetLongField(unitObj, FindCachedField(env, env->GetObjectClass(unitObj), \"pointer\", \"J\"));\n" +
"\tjobject targetObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, \"getTarget\", \"()L" + javaContext.getPackageName() + "/Unit;\"));\n" +
"\tUnit target = (Unit)env->GetLongField(targetObj, FindCachedField(env, env->GetObjectClass(targetObj), \"pointer\", \"J\"));\n" +
"\tjobject typeObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, \"getType\", \"()L" + javaContext.getPackageName() + "/UnitCommandType;\"));\n" +
"\tUnitCommandType type = (UnitCommandType)env->GetIntField(typeObj, FindCachedField(env, env->GetObjectClass(typeObj), \"value\", \"I\"));\n" +
"\tint extra = (int)env->GetIntField(obj, FindCachedField(env, clz, \"extra\", \"I\"));\n" +
"\tjobject posObj = env->CallObjectMethod(obj, FindCachedMethod(env, clz, \"getPosition\", \"()L" + javaContext.getPackageName() + "/Position;\"));\n" +
"\t" + javaContext.copyJavaObjectToC("Position", "position", "posObj") + "\n" +
"\treturn UnitCommand(unit, UnitCommandType(type), target, position.x, position.y, extra);\n" +
"}\n\n");
out.println("int resolveUnitCommandExtra(UnitCommand& command){\n" +
"\tif(command.getUnitType() != UnitTypes::None){" +
"\t\treturn command.getUnitType().getID();" +
"}\n" +
"\tif(command.getTechType() != TechTypes::None){" +
"\t\treturn command.getTechType().getID();" +
"}\n" +
"\tif(command.getUpgradeType() != UpgradeTypes::None){" +
"\t\treturn command.getUpgradeType().getID();" +
"}\n" +
"\tif(command.getSlot() != -1){" +
"\t\treturn command.extra;" +
"}\n" +
"\treturn command.isQueued();\n" +
"}\n\n");
}
}

View file

@ -129,7 +129,7 @@ public class ClassMirror extends Mirror {
if(checkDefaults){
handleDefaults(method);
}
out.print(INTEND + "public" + SPACE + (cClass.isStatic() ? "static" + SPACE + "native" + SPACE : "") + context.toJavaType(method.getType()) + SPACE + method.getName() + "(");
out.print(INTEND + "public" + SPACE + (cClass.isStatic() || method.isStatic() ? "static" + SPACE + "native" + SPACE : "") + context.toJavaType(method.getType()) + SPACE + method.getName() + "(");
boolean first = true;
for (Param param : method.getParams()) {
if (!first) {
@ -139,7 +139,7 @@ public class ClassMirror extends Mirror {
out.print(paramString(param));
}
out.print(")");
if (!cClass.isStatic()) {
if (!cClass.isStatic() && !method.isStatic()) {
out.println(SPACE + "{");
writeNativeCall(method);
out.println(INTEND + "}");

View file

@ -1,6 +1,7 @@
package impl;
import c.*;
import generator.CJavaPipeline;
import java.io.BufferedReader;
import java.io.File;
@ -41,12 +42,13 @@ public class CApiParser {
//String FUNC_REGEX = "^(\\s*)(virtual)?\\s([\\w\\*]+)\\s([\\w\\*]+)\\((.*)\\)(\\s=\\s0;)?";
//String FUNC_REGEX = "^(\\s*)(virtual)?\\s(BWAPI::)?([\\w\\*]+)\\s([\\w\\*]+)\\((.*)\\)((\\sconst)?\\s=\\s0;)?";
//String FUNC_REGEX = "^(\\s*)(virtual)?\\s((BWAPI)|(std)::)?([\\w\\*]+)\\s([\\w\\*]+)\\((.*)\\)((\\sconst)?\\s=\\s0;)?";
// 1 2 3 45 6 78 9 10 11 12 13,14 15,16
String FUNC_REGEX = "^(\\s*)(virtual)?\\s(const\\s)?((BWAPI::)|(std)::)?((set<(\\s*(BWAPI::)?\\w+\\*?\\s*)>)|([\\w\\*]+))&?\\s([\\w\\*]+)\\((.*)\\)((\\sconst)?\\s=\\s0;)?\\s*";
// 1 2 3 4 56 7 89 10 11 12 13 14,15 15,17
String FUNC_REGEX = "^(\\s*)(virtual)?\\s(const\\s)?(static\\s)?((BWAPI::)|(std)::)?((set<(\\s*(BWAPI::)?\\w+\\*?\\s*)>)|([\\w\\*]+))&?\\s+([\\w\\*]+)\\((.*)\\)((\\sconst)?\\s=\\s0;)?\\s*";
static final int F_REGEX_RETURN_TYPE = 7;
static final int F_REGEX_NAME = 12;
static final int F_REGEX_PARAMS = 13;
static final int F_REGEX_STATIC = 4;
static final int F_REGEX_RETURN_TYPE = 8;
static final int F_REGEX_NAME = 13;
static final int F_REGEX_PARAMS = 14;
String ENUM_VALUE_REGEX = "^(\\s*)(\\w+)(\\s*=\\s*(0x)?([0-9A-Fa-f]+))?\\s*[\\,;]";
@ -161,7 +163,7 @@ public class CApiParser {
return LineState.SKIP;
}
private static final boolean isSkip(String line) {
private static boolean isSkip(String line) {
if (line.isEmpty()) {
return true;
}
@ -244,7 +246,7 @@ public class CApiParser {
System.err.println("function skipped - GameData* return (" + function.name + ")");
return null;
}
if (function.returnType.equals("UnitCommand")) {
if (CJavaPipeline.isBWAPI3() && function.returnType.equals("UnitCommand")) {
System.err.println("function skipped - UnitCommand return (" + function.name + ")");
return null;
}
@ -266,6 +268,10 @@ public class CApiParser {
return null;
}
if(matcher.group(F_REGEX_STATIC) != null){
function.setStatic(true);
}
if (matcher.group(F_REGEX_PARAMS) != null) {
String paramsString = matcher.group(F_REGEX_PARAMS);
String paramStrings[] = paramsString.split("\\,");
@ -391,6 +397,16 @@ public class CApiParser {
return null;
}
if (argType.equals("UnitFilter")) {
System.err.println("function skipped - UnitFilter param (" + function.name + ")");
return null;
}
if (argType.equals("BestUnitFilter")) {
System.err.println("function skipped - BestUnitFilter param (" + function.name + ")");
return null;
}
if (arg.length > 2 && arg[2].equals("=")) {
function.args.add(new Param(argType, argName, arg[3]));

View file

@ -20,6 +20,8 @@ public class Function implements Method {
ArrayList<Param> args = new ArrayList<Param>();
boolean isStatic = false;
@Override
public List<Param> getParams() {
return args;
@ -96,4 +98,13 @@ public class Function implements Method {
public void setJavadoc(String javadoc) {
this.javadoc = javadoc;
}
@Override
public boolean isStatic() {
return isStatic;
}
public void setStatic(boolean isStatic) {
this.isStatic = isStatic;
}
}

View file

@ -1,9 +1,8 @@
package test.api;
import bwapi.*;
import bwta.BWTA;
import bwta.BaseLocation;
import org.jsoup.Connection;
import bwapi4.*;
import bwapi4.Text.Size.*;
import bwapi4.Text.Size.Enum;
/**
* User: PC
@ -24,11 +23,11 @@ public class TestBot1 {
@Override
public void onStart() {
System.out.println("-------Analysing map-------");
BWTA.readMap();
BWTA.analyze();
//BWTA.readMap();
//BWTA.analyze();
System.out.println();
mirror.getGame().enableFlag(bwapi.Flag.Enum.UserInput.getValue());
mirror.getGame().enableFlag(bwapi4.Flag.Enum.UserInput.getValue());
}
@Override
@ -38,14 +37,14 @@ public class TestBot1 {
game.drawBoxScreen(0, 0, 100,100,Color.Red,true);
game.setTextSize(10);
game.setTextSize(Enum.Small);
game.drawTextScreen(10, 10, "Playing as " + self.getName() + " - " + self.getRace());
StringBuilder units = new StringBuilder("My units:\n");
/*
for(Player player : game.getPlayers()){
System.out.println(player.getName());
for(Unit enemyUnit: player.getUnits()){
for(Unit enemyUnit: player.()){
System.out.println(enemyUnit.getType());
}
}
@ -75,7 +74,7 @@ public class TestBot1 {
}
}
}
*/
//draw my units on screen