Call to train:
JNIEXPORT void JNICALL Java_eisbot_proxy_JNIBWAPI_train(JNIEnv *env, jobject
jObj, jint unitID, jint typeID){
Unit* unit = Broodwar->getUnit(unitID);
if (unit != NULL) {
if (unitTypeMap[typeID] == NULL)
{
unit->train(unitTypeMap[typeID]);
}
}
}
What is the expected output? What do you see instead?
unit->train(unitTypeMap[typeID]) should be called if typeID is in unitTypeMap's
keys.
Instead it will fail if the typeID is zero, as the BWAPI::UnitType returned
from the map is being implicitly converted to an integer type (giving its
typeID as an integer) to compare with NULL.
Fix:
JNIEXPORT void JNICALL Java_eisbot_proxy_JNIBWAPI_train(JNIEnv *env, jobject
jObj, jint unitID, jint typeID){
Unit* unit = Broodwar->getUnit(unitID);
if (unit != NULL) {
if (unitTypeMap.count(typeID) > 0)
{
unit->train(unitTypeMap[typeID]);
}
}
}
This bug is found in many places throughout the jni bridge wherever typeIDs are
checked as being present in the respective type map, and will fail with a type
ID of zero in the same way.
Original issue reported on code.google.com by Fobbah on 25 Oct 2011 at 5:14
Original issue reported on code.google.com by
Fobbah
on 25 Oct 2011 at 5:14