Page 1 of 1

GetUnitDef(int id) causing trouble

Posted: 25 Oct 2005, 18:54
by submarine
GetUnitDef(int id) return a null pointer when called during initialization of an ai

however, GetUnitDef("ARMCOM") works fine for me; is it possible that the unit ids are not set when spring ai intefrace calls InitAI() ??

Posted: 25 Oct 2005, 19:19
by cain
wewll, you shuldn't call it during the init, as you don't have any units.

the first unit you see is the commander after the game start and before the first update.

the best place to put it is inside a unitcreated (called whenewer a unit is started being built) or unitfinisched (called when the unit is ready).

Posted: 25 Oct 2005, 19:32
by submarine
lol thanks cain :) i´ve been trying to hunt that bug for hours

i confused UnitDef->id with the unit ids spring assigns to units in the game...

how stupid... :|