PHP-Code:
void CvPlot::doFeature()
{
PROFILE("CvPlot::doFeature()")
CvCity* pCity;
CvPlot* pLoopPlot;
CvWString szBuffer;
int iProbability;
int iI, iJ;
if (getFeatureType() != NO_FEATURE)
{
iProbability = GC.getFeatureInfo(getFeatureType()).getDisappearanceProbability();
if (iProbability > 0)
{
if (GC.getGameINLINE().getSorenRandNum(10000, "Feature Disappearance") < iProbability)
{
setFeatureType(NO_FEATURE);
}
}
}
else
{
if (!isUnit())
{
if (getImprovementType() == NO_IMPROVEMENT)
{
for (iI = 0; iI < GC.getNumFeatureInfos(); ++iI)
{
if (canHaveFeature((FeatureTypes)iI))
{
if ((getBonusType() == NO_BONUS) || (GC.getBonusInfo(getBonusType()).isFeature(iI)))
{
iProbability = 0;
for (iJ = 0; iJ < NUM_CARDINALDIRECTION_TYPES; iJ++)
{
pLoopPlot = plotCardinalDirection(getX_INLINE(), getY_INLINE(), ((CardinalDirectionTypes)iJ));
if (pLoopPlot != NULL)
{
if (pLoopPlot->getFeatureType() == ((FeatureTypes)iI))
{
if (pLoopPlot->getImprovementType() == NO_IMPROVEMENT)
{
iProbability += GC.getFeatureInfo((FeatureTypes)iI).getGrowthProbability();
}
else
{
iProbability += GC.getImprovementInfo(pLoopPlot->getImprovementType()).getFeatureGrowthProbability();
}
}
}
}
iProbability *= std::max(0, (GC.getFEATURE_GROWTH_MODIFIER() + 100));
iProbability /= 100;
if (isRoute())
{
iProbability *= std::max(0, (GC.getROUTE_FEATURE_GROWTH_MODIFIER() + 100));
iProbability /= 100;
}
if (iProbability > 0)
{
if (GC.getGameINLINE().getSorenRandNum(10000, "Feature Growth") < iProbability)
{
setFeatureType((FeatureTypes)iI);
pCity = GC.getMapINLINE().findCity(getX_INLINE(), getY_INLINE(), getOwnerINLINE(), NO_TEAM, false);
if (pCity != NULL)
{
// Tell the owner of this city.
szBuffer = gDLL->getText("TXT_KEY_MISC_FEATURE_GROWN_NEAR_CITY", GC.getFeatureInfo((FeatureTypes) iI).getTextKeyWide(), pCity->getNameKey());
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_FEATUREGROWTH", MESSAGE_TYPE_INFO, GC.getFeatureInfo((FeatureTypes) iI).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_WHITE"), getX_INLINE(), getY_INLINE(), true, true);
}
break;
}
}
}
}
}
}
}
}
}