Bazaar developer reference

CvWorldBuilderMapLoader::ValidateTerrain()

Defined in
CvWorldBuilderMapLoader.cpp, line 1708
Class
CvWorldBuilderMapLoader
Hook name
CivHooks::CvWorldBuilderMapLoader_ValidateTerrain

Hooks

static bool BeforeCvWorldBuilderMapLoader_ValidateTerrain();static void AfterCvWorldBuilderMapLoader_ValidateTerrain();static void ReplaceCvWorldBuilderMapLoader_ValidateTerrain(void (*original)());CivRegisterBefore<CivHooks::CvWorldBuilderMapLoader_ValidateTerrain>(host, &BeforeCvWorldBuilderMapLoader_ValidateTerrain);CivRegisterAfter<CivHooks::CvWorldBuilderMapLoader_ValidateTerrain>(host, &AfterCvWorldBuilderMapLoader_ValidateTerrain);CivRegisterReplace<CivHooks::CvWorldBuilderMapLoader_ValidateTerrain>(host, &ReplaceCvWorldBuilderMapLoader_ValidateTerrain);

Code

1708void CvWorldBuilderMapLoader::ValidateTerrain()1709{1710	CvMap& kMap = GC.getMap();17111712	TerrainTypes eValidTerrain = NO_TERRAIN;1713	const int iNumTerrainTypes = GC.getNumTerrainInfos();1714	for(int i = 0; i < iNumTerrainTypes; ++i)1715	{1716		const TerrainTypes eTerrain = (TerrainTypes)i;1717		const CvTerrainInfo* pkTerrain = GC.getTerrainInfo(eTerrain);1718		if(pkTerrain != NULL)1719		{1720			eValidTerrain = eTerrain;1721			break;1722		}1723	}17241725	FAssertMsg(eValidTerrain != NO_TERRAIN, "Could not find ANY valid terrain types!");17261727	const int iPlotCount = kMap.getGridWidth() * kMap.getGridHeight();1728	for(int i = 0; i < iPlotCount; ++i)1729	{1730		CvPlot* pkPlot = kMap.plotByIndex(i);1731		if(pkPlot != NULL)1732		{1733			const TerrainTypes eTerrainType = pkPlot->getTerrainType();1734			if(eTerrainType < 0 || eTerrainType >= iNumTerrainTypes)1735			{1736				pkPlot->setTerrainType(eValidTerrain);1737			}1738			else1739			{1740				const CvTerrainInfo* pkTerrain = GC.getTerrainInfo(eTerrainType);1741				if(pkTerrain == NULL)1742					pkPlot->setTerrainType(eValidTerrain);1743			}1744		}1745	}1746}

Calls

Called by