]>
git.zerfleddert.de Git - micropolis/blob - src/sim/headers/sim.h
d6a31a11eb56a5952a79034a6c0bfc7a0333b204
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)
99 #include <sys/types.h>
100 #include <sys/time.h>
101 #include <sys/stat.h>
102 #include <sys/file.h>
103 #include <sys/ioctl.h>
104 #include <sys/resource.h>
109 #include <sys/mman.h>
110 #include <netinet/in.h>
111 #include <arpa/inet.h>
116 #include <sys/systeminfo.h>
118 #include <sys/vadvise.h>
130 #include <X11/Xlib.h>
131 #include <X11/Xutil.h>
132 #include <X11/Xatom.h>
133 #include <X11/extensions/XShm.h>
138 /* gcc compat workaround! */
141 #include "tclxtend.h"
144 #include "tkconfig.h"
157 #define SimWidth (120 * MEGA)
158 #define SimHeight (100 * MEGA)
161 #define SimHeight 100
164 #define WORLD_X SimWidth
165 #define WORLD_Y SimHeight
166 #define HWLDX (SimWidth >>1)
167 #define HWLDY (SimHeight >>1)
168 #define QWX (SimWidth >>2)
169 #define QWY (SimHeight >>2)
170 #define SmX (SimWidth >>3)
171 #define SmY ((SimHeight + 7) >>3)
173 #define EDITOR_W (WORLD_X * 16)
174 #define EDITOR_H (WORLD_Y * 16)
175 #define MAP_W (WORLD_X * 3)
176 #define MAP_H (WORLD_Y * 3)
185 #define MISCHISTLEN 240
187 #define POWERMAPROW ((WORLD_X + 15) / 16)
190 #define POWERMAPLEN ((QUAD)(2 * POWERMAPROW * WORLD_Y))
191 #define POWERWORD(x, y) ((((QUAD)(x)) >>4) + (((QUAD)(y)) * POWERMAPROW))
193 #define POWERMAPLEN 1700 /* ??? PWRMAPSIZE */
194 #define POWERWORD(x, y) (((x) >>4) + ((y) <<3))
197 #define SETPOWERBIT(x, y) PowerMap[POWERWORD((x), (y))] |= 1 << ((x) & 15)
198 #define PWRMAPSIZE (POWERMAPROW * WORLD_Y)
199 #define PWRSTKSIZE ((WORLD_X * WORLD_Y) / 4)
201 #define ALMAP 0 /* all */
202 #define REMAP 1 /* residential */
203 #define COMAP 2 /* commercial */
204 #define INMAP 3 /* industrial */
206 #define PRMAP 4 /* power */
207 #define RDMAP 5 /* road */
209 #define PDMAP 6 /* population density */
210 #define RGMAP 7 /* rate of growth */
212 #define TDMAP 8 /* traffic density */
213 #define PLMAP 9 /* pollution */
214 #define CRMAP 10 /* crime */
215 #define LVMAP 11 /* land value */
217 #define FIMAP 12 /* fire radius */
218 #define POMAP 13 /* police radius */
219 #define DYMAP 14 /* dynamic */
223 /* These adjust frequency in Simulate() */
229 /* These are names of the 16 colors */
230 #define COLOR_WHITE 0
231 #define COLOR_YELLOW 1
232 #define COLOR_ORANGE 2
234 #define COLOR_DARKRED 4
235 #define COLOR_DARKBLUE 5
236 #define COLOR_LIGHTBLUE 6
237 #define COLOR_BROWN 7
238 #define COLOR_LIGHTGREEN 8
239 #define COLOR_DARKGREEN 9
240 #define COLOR_OLIVE 10
241 #define COLOR_LIGHTBROWN 11
242 #define COLOR_LIGHTGRAY 12
243 #define COLOR_MEDIUMGRAY 13
244 #define COLOR_DARKGRAY 14
245 #define COLOR_BLACK 15
249 #define PWRBIT 32768 /*20 bit 15 */
250 #define CONDBIT 16384 /*10 bit 14 */
251 #define BURNBIT 8192 /*8 bit 13 */
252 #define BULLBIT 4096 /*4 bit 12 */
253 #define ANIMBIT 2048 /*2 bit 11 */
254 #define ZONEBIT 1024 /*1 bit 10 */
255 #define ALLBITS 64512 /* mask for upper 6 bits */
256 #define LOMASK 1023 /* mask for low 10 bits */
258 #define BLBNBIT (BULLBIT+BURNBIT)
259 #define BLBNCNBIT (BULLBIT+BURNBIT+CONDBIT)
260 #define BNCNBIT (BURNBIT+CONDBIT)
262 /* Object & Sound Numbers */
273 /* Max # of Objects */
277 /* Graph Histories */
283 #define POLLUTION_HIST 5
285 #define ALL_HISTORIES ((1 <<HISTORIES) - 1)
287 /* Character Mapping */
293 #define FIRSTRIVEDGE 5
294 #define LASTRIVEDGE 20
298 #define UNUSED_TRASH1 38
299 #define UNUSED_TRASH2 39
305 #define LASTRUBBLE 47
309 #define UNUSED_TRASH3 53
310 #define UNUSED_TRASH4 54
311 #define UNUSED_TRASH5 55
319 #define INTERSECTION 76
320 #define HROADPOWER 77
321 #define VROADPOWER 78
334 #define POWERBASE 208
339 #define RAILHPOWERV 221
340 #define RAILVPOWERH 222
341 #define LASTPOWER 222
342 #define UNUSED_TRASH6 223
348 #define HRAILROAD 237
349 #define VRAILROAD 238
351 #define ROADVPOWERH 239 /* bogus? */
379 #define AIRPORTBASE 709
383 #define POWERPLANT 750
384 #define LASTPOWERPLANT 760
385 #define FIRESTBASE 761
386 #define FIRESTATION 765
387 #define POLICESTBASE 770
388 #define POLICESTATION 774
389 #define STADIUMBASE 779
391 #define FULLSTADIUM 800
392 #define NUCLEARBASE 811
395 #define LIGHTNINGBOLT 827
412 #define SMOKEBASE 852
414 #define SOMETINYEXP 864
415 #define LASTTINYEXP 867
416 #define COALSMOKE1 916
417 #define COALSMOKE2 920
418 #define COALSMOKE3 924
419 #define COALSMOKE4 928
420 #define FOOTBALLGAME1 932
421 #define FOOTBALLGAME2 940
427 #define TILE_COUNT 960
430 * These describe the wand values, the object dragged around on the screen.
433 #define residentialState 0
434 #define commercialState 1
435 #define industrialState 2
438 #define policeState 5
443 #define chalkState 10
444 #define eraserState 11
445 #define stadiumState 12
447 #define seaportState 14
448 #define powerState 15
449 #define nuclearState 16
450 #define airportState 17
451 #define networkState 18
454 #define firstState residentialState
455 #define lastState networkState
458 #define specialState 16
459 #define monsterGoalState 17
460 #define helicopterGoalState 18
461 #define blackState 19
462 #define whiteState 20
464 #define orangeState 23
466 #define greenState 25
467 #define brownState 26
472 #define STATE_TILES 1
473 #define STATE_OVERLAYS 2
474 #define STATE_GRAPHS 3
477 extern short *Map
[WORLD_X
]; /* Main Map 120 x 100 */
478 extern Byte
*PopDensity
[HWLDX
]; /* 2X2 Maps 60 x 50 */
479 extern Byte
*TrfDensity
[HWLDX
];
480 extern Byte
*PollutionMem
[HWLDX
];
481 extern Byte
*LandValueMem
[HWLDX
];
482 extern Byte
*CrimeMem
[HWLDX
];
483 extern Byte
*tem
[HWLDX
];
484 extern Byte
*tem2
[HWLDX
];
485 extern Byte
*TerrainMem
[QWX
]; /* 4X4 Maps 30 x 25 */
486 extern Byte
*Qtem
[QWX
];
487 extern short RateOGMem
[SmX
][SmY
];
488 extern short FireStMap
[SmX
][SmY
]; /* 8X8 Maps 15 x 13 */
489 extern short PoliceMap
[SmX
][SmY
];
490 extern short PoliceMapEffect
[SmX
][SmY
];
491 extern short ComRate
[SmX
][SmY
];
492 extern short FireRate
[SmX
][SmY
];
493 extern short STem
[SmX
][SmY
];
494 extern short SpriteXOffset
[OBJN
];
495 extern short SpriteYOffset
[OBJN
];
496 extern short SMapX
, SMapY
;
497 extern short CChr
, CChr9
;
498 extern short RoadTotal
, RailTotal
, FirePop
;
499 extern short ResPop
, ComPop
, IndPop
, TotalPop
, LastTotalPop
;
500 extern short ResZPop
, ComZPop
, IndZPop
, TotalZPop
;
501 extern short HospPop
, ChurchPop
, StadiumPop
;
502 extern short PolicePop
, FireStPop
;
503 extern short CoalPop
, NuclearPop
, PortPop
, APortPop
;
504 extern short NeedHosp
, NeedChurch
;
505 extern short CrimeAverage
, PolluteAverage
, LVAverage
;
506 extern char *MicropolisVersion
;
507 extern char *CityName
;
508 extern char *CityFileName
;
509 extern char *StartupName
;
510 extern short StartingYear
;
511 extern QUAD CityTime
;
512 extern QUAD LastCityTime
;
513 extern QUAD LastCityMonth
;
514 extern QUAD LastCityYear
;
515 extern QUAD LastFunds
;
516 extern QUAD LastR
, LastC
, LastI
;
517 extern short GameLevel
;
519 extern short ScenarioID
;
520 extern short ShakeNow
;
521 extern QUAD DonDither
;
522 extern int DoOverlay
;
524 extern short *ResHis
, ResHisMax
;
525 extern short *ComHis
, ComHisMax
;
526 extern short *IndHis
, IndHisMax
;
527 extern short *MoneyHis
, *CrimeHis
, *PollutionHis
, *MiscHis
;
528 extern short *PowerMap
;
530 extern float roadPercent
, policePercent
, firePercent
;
531 extern QUAD RoadSpend
, PoliceSpend
, FireSpend
;
532 extern QUAD roadMaxValue
, policeMaxValue
, fireMaxValue
;
533 extern QUAD TaxFund
, RoadFund
, PoliceFund
, FireFund
;
534 extern short RoadEffect
, PoliceEffect
, FireEffect
;
535 extern short TaxFlag
, CityTax
;
536 extern QUAD TotalFunds
;
538 extern QUAD costOf
[];
540 extern short flagBlink
;
541 extern unsigned char tileSynch
;
542 extern short aniTile
[];
543 extern unsigned char aniSynch
[];
544 extern int TilesAnimated
;
545 extern int DoAnimation
;
546 extern int DoMessages
;
547 extern int DoNotices
;
548 extern unsigned char ColorIntensities
[];
550 extern short MesX
, MesY
;
551 extern short MesNum
, MessagePort
;
552 extern QUAD LastMesTime
;
554 extern short SimSpeed
;
555 extern short SimMetaSpeed
;
556 extern short NoDisasters
;
557 extern short autoBulldoze
;
558 extern short autoBudget
;
560 extern short UserSoundOn
;
562 extern short DisasterEvent
;
563 extern short DisasterWait
;
565 extern short ResCap
, ComCap
, IndCap
;
566 extern short RValve
, CValve
, IValve
;
567 extern short PwrdZCnt
;
568 extern short unPwrdZCnt
;
570 extern char *HomeDir
, *ResourceDir
, *HostName
;
572 extern short Graph10Max
, Graph120Max
;
573 extern short Res2HisMax
, Com2HisMax
, Ind2HisMax
;
574 extern unsigned char *History10
[HISTORIES
], *History120
[HISTORIES
];
575 extern short CityScore
;
576 extern short deltaCityScore
;
577 extern short ScoreType
;
578 extern short ScoreWait
;
579 extern short CityClass
;
580 extern short PolMaxX
, PolMaxY
;
581 extern int PowerStackNum
;
582 extern short TrafficAverage
;
583 extern short PosStackN
;
584 extern short SMapXStack
[], SMapYStack
[];
585 extern short Zsource
;
586 extern short HaveLastMessage
;
587 extern short PdestX
, PdestY
;
588 extern short CdestX
, CdestY
;
590 extern short CopFltCnt
;
592 extern short GdestX
, GdestY
;
593 extern short GorgX
, GorgY
;
594 extern short GodControl
;
595 extern short CopControl
;
596 extern short CdestX
, CdestY
;
597 extern short TrafMaxX
, TrafMaxY
;
598 extern short CrimeMaxX
, CrimeMaxY
;
599 extern short FloodX
, FloodY
;
600 extern short CrashX
, CrashY
;
601 extern short CCx
, CCy
;
602 extern QUAD CityPop
, deltaCityPop
;
603 extern char *cityClassStr
[6];
604 extern short CityYes
, CityNo
;
605 extern short ProblemTable
[PROBNUM
];
606 extern short ProblemVotes
[PROBNUM
];
607 extern short ProblemOrder
[4];
608 extern QUAD CityAssValue
;
610 extern short InitSimLoad
;
611 extern short DoInitialEval
;
613 extern int StartupGameLevel
;
614 extern int PerformanceTiming
;
615 extern double FlushTime
;
619 extern struct timeval start_time
, now_time
, beat_time
, last_now_time
;
622 extern int MultiPlayerMode
;
623 extern int SugarMode
;
624 extern int sim_delay
;
625 extern int sim_skips
;
627 extern int sim_paused
;
628 extern int sim_paused_speed
;
631 extern int sim_just_cam
;
633 extern int heat_steps
;
634 extern int heat_flow
;
635 extern int heat_rule
;
636 extern int UpdateDelayed
;
637 extern int DynamicData
[32];
640 extern int BobHeight
;
642 extern int Expensive
;
643 extern int PendingTool
;
646 extern int TreeLevel
;
647 extern int LakeLevel
;
648 extern int CurveLevel
;
649 extern int CreateIsland
;
650 extern short specialBase
;
651 extern short PunishCnt
;
653 extern short toolSize
[];
654 extern short toolOffset
[];
655 extern QUAD toolColors
[];
656 extern char *Displays
;
657 extern char *FirstDisplay
;
658 extern char *dateStr
[12];
661 extern short NewMapFlags
[NMAPS
];
662 extern short NewGraph
;
663 extern short ValveFlag
;
664 extern short MustUpdateFunds
;
665 extern short MustUpdateOptions
;
666 extern short CensusChanged
;
667 extern short EvalChanged
;
668 extern short MeltX
, MeltY
;
670 extern int ExitReturn
;
672 extern Tcl_Interp
*tk_mainInterp
;
673 extern Tk_Window MainWindow
;
674 extern int FlushStyle
;
675 extern int GotXError
;
677 extern short Rand(short range
);
678 extern short RandInt(void);
680 extern Sim
*MakeNewSim();
681 extern SimView
*MakeNewView();
682 extern SimSprite
*GetSprite();
683 extern SimSprite
*MakeSprite();
684 extern SimSprite
*MakeNewSprite();
686 extern int setSpeed(short speed
);
687 extern int setSkips(int skips
);
688 extern int SetGameLevel(short level
);
689 extern int SetGameLevelFunds(short level
);
691 extern struct XDisplay
*XDisplays
;