Page 1 of 1

Java unitdef crash

Posted: 06 May 2012, 13:16
by w00tguy123
Using code from the NullJavaAI, I've made a small test that is supposed to identify the commander when the game starts. The only code I've added is for this event:

Code: Select all

	@Override public int unitFinished(int unit) 
	{
		int def = clb.Unit_getDef(unit);
		String name = clb.UnitDef_getName(def);
		clb.Log_log("Unit " + unit + " has unitdef " + def + " which has name " + name);
		return 0;
	}
The game crashes as soon as I call 'UnitDef_getName(def)'. Is there anything that needs to be called/setup before using the UnitDef_ methods? The tutorial for the Java interface seems to be outdated. I'm testing this with Spring v0.88 and BA v7.68.

Edit: just realized that the tutorial is for the OO java AI. I'll try that one and see if it works.

Edit2: The OO java AI works fine, so I guess I'll use that instead. Out of curiosity, is the Java one broken or a WIP?

Re: Java unitdef crash

Posted: 07 May 2012, 07:41
by hoijui
yeah, tutorial is outdated. :/
the non-OO java AI Interface is not meant ot be used by devs directly, but rather (maybe) ... for example when you implement an AI Wrapper in an other JVM supported language then Java. though that will likely nto make sense, as probably all of these languages may be able to use the Java OO Wrapper directly, and thus not need their own wrapper.
it should not crash though, but .. i have no time, nad there are way more important things to fix first, with the Java AI Interface.