bool CvGameObjectPlot::hasGOM(GOMTypes eType, int iID) { switch (eType) { case GOM_BUILDING: { // return true if the building is present in the city on this plot and active BuildingTypes eBuilding = (BuildingTypes) iID; CvCity* pCity = m_pPlot->getPlotCity(); if (pCity) { return pCity->getNumActiveBuilding(eBuilding) > 0; } else { return false; } break; } case GOM_PROMOTION: { // Defer to units on the plot, combine with OR bool bHasGOM = false; foreach(GAMEOBJECT_UNIT, boost::bind(aggregateHasGOM, _1, eType, iID, &bHasGOM)); return bHasGOM; break; } case GOM_TRAIT: { // Return true if the owner has the trait TraitTypes eTrait = (TraitTypes) iID; PlayerTypes ePlayer = m_pPlot->getOwnerINLINE(); if (ePlayer != NO_PLAYER) { return GET_PLAYER(ePlayer).hasTrait(eTrait); } else { return false; } break; } case GOM_FEATURE: { // Check feature type FeatureTypes eFeature = (FeatureTypes) iID; #ifdef MULTI_FEATURE_MOD return m_pPlot->getHasFeature(eFeature); #else return m_pPlot->getFeatureType() == eFeature; #endif break; } case GOM_OPTION: { GameOptionTypes eOption = (GameOptionTypes) iID; return GC.getGameINLINE().isOption(eOption); break; } case GOM_TERRAIN: { // Check terrain type TerrainTypes eTerrain = (TerrainTypes) iID; return m_pPlot->getTerrainType() == eTerrain; break; } case GOM_GAMESPEED: { GameSpeedTypes eSpeed = (GameSpeedTypes) iID; return GC.getGameINLINE().getGameSpeedType() == eSpeed; break; } case GOM_ROUTE: { // Check route type RouteTypes eRoute = (RouteTypes) iID; return m_pPlot->getRouteType() == eRoute; break; } case GOM_BONUS: { // Check bonus type BonusTypes eBonus = (BonusTypes) iID; return m_pPlot->getBonusType() == eBonus; break; } case GOM_UNITTYPE: { // Defer to units on the plot, combine with OR bool bHasGOM = false; foreach(GAMEOBJECT_UNIT, boost::bind(aggregateHasGOM, _1, eType, iID, &bHasGOM)); return bHasGOM; break; } case GOM_TECH: { // If the team has researched that tech, return true TechTypes eTech = (TechTypes) iID; TeamTypes eTeam = m_pPlot->getTeam(); if (eTeam != NO_TEAM) { return GET_TEAM(eTeam).isHasTech(eTech); } else { return false; } break; } case GOM_CIVIC: { // Return true if the owning player has the civic active CivicTypes eCivic = (CivicTypes) iID; PlayerTypes ePlayer = m_pPlot->getOwnerINLINE(); if (ePlayer != NO_PLAYER) { return GET_PLAYER(ePlayer).isCivic(eCivic); } else { return false; } break; } case GOM_RELIGION: { // return true if the religion is present in the city on this plot CvCity* pCity = m_pPlot->getPlotCity(); if (pCity) { return pCity->isHasReligion((ReligionTypes)iID); } else { return false; } break; } case GOM_CORPORATION: { // return true if the corporation is present in the city on this plot CvCity* pCity = m_pPlot->getPlotCity(); if (pCity) { return pCity->isHasCorporation((CorporationTypes)iID); } else { return false; } break; } case GOM_IMPROVEMENT: { // Check improvement type ImprovementTypes eImprovement = (ImprovementTypes) iID; return m_pPlot->getImprovementType() == eImprovement; break; } } return false; }
bool CvGameObjectUnit::hasGOM(GOMTypes eType, int iID) { switch (eType) { case GOM_BUILDING: { // return true if the building is present in the city the unit is in and active BuildingTypes eBuilding = (BuildingTypes) iID; CvCity* pCity = m_pUnit->plot()->getPlotCity(); if (pCity) { return pCity->getNumActiveBuilding(eBuilding) > 0; } else { return false; } break; } case GOM_PROMOTION: { // return true if the unit has that promotion PromotionTypes ePromotion = (PromotionTypes) iID; return m_pUnit->isHasPromotion(ePromotion); break; } case GOM_TRAIT: { // Return true if the owner has the trait TraitTypes eTrait = (TraitTypes) iID; return GET_PLAYER(m_pUnit->getOwnerINLINE()).hasTrait(eTrait); break; } case GOM_FEATURE: { // Check plot on which the unit is FeatureTypes eFeature = (FeatureTypes) iID; #ifdef MULTI_FEATURE_MOD return m_pUnit->plot()->getHasFeature(eFeature); #else return m_pUnit->plot()->getFeatureType() == eFeature; #endif break; } case GOM_OPTION: { GameOptionTypes eOption = (GameOptionTypes) iID; return GC.getGameINLINE().isOption(eOption); break; } case GOM_TERRAIN: { // Check plot on which the unit is TerrainTypes eTerrain = (TerrainTypes) iID; return m_pUnit->plot()->getTerrainType() == eTerrain; break; } case GOM_GAMESPEED: { GameSpeedTypes eSpeed = (GameSpeedTypes) iID; return GC.getGameINLINE().getGameSpeedType() == eSpeed; break; } case GOM_ROUTE: { // Check plot on which the unit is RouteTypes eRoute = (RouteTypes) iID; return m_pUnit->plot()->getRouteType() == eRoute; break; } case GOM_BONUS: { // Check plot on which the unit is BonusTypes eBonus = (BonusTypes) iID; return m_pUnit->plot()->getBonusType() == eBonus; break; } case GOM_UNITTYPE: { // Check the type of the unit UnitTypes eType = (UnitTypes) iID; return m_pUnit->getUnitType() == eType; break; } case GOM_TECH: { // If the team has researched that tech, return true TechTypes eTech = (TechTypes) iID; return GET_TEAM(m_pUnit->getTeam()).isHasTech(eTech); break; } case GOM_CIVIC: { // Return true if the owning player has the civic active CivicTypes eCivic = (CivicTypes) iID; return GET_PLAYER(m_pUnit->getOwnerINLINE()).isCivic(eCivic); break; } case GOM_RELIGION: { // True if the religion is state religion return GET_PLAYER(m_pUnit->getOwnerINLINE()).getStateReligion() == (ReligionTypes)iID; break; } case GOM_CORPORATION: { // True if the corporation is active return GET_PLAYER(m_pUnit->getOwnerINLINE()).isActiveCorporation((CorporationTypes)iID); break; } case GOM_IMPROVEMENT: { // Check plot on which the unit is ImprovementTypes eImprovement = (ImprovementTypes) iID; return m_pUnit->plot()->getImprovementType() == eImprovement; break; } } return false; }