109 (tile < CHURCH1BASE)) {
115 if (tile < HOSPITAL) {
121 if ((tile < COMBASE) ||
122 ((tile >= CHURCH1BASE) &&
123 (tile <= CHURCH7LAST))) {
135 if (tile < CHURCH1BASE) {
140 printf(
"UNEXPECTED ZONE: %d !!!\n", tile);
151 if (tile == HOSPITAL) {
165 }
else if ((tile == CHURCH0) ||
178 bool simulate =
true;
194 int churchNumber = 0;
226 callback->simulateChurch(
this, callbackVal, pos.
posX, pos.
posY, churchNumber);
234#define ASCBIT (ANIMBIT | CONDBIT | BURNBIT)
235#define REGBIT (CONDBIT | BURNBIT)
239 static bool aniThis[8] = {
true,
false,
true,
true,
false,
false,
true,
true };
240 static short dx1[8] = { -1, 0, 1, 0, 0, 0, 0, 1 };
241 static short dy1[8] = { -1, 0, -1, -1, 0, 0, -1, -1 };
242 static short aniTabA[8] = { 0, 0, 32, 40, 0, 0, 48, 56 };
243 static short aniTabB[8] = { 0, 0, 36, 44, 0, 0, 52, 60 };
244 static short aniTabC[8] = {
IND1, 0, IND2, IND4, 0, 0, IND6, IND8 };
245 static short aniTabD[8] = {
IND1, 0, IND3, IND5, 0, 0, IND7, IND9 };
253 int z = (tile -
IZB) >>3;
257 int xx = pos.
posX + dx1[z];
258 int yy = pos.
posY + dy1[z];
266 if ((
map[xx][yy] &
LOMASK) == aniTabC[z]) {
267 map[xx][yy] = ASCBIT | (SMOKEBASE + aniTabA[z]);
268 map[xx][yy] = ASCBIT | (SMOKEBASE + aniTabB[z]);
274 if ((
map[xx][yy] &
LOMASK) > aniTabC[z]) {
275 map[xx][yy] = REGBIT | aniTabC[z];
276 map[xx][yy] = REGBIT | aniTabD[z];
303 if (churchType == 0) {
306 tile = CHURCH1 + ((churchType - 1) * 9);
355 value =
clamp(value + amount * 4, -200, 200);
369 static const short Zx[9] = {-1, 0, 1,-1, 0, 1,-1, 0, 1};
370 static const short Zy[9] = {-1,-1,-1, 0, 0, 0, 1, 1, 1};
372 for (z = 0; z < 9; z++) {
373 int xx = pos.
posX + Zx[z];
374 int yy = pos.
posY + Zy[z];
379 if ((x >= FLOOD) && (x < ROADBASE)) {
387 for (z = 0; z < 9; z++) {
388 int xx = pos.
posX + Zx[z];
389 int yy = pos.
posY + Zy[z];
392 map[xx][yy] = base + BNCNBIT;
413 for (
short x = pos.
posX - 1; x <= pos.
posX + 1; x++) {
414 for (
short y = pos.
posY - 1; y <= pos.
posY + 1; y++) {
415 if (x >= 0 && x < WORLD_W && y >= 0 && y <
WORLD_H) {
417 if (tile >= LHTHR && tile <= HHTHR) {
461 short z, score, hscore, BestLoc;
462 static short ZeX[9] = { 0,-1, 0, 1,-1, 1,-1, 0, 1};
463 static short ZeY[9] = { 0,-1,-1,-1, 0, 0, 1, 1, 1};
468 for (z = 1; z < 9; z++) {
469 int xx = pos.
posX + ZeX[z];
470 int yy = pos.
posY + ZeY[z];
479 if (score > hscore) {
498 int xx = pos.
posX + ZeX[BestLoc];
499 int yy = pos.
posY + ZeY[BestLoc];
503 map[xx][yy] = HOUSE + BLBNCNBIT +
getRandom(2) + value * 3;
517 static short DX[4] = { 0, 1, 0,-1};
518 static short DY[4] = {-1, 0, 1, 0};
523 if (z && (z < RESBASE || z > RESBASE + 8)) {
529 for (z = 0; z < 4; z++) {
550 short tpop, zscore, locvalve, value, TrfGood;
579 locvalve =
evalRes(pos, TrfGood);
580 zscore = resValve + locvalve;
618 if (pollution > 128) {
642 resPlop(pos, (pop / 8) - 1, value);
657 static short Brdr[9] = {0,3,6,1,4,7,2,5,8};
665 resPlop(pos, (pop - 24) / 8, value);
673 for (x = pos.
posX - 1; x <= pos.
posX + 1; x++) {
674 for (y = pos.
posY - 1; y <= pos.
posY + 1; y++) {
687 for (x = pos.
posX - 1; x <= pos.
posX + 1; x++) {
688 for (y = pos.
posY - 1; y <= pos.
posY + 1; y++) {
691 if ((loc >= LHTHR) && (loc <= HHTHR)) {
692 map[x][y] = Brdr[z] + BLBNCNBIT + FREEZ - 4;
713 short CzDen = ((mapTile - RZB) / 9) % 4;
715 return CzDen * 8 + 16;
728 base = ((value * 4 + den) * 9) + RZB - 4;
750 value =
min(value * 32, 6000);
753 value = value - 3000;
768 short zscore, locvalve, value;
791 locvalve =
evalCom(pos, TrfGood);
792 zscore = comValve + locvalve;
806 if ((zscore < 350) &&
868 if (tile == COMCLR) {
872 short CzDen = ((tile - CZB) / 9) % 5 + 1;
887 base = ((Value * 5) + Den) * 9 + CZB - 4;
919 short tpop, zscore, TrfGood;
941 zscore = indValve +
evalInd(TrfGood);
1007 short CzDen = (((tile -
IZB) / 9) % 4) + 1;
1019 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)