Bazaar developer reference

CvMap::calculateAreas()

Defined in
CvMap.cpp, line 1491
Class
CvMap
Hook name
CivHooks::CvMap_calculateAreas

Hooks

static bool BeforeCvMap_calculateAreas(CvMap* self);static void AfterCvMap_calculateAreas(CvMap* self);static void ReplaceCvMap_calculateAreas(void (*original)(CvMap*), CvMap* self);CivRegisterBefore<CivHooks::CvMap_calculateAreas>(host, &BeforeCvMap_calculateAreas);CivRegisterAfter<CivHooks::CvMap_calculateAreas>(host, &AfterCvMap_calculateAreas);CivRegisterReplace<CivHooks::CvMap_calculateAreas>(host, &ReplaceCvMap_calculateAreas);

Code

1491void CvMap::calculateAreas()1492{1493	CvPlot* pLoopPlot;1494	CvArea* pArea;1495	int iArea;1496	int iI;14971498	for(iI = 0; iI < numPlots(); iI++)1499	{1500		pLoopPlot = plotByIndexUnchecked(iI);1501		CvAssertMsg(pLoopPlot != NULL, "LoopPlot is not assigned a valid value");15021503		if(!pLoopPlot) continue;15041505		if(pLoopPlot->getArea() == FFreeList::INVALID_INDEX)1506		{1507			pArea = addArea();1508			pArea->init(pArea->GetID(), pLoopPlot->isWater());15091510			pArea->SetMountains(pLoopPlot->isMountain());15111512			iArea = pArea->GetID();15131514			pLoopPlot->setArea(iArea);15151516			GC.getAreaFinder().GeneratePath(pLoopPlot->getX(), pLoopPlot->getY(), -1, -1, iArea);15171518			CvAreaBoundaries boundaries;1519			boundaries.m_iEastEdge = pLoopPlot->getX();1520			boundaries.m_iWestEdge = pLoopPlot->getX();1521			boundaries.m_iNorthEdge = pLoopPlot->getY();1522			boundaries.m_iSouthEdge = pLoopPlot->getY();1523			pArea->setAreaBoundaries(boundaries);1524		}15251526		// Update area boundaries if they've grown1527		else1528		{1529			int iX, iY;1530			CvAreaBoundaries boundaries = getArea(pLoopPlot->getArea())->getAreaBoundaries();1531			iX = pLoopPlot->getX();1532			iY = pLoopPlot->getY();15331534			if(iX < boundaries.m_iWestEdge)1535			{1536				boundaries.m_iWestEdge = iX;1537			}1538			else if(iX > boundaries.m_iEastEdge)1539			{1540				boundaries.m_iEastEdge = iX;1541			}1542			else if(iY < boundaries.m_iSouthEdge)1543			{1544				boundaries.m_iSouthEdge = iY;1545			}1546			else if(iY > boundaries.m_iNorthEdge)1547			{1548				boundaries.m_iNorthEdge = iY;1549			}1550			getArea(pLoopPlot->getArea())->setAreaBoundaries(boundaries);1551		}1552	}1553}

Calls

Called by