plotCity(int, int, int)
- Defined in
- CvGameCoreUtils.cpp, line 30
- Hook name
CivHooks::plotCity
Hooks
static bool BeforeplotCity(int iX, int iY, int iIndex, CvPlot*& result);static void AfterplotCity(int iX, int iY, int iIndex, CvPlot*& result);static CvPlot* ReplaceplotCity(CvPlot* (*original)(int, int, int), int iX, int iY, int iIndex);CivRegisterBefore<CivHooks::plotCity>(host, &BeforeplotCity);CivRegisterAfter<CivHooks::plotCity>(host, &AfterplotCity);CivRegisterReplace<CivHooks::plotCity>(host, &ReplaceplotCity);
Code
29/// This function will return the CvPlot associated with the Index (0 to 36) of a City at iX,iY. The lower the Index the closer the Plot is to the City (roughly)30CvPlot* plotCity(int iX, int iY, int iIndex)31{32 int iDeltaHexX = 0;33 int iDeltaHexY = 0;34#if defined(MOD_GLOBAL_CITY_WORKING)35 if(iIndex < MAX_CITY_PLOTS)36#else37 if(iIndex < NUM_CITY_PLOTS)38#endif39 {40 iDeltaHexX = GC.getCityPlotX()[iIndex]; // getCityPlotX now uses hex-space coords41 iDeltaHexY = GC.getCityPlotY()[iIndex];42 }43 else44 {45 // loop till we find the ring this is on46 int iThisRing = 0;47 int iHighestValueOnThisRing = 0;48 int iLowestValueOnThisRing = 0;49 while(iHighestValueOnThisRing < iIndex)50 {51 iThisRing++;52 iLowestValueOnThisRing = iHighestValueOnThisRing + 1;53 iHighestValueOnThisRing += iThisRing*6;54 }55 // determine what side of the hex we are on56 int iDiff = (iIndex - iLowestValueOnThisRing);57 int iSide = iDiff / iThisRing;58 int iOffset = iDiff % iThisRing;5960 switch(iSide)61 {62 case 0:63 iDeltaHexX = 0 + iOffset;64 iDeltaHexY = iThisRing - iOffset;65 break;66 case 1:67 iDeltaHexX = iThisRing;68 iDeltaHexY = 0 - iOffset;69 break;70 case 2:71 iDeltaHexX = iThisRing - iOffset;72 iDeltaHexY = -iThisRing;73 break;74 case 3:75 iDeltaHexX = 0 - iOffset;76 iDeltaHexY = -iThisRing + iOffset;77 break;78 case 4:79 iDeltaHexX = -iThisRing;80 iDeltaHexY = 0 + iOffset;81 break;82 case 5:83 iDeltaHexX = -iThisRing + iOffset;84 iDeltaHexY = iThisRing;85 break;86 default:87 return 0;88 }8990 }91 // convert the city coord to hex-space coordinates92 int iCityHexX = xToHexspaceX(iX, iY);9394 int iPlotHexX = iCityHexX + iDeltaHexX;95 int iPlotY = iY + iDeltaHexY; // Y is the same in both coordinate systems9697 // convert from hex-space coordinates to the storage array98 int iPlotX = hexspaceXToX(iPlotHexX, iPlotY);99100 return GC.getMap().plot(iPlotX , iPlotY);101}
Calls
Called by
51 functions in 12 files
- CvCity::BuyPlot(int, int)
- CvCity::CountFeature(FeatureTypes) const
- CvCity::CountImprovement(ImprovementTypes) const
- CvCity::CountPlotType(PlotTypes) const
- CvCity::CountResource(ResourceTypes) const
- CvCity::CountTerrain(TerrainTypes) const
- CvCity::CountWorkedFeature(FeatureTypes) const
- CvCity::CountWorkedImprovement(ImprovementTypes) const
- CvCity::CountWorkedPlotType(PlotTypes) const
- CvCity::CountWorkedResource(ResourceTypes) const
- CvCity::CountWorkedTerrain(TerrainTypes) const
- CvCity::DoCreatePuppet()
- CvCity::DoPickResourceDemanded(bool)
- CvCity::HasAnyNaturalWonder() const
- CvCity::HasFeature(FeatureTypes) const
- CvCity::HasImprovement(ImprovementTypes) const
- CvCity::HasPlotType(PlotTypes) const
- CvCity::HasResource(ResourceTypes) const
- CvCity::HasTerrain(TerrainTypes) const
- CvCity::HasWorkedFeature(FeatureTypes) const
- CvCity::HasWorkedImprovement(ImprovementTypes) const
- CvCity::HasWorkedPlotType(PlotTypes) const
- CvCity::HasWorkedResource(ResourceTypes) const
- CvCity::HasWorkedTerrain(TerrainTypes) const
- CvCity::IsHasResourceLocal(ResourceTypes, bool) const
- CvCity::changeCityWorkingChange(int)
- CvCity::init(int, PlayerTypes, int, int, bool, bool, ReligionTypes, const char *)
- CvCity::processBuilding(BuildingTypes, int, bool, bool, bool)
- CvCityAI::AI_stealPlots()
- CvCityCitizens::GetCityPlotFromIndex(int) const
- CvCitySpecializationAI::PlotValueForScience(CvPlot *)
- CvCitySpecializationAI::PlotValueForSpecificYield(CvPlot *, YieldTypes)
- CityStrategyAIHelpers::IsTestCityStrategy_NeedNavalGrowth(AICityStrategyTypes, CvCity *)
- CityStrategyAIHelpers::IsTestCityStrategy_NeedNavalTileImprovement(CvCity *)
- CityStrategyAIHelpers::IsTestCityStrategy_NeedTileImprovers(AICityStrategyTypes, CvCity *)
- CityStrategyAIHelpers::IsTestCityStrategy_WantTileImprovers(AICityStrategyTypes, CvCity *)
- CvPlayer::ChangeCityWorkingChange(int)
- CvPlayer::countCityFeatures(FeatureTypes) const
- CvPlayerAI::FindBestMusicianTargetPlot(CvUnit *, bool)
- CvPlot::DoFindCityToLinkResourceTo(CvCity *)
- CvPlot::isPotentialCityWorkForArea(CvArea *) const
- CvPlot::setPlotCity(CvCity *)
- CvPlot::setPlotType(PlotTypes, bool, bool, bool)
- CvPlot::updatePotentialCityWork()
- CvPlot::updateWorkingCity()
- CvSiteEvaluatorForStart::PlotFoundValue(CvPlot *, CvPlayer *, YieldTypes, bool)
- CvTacticalAI::MoveToEmptySpaceTwoFromTarget(UnitHandle, CvPlot *, bool)
- CvTacticalAI::ScoreCloseOnPlots(CvPlot *, bool)
- CvTacticalAI::ScoreHedgehogPlots(CvPlot *)
- CvTeam::changeCityWorkingChange(int)
- CvPlayerTechs::SetLocalePriorities()