Just to be sure, if you call IsLive() on a dead unit, the unitID gets set to 0, right?I don't think so.
// Untested pseudo code
int _Unit::IsLive()
{
if (this->unitIndex == 0)
return FALSE;
Unit* unit = map.unit[this->unitIndex];
if ((unit->next != -1) && ((unit->flags & IsDeadFlag) == 0))
return TRUE;
this->unitIndex = 0; // ** Clear unitIndex to 0
return FALSE;
}