Page 1 of 1

Crash in CCommandAI::UpdateTargetLostTimer()

Posted: 11 Oct 2006, 11:41
by submarine
Using latest svn version, 4 AAI 2vs2 on long divison





crashed here:

Code: Select all

	if (uh->units[unitid] && (uh->units[unitid]->losStatus[owner->allyteam] & LOS_INRADAR))

Callstack:

> spring.exe!CCommandAI::UpdateTargetLostTimer() Line 647 + 0x1b C++
spring.exe!CMobileCAI::SlowUpdate() Line 424 + 0x5f C++
spring.exe!CCommandAI::GiveAllowedCommand() Line 550 C++
spring.exe!CMobileCAI::GiveCommand() Line 142 + 0x8 C++
spring.exe!std::vector<float,std::allocator<float> >::push_back() Line 583 + 0x10 C++
spring.exe!CSelectedUnits::AiOrder() Line 561 C++
spring.exe!CGame::ClientReadNet() Line 2189 C++
spring.exe!streflop_libm::__tanf() Line 39 + 0x15 C++
spring.exe!COverheadController::KeyMove() Line 133 + 0x2e C++
spring.exe!CGame::UpdateUI() Line 2439 C++
spring.exe!CGame::Update() Line 1333 + 0x7 C++
spring.exe!SpringApp::Run() Line 885 + 0x2f C++
spring.exe!Run() Line 964 + 0x1b C++
spring.exe!_WinMain@16() Line 990 + 0x19 C++
spring.exe!WinMainCRTStartup() Line 390 + 0x1b C

Posted: 11 Oct 2006, 17:03
by submarine
compiled spring in debug mode to get more information:

Code: Select all

int CCommandAI::UpdateTargetLostTimer(int unitid)
is called with unitid = -1 from

Code: Select all

case CMD_GUARD:
		assert(owner->unitDef->canGuard);
		if(uh->units[int(c.params[0])]!=0 && UpdateTargetLostTimer(int(c.params[0]))){....
in CMobileCAI::SlowUpdate() Line 424

Posted: 11 Oct 2006, 20:08
by Tobi
Are you really sure it isn't AAI that sets the (first) argument of the CMD_GUARD command to -1? (for example by directly passing the return value of another function - that may fail by returning -1 - to it)

In any case I'll add a little check so it doesn't crash but just ignores those cases in the future.

Posted: 12 Oct 2006, 10:18
by submarine
it doesnt do this on purpose, but who knows :)

i'll check that