本文整理汇总了C++中CvArea类的典型用法代码示例。如果您正苦于以下问题:C++ CvArea类的具体用法?C++ CvArea怎么用?C++ CvArea使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CvArea类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CvAssert
/// Value of this site for a settler
int CvSiteEvaluatorForSettler::PlotFoundValue(CvPlot* pPlot, CvPlayer* pPlayer, YieldTypes eYield, bool bCoastOnly)
{
CvAssert(pPlot);
if(!pPlot) return 0;
if(!CanFound(pPlot, pPlayer, true))
{
return 0;
}
// Is there any reason this site doesn't work for a settler?
//
// First must be on coast if settling a new continent
bool bIsCoastal = pPlot->isCoastalLand(GC.getMIN_WATER_SIZE_FOR_OCEAN());
CvArea* pArea = pPlot->area();
CvAssert(pArea);
if(!pArea) return 0;
int iNumAreaCities = pArea->getCitiesPerPlayer(pPlayer->GetID());
if(bCoastOnly && !bIsCoastal && iNumAreaCities == 0)
{
return 0;
}
// Seems okay for a settler, use base class to determine exact value
else
{
return CvCitySiteEvaluator::PlotFoundValue(pPlot, pPlayer, eYield);
}
}
示例2: GetInstance
//------------------------------------------------------------------------------
//bool isWater();
int CvLuaArea::lIsWater(lua_State* L)
{
CvArea* pkArea = GetInstance(L);
const bool bResult = pkArea->isWater();
lua_pushboolean(L, bResult);
return 1;
}
示例3: PROFILE_FUNC
void CvMap::calculateAreas()
{
PROFILE_FUNC();
CvPlot* pLoopPlot;
CvArea* pArea;
int iArea;
int iI;
for (iI = 0; iI < numPlotsINLINE(); iI++)
{
pLoopPlot = plotByIndexINLINE(iI);
gDLL->callUpdater();
FAssertMsg(pLoopPlot != NULL, "LoopPlot is not assigned a valid value");
if (pLoopPlot->getArea() == FFreeList::INVALID_INDEX)
{
pArea = addArea();
pArea->init(pArea->getID(), pLoopPlot->isWater());
iArea = pArea->getID();
pLoopPlot->setArea(iArea);
gDLL->getFAStarIFace()->GeneratePath(&GC.getAreaFinder(), pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), -1, -1, pLoopPlot->isWater(), iArea);
}
}
}
示例4: PROFILE
void CvMapGenerator::addGoodies()
{
PROFILE("CvMapGenerator::addGoodies");
if (gDLL->getPythonIFace()->callFunction(gDLL->getPythonIFace()->getMapScriptModule(), "addGoodies"))
{
if (!gDLL->getPythonIFace()->pythonUsingDefaultImpl())
{
return; // Python override
}
}
gDLL->NiTextOut("Adding Goodies...");
if (GC.getEraInfo(GC.getGameINLINE().getStartEra()).isNoGoodies())
{
return;
}
int iNumPlots = GC.getMapINLINE().numPlotsINLINE();
int* piShuffle = shuffle(iNumPlots, GC.getGameINLINE().getMapRand());
for (int iI = 0; iI < GC.getNumImprovementInfos(); iI++)
{
if (GC.getImprovementInfo((ImprovementTypes)iI).isGoody() && GC.getImprovementInfo((ImprovementTypes)iI).getTilesPerGoody() > 0)
{
for (int iJ = 0; iJ < iNumPlots; iJ++)
{
gDLL->callUpdater();
CvPlot *pPlot = GC.getMapINLINE().plotByIndexINLINE(piShuffle[iJ]);
FAssertMsg(pPlot, "pPlot is expected not to be NULL");
if (!(pPlot->isWater()))
{
CvArea *pArea = GC.getMapINLINE().getArea(pPlot->getArea());
FAssertMsg(pArea, "pArea is expected not to be NULL");
if (pArea->getNumImprovements((ImprovementTypes)iI) < ((pArea->getNumTiles() + (GC.getImprovementInfo((ImprovementTypes)iI).getTilesPerGoody() / 2)) / GC.getImprovementInfo((ImprovementTypes) iI).getTilesPerGoody()))
{
if (canPlaceGoodyAt(((ImprovementTypes)iI), pPlot->getX_INLINE(), pPlot->getY_INLINE()))
{
pPlot->setImprovementType((ImprovementTypes)iI);
}
}
}
}
}
}
SAFE_DELETE_ARRAY(piShuffle);
}
示例5: PROFILE_FUNC
void CvMapGenerator::addGoodies()
{
PROFILE_FUNC();
if (gDLL->getPythonIFace()->pythonAddGoodies() && !gDLL->getPythonIFace()->pythonUsingDefaultImpl())
{
return; // Python override
}
gDLL->NiTextOut("Adding Goodies...");
if (GC.getEraInfo(GC.getGameINLINE().getStartEra()).isNoGoodies())
{
return;
}
int iNumPlots = GC.getMapINLINE().numPlotsINLINE();
std::vector<int> aiShuffle(iNumPlots);
GC.getGameINLINE().getMapRand().shuffleSequence(aiShuffle, "addNonUniqueBonusType shuffle");
for (int iI = 0; iI < GC.getNumImprovementInfos(); iI++)
{
if (GC.getImprovementInfo((ImprovementTypes)iI).isGoody() && GC.getImprovementInfo((ImprovementTypes)iI).getTilesPerGoody() > 0)
{
for (int iJ = 0; iJ < iNumPlots; iJ++)
{
gDLL->callUpdater();
CvPlot *pPlot = GC.getMapINLINE().plotByIndexINLINE(aiShuffle[iJ]);
FAssertMsg(pPlot, "pPlot is expected not to be NULL");
if (!(pPlot->isWater()))
{
CvArea *pArea = GC.getMapINLINE().getArea(pPlot->getArea());
FAssertMsg(pArea, "pArea is expected not to be NULL");
if (pArea->getNumImprovements((ImprovementTypes)iI) < ((pArea->getNumTiles() + (GC.getImprovementInfo((ImprovementTypes)iI).getTilesPerGoody() / 2)) / GC.getImprovementInfo((ImprovementTypes) iI).getTilesPerGoody()))
{
if (canPlaceGoodyAt(((ImprovementTypes)iI), pPlot->getX_INLINE(), pPlot->getY_INLINE()))
{
pPlot->setImprovementType((ImprovementTypes)iI);
}
}
}
}
}
}
}
示例6: getNumLandAreas
int CvMap::getNumLandAreas()
{
CvArea* pLoopArea;
int iNumLandAreas;
int iLoop;
iNumLandAreas = 0;
for(pLoopArea = GC.getMap().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMap().nextArea(&iLoop))
{
if (!(pLoopArea->isWater()))
{
iNumLandAreas++;
}
}
return iNumLandAreas;
}
示例7: CvAssert
/// Value of this site for a settler
int CvSiteEvaluatorForSettler::PlotFoundValue(CvPlot* pPlot, CvPlayer* pPlayer, YieldTypes eYield, bool bCoastOnly)
{
CvAssert(pPlot);
if(!pPlot) return 0;
if(!CanFound(pPlot, pPlayer, true))
{
return 0;
}
// Is there any reason this site doesn't work for a settler?
//
// First must be on coast if settling a new continent
bool bIsCoastal = pPlot->isCoastalLand(GC.getMIN_WATER_SIZE_FOR_OCEAN());
CvArea* pArea = pPlot->area();
CvAssert(pArea);
if(!pArea) return 0;
int iNumAreaCities = pArea->getCitiesPerPlayer(pPlayer->GetID());
if(bCoastOnly && !bIsCoastal && iNumAreaCities == 0)
{
return 0;
}
// Seems okay for a settler, use base class to determine exact value
else
{
// if the civ gets a benefit from settling on a new continent (ie: Indonesia)
// double the fertility of that plot
int iLuxuryModifier = 0;
if (pPlayer->GetPlayerTraits()->WillGetUniqueLuxury(pArea))
{
iLuxuryModifier = CvCitySiteEvaluator::PlotFoundValue(pPlot, pPlayer, eYield) * 2;
return iLuxuryModifier;
}
else
{
return CvCitySiteEvaluator::PlotFoundValue(pPlot, pPlayer, eYield);
}
}
}
示例8: findBiggestArea
CvArea* CvMap::findBiggestArea(bool bWater)
{
int iBestValue = 0;
CvArea* pBestArea = NULL;
int iLoop;
for (CvArea* pLoopArea = firstArea(&iLoop); pLoopArea != NULL; pLoopArea = nextArea(&iLoop))
{
if (pLoopArea->isWater() == bWater)
{
int iValue = pLoopArea->getNumTiles();
if (iValue > iBestValue)
{
iBestValue = iValue;
pBestArea = pLoopArea;
}
}
}
return pBestArea;
}
示例9: GetID
void CvPlayerAI::AI_updateFoundValues(bool bStartingLoc)
{
int iGoodEnoughToBeWorthOurTime = GC.getAI_STRATEGY_MINIMUM_SETTLE_FERTILITY();
int iLoop;
const int iNumPlots = GC.getMap().numPlots();
for(CvArea* pLoopArea = GC.getMap().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMap().nextArea(&iLoop))
{
pLoopArea->setTotalFoundValue(0);
}
const PlayerTypes eID = GetID();
if(bStartingLoc)
{
for(int iI = 0; iI < iNumPlots; iI++)
{
GC.getMap().plotByIndexUnchecked(iI)->setFoundValue(eID, -1);
}
}
else
{
const TeamTypes eTeam = getTeam();
GC.getGame().GetSettlerSiteEvaluator()->ComputeFlavorMultipliers(this);
for (int iI = 0; iI < iNumPlots; iI++)
{
CvPlot* pLoopPlot = GC.getMap().plotByIndexUnchecked(iI);
if (pLoopPlot->isRevealed(eTeam))
{
const int iValue = GC.getGame().GetSettlerSiteEvaluator()->PlotFoundValue(pLoopPlot, this, NO_YIELD, false);
pLoopPlot->setFoundValue(eID, iValue);
if (iValue >= iGoodEnoughToBeWorthOurTime)
{
CvArea* pLoopArea = GC.getMap().getArea(pLoopPlot->getArea());
if(pLoopArea && !pLoopArea->isWater())
{
pLoopArea->setTotalFoundValue(pLoopArea->getTotalFoundValue() + iValue);
}
}
}
else
{
pLoopPlot->setFoundValue(eID, -1);
}
}
}
}
示例10: GetID
void CvPlayerAI::AI_updateFoundValues(bool bStartingLoc)
{
int iLoop;
const int iNumPlots = GC.getMap().numPlots();
for(CvArea *pLoopArea = GC.getMap().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMap().nextArea(&iLoop))
{
pLoopArea->setTotalFoundValue(0);
}
const PlayerTypes eID = GetID();
if (bStartingLoc)
{
for (int iI = 0; iI < iNumPlots; iI++)
{
GC.getMap().plotByIndexUnchecked(iI)->setFoundValue(eID, -1);
}
}
else
{
const TeamTypes eTeam = getTeam();
for (int iI = 0; iI < iNumPlots; iI++)
{
CvPlot* pLoopPlot = GC.getMap().plotByIndexUnchecked(iI);
if (pLoopPlot->isRevealed(eTeam))
{
const int iValue = AI_foundValue(pLoopPlot->getX(), pLoopPlot->getY());
pLoopPlot->setFoundValue(eID, iValue);
CvArea *pLoopArea = GC.getMap().getArea(pLoopPlot->getArea());
if (pLoopArea && !pLoopArea->isWater())
{
pLoopArea->setTotalFoundValue(pLoopArea->getTotalFoundValue() + iValue);
}
}
else
{
pLoopPlot->setFoundValue(eID, -1);
}
}
}
}
示例11: calculateNumBonusesToAdd
void CvMapGenerator::addUniqueBonusType(BonusTypes eBonusType)
{
int* piAreaTried = new int[GC.getMapINLINE().getNumAreas()];
for (int iI = 0; iI < GC.getMapINLINE().getNumAreas(); iI++)
{
piAreaTried[iI] = FFreeList::INVALID_INDEX;
}
CvBonusInfo& pBonusInfo = GC.getBonusInfo(eBonusType);
int iBonusCount = calculateNumBonusesToAdd(eBonusType);
bool bIgnoreLatitude = false;
gDLL->getPythonIFace()->pythonIsBonusIgnoreLatitudes(&bIgnoreLatitude);
FAssertMsg(pBonusInfo.isOneArea(), "addUniqueBonusType called with non-unique bonus type");
while (true)
{
int iBestValue = 0;
int iLoop = 0;
CvArea *pBestArea = NULL;
CvArea *pLoopArea = NULL;
for(pLoopArea = GC.getMapINLINE().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMapINLINE().nextArea(&iLoop))
{
bool bTried = false;
for (int iI = 0; iI < GC.getMapINLINE().getNumAreas(); iI++)
{
if (pLoopArea->getID() == piAreaTried[iI])
{
bTried = true;
break;
}
}
if (!bTried)
{
int iNumUniqueBonusesOnArea = pLoopArea->countNumUniqueBonusTypes() + 1; // number of unique bonuses starting on the area, plus this one
int iNumTiles = pLoopArea->getNumTiles();
int iValue = iNumTiles / iNumUniqueBonusesOnArea;
if (iValue > iBestValue)
{
iBestValue = iValue;
pBestArea = pLoopArea;
}
}
}
if (pBestArea == NULL)
{
break; // can't place bonus on any area
}
for (int iI = 0; iI < GC.getMapINLINE().getNumAreas(); iI++)
{
if (piAreaTried[iI] == FFreeList::INVALID_INDEX)
{
piAreaTried[iI] = pBestArea->getID();
break;
}
}
// Place the bonuses:
std::vector<int> aiShuffle(GC.getMapINLINE().numPlotsINLINE());
GC.getGameINLINE().getMapRand().shuffleSequence(aiShuffle, "addUniqueBonusType shuffle");
for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
{
CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(aiShuffle[iI]);
FAssertMsg(pPlot != NULL, "addUniqueBonusType(): pPlot is null");
if (GC.getMapINLINE().getNumBonuses(eBonusType) >= iBonusCount)
{
break; // We already have enough
}
if (pBestArea == pPlot->area())
{
if (canPlaceBonusAt(eBonusType, pPlot->getX_INLINE(), pPlot->getY_INLINE(), bIgnoreLatitude))
{
pPlot->setBonusType(eBonusType);
for (int iDX = -(pBonusInfo.getGroupRange()); iDX <= pBonusInfo.getGroupRange(); iDX++)
{
for (int iDY = -(pBonusInfo.getGroupRange()); iDY <= pBonusInfo.getGroupRange(); iDY++)
{
if (GC.getMapINLINE().getNumBonuses(eBonusType) < iBonusCount)
{
CvPlot* pLoopPlot = plotXY(pPlot->getX_INLINE(), pPlot->getY_INLINE(), iDX, iDY);
if (pLoopPlot != NULL && (pLoopPlot->area() == pBestArea))
{
if (canPlaceBonusAt(eBonusType, pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), bIgnoreLatitude))
{
if (GC.getGameINLINE().getMapRandNum(100, "addUniqueBonusType") < pBonusInfo.getGroupRand())
//.........这里部分代码省略.........
示例12: PROFILE_FUNC
bool CvSelectionGroupAI::AI_tradeRoutes()
{
PROFILE_FUNC();
const IDInfo kEurope(getOwnerINLINE(), CvTradeRoute::EUROPE_CITY_ID);
CvCity* pPlotCity = plot()->getPlotCity();
CvPlayerAI& kOwner = GET_PLAYER(getOwnerINLINE());
std::set<int>::iterator it;
std::map<IDInfo, int> cityValues;
std::vector<CvTradeRoute*> routes;
std::vector<int> routeValues;
std::vector<bool> yieldsDelivered(NUM_YIELD_TYPES, false);
std::vector<bool> yieldsToUnload(NUM_YIELD_TYPES, false);
std::vector<int> yieldsOnBoard(NUM_YIELD_TYPES, false);
if (!isHuman() || (getAutomateType() == AUTOMATE_TRANSPORT_FULL))
{
std::vector<CvTradeRoute*> aiRoutes;
kOwner.getTradeRoutes(aiRoutes);
for (uint i = 0; i < aiRoutes.size(); ++i)
{
CvTradeRoute* pRoute = aiRoutes[i];
// transport feeder - start - Nightinggale
CvCity* pDestinationCity = ::getCity(pRoute->getDestinationCity());
if (pDestinationCity != NULL && pDestinationCity->isAutoImportStopped(pRoute->getYield()))
{
// ignore trade routes where destination is using feeder service and is full
continue;
}
// transport feeder - end - Nightinggale
// traderoute fix - start - Nightinggale
if (isHuman() && pRoute->getDestinationCity().eOwner != getOwnerINLINE())
{
// humans can't transport to allied cities with fully automated transports
continue;
}
// traderoute fix - end - Nightinggale
CvCity* pSourceCity = ::getCity(pRoute->getSourceCity());
CvArea* pSourceWaterArea = pSourceCity->waterArea();
if ((pSourceCity != NULL) && ((getDomainType() != DOMAIN_SEA) || (pSourceWaterArea != NULL)))
{
int iSourceArea = (getDomainType() == DOMAIN_SEA) ? pSourceWaterArea->getID() : pSourceCity->getArea();
if (getDomainType() == DOMAIN_SEA ? plot()->isAdjacentToArea(iSourceArea) : (iSourceArea == getArea()))
{
if ((getDomainType() == DOMAIN_SEA) || (pRoute->getDestinationCity() != kEurope))
{
routes.push_back(pRoute);
routeValues.push_back(0);
yieldsDelivered[pRoute->getYield()] = true;
if (pPlotCity != NULL && ::getCity(pRoute->getDestinationCity()) == pPlotCity)
{
yieldsToUnload[pRoute->getYield()] = true;
}
cityValues[pRoute->getSourceCity()] = 0;
cityValues[pRoute->getDestinationCity()] = 0;
}
}
}
}
}
else
{
for (it = m_aTradeRoutes.begin(); it != m_aTradeRoutes.end(); ++it)
{
CvTradeRoute* pRoute = kOwner.getTradeRoute(*it);
CvCity* pSourceCity = ::getCity(pRoute->getSourceCity());
if (pSourceCity != NULL)
{
CvArea* pSourceWaterArea = pSourceCity->waterArea();
if (getDomainType() != DOMAIN_SEA || pSourceWaterArea != NULL)
{
int iSourceArea = (getDomainType() == DOMAIN_SEA) ? pSourceWaterArea->getID() : pSourceCity->getArea();
if (getDomainType() == DOMAIN_SEA ? plot()->isAdjacentToArea(iSourceArea) : (iSourceArea == getArea()))
{
if ((getDomainType() == DOMAIN_SEA) || (pRoute->getDestinationCity() != kEurope))
{
routes.push_back(pRoute);
routeValues.push_back(0);
yieldsDelivered[pRoute->getYield()] = true;
if (pPlotCity != NULL && ::getCity(pRoute->getDestinationCity()) == pPlotCity)
{
yieldsToUnload[pRoute->getYield()] = true;
}
cityValues[pRoute->getSourceCity()] = 0;
cityValues[pRoute->getDestinationCity()] = 0;
//.........这里部分代码省略.........
示例13: CvAssert
//.........这里部分代码省略.........
// Finally, look at the city plot itself
if (pPlot->getResourceType(eTeam) != NO_RESOURCE)
{
iValueModifier += (int)iTotalPlotValue * /*-50*/ GC.getBUILD_ON_RESOURCE_PERCENT() / 100;
vQualifiersNegative.push_back("(V) city on resource");
}
if (pPlot->IsNaturalWonder())
{
iValueModifier += (int)iTotalPlotValue * /*-50*/ GC.getBUILD_ON_RESOURCE_PERCENT() / 100;
vQualifiersNegative.push_back("(V) city on natural wonder");
}
if ( iTotalFoodValue>5*iTotalProductionValue || iTotalProductionValue > 2*iTotalFoodValue )
{
iValueModifier -= (int)iTotalPlotValue * 10 / 100;
vQualifiersNegative.push_back("(V) unbalanced yields");
}
if (pPlot->isRiver())
{
iValueModifier += (int)iTotalPlotValue * /*15*/ GC.getBUILD_ON_RIVER_PERCENT() / 100;
if(pPlayer && pPlayer->GetPlayerTraits()->IsRiverTradeRoad())
iValueModifier += (int)iTotalPlotValue * /*15*/ GC.getBUILD_ON_RIVER_PERCENT() / 100 * 2;
vQualifiersPositive.push_back("(V) river");
}
if (bIsAlmostCoast)
{
iValueModifier -= (iTotalPlotValue * 25) / 100;
vQualifiersNegative.push_back("(V) almost coast");
}
CvArea* pArea = pPlot->area();
int iGoodTiles = 1;
if(pArea != NULL)
{
iGoodTiles = max(1,(pArea->getNumUnownedTiles() - pArea->GetNumBadPlots()));
}
//Island maps need a little more loose restriction here.
if(GC.getMap().GetAIMapHint() & ciMapHint_NavalOffshore)
{
if (pPlot->isCoastalLand(GC.getMIN_WATER_SIZE_FOR_OCEAN()))
{
if(pArea != NULL && iGoodTiles > 0)
{
iValueModifier += (iTotalPlotValue * /*40*/ GC.getSETTLER_BUILD_ON_COAST_PERCENT()) / 100;
vQualifiersPositive.push_back("(V) coast");
if (pPlayer)
{
int iNavalFlavor = pPlayer->GetGrandStrategyAI()->GetPersonalityAndGrandStrategy((FlavorTypes)m_iNavalIndex);
if (iNavalFlavor > 7)
{
iValueModifier += (iTotalPlotValue * /*40*/ GC.getSETTLER_BUILD_ON_COAST_PERCENT()) / 100;
}
if (pPlayer->getCivilizationInfo().isCoastalCiv()) // we really like the coast (England, Norway, Polynesia, Carthage, etc.)
{
iValueModifier += iTotalPlotValue;
}
}
}
}
else
{