]>
git.zerfleddert.de Git - micropolis/blob - src/sim/headers/sim.h
7a81f7cc2718c2859f4b6f51352474571377d607
1 /* sim.h: Main include file
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.
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.
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/>.
21 * ADDITIONAL TERMS per GNU GPL Section 7
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.
29 * Any propagation or conveyance of this program must include this
30 * copyright notice and these terms.
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.
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.
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
63 /* workaround sun c compiler junk */
68 #define CTRL(c) (#c[0]&037)
71 #define __sys_ioccom_h
72 #define _IOCPARM_MASK 0xff /* parameters must be < 256 bytes */
73 #define _IOC_VOID 0x20000000 /* no parameters */
74 #define _IOC_OUT 0x40000000 /* copy out parameters */
75 #define _IOC_IN 0x80000000 /* copy in parameters */
76 #define _IOC_INOUT (_IOC_IN|_IOC_OUT)
77 #define _IO(x,y) (_IOC_VOID|(#x[0]<<8)|y)
78 #define _IOR(x,y,t) (_IOC_OUT|((sizeof(t)&_IOCPARM_MASK)<<16)|(#x[0]<<8)|y)
79 #define _IORN(x,y,t) (_IOC_OUT|(((t)&_IOCPARM_MASK)<<16)|(#x[0]<<8)|y)
80 #define _IOW(x,y,t) (_IOC_IN|((sizeof(t)&_IOCPARM_MASK)<<16)|(#x[0]<<8)|y)
81 #define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|(#x[0]<<8)|y)
82 #define _IOWR(x,y,t) (_IOC_INOUT|((sizeof(t)&_IOCPARM_MASK)<<16)|(#x[0]<<8)|y)
83 #define _IOWRN(x,y,t) (_IOC_INOUT|(((t)&_IOCPARM_MASK)<<16)|(#x[0]<<8)|y)
98 #include <sys/types.h>
100 #include <sys/stat.h>
101 #include <sys/file.h>
102 #include <sys/ioctl.h>
103 #include <sys/resource.h>
108 #include <sys/mman.h>
109 #include <netinet/in.h>
110 #include <arpa/inet.h>
115 #include <sys/systeminfo.h>
117 #include <sys/vadvise.h>
129 #include <X11/Xlib.h>
130 #include <X11/Xutil.h>
131 #include <X11/Xatom.h>
132 #include <X11/extensions/XShm.h>
137 /* gcc compat workaround! */
140 #include "tclxtend.h"
143 #include "tkconfig.h"
156 #define SimWidth (120 * MEGA)
157 #define SimHeight (100 * MEGA)
160 #define SimHeight 100
163 #define WORLD_X SimWidth
164 #define WORLD_Y SimHeight
165 #define HWLDX (SimWidth >>1)
166 #define HWLDY (SimHeight >>1)
167 #define QWX (SimWidth >>2)
168 #define QWY (SimHeight >>2)
169 #define SmX (SimWidth >>3)
170 #define SmY ((SimHeight + 7) >>3)
172 #define EDITOR_W (WORLD_X * 16)
173 #define EDITOR_H (WORLD_Y * 16)
174 #define MAP_W (WORLD_X * 3)
175 #define MAP_H (WORLD_Y * 3)
184 #define MISCHISTLEN 240
186 #define POWERMAPROW ((WORLD_X + 15) / 16)
189 #define POWERMAPLEN ((QUAD)(2 * POWERMAPROW * WORLD_Y))
190 #define POWERWORD(x, y) ((((QUAD)(x)) >>4) + (((QUAD)(y)) * POWERMAPROW))
192 #define POWERMAPLEN 1700 /* ??? PWRMAPSIZE */
193 #define POWERWORD(x, y) (((x) >>4) + ((y) <<3))
196 #define SETPOWERBIT(x, y) PowerMap[POWERWORD((x), (y))] |= 1 << ((x) & 15)
197 #define PWRMAPSIZE (POWERMAPROW * WORLD_Y)
198 #define PWRSTKSIZE ((WORLD_X * WORLD_Y) / 4)
200 #define ALMAP 0 /* all */
201 #define REMAP 1 /* residential */
202 #define COMAP 2 /* commercial */
203 #define INMAP 3 /* industrial */
205 #define PRMAP 4 /* power */
206 #define RDMAP 5 /* road */
208 #define PDMAP 6 /* population density */
209 #define RGMAP 7 /* rate of growth */
211 #define TDMAP 8 /* traffic density */
212 #define PLMAP 9 /* pollution */
213 #define CRMAP 10 /* crime */
214 #define LVMAP 11 /* land value */
216 #define FIMAP 12 /* fire radius */
217 #define POMAP 13 /* police radius */
218 #define DYMAP 14 /* dynamic */
222 /* These adjust frequency in Simulate() */
228 /* These are names of the 16 colors */
229 #define COLOR_WHITE 0
230 #define COLOR_YELLOW 1
231 #define COLOR_ORANGE 2
233 #define COLOR_DARKRED 4
234 #define COLOR_DARKBLUE 5
235 #define COLOR_LIGHTBLUE 6
236 #define COLOR_BROWN 7
237 #define COLOR_LIGHTGREEN 8
238 #define COLOR_DARKGREEN 9
239 #define COLOR_OLIVE 10
240 #define COLOR_LIGHTBROWN 11
241 #define COLOR_LIGHTGRAY 12
242 #define COLOR_MEDIUMGRAY 13
243 #define COLOR_DARKGRAY 14
244 #define COLOR_BLACK 15
248 #define PWRBIT 32768 /*20 bit 15 */
249 #define CONDBIT 16384 /*10 bit 14 */
250 #define BURNBIT 8192 /*8 bit 13 */
251 #define BULLBIT 4096 /*4 bit 12 */
252 #define ANIMBIT 2048 /*2 bit 11 */
253 #define ZONEBIT 1024 /*1 bit 10 */
254 #define ALLBITS 64512 /* mask for upper 6 bits */
255 #define LOMASK 1023 /* mask for low 10 bits */
257 #define BLBNBIT (BULLBIT+BURNBIT)
258 #define BLBNCNBIT (BULLBIT+BURNBIT+CONDBIT)
259 #define BNCNBIT (BURNBIT+CONDBIT)
261 /* Object & Sound Numbers */
272 /* Max # of Objects */
276 /* Graph Histories */
282 #define POLLUTION_HIST 5
284 #define ALL_HISTORIES ((1 <<HISTORIES) - 1)
286 /* Character Mapping */
292 #define FIRSTRIVEDGE 5
293 #define LASTRIVEDGE 20
297 #define UNUSED_TRASH1 38
298 #define UNUSED_TRASH2 39
304 #define LASTRUBBLE 47
308 #define UNUSED_TRASH3 53
309 #define UNUSED_TRASH4 54
310 #define UNUSED_TRASH5 55
318 #define INTERSECTION 76
319 #define HROADPOWER 77
320 #define VROADPOWER 78
333 #define POWERBASE 208
338 #define RAILHPOWERV 221
339 #define RAILVPOWERH 222
340 #define LASTPOWER 222
341 #define UNUSED_TRASH6 223
347 #define HRAILROAD 237
348 #define VRAILROAD 238
350 #define ROADVPOWERH 239 /* bogus? */
378 #define AIRPORTBASE 709
382 #define POWERPLANT 750
383 #define LASTPOWERPLANT 760
384 #define FIRESTBASE 761
385 #define FIRESTATION 765
386 #define POLICESTBASE 770
387 #define POLICESTATION 774
388 #define STADIUMBASE 779
390 #define FULLSTADIUM 800
391 #define NUCLEARBASE 811
394 #define LIGHTNINGBOLT 827
411 #define SMOKEBASE 852
413 #define SOMETINYEXP 864
414 #define LASTTINYEXP 867
415 #define COALSMOKE1 916
416 #define COALSMOKE2 920
417 #define COALSMOKE3 924
418 #define COALSMOKE4 928
419 #define FOOTBALLGAME1 932
420 #define FOOTBALLGAME2 940
426 #define TILE_COUNT 960
429 * These describe the wand values, the object dragged around on the screen.
432 #define residentialState 0
433 #define commercialState 1
434 #define industrialState 2
437 #define policeState 5
442 #define chalkState 10
443 #define eraserState 11
444 #define stadiumState 12
446 #define seaportState 14
447 #define powerState 15
448 #define nuclearState 16
449 #define airportState 17
450 #define networkState 18
453 #define firstState residentialState
454 #define lastState networkState
457 #define specialState 16
458 #define monsterGoalState 17
459 #define helicopterGoalState 18
460 #define blackState 19
461 #define whiteState 20
463 #define orangeState 23
465 #define greenState 25
466 #define brownState 26
471 #define STATE_TILES 1
472 #define STATE_OVERLAYS 2
473 #define STATE_GRAPHS 3
476 extern short *Map
[WORLD_X
]; /* Main Map 120 x 100 */
477 extern Byte
*PopDensity
[HWLDX
]; /* 2X2 Maps 60 x 50 */
478 extern Byte
*TrfDensity
[HWLDX
];
479 extern Byte
*PollutionMem
[HWLDX
];
480 extern Byte
*LandValueMem
[HWLDX
];
481 extern Byte
*CrimeMem
[HWLDX
];
482 extern Byte
*tem
[HWLDX
];
483 extern Byte
*tem2
[HWLDX
];
484 extern Byte
*TerrainMem
[QWX
]; /* 4X4 Maps 30 x 25 */
485 extern Byte
*Qtem
[QWX
];
486 extern short RateOGMem
[SmX
][SmY
];
487 extern short FireStMap
[SmX
][SmY
]; /* 8X8 Maps 15 x 13 */
488 extern short PoliceMap
[SmX
][SmY
];
489 extern short PoliceMapEffect
[SmX
][SmY
];
490 extern short ComRate
[SmX
][SmY
];
491 extern short FireRate
[SmX
][SmY
];
492 extern short STem
[SmX
][SmY
];
493 extern short SpriteXOffset
[OBJN
];
494 extern short SpriteYOffset
[OBJN
];
495 extern short SMapX
, SMapY
;
496 extern short CChr
, CChr9
;
497 extern short RoadTotal
, RailTotal
, FirePop
;
498 extern short ResPop
, ComPop
, IndPop
, TotalPop
, LastTotalPop
;
499 extern short ResZPop
, ComZPop
, IndZPop
, TotalZPop
;
500 extern short HospPop
, ChurchPop
, StadiumPop
;
501 extern short PolicePop
, FireStPop
;
502 extern short CoalPop
, NuclearPop
, PortPop
, APortPop
;
503 extern short NeedHosp
, NeedChurch
;
504 extern short CrimeAverage
, PolluteAverage
, LVAverage
;
505 extern char *MicropolisVersion
;
506 extern char *CityName
;
507 extern char *CityFileName
;
508 extern char *StartupName
;
509 extern short StartingYear
;
510 extern QUAD CityTime
;
511 extern QUAD LastCityTime
;
512 extern QUAD LastCityMonth
;
513 extern QUAD LastCityYear
;
514 extern QUAD LastFunds
;
515 extern QUAD LastR
, LastC
, LastI
;
516 extern short GameLevel
;
518 extern short ScenarioID
;
519 extern short ShakeNow
;
520 extern QUAD DonDither
;
521 extern int DoOverlay
;
523 extern short *ResHis
, ResHisMax
;
524 extern short *ComHis
, ComHisMax
;
525 extern short *IndHis
, IndHisMax
;
526 extern short *MoneyHis
, *CrimeHis
, *PollutionHis
, *MiscHis
;
527 extern short *PowerMap
;
529 extern float roadPercent
, policePercent
, firePercent
;
530 extern QUAD RoadSpend
, PoliceSpend
, FireSpend
;
531 extern QUAD roadMaxValue
, policeMaxValue
, fireMaxValue
;
532 extern QUAD TaxFund
, RoadFund
, PoliceFund
, FireFund
;
533 extern short RoadEffect
, PoliceEffect
, FireEffect
;
534 extern short TaxFlag
, CityTax
;
535 extern QUAD TotalFunds
;
537 extern QUAD costOf
[];
539 extern short flagBlink
;
540 extern unsigned char tileSynch
;
541 extern short aniTile
[];
542 extern unsigned char aniSynch
[];
543 extern int TilesAnimated
;
544 extern int DoAnimation
;
545 extern int DoMessages
;
546 extern int DoNotices
;
547 extern unsigned char ColorIntensities
[];
549 extern short MesX
, MesY
;
550 extern short MesNum
, MessagePort
;
551 extern QUAD LastMesTime
;
553 extern short SimSpeed
;
554 extern short SimMetaSpeed
;
555 extern short NoDisasters
;
556 extern short autoBulldoze
;
557 extern short autoBudget
;
559 extern short UserSoundOn
;
561 extern short DisasterEvent
;
562 extern short DisasterWait
;
564 extern short ResCap
, ComCap
, IndCap
;
565 extern short RValve
, CValve
, IValve
;
566 extern short PwrdZCnt
;
567 extern short unPwrdZCnt
;
569 extern char *HomeDir
, *ResourceDir
, *HostName
;
571 extern short Graph10Max
, Graph120Max
;
572 extern short Res2HisMax
, Com2HisMax
, Ind2HisMax
;
573 extern unsigned char *History10
[HISTORIES
], *History120
[HISTORIES
];
574 extern short CityScore
;
575 extern short deltaCityScore
;
576 extern short ScoreType
;
577 extern short ScoreWait
;
578 extern short CityClass
;
579 extern short PolMaxX
, PolMaxY
;
580 extern int PowerStackNum
;
581 extern short TrafficAverage
;
582 extern short PosStackN
;
583 extern short SMapXStack
[], SMapYStack
[];
584 extern short Zsource
;
585 extern short HaveLastMessage
;
586 extern short PdestX
, PdestY
;
587 extern short CdestX
, CdestY
;
589 extern short CopFltCnt
;
591 extern short GdestX
, GdestY
;
592 extern short GorgX
, GorgY
;
593 extern short GodControl
;
594 extern short CopControl
;
595 extern short CdestX
, CdestY
;
596 extern short TrafMaxX
, TrafMaxY
;
597 extern short CrimeMaxX
, CrimeMaxY
;
598 extern short FloodX
, FloodY
;
599 extern short CrashX
, CrashY
;
600 extern short CCx
, CCy
;
601 extern QUAD CityPop
, deltaCityPop
;
602 extern char *cityClassStr
[6];
603 extern short CityYes
, CityNo
;
604 extern short ProblemTable
[PROBNUM
];
605 extern short ProblemVotes
[PROBNUM
];
606 extern short ProblemOrder
[4];
607 extern QUAD CityAssValue
;
609 extern short InitSimLoad
;
610 extern short DoInitialEval
;
612 extern int StartupGameLevel
;
613 extern int PerformanceTiming
;
614 extern double FlushTime
;
618 extern struct timeval start_time
, now_time
, beat_time
, last_now_time
;
621 extern int MultiPlayerMode
;
622 extern int SugarMode
;
623 extern int sim_delay
;
624 extern int sim_skips
;
626 extern int sim_paused
;
627 extern int sim_paused_speed
;
630 extern int sim_just_cam
;
632 extern int heat_steps
;
633 extern int heat_flow
;
634 extern int heat_rule
;
635 extern int UpdateDelayed
;
636 extern int DynamicData
[32];
639 extern int BobHeight
;
641 extern int Expensive
;
642 extern int PendingTool
;
645 extern int TreeLevel
;
646 extern int LakeLevel
;
647 extern int CurveLevel
;
648 extern int CreateIsland
;
649 extern short specialBase
;
650 extern short PunishCnt
;
652 extern short toolSize
[];
653 extern short toolOffset
[];
654 extern QUAD toolColors
[];
655 extern char *Displays
;
656 extern char *FirstDisplay
;
657 extern char *dateStr
[12];
660 extern short NewMapFlags
[NMAPS
];
661 extern short NewGraph
;
662 extern short ValveFlag
;
663 extern short MustUpdateFunds
;
664 extern short MustUpdateOptions
;
665 extern short CensusChanged
;
666 extern short EvalChanged
;
667 extern short MeltX
, MeltY
;
669 extern int ExitReturn
;
671 extern Tcl_Interp
*tk_mainInterp
;
672 extern Tk_Window MainWindow
;
673 extern int FlushStyle
;
674 extern int GotXError
;
676 extern short Rand(short range
);
677 extern short RandInt(void);
679 extern Sim
*MakeNewSim();
680 extern SimView
*MakeNewView();
681 extern SimSprite
*GetSprite();
682 extern SimSprite
*MakeSprite();
683 extern SimSprite
*MakeNewSprite();
685 extern int setSpeed(short speed
);
686 extern int setSkips(int skips
);
687 extern int SetGameLevel(short level
);
688 extern int SetGameLevelFunds(short level
);
690 extern struct XDisplay
*XDisplays
;