CvMinorCivAI::IsLackingGiftableTileImprovementAtPlot(PlayerTypes, int, int)
- Defined in
- CvMinorCivAI.cpp, line 10097
- Class
- CvMinorCivAI
- Hook name
CivHooks::CvMinorCivAI_IsLackingGiftableTileImprovementAtPlot
Hooks
static bool BeforeCvMinorCivAI_IsLackingGiftableTileImprovementAtPlot(CvMinorCivAI* self, PlayerTypes eMajor, int iPlotX, int iPlotY, bool& result);static void AfterCvMinorCivAI_IsLackingGiftableTileImprovementAtPlot(CvMinorCivAI* self, PlayerTypes eMajor, int iPlotX, int iPlotY, bool& result);static bool ReplaceCvMinorCivAI_IsLackingGiftableTileImprovementAtPlot(bool (*original)(CvMinorCivAI*, PlayerTypes, int, int), CvMinorCivAI* self, PlayerTypes eMajor, int iPlotX, int iPlotY);CivRegisterBefore<CivHooks::CvMinorCivAI_IsLackingGiftableTileImprovementAtPlot>(host, &BeforeCvMinorCivAI_IsLackingGiftableTileImprovementAtPlot);CivRegisterAfter<CivHooks::CvMinorCivAI_IsLackingGiftableTileImprovementAtPlot>(host, &AfterCvMinorCivAI_IsLackingGiftableTileImprovementAtPlot);CivRegisterReplace<CivHooks::CvMinorCivAI_IsLackingGiftableTileImprovementAtPlot>(host, &ReplaceCvMinorCivAI_IsLackingGiftableTileImprovementAtPlot);
Code
10096// Does this plot lack a resource tile improvement that eMajor has access to?10097bool CvMinorCivAI::IsLackingGiftableTileImprovementAtPlot(PlayerTypes eMajor, int iPlotX, int iPlotY)10098{10099 CvAssertMsg(eMajor >= 0, "eMajor is expected to be non-negative (invalid Index)");10100 CvAssertMsg(eMajor < MAX_MAJOR_CIVS, "eMajor is expected to be within maximum bounds (invalid Index)");10101 if(eMajor < 0 || eMajor >= MAX_MAJOR_CIVS) return false;10102 CvPlot* pPlot = GC.getMap().plot(iPlotX, iPlotY);10103 if(pPlot == NULL)10104 {10105 CvAssertMsg(false, "pPlot not expected to be NULL, invalid coordinates. Please send Anton your save file and version.");10106 return false;10107 }1010810109 // Only allowed to improve plots that the minor actually owns10110 if(pPlot->getOwner() != GetPlayer()->GetID())10111 return false;1011210113 // Only allowed to improve Luxury and Strategic resources10114 ResourceTypes eResource = pPlot->getResourceType();10115 if(eResource == NO_RESOURCE)10116 {10117 return false;10118 }10119 else10120 {10121 ResourceUsageTypes eUsage = GC.getResourceInfo(eResource)->getResourceUsage();10122 if(eUsage != RESOURCEUSAGE_STRATEGIC && eUsage != RESOURCEUSAGE_LUXURY)10123 {10124 return false;10125 }10126 }1012710128 ImprovementTypes eImprovement = pPlot->getImprovementTypeNeededToImproveResource(eMajor, false /*bTestOwner*/);1012910130 // There must be a valid improvement for the player to build10131 if(eImprovement == NO_IMPROVEMENT)10132 return false;1013310134 return true;10135}
Calls
- CvGlobals::getMap()
- CvGlobals::getResourceInfo(ResourceTypes)
- CvMap::plot(int, int) const
- CvMinorCivAI::GetPlayer()
- CvPlayer::GetID() const
- CvPlot::getImprovementTypeNeededToImproveResource(PlayerTypes, bool)
- CvPlot::getOwner() const
- CvPlot::getResourceType(TeamTypes) const
- CvResourceInfo::getResourceUsage() const