IUnitTacticsPtr makeUnitTactics(const Player& player, const boost::shared_ptr<UnitInfo>& pUnitInfo) { const int lookAheadDepth = 2; if (couldConstructUnit(player, lookAheadDepth, pUnitInfo, true)) { const UnitTypes unitType = pUnitInfo->getUnitType(); const CvUnitInfo& unitInfo = gGlobals.getUnitInfo(unitType); IUnitTacticsPtr pTactic(new UnitTactic(unitType)); CityIter iter(*player.getCvPlayer()); while (CvCity* pCity = iter()) { #ifdef ALTAI_DEBUG CivLog::getLog(*player.getCvPlayer())->getStream() << "\n" << __FUNCTION__ << " Adding tactic for unit: " << unitInfo.getType(); #endif pTactic->addCityTactic(pCity->getIDInfo(), makeCityUnitTactics(player, player.getCity(pCity), pUnitInfo)); } MakeUnitTacticsDependenciesVisitor dependentTacticsVisitor(player, NULL); boost::apply_visitor(dependentTacticsVisitor, pUnitInfo->getInfo()); const std::vector<ResearchTechDependencyPtr>& dependentTechs = dependentTacticsVisitor.getTechDependencies(); for (size_t i = 0, count = dependentTechs.size(); i < count; ++i) { pTactic->addTechDependency(dependentTechs[i]); } return pTactic; } return IUnitTacticsPtr(); }
ILimitedBuildingTacticsPtr makeGlobalBuildingTactics(const Player& player, const boost::shared_ptr<BuildingInfo>& pBuildingInfo) { const int lookAheadDepth = 2; ILimitedBuildingTacticsPtr pTactic(new GlobalBuildingTactic(pBuildingInfo->getBuildingType())); CityIter iter(*player.getCvPlayer()); while (CvCity* pCity = iter()) { if (couldConstructBuilding(player, player.getCity(pCity), lookAheadDepth, pBuildingInfo, true)) { #ifdef ALTAI_DEBUG CivLog::getLog(*player.getCvPlayer())->getStream() << "\n" << __FUNCTION__ << " Adding tactic for building: " << gGlobals.getBuildingInfo(pBuildingInfo->getBuildingType()).getType(); #endif pTactic->addCityTactic(pCity->getIDInfo(), makeCityBuildingTactics(player, player.getCity(pCity), pBuildingInfo)); } } return pTactic; }