Micropolis
zone.cpp
Go to the documentation of this file.
1/* zone.cpp
2 *
3 * Micropolis, Unix Version. This game was released for the Unix platform
4 * in or about 1990 and has been modified for inclusion in the One Laptop
5 * Per Child program. Copyright (C) 1989 - 2007 Electronic Arts Inc. If
6 * you need assistance with this program, you may contact:
7 * http://wiki.laptop.org/go/Micropolis or email micropolis@laptop.org.
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or (at
12 * your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. You should have received a
18 * copy of the GNU General Public License along with this program. If
19 * not, see <http://www.gnu.org/licenses/>.
20 *
21 * ADDITIONAL TERMS per GNU GPL Section 7
22 *
23 * No trademark or publicity rights are granted. This license does NOT
24 * give you any right, title or interest in the trademark SimCity or any
25 * other Electronic Arts trademark. You may not distribute any
26 * modification of this program using the trademark SimCity or claim any
27 * affliation or association with Electronic Arts Inc. or its employees.
28 *
29 * Any propagation or conveyance of this program must include this
30 * copyright notice and these terms.
31 *
32 * If you convey this program (or any modifications of it) and assume
33 * contractual liability for the program to recipients of it, you agree
34 * to indemnify Electronic Arts for any liability that those contractual
35 * assumptions impose on Electronic Arts.
36 *
37 * You may not misrepresent the origins of this program; modified
38 * versions of the program must be marked as such and not identified as
39 * the original program.
40 *
41 * This disclaimer supplements the one included in the General Public
42 * License. TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, THIS
43 * PROGRAM IS PROVIDED TO YOU "AS IS," WITH ALL FAULTS, WITHOUT WARRANTY
44 * OF ANY KIND, AND YOUR USE IS AT YOUR SOLE RISK. THE ENTIRE RISK OF
45 * SATISFACTORY QUALITY AND PERFORMANCE RESIDES WITH YOU. ELECTRONIC ARTS
46 * DISCLAIMS ANY AND ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES,
47 * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY,
48 * FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT OF THIRD PARTY
49 * RIGHTS, AND WARRANTIES (IF ANY) ARISING FROM A COURSE OF DEALING,
50 * USAGE, OR TRADE PRACTICE. ELECTRONIC ARTS DOES NOT WARRANT AGAINST
51 * INTERFERENCE WITH YOUR ENJOYMENT OF THE PROGRAM; THAT THE PROGRAM WILL
52 * MEET YOUR REQUIREMENTS; THAT OPERATION OF THE PROGRAM WILL BE
53 * UNINTERRUPTED OR ERROR-FREE, OR THAT THE PROGRAM WILL BE COMPATIBLE
54 * WITH THIRD PARTY SOFTWARE OR THAT ANY ERRORS IN THE PROGRAM WILL BE
55 * CORRECTED. NO ORAL OR WRITTEN ADVICE PROVIDED BY ELECTRONIC ARTS OR
56 * ANY AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. SOME
57 * JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF OR LIMITATIONS ON IMPLIED
58 * WARRANTIES OR THE LIMITATIONS ON THE APPLICABLE STATUTORY RIGHTS OF A
59 * CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS MAY
60 * NOT APPLY TO YOU.
61 */
62
79
80
81#include "micropolis.h"
82
83
85
86
92{
93 //printf("doZone %d %d\n", pos.posX, pos.posY);
94
95 // Set Power Bit in Map from powerGridMap
96 bool zonePowerFlag = setZonePower(pos);
97
98
99 if (zonePowerFlag) {
101 } else {
103 }
104
105 MapTile tile = map[pos.posX][pos.posY] & LOMASK;
106
107 // Do special zones.
108 if ((tile > PORTBASE) &&
109 (tile < CHURCH1BASE)) {
110 doSpecialZone(pos, zonePowerFlag);
111 return;
112 }
113
114 // Do residential zones.
115 if (tile < HOSPITAL) {
116 doResidential(pos, zonePowerFlag);
117 return;
118 }
119
120 // Do hospitals and churches.
121 if ((tile < COMBASE) ||
122 ((tile >= CHURCH1BASE) &&
123 (tile <= CHURCH7LAST))) {
124 doHospitalChurch(pos);
125 return;
126 }
127
128 // Do commercial zones.
129 if (tile < INDBASE) {
130 doCommercial(pos, zonePowerFlag);
131 return;
132 }
133
134 // Do industrial zones.
135 if (tile < CHURCH1BASE) {
136 doIndustrial(pos, zonePowerFlag);
137 return;
138 }
139
140 printf("UNEXPECTED ZONE: %d !!!\n", tile);
141}
142
148{
149 MapTile tile = map[pos.posX][pos.posY] & LOMASK;
150
151 if (tile == HOSPITAL) {
152
153 hospitalPop++;
154
155 if (!(cityTime & 15)) {
156 repairZone(pos, HOSPITAL, 3);
157 }
158
159 if (needHospital == -1) { // Too many hospitals!
160 if (!getRandom(20)) {
161 zonePlop(pos, RESBASE); // Remove hospital.
162 }
163 }
164
165 } else if ((tile == CHURCH0) ||
166 (tile == CHURCH1) ||
167 (tile == CHURCH2) ||
168 (tile == CHURCH3) ||
169 (tile == CHURCH4) ||
170 (tile == CHURCH5) ||
171 (tile == CHURCH6) ||
172 (tile == CHURCH7)) {
173
174 churchPop++;
175
176 //printf("CHURCH %d %d %d %d\n", churchPop, pos.posX, pos.posY, tile);
177
178 bool simulate = true;
179
180 if (!(cityTime & 15)) {
181 repairZone(pos, tile, 3);
182 }
183
184 if (needChurch == -1) { // Too many churches!
185 if (!getRandom(20)) {
186 zonePlop(pos, RESBASE); // Remove church.
187 simulate = false;
188 }
189 }
190
191 if (simulate) {
192 //printf("SIM %d %d %d\n", pos.posX, pos.posY, tile);
193
194 int churchNumber = 0;
195
196 switch (tile) {
197 case CHURCH0:
198 churchNumber = 0;
199 break;
200 case CHURCH1:
201 churchNumber = 1;
202 break;
203 case CHURCH2:
204 churchNumber = 2;
205 break;
206 case CHURCH3:
207 churchNumber = 3;
208 break;
209 case CHURCH4:
210 churchNumber = 4;
211 break;
212 case CHURCH5:
213 churchNumber = 5;
214 break;
215 case CHURCH6:
216 churchNumber = 6;
217 break;
218 case CHURCH7:
219 churchNumber = 7;
220 break;
221 default:
222 assert(0); // Unexpected church tile
223 break;
224 }
225
226 callback->simulateChurch(this, callbackVal, pos.posX, pos.posY, churchNumber);
227 }
228
229 }
230
231}
232
233
234#define ASCBIT (ANIMBIT | CONDBIT | BURNBIT)
235#define REGBIT (CONDBIT | BURNBIT)
236
237void Micropolis::setSmoke(const Position &pos, bool zonePower)
238{
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 };
246
247 MapTile tile = map[pos.posX][pos.posY] & LOMASK;
248
249 if (tile < IZB) {
250 return;
251 }
252
253 int z = (tile - IZB) >>3;
254 z = z & 7;
255
256 if (aniThis[z]) {
257 int xx = pos.posX + dx1[z];
258 int yy = pos.posY + dy1[z];
259
260 if (testBounds(xx, yy)) {
261
262 if (zonePower) {
263
266 if ((map[xx][yy] & LOMASK) == aniTabC[z]) {
267 map[xx][yy] = ASCBIT | (SMOKEBASE + aniTabA[z]);
268 map[xx][yy] = ASCBIT | (SMOKEBASE + aniTabB[z]);
269 }
270
271 } else {
272
274 if ((map[xx][yy] & LOMASK) > aniTabC[z]) {
275 map[xx][yy] = REGBIT | aniTabC[z];
276 map[xx][yy] = REGBIT | aniTabD[z];
277 }
278
279 }
280
281 }
282
283 }
284
285}
286
287
293{
294 if (needHospital > 0) {
295 zonePlop(pos, HOSPITAL - 4);
296 needHospital = 0;
297 return;
298 }
299
300 if (needChurch > 0) {
301 int churchType = getRandom(7); // 0 to 7 inclusive
302 int tile;
303 if (churchType == 0) {
304 tile = CHURCH0;
305 } else {
306 tile = CHURCH1 + ((churchType - 1) * 9);
307 }
308
309 //printf("NEW CHURCH tile %d x %d y %d type %d\n", tile, pos.posX, pos.posY, churchType);
310
311 zonePlop(pos, tile - 4);
312 needChurch = 0;
313 return;
314 }
315}
316
324{
325 short landVal;
326
327 landVal = landValueMap.worldGet(pos.posX, pos.posY);
328 landVal -= pollutionDensityMap.worldGet(pos.posX, pos.posY);
329
330 if (landVal < 30) {
331 return 0;
332 }
333
334 if (landVal < 80) {
335 return 1;
336 }
337
338 if (landVal < 150) {
339 return 2;
340 }
341
342 return 3;
343}
344
345
351void Micropolis::incRateOfGrowth(const Position &pos, int amount)
352{
353 int value = rateOfGrowthMap.worldGet(pos.posX, pos.posY);
354
355 value = clamp(value + amount * 4, -200, 200);
356 rateOfGrowthMap.worldSet(pos.posX, pos.posY, value);
357}
358
359
366bool Micropolis::zonePlop(const Position &pos, int base)
367{
368 short z, x;
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};
371
372 for (z = 0; z < 9; z++) { /* check for fire */
373 int xx = pos.posX + Zx[z];
374 int yy = pos.posY + Zy[z];
375
376 if (testBounds(xx, yy)) {
377 x = map[xx][yy] & LOMASK;
378
379 if ((x >= FLOOD) && (x < ROADBASE)) {
380 return false;
381 }
382
383 }
384
385 }
386
387 for (z = 0; z < 9; z++) {
388 int xx = pos.posX + Zx[z];
389 int yy = pos.posY + Zy[z];
390
391 if (testBounds(xx, yy)) {
392 map[xx][yy] = base + BNCNBIT;
393 }
394
395 base++;
396 }
397
398 setZonePower(pos);
399 map[pos.posX][pos.posY] |= ZONEBIT + BULLBIT;
400
401 return true;
402}
403
410{
411 short count = 0;
412
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) {
416 MapTile tile = map[x][y] & LOMASK;
417 if (tile >= LHTHR && tile <= HHTHR) {
418 count++;
419 }
420 }
421 }
422 }
423
424 return count;
425}
426
427
434{
435 MapValue mapValue = map[pos.posX][pos.posY];
436 MapTile tile = mapValue & LOMASK;
437
438 if (tile == NUCLEAR || tile == POWERPLANT) {
439 map[pos.posX][pos.posY] = mapValue | PWRBIT;
440 return true;
441 }
442
443 if (powerGridMap.worldGet(pos.posX, pos.posY)) {
444 map[pos.posX][pos.posY] = mapValue | PWRBIT;
445 return true;
446 } else {
447 map[pos.posX][pos.posY] = mapValue & (~PWRBIT);
448 return false;
449 }
450}
451
452
459void Micropolis::buildHouse(const Position &pos, int value)
460{
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};
464
465 BestLoc = 0;
466 hscore = 0;
467
468 for (z = 1; z < 9; z++) {
469 int xx = pos.posX + ZeX[z];
470 int yy = pos.posY + ZeY[z];
471
472 if (testBounds(xx, yy)) {
473
474 score = evalLot(xx, yy);
475
477 if (score != 0) {
478
479 if (score > hscore) {
480 hscore = score;
481 BestLoc = z;
482 }
483
486 // trigger this code too.
487 if (score == hscore && !(getRandom16() & 7)) {
488 BestLoc = z;
489 }
490
491 }
492
493 }
494
495 }
496
497 if (BestLoc) {
498 int xx = pos.posX + ZeX[BestLoc];
499 int yy = pos.posY + ZeY[BestLoc];
500
501 if (testBounds(xx, yy)) {
503 map[xx][yy] = HOUSE + BLBNCNBIT + getRandom(2) + value * 3;
504 }
505
506 }
507}
508
509
514short Micropolis::evalLot(int x, int y)
515{
516 short z, score;
517 static short DX[4] = { 0, 1, 0,-1};
518 static short DY[4] = {-1, 0, 1, 0};
519
520 /* test for clear lot */
521 z = map[x][y] & LOMASK;
522
523 if (z && (z < RESBASE || z > RESBASE + 8)) {
524 return -1;
525 }
526
527 score = 1;
528
529 for (z = 0; z < 4; z++) {
530 int xx = x + DX[z];
531 int yy = y + DY[z];
532
533 if (testBounds(xx, yy) &&
534 map[xx][yy] != DIRT && (map[xx][yy] & LOMASK) <= LASTROAD) {
535 score++; /* look for road */
536 }
537
538 }
539
540 return score;
541}
542
548void Micropolis::doResidential(const Position &pos, bool zonePower)
549{
550 short tpop, zscore, locvalve, value, TrfGood;
551
552 resZonePop++;
553
554 MapTile tile = map[pos.posX][pos.posY] & LOMASK;
555
556 if (tile == FREEZ) {
557 tpop = doFreePop(pos);
558 } else {
559 tpop = getResZonePop(tile);
560 }
561
562 resPop += tpop;
563
564 if (tpop > getRandom(35)) {
565 /* Try driving from residential to commercial */
566 TrfGood = makeTraffic(pos, ZT_COMMERCIAL);
567 } else {
568 TrfGood = 1;
569 }
570
571 if (TrfGood == -1) {
572 value = getLandPollutionValue(pos);
573 doResOut(pos, tpop, value);
574 return;
575 }
576
577 if (tile == FREEZ || !(getRandom16() & 7)) {
578
579 locvalve = evalRes(pos, TrfGood);
580 zscore = resValve + locvalve;
581
582 if (!zonePower) {
583 zscore = -500;
584 }
585
586 if (zscore > -350 &&
587 ((short)(zscore - 26380) > ((short)getRandom16Signed()))) {
588
589 if (!tpop && !(getRandom16() & 3)) {
590 makeHospital(pos);
591 return;
592 }
593
594 value = getLandPollutionValue(pos);
595 doResIn(pos, tpop, value);
596 return;
597 }
598
599 if (zscore < 350 &&
600 (((short)(zscore + 26380)) < ((short)getRandom16Signed()))) {
601 value = getLandPollutionValue(pos);
602 doResOut(pos, tpop, value);
603 }
604 }
605}
606
607
614void Micropolis::doResIn(const Position &pos, int pop, int value)
615{
616 short pollution = pollutionDensityMap.worldGet(pos.posX, pos.posY);
617
618 if (pollution > 128) {
619 return;
620 }
621
622 MapTile tile = map[pos.posX][pos.posY] & LOMASK;
623
624 if (tile == FREEZ) {
625
626 if (pop < 8) {
627 buildHouse(pos, value);
628 incRateOfGrowth(pos, 1);
629 return;
630 }
631
632 if (populationDensityMap.worldGet(pos.posX, pos.posY) > 64) {
633 resPlop(pos, 0, value);
634 incRateOfGrowth(pos, 8);
635 return;
636 }
637
638 return;
639 }
640
641 if (pop < 40) {
642 resPlop(pos, (pop / 8) - 1, value);
643 incRateOfGrowth(pos, 8);
644 }
645
646}
647
648
655void Micropolis::doResOut(const Position &pos, int pop, int value)
656{
657 static short Brdr[9] = {0,3,6,1,4,7,2,5,8};
658 short x, y, loc, z;
659
660 if (!pop) {
661 return;
662 }
663
664 if (pop > 16) {
665 resPlop(pos, (pop - 24) / 8, value);
666 incRateOfGrowth(pos, -8);
667 return;
668 }
669
670 if (pop == 16) {
671 incRateOfGrowth(pos, -8);
672 map[pos.posX][pos.posY] = (FREEZ | BLBNCNBIT | ZONEBIT);
673 for (x = pos.posX - 1; x <= pos.posX + 1; x++) {
674 for (y = pos.posY - 1; y <= pos.posY + 1; y++) {
675 if (testBounds(x, y)) {
676 if ((map[x][y] & LOMASK) != FREEZ) {
677 map[x][y] = LHTHR + value + getRandom(2) + BLBNCNBIT;
678 }
679 }
680 }
681 }
682 }
683
684 if (pop < 16) {
685 incRateOfGrowth(pos, -1);
686 z = 0;
687 for (x = pos.posX - 1; x <= pos.posX + 1; x++) {
688 for (y = pos.posY - 1; y <= pos.posY + 1; y++) {
689 if (testBounds(x, y)) {
690 loc = map[x][y] & LOMASK;
691 if ((loc >= LHTHR) && (loc <= HHTHR)) {
692 map[x][y] = Brdr[z] + BLBNCNBIT + FREEZ - 4;
693 return;
694 }
695 }
696 z++;
697 }
698 }
699 }
700}
701
702
712{
713 short CzDen = ((mapTile - RZB) / 9) % 4;
714
715 return CzDen * 8 + 16;
716}
717
724void Micropolis::resPlop(const Position &pos, int den, int value)
725{
726 short base;
727
728 base = ((value * 4 + den) * 9) + RZB - 4;
729 zonePlop(pos, base);
730}
731
732
736short Micropolis::evalRes(const Position &pos, int traf)
737{
738 short value;
739
740 if (traf < 0) {
741 return -3000;
742 }
743
744 value = landValueMap.worldGet(pos.posX, pos.posY);
745 value -= pollutionDensityMap.worldGet(pos.posX, pos.posY);
746
747 if (value < 0) {
748 value = 0; /* Cap at 0 */
749 } else {
750 value = min(value * 32, 6000); /* Cap at 6000 */
751 }
752
753 value = value - 3000;
754
755 return value;
756}
757
758
765void Micropolis::doCommercial(const Position &pos, bool zonePower)
766{
767 short tpop, TrfGood;
768 short zscore, locvalve, value;
769
770 MapTile tile = map[pos.posX][pos.posY] & LOMASK;
771
772 comZonePop++;
773 tpop = getComZonePop(tile);
774 comPop += tpop;
775
776 if (tpop > getRandom(5)) {
777 /* Try driving from commercial to industrial */
778 TrfGood = makeTraffic(pos, ZT_INDUSTRIAL);
779 } else {
780 TrfGood = 1;
781 }
782
783 if (TrfGood == -1) {
784 value = getLandPollutionValue(pos);
785 doComOut(pos, tpop, value);
786 return;
787 }
788
789 if (!(getRandom16() & 7)) {
790
791 locvalve = evalCom(pos, TrfGood);
792 zscore = comValve + locvalve;
793
794 if (!zonePower) {
795 zscore = -500;
796 }
797
798 if (TrfGood &&
799 (zscore > -350) &&
800 (((short)(zscore - 26380)) > ((short)getRandom16Signed()))) {
801 value = getLandPollutionValue(pos);
802 doComIn(pos, tpop, value);
803 return;
804 }
805
806 if ((zscore < 350) &&
807 (((short)(zscore + 26380)) < ((short)getRandom16Signed()))) {
808 value = getLandPollutionValue(pos);
809 doComOut(pos, tpop, value);
810 }
811
812 }
813
814}
815
816
823void Micropolis::doComIn(const Position &pos, int pop, int value)
824{
825 short z;
826
827 z = landValueMap.worldGet(pos.posX, pos.posY);
828 z = z >>5;
829
830 if (pop > z) {
831 return;
832 }
833
834 if (pop < 5) {
835 comPlop(pos, pop, value);
836 incRateOfGrowth(pos, 8);
837 }
838}
839
846void Micropolis::doComOut(const Position &pos, int pop, int value)
847{
848 if (pop > 1) {
849 comPlop(pos, pop - 2, value);
850 incRateOfGrowth(pos, -8);
851 return;
852 }
853
854 if (pop == 1) {
855 zonePlop(pos, COMBASE);
856 incRateOfGrowth(pos, -8);
857 }
858}
859
860
867{
868 if (tile == COMCLR) {
869 return 0;
870 }
871
872 short CzDen = ((tile - CZB) / 9) % 5 + 1;
873 return CzDen;
874}
875
876
883void Micropolis::comPlop(const Position &pos, int Den, int Value)
884{
885 short base;
886
887 base = ((Value * 5) + Den) * 9 + CZB - 4;
888 zonePlop(pos, base);
889}
890
891
897short Micropolis::evalCom(const Position &pos, int traf)
898{
899 short Value;
900
901 if (traf < 0) {
902 return -3000;
903 }
904
905 Value = comRateMap.worldGet(pos.posX, pos.posY);
906
907 return Value;
908}
909
910
917void Micropolis::doIndustrial(const Position &pos, bool zonePower)
918{
919 short tpop, zscore, TrfGood;
920
921 MapTile tile = map[pos.posX][pos.posY] & LOMASK;
922
923 indZonePop++;
924 setSmoke(pos, zonePower);
925 tpop = getIndZonePop(tile);
926 indPop += tpop;
927
928 if (tpop > getRandom(5)) {
929 /* Try driving from industrial to residential */
930 TrfGood = makeTraffic(pos, ZT_RESIDENTIAL);
931 } else {
932 TrfGood = 1;
933 }
934
935 if (TrfGood == -1) {
936 doIndOut(pos, tpop, getRandom16() & 1);
937 return;
938 }
939
940 if (!(getRandom16() & 7)) {
941 zscore = indValve + evalInd(TrfGood);
942
943 if (!zonePower) {
944 zscore = -500;
945 }
946
947 if (zscore > -350 &&
948 (((short)(zscore - 26380)) > ((short)getRandom16Signed()))) {
949 doIndIn(pos, tpop, getRandom16() & 1);
950 return;
951 }
952
953 if (zscore < 350 &&
954 (((short)(zscore + 26380)) < ((short)getRandom16Signed()))) {
955 doIndOut(pos, tpop, getRandom16() & 1);
956 }
957 }
958}
959
960
967void Micropolis::doIndIn(const Position &pos, int pop, int value)
968{
969 if (pop < 4) {
970 indPlop(pos, pop, value);
971 incRateOfGrowth(pos, 8);
972 }
973}
974
981void Micropolis::doIndOut(const Position &pos, int pop, int value)
982{
983 if (pop > 1) {
984 indPlop(pos, pop - 2, value);
985 incRateOfGrowth(pos, -8);
986 return;
987 }
988
989 if (pop == 1) {
990 zonePlop(pos, INDBASE); // empty industrial zone
991 incRateOfGrowth(pos, -8);
992 }
993}
994
995
1002{
1003 if (tile == INDCLR) {
1004 return 0;
1005 }
1006
1007 short CzDen = (((tile - IZB) / 9) % 4) + 1;
1008 return CzDen;
1009}
1010
1017void Micropolis::indPlop(const Position &pos, int den, int value)
1018{
1019 short base = ((value * 4) + den) * 9 + IND1;
1020 zonePlop(pos, base);
1021}
1022
1023
1029short Micropolis::evalInd(int traf)
1030{
1031 if (traf < 0) {
1032 return -1000;
1033 }
1034
1035 return 0;
1036}
1037
1038
DATA worldGet(int x, int y) const
Definition map_type.h:316
void worldSet(int x, int y, DATA val)
Definition map_type.h:297
short getLandPollutionValue(const Position &pos)
Definition zone.cpp:323
short indPop
Definition micropolis.h:997
short getResZonePop(MapTile mapTile)
Definition zone.cpp:711
short doFreePop(const Position &pos)
Definition zone.cpp:409
short indZonePop
Number of industrial zones.
void makeHospital(const Position &pos)
Definition zone.cpp:292
void resPlop(const Position &pos, int Den, int Value)
Definition zone.cpp:724
void doZone(const Position &pos)
Definition zone.cpp:91
void buildHouse(const Position &pos, int value)
Definition zone.cpp:459
short getIndZonePop(MapTile tile)
Definition zone.cpp:1001
void doResidential(const Position &pos, bool zonePower)
Definition zone.cpp:548
short poweredZoneCount
Number of powered tiles in all zone.
void doSpecialZone(const Position &pos, bool PwrOn)
Callback * callback
Definition micropolis.h:955
MapByte1 powerGridMap
void indPlop(const Position &pos, int den, int value)
Definition zone.cpp:1017
short unpoweredZoneCount
Number of unpowered tiles in all zones.
bool setZonePower(const Position &pos)
Definition zone.cpp:433
void comPlop(const Position &pos, int Den, int Value)
Definition zone.cpp:883
short churchPop
Number of churches.
MapShort8 comRateMap
short makeTraffic(int x, int y, ZoneType dest)
Definition traffic.cpp:118
short evalCom(const Position &pos, int traf)
Definition zone.cpp:897
short resPop
Definition micropolis.h:983
short getRandom(short range)
Definition random.cpp:110
void doIndustrial(const Position &pos, bool zonePower)
Definition zone.cpp:917
int getRandom16()
Definition random.cpp:130
void setSmoke(const Position &pos, bool zonePower)
Definition zone.cpp:237
bool zonePlop(const Position &pos, int base)
Definition zone.cpp:366
short resZonePop
Number of residential zones.
short evalRes(const Position &pos, int traf)
Definition zone.cpp:736
short evalInd(int traf)
Definition zone.cpp:1029
void doIndIn(const Position &pos, int pop, int value)
Definition zone.cpp:967
void doIndOut(const Position &pos, int pop, int value)
Definition zone.cpp:981
void repairZone(const Position &pos, MapTile zCent, short zSize)
void doResOut(const Position &pos, int pop, int value)
Definition zone.cpp:655
void doComOut(const Position &pos, int pop, int value)
Definition zone.cpp:846
short getComZonePop(MapTile tile)
Definition zone.cpp:866
unsigned short * map[WORLD_W]
short hospitalPop
Number of hospitals.
void doResIn(const Position &pos, int pop, int value)
Definition zone.cpp:614
void doHospitalChurch(const Position &pos)
Definition zone.cpp:147
MapByte2 pollutionDensityMap
Pollution density map.
static bool testBounds(int wx, int wy)
int getRandom16Signed()
Definition random.cpp:137
short comPop
Definition micropolis.h:990
short needHospital
short evalLot(int x, int y)
Definition zone.cpp:514
MapByte2 populationDensityMap
Population density map.
void incRateOfGrowth(const Position &pos, int amount)
Definition zone.cpp:351
void doCommercial(const Position &pos, bool zonePower)
Definition zone.cpp:765
MapByte2 landValueMap
Land value map.
short needChurch
MapShort8 rateOfGrowthMap
short comZonePop
Number of commercial zones.
void doComIn(const Position &pos, int pop, int value)
Definition zone.cpp:823
int posY
Vertical coordnate of the position.
Definition position.h:169
int posX
Horizontal coordinate of the position.
Definition position.h:168
static const int WORLD_H
Definition map_type.h:95
Header file for Micropolis game engine.
@ ZT_RESIDENTIAL
Residential zone.
Definition micropolis.h:721
@ ZT_COMMERCIAL
Commercial zone.
Definition micropolis.h:719
@ ZT_INDUSTRIAL
Industrial zone.
Definition micropolis.h:720
@ NUCLEAR
'Center' tile nuclear power plant.
Definition micropolis.h:604
@ PORTBASE
Top-left tile of the seaport.
Definition micropolis.h:567
@ IZB
Center tile of first non-empty industry zone.
Definition micropolis.h:542
@ POWERPLANT
'Center' tile of coal power plant.
Definition micropolis.h:580
@ INDCLR
Center tile of empty industrial zone.
Definition micropolis.h:537
@ DIRT
Clear tile.
Definition micropolis.h:382
@ INDBASE
Top-left tile of empty industrial zone.
Definition micropolis.h:536
@ IND1
Top-left tile of first non-empty industry zone.
Definition micropolis.h:541
static T min(const T a, const T b)
Definition micropolis.h:784
static T clamp(const T val, const T lower, const T upper)
Definition micropolis.h:809
unsigned short MapTile
Definition tool.h:108
@ LOMASK
Mask for the Tiles part of the tile.
Definition tool.h:129
@ ZONEBIT
bit 10, tile is the center tile of the zone.
Definition tool.h:125
@ PWRBIT
bit 15, tile has power.
Definition tool.h:120
@ BULLBIT
bit 12, tile is bulldozable.
Definition tool.h:123
unsigned short MapValue
Definition tool.h:101