Ejemplo n.º 1
0
int
CombatGroup::CountUnits() const
{
	int n = 0;

	CombatGroup* g = (CombatGroup*) this;

	ListIter<CombatUnit> unit = g->units;
	while (++unit)
	n += unit->Count() - unit->DeadCount();

	CombatGroup* pThis = ((CombatGroup*) this);
	pThis->live_comp.clear();
	ListIter<CombatGroup> iter = g->components;
	while (++iter) {
		CombatGroup* comp = iter.value();

		if (!comp->IsReserve()) {
			int unit_count = comp->CountUnits();
			if (unit_count > 0)
			pThis->live_comp.append(comp);

			n += unit_count;
		}
	}

	return n;
}
CampaignMissionRequest*
CampaignPlanMission::PlanRandomStarshipMission()
{
    int type    = Mission::PATROL;
    int r       = RandomIndex();
    int ownside = player_group->GetIFF();

    if (mission_type_index < 0)
    mission_type_index = r;

    else if (mission_type_index >= 16)
    mission_type_index = 0;

    type = mission_types[mission_type_index++];

    if (type == Mission::ESCORT_FREIGHT) {
        CombatGroup*  freight  = campaign->FindGroup(ownside, CombatGroup::FREIGHT);
        if (!freight || freight->CountUnits() < 1)
        type = Mission::PATROL;
    }

    CampaignMissionRequest* request = 0;
    request = new(__FILE__,__LINE__)
    CampaignMissionRequest(campaign, type, start, player_group);

    return request;
}