void CvPlot::doFeature()
{
PROFILE("CvPlot::doFeature()")
CvCity* pCity;
CvPlot* pLoopPlot;
CvWString szBuffer;
int iProbability;
int iI, iJ;
if (getFeatureType() != NO_FEATURE)
{
//FfH: Added by Kael 03/20/2008
if (GC.getFeatureInfo(getFeatureType()).getFeatureUpgrade() != NO_FEATURE)
{
if (GC.getFeatureInfo((FeatureTypes)GC.getFeatureInfo(getFeatureType()).getFeatureUpgrade()).isTerrain(getTerrainType()))
{
if (GC.getFeatureInfo((FeatureTypes)GC.getFeatureInfo(getFeatureType()).getFeatureUpgrade()).getPrereqStateReligion() == NO_RELIGION
|| isOwned() && GC.getFeatureInfo((FeatureTypes)GC.getFeatureInfo(getFeatureType()).getFeatureUpgrade()).getPrereqStateReligion() == GET_PLAYER(getOwnerINLINE()).getStateReligion())
{
/************************************************************************************************/
/* UNOFFICIAL_PATCH 10/22/09 jdog5000 */
/* */
/* Gamespeed scaling */
/************************************************************************************************/
/* original bts code
if (GC.getGameINLINE().getSorenRandNum(100, "Feature Upgrade") < GC.getDefineINT("FEATURE_UPGRADE_CHANCE"))
*/
int iOdds = (100 * GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getFeatureProductionPercent())/100;
if (GC.getGameINLINE().getSorenRandNum(iOdds, "Feature Upgrade") < GC.getDefineINT("FEATURE_UPGRADE_CHANCE"))
/************************************************************************************************/
/* UNOFFICIAL_PATCH END */
/************************************************************************************************/
{
setFeatureType((FeatureTypes)GC.getFeatureInfo(getFeatureType()).getFeatureUpgrade());
}
}
}
}
if (GC.getDefineINT("FLAMES_FEATURE") != -1 && GC.getDefineINT("FLAMES_SPREAD_EFFECT") != -1)
{
if (getFeatureType() == GC.getDefineINT("FLAMES_FEATURE"))
{
if (GC.getGameINLINE().getSorenRandNum(100, "Flames Spread") < GC.getDefineINT("FLAMES_SPREAD_CHANCE"))
{
CvPlot* pAdjacentPlot;
for (int iI = 0; iI < NUM_DIRECTION_TYPES; ++iI)
{
pAdjacentPlot = plotDirection(getX_INLINE(), getY_INLINE(), ((DirectionTypes)iI));
if (pAdjacentPlot != NULL)
{
if (pAdjacentPlot->getFeatureType() != NO_FEATURE)
{
if (GC.getFeatureInfo((FeatureTypes)pAdjacentPlot->getFeatureType()).isFlammable())
{
if (pAdjacentPlot->getImprovementType() == NO_IMPROVEMENT)
{
pAdjacentPlot->setImprovementType((ImprovementTypes)GC.getDefineINT("FLAMES_SPREAD_EFFECT"));
}
}
}
}
}
}
if (!GC.getFeatureInfo((FeatureTypes)GC.getDefineINT("FLAMES_FEATURE")).isTerrain(getTerrainType()))
{
if (GC.getGameINLINE().getSorenRandNum(100, "Flames Spread") < GC.getDefineINT("FLAMES_EXPIRE_CHANCE"))
{
setFeatureType(NO_FEATURE);
if (GC.getDefineINT("FLAMES_EXPIRE_EFFECT") != -1)
{
if (canHaveFeature((FeatureTypes)GC.getDefineINT("FLAMES_EXPIRE_EFFECT")))
{
setFeatureType((FeatureTypes)GC.getDefineINT("FLAMES_EXPIRE_EFFECT"), -1);
}
}
if (getFeatureType() == NO_FEATURE)
{
return;
}
}
}
}
}
//FfH: End Add
iProbability = GC.getFeatureInfo(getFeatureType()).getDisappearanceProbability();
if (iProbability > 0)
{
/************************************************************************************************/
/* UNOFFICIAL_PATCH 03/04/10 jdog5000 */
/* */
/* Gamespeed scaling */
/************************************************************************************************/
/* original bts code
if (GC.getGameINLINE().getSorenRandNum(10000, "Feature Disappearance") < iProbability)
*/
int iOdds = (10000*GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getVictoryDelayPercent())/100;
if (GC.getGameINLINE().getSorenRandNum(iOdds, "Feature Disappearance") < iProbability)
/************************************************************************************************/
/* UNOFFICIAL_PATCH END */
/************************************************************************************************/
{
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)
{
/************************************************************************************************/
/* UNOFFICIAL_PATCH 03/04/10 jdog5000 */
/* */
/* Gamespeed scaling */
/************************************************************************************************/
/* original bts code
if (GC.getGameINLINE().getSorenRandNum(10000, "Feature Growth") < iProbability)
*/
int iOdds = (10000*GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getVictoryDelayPercent())/100;
if( GC.getGameINLINE().getSorenRandNum(iOdds, "Feature Growth") < iProbability )
/************************************************************************************************/
/* UNOFFICIAL_PATCH END */
/************************************************************************************************/
{
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;
}
}
}
}
}
}
}
}
}