CvCity::IsHasResourceLocal(ResourceTypes, bool) const
- Defined in
- CvCity.cpp, line 3287
- Class
- CvCity
- Hook name
CivHooks::CvCity_IsHasResourceLocal
Hooks
static bool BeforeCvCity_IsHasResourceLocal(const CvCity* self, ResourceTypes eResource, bool bTestVisible, bool& result);static void AfterCvCity_IsHasResourceLocal(const CvCity* self, ResourceTypes eResource, bool bTestVisible, bool& result);static bool ReplaceCvCity_IsHasResourceLocal(bool (*original)(const CvCity*, ResourceTypes, bool), const CvCity* self, ResourceTypes eResource, bool bTestVisible);CivRegisterBefore<CivHooks::CvCity_IsHasResourceLocal>(host, &BeforeCvCity_IsHasResourceLocal);CivRegisterAfter<CivHooks::CvCity_IsHasResourceLocal>(host, &AfterCvCity_IsHasResourceLocal);CivRegisterReplace<CivHooks::CvCity_IsHasResourceLocal>(host, &ReplaceCvCity_IsHasResourceLocal);
Code
3286/// Does this City have eResource nearby?3287bool CvCity::IsHasResourceLocal(ResourceTypes eResource, bool bTestVisible) const3288{3289 VALIDATE_OBJECT3290 CvAssertMsg(eResource > -1 && eResource < GC.getNumResourceInfos(), "Invalid resource index.");32913292 // Actually check to see if we have this Resource to use right now3293 if(!bTestVisible)3294 {3295 return m_paiNumResourcesLocal[eResource] > 0;3296 }32973298 // See if we have the resource linked to this city, but not connected yet32993300 bool bFoundResourceLinked = false;33013302 // Loop through all plots near this City to see if we can find eResource - tests are ordered to optimize performance3303 CvPlot* pLoopPlot;3304#if defined(MOD_GLOBAL_CITY_WORKING)3305 for(int iCityPlotLoop = 0; iCityPlotLoop < GetNumWorkablePlots(); iCityPlotLoop++)3306#else3307 for(int iCityPlotLoop = 0; iCityPlotLoop < NUM_CITY_PLOTS; iCityPlotLoop++)3308#endif3309 {3310 pLoopPlot = plotCity(getX(), getY(), iCityPlotLoop);33113312 // Invalid plot3313 if(pLoopPlot == NULL)3314 continue;33153316 // Doesn't have the resource (ignore team first to save time)3317 if(pLoopPlot->getResourceType() != eResource)3318 continue;33193320 // Not owned by this player3321 if(pLoopPlot->getOwner() != getOwner())3322 continue;33233324 // Team can't see the resource here3325 if(pLoopPlot->getResourceType(getTeam()) != eResource)3326 continue;33273328 // Resource not linked to this city3329 if(pLoopPlot->GetResourceLinkedCity() != this)3330 continue;33313332 bFoundResourceLinked = true;3333 break;3334 }33353336 return bFoundResourceLinked;3337}
Calls
Called by
- CvCity::ChangeNumResourceLocal(ResourceTypes, int)
- CvCity::GetLocalResourceWonderProductionMod(BuildingTypes, CvString *) const
- CvCity::IsBuildingLocalResourceValid(BuildingTypes, bool, CvString *) const
- CvCity::processBuilding(BuildingTypes, int, bool, bool, bool)
- CvGameTrade::CanCreateTradeRoute(CvCity *, CvCity *, DomainTypes, TradeConnectionType, bool, bool)
- CvPlayerTrade::GetTradeConnectionResourceValueTimes100(const TradeConnection &, YieldTypes, bool)
- CvTradeAI::PrioritizeTradeRoutes(TradeConnectionList &)
- CvLuaCity::lIsHasResourceLocal(lua_State *)