Esempio n. 1
0
void cUnitManager::GroupRemoveUnit(int unit, UnitInfo* U)
{
	UpdateGroupSize();
	U->group->Units.erase(unit);

	if( U->udrBL->task == TASK_ASSAULT )
	{
		U->group->M->count--;
		if( U->group->M->count == 0 )
		{
			delete U->group->M;
			U->group->M = 0;
		}
	}
	else if( U->udrBL->task == TASK_CONSTRUCT )
	{
		U->group->C->count--;
		if( U->group->C->count == 0 )
		{
			delete U->group->C;
			U->group->C = 0;
		}
	}

	if( int(U->group->Units.size()) == 0 )
	{
		GroupSize--;
		sRAIGroup* RGroup=Group[U->group->index];
		Group[U->group->index]=Group[GroupSize];
		Group[U->group->index]->index = U->group->index;
		delete RGroup;
	}
}
void cUnitManager::UnitDestroyed(int unit,UnitInfo *U)
{
//	*l<<" (t="<<U->pBOL->task<<")";
	switch( U->pBOL->task )
	{
	case TASK_CONSTRUCT:
		G->Build->UBuilderDestroyed(unit,U);
		break;
	case TASK_ASSAULT:
		{
			UAssault.erase(unit);
			UpdateGroupSize();

			U->Group->Units.erase(unit);
			if( int(U->Group->Units.size()) == 0 )
			{
				GroupSize--;
				sRAIGroup* RGroup=Group[U->Group->index];
				Group[U->Group->index]=Group[GroupSize];
				Group[U->Group->index]->index = U->Group->index;
				delete RGroup;
			}
		}
		break;
	case TASK_SCOUT:
		{
			UScout.erase(unit);
		}
		break;
	case TASK_SUICIDE:
		{
			USuicide.erase(unit);
		}
		break;
	case TASK_SUPPORT:
		{
			USupport.erase(unit);
		}
		break;
	case TASK_TRANSPORT:
		{
			UTrans.erase(unit);
		}
		break;
	}
}
void cUnitManager::UnitFinished(int unit,UnitInfo *U)
{
//	*l<<" (t="<<U->pBOL->task<<")";
	switch( U->pBOL->task )
	{
	case TASK_CONSTRUCT:
		G->Build->UBuilderFinished(unit,U);
		break;
	case TASK_ASSAULT:
		{
			UAssault.insert(cRAI::iupPair(unit,U));
			UpdateGroupSize();
			Assign(unit,U);
			if( ActiveAttackOrders() )
				SendAttackGroups();
		}
		break;
	case TASK_SCOUT:
		{
			UScout.insert(isPair(unit,sScoutUnitInfo()));
		}
		break;
	case TASK_SUICIDE:
		{
			USuicide.insert(cRAI::iupPair(unit,U));
		}
		break;
	case TASK_SUPPORT:
		{
			USupport.insert(unit);
		}
		break;
	case TASK_TRANSPORT:
		{
			UTrans.insert(itPair(unit,sTransportUnitInfo(U->ud)));
		}
		break;
	}
}