Code
258void CvMap::InitPlots()259{260 m_pMapPlots = FNEW(CvPlot[numPlots()], c_eCiv5GameplayDLL, 0);261 //allocate all the memory we need up front262263 int iNumPlots = numPlots();264265 m_pYields = FNEW(short[NUM_YIELD_TYPES*iNumPlots], c_eCiv5GameplayDLL, 0);266 m_pFoundValue = FNEW(int[REALLY_MAX_PLAYERS*iNumPlots], c_eCiv5GameplayDLL, 0);267 m_pPlayerCityRadiusCount = FNEW(char[REALLY_MAX_PLAYERS*iNumPlots], c_eCiv5GameplayDLL, 0);268 m_pVisibilityCount = FNEW(short[REALLY_MAX_TEAMS*iNumPlots], c_eCiv5GameplayDLL, 0);269 m_pRevealedOwner = FNEW(char[REALLY_MAX_TEAMS*iNumPlots], c_eCiv5GameplayDLL, 0);270 m_pRevealed = FNEW(bool[REALLY_MAX_TEAMS*iNumPlots], c_eCiv5GameplayDLL, 0);271 m_pRevealedImprovementType = FNEW(short[REALLY_MAX_TEAMS*iNumPlots], c_eCiv5GameplayDLL, 0);272 m_pRevealedRouteType = FNEW(short[REALLY_MAX_TEAMS*iNumPlots], c_eCiv5GameplayDLL, 0);273 m_pNoSettling = FNEW(bool[MAX_MAJOR_CIVS*iNumPlots], c_eCiv5GameplayDLL, 0);274 m_pResourceForceReveal = FNEW(bool[REALLY_MAX_TEAMS*iNumPlots], c_eCiv5GameplayDLL, 0);275276 memset(m_pYields, 0, NUM_YIELD_TYPES*iNumPlots*sizeof(short));277 memset(m_pFoundValue, 0, REALLY_MAX_PLAYERS*iNumPlots*sizeof(int));278 memset(m_pPlayerCityRadiusCount, 0, REALLY_MAX_PLAYERS*iNumPlots*sizeof(char));279 memset(m_pVisibilityCount, 0,REALLY_MAX_TEAMS*iNumPlots *sizeof(short));280 memset(m_pRevealedOwner, -1 ,REALLY_MAX_TEAMS*iNumPlots *sizeof(char));281 memset(m_pRevealed, 0,REALLY_MAX_TEAMS*iNumPlots *sizeof(bool));282 memset(m_pRevealedImprovementType, 0,REALLY_MAX_TEAMS*iNumPlots *sizeof(short));283 memset(m_pRevealedRouteType, 0,REALLY_MAX_TEAMS*iNumPlots *sizeof(short));284 memset(m_pNoSettling, 0,MAX_MAJOR_CIVS*iNumPlots *sizeof(bool));285 memset(m_pResourceForceReveal, 0,REALLY_MAX_TEAMS*iNumPlots *sizeof(bool));286287288 short* pYields = m_pYields;289 int* pFoundValue = m_pFoundValue;290 char* pPlayerCityRadiusCount = m_pPlayerCityRadiusCount;291 short* pVisibilityCount = m_pVisibilityCount;292 char* pRevealedOwner = m_pRevealedOwner;293 short* pRevealedImprovementType = m_pRevealedImprovementType;294 short* pRevealedRouteType = m_pRevealedRouteType;295 bool* pNoSettling = m_pNoSettling;296 bool* pResourceForceReveal = m_pResourceForceReveal;297298 for(int i = 0; i < iNumPlots; i++)299 {300 m_pMapPlots[i].m_aiYield = pYields;301 m_pMapPlots[i].m_aiFoundValue = pFoundValue;302 m_pMapPlots[i].m_aiPlayerCityRadiusCount= pPlayerCityRadiusCount;303 m_pMapPlots[i].m_aiVisibilityCount = pVisibilityCount;304 m_pMapPlots[i].m_aiRevealedOwner = pRevealedOwner;305306 m_pMapPlots[i].m_aeRevealedImprovementType = pRevealedImprovementType;307 m_pMapPlots[i].m_aeRevealedRouteType = pRevealedRouteType;308 m_pMapPlots[i].m_abNoSettling = pNoSettling;309310 m_pMapPlots[i].m_abResourceForceReveal = pResourceForceReveal;311312313 pYields += NUM_YIELD_TYPES;314 pFoundValue += REALLY_MAX_PLAYERS;315 pPlayerCityRadiusCount += REALLY_MAX_PLAYERS;316 pVisibilityCount += REALLY_MAX_TEAMS;317 pRevealedOwner += REALLY_MAX_TEAMS;318 pRevealedImprovementType+= REALLY_MAX_TEAMS;319 pRevealedRouteType += REALLY_MAX_TEAMS;320 pNoSettling += MAX_MAJOR_CIVS;321 pResourceForceReveal += REALLY_MAX_TEAMS;322323 }324325 m_kPlotManager.Init(getGridWidth(), getGridHeight());326}