int BuildOrderManager::nextFreeTime(const MetaUnit* unit, UpgradeType t)
{
  int time=nextFreeTime(unit);
  if (!Broodwar->self()->isUpgrading(t))
    return time;
  for(std::set<MetaUnit*>::iterator i=this->MetaUnitPointers.begin();i!=this->MetaUnitPointers.end();i++)
  {
    if ((*i)->getType()!=t.whatUpgrades()) continue;
    if ((*i)->isUpgrading() && (*i)->getUpgrade()==t)
    {
      time=max(time,nextFreeTime(*i));
    }
  }
  return time;
}
//----------------------------------------------------------------------------------------------
EntityClassType StarCraftTechTree::SourceEntity(int p_typeOrResearchId) const
{
    TName ident;
    TID id;
    UpgradeType upgrade;
    TechType tech;
    BWAPI::UnitType unitType;
    BWAPI::UnitType sourceType;

    if (BELONG(ResearchType, p_typeOrResearchId))
    {
        // Is Tech
        if ((int)p_typeOrResearchId >= ((int)(RESEARCH_START +  TechIdOffset)))
        {
            id = g_Database.TechMapping.GetBySecond((ResearchType)p_typeOrResearchId);
            ident = g_Database.TechIdentMapping.GetByFirst(id);
            tech = TechType::getType(ident);
            sourceType = tech.whatResearches();

            return g_Database.EntityMapping.GetByFirst(sourceType.getID());
        }
        // Is Upgrade
        else
        {
            id = g_Database.UpgradeMapping.GetBySecond((ResearchType)p_typeOrResearchId);
            ident = g_Database.UpgradeIdentMapping.GetByFirst(id);
            upgrade = UpgradeType::getType(ident);
            sourceType = upgrade.whatUpgrades();

            return g_Database.EntityMapping.GetByFirst(sourceType.getID());
        }
    }
    else if(BELONG(EntityClassType, p_typeOrResearchId))
    {
        id = g_Database.EntityMapping.GetBySecond((EntityClassType)p_typeOrResearchId);
        ident = g_Database.EntityIdentMapping.GetByFirst(id);
        unitType = UnitType::getType(ident);
        sourceType = unitType.whatBuilds().first;

        return g_Database.EntityMapping.GetByFirst(sourceType.getID());
    }

    return ECLASS_END;
}
Exemple #3
0
/*** 
 * Check if we can research the given UpgradeType w.r.t. tech structures
 * !!! Ask TheBuilder to build them otherwise. !!!
 */
bool Producer::checkCanUpgrade(UpgradeType t)
{
	return checkHaveTech(t.whatsRequired()) && checkHaveTech(t.whatUpgrades());
}