]>
git.zerfleddert.de Git - micropolis/blob - src/sim/w_sim.c
c256e1e866fcaaf38d2e8391c699ba959bedf9bf
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
65 Tcl_HashTable SimCmds
;
68 #define SIMCMD_CALL(proc) \
69 int SimCmd##proc(ARGS) { proc(); return (TCL_OK); }
71 #define SIMCMD_CALL_KICK(proc) \
72 int SimCmd##proc(ARGS) { proc(); Kick(); return (TCL_OK); }
74 #define SIMCMD_CALL_INT(proc) \
75 int SimCmd##proc(ARGS) { \
77 if (argc != 3) return (TCL_ERROR); \
78 if ((Tcl_GetInt(interp, argv[2], &val) != TCL_OK)) return (TCL_ERROR); \
83 #define SIMCMD_CALL_STR(proc) \
84 int SimCmd##proc(ARGS) { \
85 if (argc != 3) return (TCL_ERROR); \
90 #define SIMCMD_CALL_TILEXY(proc) \
91 int SimCmd##proc(ARGS) { \
93 if (argc != 4) return (TCL_ERROR); \
94 if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) || \
95 (x < 0) || (x >= WORLD_X)) return (TCL_ERROR); \
96 if ((Tcl_GetInt(interp, argv[3], &y) != TCL_OK) || \
97 (y < 0) || (y >= WORLD_Y)) return (TCL_ERROR); \
102 #define SIMCMD_ACCESS_INT(var) \
103 int SimCmd##var(ARGS) { \
105 if ((argc != 2) && (argc != 3)) return (TCL_ERROR); \
107 if (Tcl_GetInt(interp, argv[2], &val) != TCL_OK) return (TCL_ERROR); \
110 sprintf(interp->result, "%d", var); \
114 #define SIMCMD_GET_INT(var) \
115 int SimCmd##var(ARGS) { \
116 sprintf(interp->result, "%d", var); \
120 #define SIMCMD_GET_STR(var) \
121 int SimCmd##var(ARGS) { \
122 sprintf(interp->result, "%s", var); \
127 SIMCMD_CALL_KICK(GameStarted
)
128 SIMCMD_CALL_KICK(InitGame
)
129 SIMCMD_CALL(SaveCity
)
130 SIMCMD_CALL(ReallyQuit
)
131 SIMCMD_CALL_KICK(UpdateHeads
)
132 SIMCMD_CALL_KICK(UpdateMaps
)
133 SIMCMD_CALL_KICK(UpdateEditors
)
134 SIMCMD_CALL_KICK(RedrawMaps
)
135 SIMCMD_CALL_KICK(RedrawEditors
)
136 SIMCMD_CALL_KICK(UpdateGraphs
)
137 SIMCMD_CALL_KICK(UpdateEvaluation
)
138 SIMCMD_CALL_KICK(UpdateBudget
)
139 SIMCMD_CALL_KICK(UpdateBudgetWindow
)
140 SIMCMD_CALL_KICK(DoBudget
)
141 SIMCMD_CALL_KICK(DoBudgetFromMenu
)
142 SIMCMD_CALL_KICK(Pause
)
143 SIMCMD_CALL_KICK(Resume
)
144 SIMCMD_CALL(StartBulldozer
)
145 SIMCMD_CALL(StopBulldozer
)
146 SIMCMD_CALL(MakeFire
)
147 SIMCMD_CALL(MakeFlood
)
148 SIMCMD_CALL(MakeAirCrash
)
149 SIMCMD_CALL(MakeTornado
)
150 SIMCMD_CALL(MakeEarthquake
)
151 SIMCMD_CALL(MakeMonster
)
152 SIMCMD_CALL(MakeMeltdown
)
153 SIMCMD_CALL(FireBomb
)
154 SIMCMD_CALL(SoundOff
)
155 SIMCMD_CALL(GenerateNewCity
)
156 SIMCMD_CALL_INT(GenerateSomeCity
)
157 SIMCMD_ACCESS_INT(LakeLevel
)
158 SIMCMD_ACCESS_INT(TreeLevel
)
159 SIMCMD_ACCESS_INT(CurveLevel
)
160 SIMCMD_ACCESS_INT(CreateIsland
)
161 SIMCMD_CALL_KICK(SmoothTrees
)
162 SIMCMD_CALL_KICK(SmoothWater
)
163 SIMCMD_CALL_KICK(SmoothRiver
)
164 SIMCMD_CALL_KICK(ClearMap
)
165 SIMCMD_CALL_KICK(ClearUnnatural
)
166 SIMCMD_CALL_INT(LoadScenario
)
167 SIMCMD_CALL_STR(LoadCity
)
168 SIMCMD_CALL_STR(SaveCityAs
)
169 SIMCMD_CALL_TILEXY(MakeExplosion
)
170 SIMCMD_CALL(EraseOverlay
)
171 SIMCMD_ACCESS_INT(OverRide
)
172 SIMCMD_ACCESS_INT(Expensive
)
173 SIMCMD_ACCESS_INT(Players
)
174 SIMCMD_ACCESS_INT(Votes
)
175 SIMCMD_ACCESS_INT(BobHeight
)
176 SIMCMD_ACCESS_INT(PendingTool
)
177 SIMCMD_ACCESS_INT(PendingX
)
178 SIMCMD_ACCESS_INT(PendingY
)
179 SIMCMD_GET_STR(Displays
)
182 int SimCmdCityName(ARGS
)
184 if ((argc
!= 2) && (argc
!= 3)) {
189 setCityName(argv
[2]);
192 sprintf(interp
->result
, "%s", CityName
);
197 int SimCmdCityFileName(ARGS
)
199 if ((argc
!= 2) && (argc
!= 3)) {
204 if (CityFileName
!= NULL
) {
205 ckfree(CityFileName
);
208 if (argv
[2][0] != '\0') {
209 CityFileName
= (char *)ckalloc(strlen(argv
[0]) + 1);
210 strcpy(CityFileName
, argv
[2]);
214 sprintf(interp
->result
, "%s", CityFileName
? CityFileName
: "");
219 int SimCmdGameLevel(ARGS
)
223 if ((argc
!= 2) && (argc
!= 3)) {
228 if ((Tcl_GetInt(interp
, argv
[2], &level
) != TCL_OK
) ||
229 (level
< 0) || (level
> 2)) {
232 SetGameLevelFunds(level
);
235 sprintf(interp
->result
, "%d", GameLevel
);
240 int SimCmdSpeed(ARGS
)
244 if ((argc
!= 2) && (argc
!= 3)) {
249 if ((Tcl_GetInt(interp
, argv
[2], &speed
) != TCL_OK
) ||
250 (speed
< 0) || (speed
> 7)) {
253 setSpeed(speed
); Kick();
256 sprintf(interp
->result
, "%d", SimSpeed
);
261 int SimCmdSkips(ARGS
)
265 if ((argc
!= 2) && (argc
!= 3)) {
270 if ((Tcl_GetInt(interp
, argv
[2], &skips
) != TCL_OK
) ||
274 setSkips(skips
); Kick();
277 sprintf(interp
->result
, "%d", sim_skips
);
287 if ((argc
!= 2) && (argc
!= 3)) {
292 if ((Tcl_GetInt(interp
, argv
[2], &skip
) != TCL_OK
) ||
299 sprintf(interp
->result
, "%d", sim_skip
);
305 int SimCmdDelay(ARGS
)
309 if ((argc
!= 2) && (argc
!= 3)) {
314 if ((Tcl_GetInt(interp
, argv
[2], &delay
) != TCL_OK
) ||
318 sim_delay
= delay
; Kick();
321 sprintf(interp
->result
, "%d", sim_delay
);
326 int SimCmdWorldX(ARGS
)
334 sprintf(interp
->result
, "%d", WORLD_X
);
339 int SimCmdWorldY(ARGS
)
347 sprintf(interp
->result
, "%d", WORLD_Y
);
352 int SimCmdHeatSteps(ARGS
)
356 if ((argc
!= 2) && (argc
!= 3)) {
361 if ((Tcl_GetInt(interp
, argv
[2], &steps
) != TCL_OK
) ||
365 heat_steps
= steps
; Kick();
368 sprintf(interp
->result
, "%d", heat_steps
);
373 int SimCmdHeatFlow(ARGS
)
377 if ((argc
!= 2) && (argc
!= 3)) {
382 if (Tcl_GetInt(interp
, argv
[2], &flow
) != TCL_OK
) {
388 sprintf(interp
->result
, "%d", heat_flow
);
393 int SimCmdHeatRule(ARGS
)
397 if ((argc
!= 2) && (argc
!= 3)) {
402 if (Tcl_GetInt(interp
, argv
[2], &rule
) != TCL_OK
) {
408 sprintf(interp
->result
, "%d", heat_rule
);
415 int SimCmdJustCam(ARGS
)
419 if ((argc
!= 2) && (argc
!= 3)) {
424 if (Tcl_GetInt(interp
, argv
[2], &cam
) != TCL_OK
) {
430 sprintf(interp
->result
, "%d", sim_just_cam
);
439 int SimCmdListenTo(ARGS
)
447 if (Tcl_GetInt(interp
, argv
[2], &port
) != TCL_OK
) {
452 sock
= udp_listen(port
);
455 sprintf(interp
->result
, "%d", sock
);
461 int SimCmdHearFrom(ARGS
)
469 if ((argv
[2][0] != 'f') ||
470 (argv
[2][1] != 'i') ||
471 (argv
[2][2] != 'l') ||
472 (argv
[2][3] != 'e') ||
473 (Tcl_GetInt(interp
, argv
[2] + 4, &sock
) != TCL_OK
)) {
487 int SimCmdFunds(ARGS
)
491 if ((argc
!= 2) && (argc
!= 3)) {
496 if ((Tcl_GetInt(interp
, argv
[2], &funds
) != TCL_OK
) ||
505 sprintf(interp
->result
, "%d", TotalFunds
);
510 int SimCmdTaxRate(ARGS
)
514 if ((argc
!= 2) && (argc
!= 3)) {
519 if ((Tcl_GetInt(interp
, argv
[2], &tax
) != TCL_OK
) ||
520 (tax
< 0) || (tax
> 20)) {
524 drawBudgetWindow(); Kick();
527 sprintf(interp
->result
, "%d", CityTax
);
532 int SimCmdFireFund(ARGS
)
536 if ((argc
!= 2) && (argc
!= 3)) {
541 if ((Tcl_GetInt(interp
, argv
[2], &percent
) != TCL_OK
) ||
542 (percent
< 0) || (percent
> 100)) {
545 firePercent
= percent
/ 100.0;
546 FireSpend
= (fireMaxValue
* percent
) / 100;
547 UpdateFundEffects(); Kick();
550 sprintf(interp
->result
, "%d", (int)(firePercent
* 100.0));
555 int SimCmdPoliceFund(ARGS
)
559 if ((argc
!= 2) && (argc
!= 3)) {
564 if ((Tcl_GetInt(interp
, argv
[2], &percent
) != TCL_OK
) ||
565 (percent
< 0) || (percent
> 100)) {
568 policePercent
= percent
/ 100.0;
569 PoliceSpend
= (policeMaxValue
* percent
) / 100;
570 UpdateFundEffects(); Kick();
573 sprintf(interp
->result
, "%d", (int)(policePercent
* 100.0));
578 int SimCmdRoadFund(ARGS
)
582 if ((argc
!= 2) && (argc
!= 3)) {
587 if ((Tcl_GetInt(interp
, argv
[2], &percent
) != TCL_OK
) ||
588 (percent
< 0) || (percent
> 100)) {
591 roadPercent
= percent
/ 100.0;
592 RoadSpend
= (roadMaxValue
* percent
) / 100;
593 UpdateFundEffects(); Kick();
596 sprintf(interp
->result
, "%d", (int)(roadPercent
* 100.0));
605 if ((argc
!= 2) && (argc
!= 3)) {
610 if ((Tcl_GetInt(interp
, argv
[2], &year
) != TCL_OK
)) {
616 sprintf(interp
->result
, "%d", CurrentYear());
621 int SimCmdAutoBudget(ARGS
)
625 if ((argc
!= 2) && (argc
!= 3)) {
630 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
631 (val
< 0) || (val
> 1)) {
635 MustUpdateOptions
= 1; Kick();
639 sprintf(interp
->result
, "%d", autoBudget
);
644 int SimCmdAutoGoto(ARGS
)
648 if ((argc
!= 2) && (argc
!= 3)) {
653 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
654 (val
< 0) || (val
> 1)) {
658 MustUpdateOptions
= 1; Kick();
661 sprintf(interp
->result
, "%d", autoGo
);
666 int SimCmdAutoBulldoze(ARGS
)
670 if ((argc
!= 2) && (argc
!= 3)) {
675 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
676 (val
< 0) || (val
> 1)) {
680 MustUpdateOptions
= 1; Kick();
683 sprintf(interp
->result
, "%d", autoBulldoze
);
688 int SimCmdDisasters(ARGS
)
692 if ((argc
!= 2) && (argc
!= 3)) {
697 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
698 (val
< 0) || (val
> 1)) {
701 NoDisasters
= val
? 0 : 1;
702 MustUpdateOptions
= 1; Kick();
705 sprintf(interp
->result
, "%d", NoDisasters
? 0 : 1);
710 int SimCmdSound(ARGS
)
714 if ((argc
!= 2) && (argc
!= 3)) {
719 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
720 (val
< 0) || (val
> 1)) {
724 MustUpdateOptions
= 1; Kick();
727 sprintf(interp
->result
, "%d", UserSoundOn
);
732 int SimCmdFlush(ARGS
)
744 int SimCmdFlushStyle(ARGS
)
748 if ((argc
!= 2) && (argc
!= 3)) {
753 if ((Tcl_GetInt(interp
, argv
[2], &style
) != TCL_OK
) ||
760 sprintf(interp
->result
, "%d", FlushStyle
);
765 int SimCmdDonDither(ARGS
)
769 if ((argc
!= 2) && (argc
!= 3)) {
774 if ((Tcl_GetInt(interp
, argv
[2], &dd
) != TCL_OK
) ||
781 sprintf(interp
->result
, "%d", DonDither
);
786 int SimCmdDoOverlay(ARGS
)
790 if ((argc
!= 2) && (argc
!= 3)) {
795 if ((Tcl_GetInt(interp
, argv
[2], &dd
) != TCL_OK
) ||
802 sprintf(interp
->result
, "%d", DoOverlay
);
807 int SimCmdMonsterGoal(ARGS
)
816 if (Tcl_GetInt(interp
, argv
[2], &x
) != TCL_OK
) {
819 if (Tcl_GetInt(interp
, argv
[3], &y
) != TCL_OK
) {
822 if ((sprite
= GetSprite(GOD
)) == NULL
) {
824 if ((sprite
= GetSprite(GOD
)) == NULL
)
829 sprite
->control
= -2;
836 int SimCmdHelicopterGoal(ARGS
)
845 if (Tcl_GetInt(interp
, argv
[2], &x
) != TCL_OK
) {
848 if (Tcl_GetInt(interp
, argv
[3], &y
) != TCL_OK
) {
852 if ((sprite
= GetSprite(COP
)) == NULL
) {
853 GenerateCopter(x
, y
);
854 if ((sprite
= GetSprite(COP
)) == NULL
) {
865 int SimCmdMonsterDirection(ARGS
)
874 if ((Tcl_GetInt(interp
, argv
[2], &dir
) != TCL_OK
) ||
875 (dir
< -1) || (dir
> 7)) {
878 if ((sprite
= GetSprite(GOD
)) == NULL
) {
880 if ((sprite
= GetSprite(GOD
)) == NULL
) {
884 sprite
->control
= dir
;
894 if ((argc
!= 4) && (argc
!= 5)) {
897 if ((Tcl_GetInt(interp
, argv
[2], &x
) != TCL_OK
) ||
900 (Tcl_GetInt(interp
, argv
[3], &y
) != TCL_OK
) ||
906 if (Tcl_GetInt(interp
, argv
[4], &tile
) != TCL_OK
) {
911 sprintf(interp
->result
, "%d", Map
[x
][y
]);
923 if (Tcl_GetInt(interp
, argv
[2], &tile
) != TCL_OK
) {
926 for (x
= 0; x
< WORLD_X
; x
++) {
927 for (y
= 0; y
< WORLD_Y
; y
++) {
931 sprintf(interp
->result
, "%d", tile
);
936 int SimCmdDynamicData(ARGS
)
940 if ((argc
!= 3) && (argc
!= 4)) {
944 if ((Tcl_GetInt(interp
, argv
[2], &index
) != TCL_OK
) ||
953 if (Tcl_GetInt(interp
, argv
[3], &val
) != TCL_OK
) {
956 DynamicData
[index
] = val
;
957 NewMapFlags
[DYMAP
] = 1;
961 sprintf(interp
->result
, "%d", DynamicData
[index
]);
966 int SimCmdResetDynamic(ARGS
)
970 for (i
= 0; i
< 16; i
++) {
971 DynamicData
[i
] = (i
& 1) ? 99999 : -99999;
973 NewMapFlags
[DYMAP
] = 1;
979 int SimCmdPerformance(ARGS
)
983 PerformanceTiming
= 1;
985 for (view
= sim
->editor
; view
!= NULL
; view
= view
->next
) {
987 view
->update_real
= view
->update_user
= view
->update_system
= 0.0;
993 int SimCmdCollapseMotion(ARGS
)
997 if ((argc
!= 2) && (argc
!= 3)) {
1002 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1005 tkCollapseMotion
= val
;
1008 sprintf(interp
->result
, "%d", tkCollapseMotion
);
1013 int SimCmdUpdate(ARGS
)
1020 int SimCmdLandValue(ARGS
)
1028 sprintf(interp
->result
, "%d", LVAverage
);
1033 int SimCmdTraffic(ARGS
)
1041 sprintf(interp
->result
, "%d", AverageTrf());
1046 int SimCmdCrime(ARGS
)
1054 sprintf(interp
->result
, "%d", CrimeAverage
);
1059 int SimCmdUnemployment(ARGS
)
1067 sprintf(interp
->result
, "%d", GetUnemployment());
1072 int SimCmdFires(ARGS
)
1080 sprintf(interp
->result
, "%d", GetFire());
1085 int SimCmdPollution(ARGS
)
1093 sprintf(interp
->result
, "%d", PolluteAverage
);
1098 int SimCmdPolMaxX(ARGS
)
1106 sprintf(interp
->result
, "%d", (PolMaxX
<<4) + 8);
1111 int SimCmdPolMaxY(ARGS
)
1119 sprintf(interp
->result
, "%d", (PolMaxY
<<4) + 8);
1124 int SimCmdTrafMaxX(ARGS
)
1132 sprintf(interp
->result
, "%d", TrafMaxX
);
1137 int SimCmdTrafMaxY(ARGS
)
1145 sprintf(interp
->result
, "%d", TrafMaxY
);
1150 int SimCmdMeltX(ARGS
)
1158 sprintf(interp
->result
, "%d", (MeltX
<<4) + 8);
1163 int SimCmdMeltY(ARGS
)
1171 sprintf(interp
->result
, "%d", (MeltY
<<4) + 8);
1176 int SimCmdCrimeMaxX(ARGS
)
1184 sprintf(interp
->result
, "%d", (CrimeMaxX
<<4) + 8);
1189 int SimCmdCrimeMaxY(ARGS
)
1197 sprintf(interp
->result
, "%d", (CrimeMaxY
<<4) + 8);
1202 int SimCmdCenterX(ARGS
)
1210 sprintf(interp
->result
, "%d", (CCx
<<4) + 8);
1215 int SimCmdCenterY(ARGS
)
1223 sprintf(interp
->result
, "%d", (CCy
<<4) + 8);
1228 int SimCmdFloodX(ARGS
)
1236 sprintf(interp
->result
, "%d", (FloodX
<<4) + 8);
1241 int SimCmdFloodY(ARGS
)
1249 sprintf(interp
->result
, "%d", (FloodY
<<4) + 8);
1254 int SimCmdCrashX(ARGS
)
1262 sprintf(interp
->result
, "%d", (CrashX
<<4) + 8);
1267 int SimCmdCrashY(ARGS
)
1275 sprintf(interp
->result
, "%d", (CrashY
<<4) + 8);
1280 int SimCmdDollars(ARGS
)
1288 makeDollarDecimalStr(argv
[1], interp
->result
);
1293 int SimCmdDoAnimation(ARGS
)
1297 if ((argc
!= 2) && (argc
!= 3)) {
1302 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1306 MustUpdateOptions
= 1; Kick();
1309 sprintf(interp
->result
, "%d", DoAnimation
);
1314 int SimCmdDoMessages(ARGS
)
1318 if ((argc
!= 2) && (argc
!= 3)) {
1323 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1327 MustUpdateOptions
= 1; Kick();
1330 sprintf(interp
->result
, "%d", DoMessages
);
1335 int SimCmdDoNotices(ARGS
)
1339 if ((argc
!= 2) && (argc
!= 3)) {
1344 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1348 MustUpdateOptions
= 1; Kick();
1351 sprintf(interp
->result
, "%d", DoNotices
);
1356 int SimCmdRand(ARGS
)
1360 if ((argc
!= 2) && (argc
!= 3)) {
1365 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1373 sprintf(interp
->result
, "%d", r
);
1378 int SimCmdPlatform(ARGS
)
1382 sprintf(interp
->result
, "msdos");
1384 sprintf(interp
->result
, "unix");
1391 int SimCmdVersion(ARGS
)
1393 sprintf(interp
->result
, MicropolisVersion
);
1399 int SimCmdOpenWebBrowser(ARGS
)
1405 (strlen(argv
[2]) > 255)) {
1410 "netscape -no-about-splash '%s' &",
1413 result
= system(buf
);
1415 sprintf(interp
->result
, "%d", result
);
1421 int SimCmdQuoteURL(ARGS
)
1427 static char *hexDigits
=
1431 (strlen(argv
[2]) > 255)) {
1438 while ((ch
= *(from
++)) != '\0') {
1449 *to
++ = hexDigits
[(ch
>> 4) & 0x0f];
1450 *to
++ = hexDigits
[ch
& 0x0f];
1451 } else if (ch
== 32) {
1460 sprintf(interp
->result
, "%s", buf
);
1466 int SimCmdNeedRest(ARGS
)
1470 if ((argc
!= 2) && (argc
!= 3)) {
1475 if (Tcl_GetInt(interp
, argv
[2], &needRest
) != TCL_OK
) {
1478 NeedRest
= needRest
;
1481 sprintf(interp
->result
, "%d", NeedRest
);
1486 int SimCmdMultiPlayerMode(ARGS
)
1488 /* This is read-only because it's specified on
1489 the command line and effects how the user
1490 interface is initialized. */
1496 sprintf(interp
->result
, "%d", MultiPlayerMode
);
1501 int SimCmdSugarMode(ARGS
)
1503 /* This is read-only because it's specified on
1504 the command line and effects how the user
1505 interface is initialized. */
1511 sprintf(interp
->result
, "%d", SugarMode
);
1515 int SimCmdHasAirCrash(ARGS
)
1527 sprintf(interp
->result
, "%d", aircrash
);
1532 /************************************************************************/
1538 int result
= TCL_OK
;
1545 if (ent
= Tcl_FindHashEntry(&SimCmds
, argv
[1])) {
1546 cmd
= (int (*)())ent
->clientData
;
1547 result
= cmd(interp
, argc
, argv
);
1559 Tcl_CreateCommand(tk_mainInterp
, "sim", SimCmd
,
1560 (ClientData
)MainWindow
, (void (*)()) NULL
);
1562 Tcl_InitHashTable(&SimCmds
, TCL_STRING_KEYS
);
1564 #define SIM_CMD(name) HASHED_CMD(Sim, name)
1566 SIM_CMD(GameStarted
);
1569 SIM_CMD(ReallyQuit
);
1570 SIM_CMD(UpdateHeads
);
1571 SIM_CMD(UpdateMaps
);
1572 SIM_CMD(RedrawEditors
);
1573 SIM_CMD(RedrawMaps
);
1574 SIM_CMD(UpdateEditors
);
1575 SIM_CMD(UpdateGraphs
);
1576 SIM_CMD(UpdateEvaluation
);
1577 SIM_CMD(UpdateBudget
);
1578 SIM_CMD(UpdateBudgetWindow
);
1580 SIM_CMD(DoBudgetFromMenu
);
1583 SIM_CMD(StartBulldozer
);
1584 SIM_CMD(StopBulldozer
);
1587 SIM_CMD(MakeAirCrash
);
1588 SIM_CMD(MakeTornado
);
1589 SIM_CMD(MakeEarthquake
);
1590 SIM_CMD(MakeMonster
);
1591 SIM_CMD(MakeMeltdown
);
1594 SIM_CMD(GenerateNewCity
);
1595 SIM_CMD(GenerateSomeCity
);
1598 SIM_CMD(CurveLevel
);
1599 SIM_CMD(CreateIsland
);
1601 SIM_CMD(ClearUnnatural
);
1602 SIM_CMD(SmoothTrees
);
1603 SIM_CMD(SmoothWater
);
1604 SIM_CMD(SmoothRiver
);
1605 SIM_CMD(LoadScenario
);
1607 SIM_CMD(SaveCityAs
);
1608 SIM_CMD(MakeExplosion
);
1610 SIM_CMD(CityFileName
);
1631 SIM_CMD(PoliceFund
);
1634 SIM_CMD(AutoBudget
);
1636 SIM_CMD(AutoBulldoze
);
1640 SIM_CMD(FlushStyle
);
1643 SIM_CMD(MonsterGoal
);
1644 SIM_CMD(HelicopterGoal
);
1645 SIM_CMD(MonsterDirection
);
1646 SIM_CMD(EraseOverlay
);
1649 SIM_CMD(DynamicData
);
1650 SIM_CMD(ResetDynamic
);
1651 SIM_CMD(Performance
);
1652 SIM_CMD(CollapseMotion
);
1659 SIM_CMD(PendingTool
);
1666 SIM_CMD(Unemployment
);
1684 SIM_CMD(DoAnimation
);
1685 SIM_CMD(DoMessages
);
1690 SIM_CMD(OpenWebBrowser
);
1693 SIM_CMD(MultiPlayerMode
);
1695 SIM_CMD(HasAirCrash
);