107 (tile < CHURCH1BASE)) {
113 if (tile < HOSPITAL) {
119 if ((tile < COMBASE) ||
120 ((tile >= CHURCH1BASE) &&
121 (tile <= CHURCH7LAST))) {
133 if (tile < CHURCH1BASE) {
138 printf(
"UNEXPOECTED ZONE: %d !!!\n", tile);
149 if (tile == HOSPITAL) {
163 }
else if ((tile == CHURCH0) ||
176 bool simulate =
true;
192 int churchNumber = 0;
224 callback->simulateChurch(
this, callbackVal, pos.
posX, pos.
posY, churchNumber);
232 #define ASCBIT (ANIMBIT | CONDBIT | BURNBIT)
233 #define REGBIT (CONDBIT | BURNBIT)
237 static bool aniThis[8] = {
true,
false,
true,
true,
false,
false,
true,
true };
238 static short dx1[8] = { -1, 0, 1, 0, 0, 0, 0, 1 };
239 static short dy1[8] = { -1, 0, -1, -1, 0, 0, -1, -1 };
240 static short aniTabA[8] = { 0, 0, 32, 40, 0, 0, 48, 56 };
241 static short aniTabB[8] = { 0, 0, 36, 44, 0, 0, 52, 60 };
242 static short aniTabC[8] = {
IND1, 0, IND2, IND4, 0, 0, IND6, IND8 };
243 static short aniTabD[8] = {
IND1, 0, IND3, IND5, 0, 0, IND7, IND9 };
251 int z = (tile -
IZB) >>3;
255 int xx = pos.
posX + dx1[z];
256 int yy = pos.
posY + dy1[z];
264 if ((
map[xx][yy] &
LOMASK) == aniTabC[z]) {
265 map[xx][yy] = ASCBIT | (SMOKEBASE + aniTabA[z]);
266 map[xx][yy] = ASCBIT | (SMOKEBASE + aniTabB[z]);
272 if ((
map[xx][yy] &
LOMASK) > aniTabC[z]) {
273 map[xx][yy] = REGBIT | aniTabC[z];
274 map[xx][yy] = REGBIT | aniTabD[z];
301 if (churchType == 0) {
304 tile = CHURCH1 + ((churchType - 1) * 9);
353 value =
clamp(value + amount * 4, -200, 200);
367 static const short Zx[9] = {-1, 0, 1,-1, 0, 1,-1, 0, 1};
368 static const short Zy[9] = {-1,-1,-1, 0, 0, 0, 1, 1, 1};
370 for (z = 0; z < 9; z++) {
371 int xx = pos.
posX + Zx[z];
372 int yy = pos.
posY + Zy[z];
377 if ((x >= FLOOD) && (x < ROADBASE)) {
385 for (z = 0; z < 9; z++) {
386 int xx = pos.
posX + Zx[z];
387 int yy = pos.
posY + Zy[z];
390 map[xx][yy] = base + BNCNBIT;
411 for (
short x = pos.
posX - 1; x <= pos.
posX + 1; x++) {
412 for (
short y = pos.
posY - 1; y <= pos.
posY + 1; y++) {
413 if (x >= 0 && x < WORLD_W && y >= 0 && y <
WORLD_H) {
415 if (tile >= LHTHR && tile <= HHTHR) {
459 short z, score, hscore, BestLoc;
460 static short ZeX[9] = { 0,-1, 0, 1,-1, 1,-1, 0, 1};
461 static short ZeY[9] = { 0,-1,-1,-1, 0, 0, 1, 1, 1};
466 for (z = 1; z < 9; z++) {
467 int xx = pos.
posX + ZeX[z];
468 int yy = pos.
posY + ZeY[z];
477 if (score > hscore) {
496 int xx = pos.
posX + ZeX[BestLoc];
497 int yy = pos.
posY + ZeY[BestLoc];
501 map[xx][yy] = HOUSE + BLBNCNBIT +
getRandom(2) + value * 3;
515 static short DX[4] = { 0, 1, 0,-1};
516 static short DY[4] = {-1, 0, 1, 0};
521 if (z && (z < RESBASE || z > RESBASE + 8)) {
527 for (z = 0; z < 4; z++) {
548 short tpop, zscore, locvalve, value, TrfGood;
577 locvalve =
evalRes(pos, TrfGood);
578 zscore = resValve + locvalve;
616 if (pollution > 128) {
640 resPlop(pos, (pop / 8) - 1, value);
655 static short Brdr[9] = {0,3,6,1,4,7,2,5,8};
663 resPlop(pos, (pop - 24) / 8, value);
671 for (x = pos.
posX - 1; x <= pos.
posX + 1; x++) {
672 for (y = pos.
posY - 1; y <= pos.
posY + 1; y++) {
685 for (x = pos.
posX - 1; x <= pos.
posX + 1; x++) {
686 for (y = pos.
posY - 1; y <= pos.
posY + 1; y++) {
689 if ((loc >= LHTHR) && (loc <= HHTHR)) {
690 map[x][y] = Brdr[z] + BLBNCNBIT + FREEZ - 4;
711 short CzDen = ((mapTile - RZB) / 9) % 4;
713 return CzDen * 8 + 16;
726 base = ((value * 4 + den) * 9) + RZB - 4;
748 value =
min(value * 32, 6000);
751 value = value - 3000;
766 short zscore, locvalve, value;
789 locvalve =
evalCom(pos, TrfGood);
790 zscore = comValve + locvalve;
804 if ((zscore < 350) &&
866 if (tile == COMCLR) {
870 short CzDen = ((tile - CZB) / 9) % 5 + 1;
885 base = ((Value * 5) + Den) * 9 + CZB - 4;
917 short tpop, zscore, TrfGood;
939 zscore = indValve +
evalInd(TrfGood);
1005 short CzDen = (((tile -
IZB) / 9) % 4) + 1;
1017 short base = ((value * 4) + den) * 9 +
IND1;
DATA worldGet(int x, int y) const
void worldSet(int x, int y, DATA val)
short getLandPollutionValue(const Position &pos)
short getResZonePop(MapTile mapTile)
short doFreePop(const Position &pos)
short indZonePop
Number of industrial zones.
void makeHospital(const Position &pos)
void resPlop(const Position &pos, int Den, int Value)
void doZone(const Position &pos)
void buildHouse(const Position &pos, int value)
short getIndZonePop(MapTile tile)
void doResidential(const Position &pos, bool zonePower)
short poweredZoneCount
Number of powered tiles in all zone.
void doSpecialZone(const Position &pos, bool PwrOn)
void indPlop(const Position &pos, int den, int value)
short unpoweredZoneCount
Number of unpowered tiles in all zones.
bool setZonePower(const Position &pos)
void comPlop(const Position &pos, int Den, int Value)
short churchPop
Number of churches.
short makeTraffic(int x, int y, ZoneType dest)
short evalCom(const Position &pos, int traf)
short getRandom(short range)
void doIndustrial(const Position &pos, bool zonePower)
void setSmoke(const Position &pos, bool zonePower)
bool zonePlop(const Position &pos, int base)
short resZonePop
Number of residential zones.
short evalRes(const Position &pos, int traf)
void doIndIn(const Position &pos, int pop, int value)
void doIndOut(const Position &pos, int pop, int value)
void repairZone(const Position &pos, MapTile zCent, short zSize)
void doResOut(const Position &pos, int pop, int value)
void doComOut(const Position &pos, int pop, int value)
short getComZonePop(MapTile tile)
unsigned short * map[WORLD_W]
short hospitalPop
Number of hospitals.
void doResIn(const Position &pos, int pop, int value)
void doHospitalChurch(const Position &pos)
MapByte2 pollutionDensityMap
Pollution density map.
static bool testBounds(int wx, int wy)
short evalLot(int x, int y)
MapByte2 populationDensityMap
Population density map.
void incRateOfGrowth(const Position &pos, int amount)
void doCommercial(const Position &pos, bool zonePower)
MapByte2 landValueMap
Land value map.
MapShort8 rateOfGrowthMap
short comZonePop
Number of commercial zones.
void doComIn(const Position &pos, int pop, int value)
int posY
Vertical coordnate of the position.
int posX
Horizontal coordinate of the position.
Header file for Micropolis game engine.
@ ZT_RESIDENTIAL
Residential zone.
@ ZT_COMMERCIAL
Commercial zone.
@ ZT_INDUSTRIAL
Industrial zone.
@ NUCLEAR
'Center' tile nuclear power plant.
@ PORTBASE
Top-left tile of the seaport.
@ IZB
Center tile of first non-empty industry zone.
@ POWERPLANT
'Center' tile of coal power plant.
@ INDCLR
Center tile of empty industrial zone.
@ INDBASE
Top-left tile of empty industrial zone.
@ IND1
Top-left tile of first non-empty industry zone.
static T min(const T a, const T b)
static T clamp(const T val, const T lower, const T upper)