95 for (x = 0; x < tempMap.
MAP_W; x++) {
96 for (y = 0; y < tempMap.
MAP_H; y++) {
99 edge += tempMap.
get(x - 1, y);
101 if (x < tempMap.
MAP_W - 1) {
102 edge += tempMap.
get(x + 1, y);
105 edge += tempMap.
get(x, y - 1);
107 if (y < tempMap.
MAP_H - 1) {
108 edge += tempMap.
get(x, y + 1);
110 edge = tempMap.
get(x, y) + edge / 4;
111 map->
set(x, y, edge / 2);
143 for (
int x = 0; x <
WORLD_W; x++) {
144 for (
int y = 0; y <
WORLD_H; y++) {
170 destMap[i] = srcMap[i] * 2;
207 if (tile < COMBASE) {
227 void Micropolis::pollutionTerrainLandValueScan()
232 int pollutionLevel, loc, worldX, worldY, Mx, My, pnum, LVnum, pmax;
243 bool landValueFlag =
false;
247 for (Mx = worldX; Mx <= worldX + 1; Mx++) {
248 for (My = worldY; My <= worldY + 1; My++) {
258 if (loc >= ROADBASE) {
259 landValueFlag =
true;
271 pollutionLevel =
min(pollutionLevel, 255);
282 dis =
clamp(dis, 1, 250);
314 if (z > pmax || (z == pmax && (
getRandom16() & 3) == 0)) {
343 if (loc < POWERBASE) {
353 if (loc < ROADBASE) {
355 if (loc > FIREBASE) {
408 return min(xDis + yDis, 64);
432 z =
clamp(z, 0, 250);
437 if (z > cmax || (z == cmax && (
getRandom16() & 3) == 0)) {
464 void Micropolis::smoothTerrain()
467 int x, y = 0, dir = 1;
478 Byte val = (Byte)(z / 8);
521 int x, y = 0, z = 0, dir = 1;
523 for (x = 0; x < srcMap.
MAP_W; x++) {
524 for (; y != srcMap.
MAP_H && y != -1; y += dir) {
526 srcMap.
get((x == 0) ? x : (x - 1), y) +
527 srcMap.
get((x == srcMap.
MAP_W - 1) ? x : (x + 1), y) +
528 srcMap.
get(x, (y == 0) ? (0) : (y - 1)) +
529 srcMap.
get(x, (y == (srcMap.
MAP_H - 1)) ? y : (y + 1)) +
531 Byte val = (Byte)(z / 4);
532 destMap->
set(x, y, val);
541 for (x = 0; x < srcMap.
MAP_W; x++) {
542 for (y = 0; y < srcMap.
MAP_H; y++) {
545 z += srcMap.
get(x - 1, y);
547 if (x < srcMap.
MAP_W - 1) {
548 z += srcMap.
get(x + 1, y);
551 z += srcMap.
get(x, y - 1);
553 if (y < (srcMap.
MAP_H - 1)) {
554 z += srcMap.
get(x, y + 1);
556 z = (z + srcMap.
get(x, y)) >>2;
560 destMap->
set(x, y, (Byte)z);
568 void Micropolis::doSmooth1()
575 void Micropolis::doSmooth2()
DATA worldGet(int x, int y) const
void set(int x, int y, DATA val)
const int MAP_W
Number of clusters in horizontal direction.
const int MAP_H
Number of clusters in vertical direction.
DATA get(int x, int y) const
void worldSet(int x, int y, DATA val)
short crimeMaxX
X coordinate of most criminal area. Not used.
MapShort8 policeStationEffectMap
short getResZonePop(MapTile mapTile)
short doFreePop(const Position &pos)
short getIndZonePop(MapTile tile)
MapByte2 crimeRateMap
Crime rate map.
MapByte4 terrainDensityMap
short newMapFlags[MAP_TYPE_COUNT]
short cityCenterY
Y coordinate of city center.
MapShort8 fireStationEffectMap
short pollutionMaxY
Y coordinate of most polluted area.
short pollutionMaxX
X coordinate of most polluted area.
int getPollutionValue(int loc)
short getComZonePop(MapTile tile)
short cityCenterX
X coordinate of city center.
unsigned short * map[WORLD_W]
MapShort8 policeStationMap
MapByte2 pollutionDensityMap
Pollution density map.
int getCityCenterDistance(int x, int y)
int getPopulationDensity(const Position &pos, MapTile tile)
MapByte2 populationDensityMap
Population density map.
MapByte2 landValueMap
Land value map.
short crimeMaxY
Y coordinate of most criminal area. Not used.
void populationDensityScan()
Header file for Micropolis game engine.
@ MAP_TYPE_POLLUTION
Pollution.
@ MAP_TYPE_POPULATION_DENSITY
Population density.
@ MAP_TYPE_DYNAMIC
Dynamic filter.
@ MAP_TYPE_LAND_VALUE
Land value.
@ MAP_TYPE_FIRE_RADIUS
Fire station coverage radius.
@ MAP_TYPE_CRIME
Crime rate.
@ MAP_TYPE_RATE_OF_GROWTH
Rate of growth.
@ MAP_TYPE_POLICE_RADIUS
Police station coverage radius.
@ LASTPOWERPLANT
Last tile of coal power plant.
@ HTRFBASE
First tile with high traffic.
@ PORTBASE
Top-left tile of the seaport.
@ RADTILE
Radio-active contaminated tile.
@ LTRFBASE
First tile with low traffic.
@ INDBASE
Top-left tile of empty industrial zone.
@ LASTIND
Last tile of empty industrial zone.
static T min(const T a, const T b)
static T clamp(const T val, const T lower, const T upper)
static void smoothStationMap(MapShort8 *map)
static void smoothDitherMap(const MapByte2 &srcMap, MapByte2 *destMap, bool ditherFlag)