cleanup: refactor smoothTerrain() to make it side-effect free
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@538 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
567adeee43
commit
50a7cf4770
1 changed files with 5 additions and 3 deletions
|
@ -1155,7 +1155,7 @@ public class Micropolis
|
||||||
|
|
||||||
pollutionAverage = pcount != 0 ? (ptotal / pcount) : 0;
|
pollutionAverage = pcount != 0 ? (ptotal / pcount) : 0;
|
||||||
|
|
||||||
smoothTerrain(qtem);
|
terrainMem = smoothTerrain(qtem);
|
||||||
|
|
||||||
fireMapOverlayDataChanged(MapState.POLLUTE_OVERLAY); //PLMAP
|
fireMapOverlayDataChanged(MapState.POLLUTE_OVERLAY); //PLMAP
|
||||||
fireMapOverlayDataChanged(MapState.LANDVALUE_OVERLAY); //LVMAP
|
fireMapOverlayDataChanged(MapState.LANDVALUE_OVERLAY); //LVMAP
|
||||||
|
@ -1347,11 +1347,12 @@ public class Micropolis
|
||||||
fireDemandChanged();
|
fireDemandChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void smoothTerrain(int [][] qtem)
|
int [][] smoothTerrain(int [][] qtem)
|
||||||
{
|
{
|
||||||
final int QWX = qtem[0].length;
|
final int QWX = qtem[0].length;
|
||||||
final int QWY = qtem.length;
|
final int QWY = qtem.length;
|
||||||
|
|
||||||
|
int [][] mem = new int[QWY][QWX];
|
||||||
for (int y = 0; y < QWY; y++)
|
for (int y = 0; y < QWY; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < QWX; x++)
|
for (int x = 0; x < QWX; x++)
|
||||||
|
@ -1365,9 +1366,10 @@ public class Micropolis
|
||||||
z += qtem[y-1][x];
|
z += qtem[y-1][x];
|
||||||
if (y+1 < QWY)
|
if (y+1 < QWY)
|
||||||
z += qtem[y+1][x];
|
z += qtem[y+1][x];
|
||||||
terrainMem[y][x] = z / 4 + qtem[y][x] / 2;
|
mem[y][x] = z / 4 + qtem[y][x] / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate manhatten distance (in 2-units) from center of city
|
// calculate manhatten distance (in 2-units) from center of city
|
||||||
|
|
Reference in a new issue