hachejay
beta shopper
hello! I've been playing around with making terrain change every few turns to simulate seasonal changes. This is the main chunk of code that I have so far: (from CvGame.cpp)
The dll compiles with one warning:
The game runs ok but the code appears to do nothing.
Would anyone with slightly better programming knowledge mind having a quick look at this and seeing if I've done anything obviously wrong?
Cheers!
hache
Code:
void CvGame::updateSeasonState()
{
int iSeasonClock; //timer
int iX, iY; //coordinates
CvPlot* pPlot; //plot
TerrainTypes eSpringGrass = ((TerrainTypes)(GC.getDefineINT("TERRAIN_SPRING_GRASS"))); //terrain defines for XML import (CvXMLLoadUtilitySet.cpp)
TerrainTypes eSummerGrass = ((TerrainTypes)(GC.getDefineINT("TERRAIN_SUMMER_GRASS")));
TerrainTypes eAutumnGrass = ((TerrainTypes)(GC.getDefineINT("TERRAIN_AUTUMN_GRASS")));
TerrainTypes eWinterGrass = ((TerrainTypes)(GC.getDefineINT("TERRAIN_WINTER_GRASS")));
if (iSeasonClock < 12) //move the timer on 1
{
iSeasonClock++;
}
if (iSeasonClock == 3) //set spring terrain on 3rd turn of timer
{
for(iX = 0; iX < GC.getMapINLINE().getGridWidthINLINE(); iX++)
{
for(iY = 0; iY < GC.getMapINLINE().getGridHeightINLINE(); iY++)
{
pPlot = GC.getMapINLINE().plotINLINE(iX, iY);
{
if (pPlot->getTerrainType() == eWinterGrass)
{
pPlot->setTerrainType(eSpringGrass);
}
}
}
}
}
if (iSeasonClock == 6) //set summer terrain on 6th turn of timer
{
for(iX = 0; iX < GC.getMapINLINE().getGridWidthINLINE(); iX++)
{
for(iY = 0; iY < GC.getMapINLINE().getGridHeightINLINE(); iY++)
{
pPlot = GC.getMapINLINE().plotINLINE(iX, iY);
{
if (pPlot->getTerrainType() == eSpringGrass)
{
pPlot->setTerrainType(eSummerGrass);
}
}
}
}
}
if (iSeasonClock == 9) //set autumn terrain on 9th turn of timer
{
for(iX = 0; iX < GC.getMapINLINE().getGridWidthINLINE(); iX++)
{
for(iY = 0; iY < GC.getMapINLINE().getGridHeightINLINE(); iY++)
{
pPlot = GC.getMapINLINE().plotINLINE(iX, iY);
{
if (pPlot->getTerrainType() == eSummerGrass)
{
pPlot->setTerrainType(eAutumnGrass);
}
}
}
}
}
if (iSeasonClock == 12) //set winter terrain on 12th turn of timer
{
for(iX = 0; iX < GC.getMapINLINE().getGridWidthINLINE(); iX++)
{
for(iY = 0; iY < GC.getMapINLINE().getGridHeightINLINE(); iY++)
{
pPlot = GC.getMapINLINE().plotINLINE(iX, iY);
{
if (pPlot->getTerrainType() == eAutumnGrass)
{
pPlot->setTerrainType(eWinterGrass);
}
}
}
}
iSeasonClock = 0; //reset timer to start
}
}
The dll compiles with one warning:
Code:
...makefile\cvgamecoredll\cvgame.cpp(6638): warning C4700: local variable 'iSeasonClock' used without having been initialized
The game runs ok but the code appears to do nothing.
Would anyone with slightly better programming knowledge mind having a quick look at this and seeing if I've done anything obviously wrong?
Cheers!
hache