]>
git.zerfleddert.de Git - micropolis/blob - src/sim/w_sim.c
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
)
332 sprintf(interp
->result
, "%d", WORLD_X
);
337 int SimCmdWorldY(ARGS
)
343 sprintf(interp
->result
, "%d", WORLD_Y
);
348 int SimCmdHeatSteps(ARGS
)
352 if ((argc
!= 2) && (argc
!= 3)) {
357 if ((Tcl_GetInt(interp
, argv
[2], &steps
) != TCL_OK
) ||
361 heat_steps
= steps
; Kick();
364 sprintf(interp
->result
, "%d", heat_steps
);
369 int SimCmdHeatFlow(ARGS
)
373 if ((argc
!= 2) && (argc
!= 3)) {
378 if (Tcl_GetInt(interp
, argv
[2], &flow
) != TCL_OK
) {
384 sprintf(interp
->result
, "%d", heat_flow
);
389 int SimCmdHeatRule(ARGS
)
393 if ((argc
!= 2) && (argc
!= 3)) {
398 if (Tcl_GetInt(interp
, argv
[2], &rule
) != TCL_OK
) {
404 sprintf(interp
->result
, "%d", heat_rule
);
411 int SimCmdJustCam(ARGS
)
415 if ((argc
!= 2) && (argc
!= 3)) {
420 if (Tcl_GetInt(interp
, argv
[2], &cam
) != TCL_OK
) {
426 sprintf(interp
->result
, "%d", sim_just_cam
);
435 int SimCmdListenTo(ARGS
)
443 if (Tcl_GetInt(interp
, argv
[2], &port
) != TCL_OK
) {
448 sock
= udp_listen(port
);
451 sprintf(interp
->result
, "%d", sock
);
457 int SimCmdHearFrom(ARGS
)
465 if ((argv
[2][0] != 'f') ||
466 (argv
[2][1] != 'i') ||
467 (argv
[2][2] != 'l') ||
468 (argv
[2][3] != 'e') ||
469 (Tcl_GetInt(interp
, argv
[2] + 4, &sock
) != TCL_OK
)) {
483 int SimCmdFunds(ARGS
)
487 if ((argc
!= 2) && (argc
!= 3)) {
492 if ((Tcl_GetInt(interp
, argv
[2], &funds
) != TCL_OK
) ||
501 sprintf(interp
->result
, "%ld", TotalFunds
);
506 int SimCmdTaxRate(ARGS
)
510 if ((argc
!= 2) && (argc
!= 3)) {
515 if ((Tcl_GetInt(interp
, argv
[2], &tax
) != TCL_OK
) ||
516 (tax
< 0) || (tax
> 20)) {
520 drawBudgetWindow(); Kick();
523 sprintf(interp
->result
, "%d", CityTax
);
528 int SimCmdFireFund(ARGS
)
532 if ((argc
!= 2) && (argc
!= 3)) {
537 if ((Tcl_GetInt(interp
, argv
[2], &percent
) != TCL_OK
) ||
538 (percent
< 0) || (percent
> 100)) {
541 firePercent
= percent
/ 100.0;
542 FireSpend
= (fireMaxValue
* percent
) / 100;
543 UpdateFundEffects(); Kick();
546 sprintf(interp
->result
, "%d", (int)(firePercent
* 100.0));
551 int SimCmdPoliceFund(ARGS
)
555 if ((argc
!= 2) && (argc
!= 3)) {
560 if ((Tcl_GetInt(interp
, argv
[2], &percent
) != TCL_OK
) ||
561 (percent
< 0) || (percent
> 100)) {
564 policePercent
= percent
/ 100.0;
565 PoliceSpend
= (policeMaxValue
* percent
) / 100;
566 UpdateFundEffects(); Kick();
569 sprintf(interp
->result
, "%d", (int)(policePercent
* 100.0));
574 int SimCmdRoadFund(ARGS
)
578 if ((argc
!= 2) && (argc
!= 3)) {
583 if ((Tcl_GetInt(interp
, argv
[2], &percent
) != TCL_OK
) ||
584 (percent
< 0) || (percent
> 100)) {
587 roadPercent
= percent
/ 100.0;
588 RoadSpend
= (roadMaxValue
* percent
) / 100;
589 UpdateFundEffects(); Kick();
592 sprintf(interp
->result
, "%d", (int)(roadPercent
* 100.0));
601 if ((argc
!= 2) && (argc
!= 3)) {
606 if ((Tcl_GetInt(interp
, argv
[2], &year
) != TCL_OK
)) {
612 sprintf(interp
->result
, "%d", CurrentYear());
617 int SimCmdAutoBudget(ARGS
)
621 if ((argc
!= 2) && (argc
!= 3)) {
626 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
627 (val
< 0) || (val
> 1)) {
631 MustUpdateOptions
= 1; Kick();
635 sprintf(interp
->result
, "%d", autoBudget
);
640 int SimCmdAutoGoto(ARGS
)
644 if ((argc
!= 2) && (argc
!= 3)) {
649 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
650 (val
< 0) || (val
> 1)) {
654 MustUpdateOptions
= 1; Kick();
657 sprintf(interp
->result
, "%d", autoGo
);
662 int SimCmdAutoBulldoze(ARGS
)
666 if ((argc
!= 2) && (argc
!= 3)) {
671 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
672 (val
< 0) || (val
> 1)) {
676 MustUpdateOptions
= 1; Kick();
679 sprintf(interp
->result
, "%d", autoBulldoze
);
684 int SimCmdDisasters(ARGS
)
688 if ((argc
!= 2) && (argc
!= 3)) {
693 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
694 (val
< 0) || (val
> 1)) {
697 NoDisasters
= val
? 0 : 1;
698 MustUpdateOptions
= 1; Kick();
701 sprintf(interp
->result
, "%d", NoDisasters
? 0 : 1);
706 int SimCmdSound(ARGS
)
710 if ((argc
!= 2) && (argc
!= 3)) {
715 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
716 (val
< 0) || (val
> 1)) {
720 MustUpdateOptions
= 1; Kick();
723 sprintf(interp
->result
, "%d", UserSoundOn
);
728 int SimCmdFlush(ARGS
)
738 int SimCmdFlushStyle(ARGS
)
742 if ((argc
!= 2) && (argc
!= 3)) {
747 if ((Tcl_GetInt(interp
, argv
[2], &style
) != TCL_OK
) ||
754 sprintf(interp
->result
, "%d", FlushStyle
);
759 int SimCmdDonDither(ARGS
)
763 if ((argc
!= 2) && (argc
!= 3)) {
768 if ((Tcl_GetInt(interp
, argv
[2], &dd
) != TCL_OK
) ||
775 sprintf(interp
->result
, "%ld", DonDither
);
780 int SimCmdDoOverlay(ARGS
)
784 if ((argc
!= 2) && (argc
!= 3)) {
789 if ((Tcl_GetInt(interp
, argv
[2], &dd
) != TCL_OK
) ||
796 sprintf(interp
->result
, "%d", DoOverlay
);
801 int SimCmdMonsterGoal(ARGS
)
810 if (Tcl_GetInt(interp
, argv
[2], &x
) != TCL_OK
) {
813 if (Tcl_GetInt(interp
, argv
[3], &y
) != TCL_OK
) {
816 if ((sprite
= GetSprite(GOD
)) == NULL
) {
818 if ((sprite
= GetSprite(GOD
)) == NULL
)
823 sprite
->control
= -2;
830 int SimCmdHelicopterGoal(ARGS
)
839 if (Tcl_GetInt(interp
, argv
[2], &x
) != TCL_OK
) {
842 if (Tcl_GetInt(interp
, argv
[3], &y
) != TCL_OK
) {
846 if ((sprite
= GetSprite(COP
)) == NULL
) {
847 GenerateCopter(x
, y
);
848 if ((sprite
= GetSprite(COP
)) == NULL
) {
859 int SimCmdMonsterDirection(ARGS
)
868 if ((Tcl_GetInt(interp
, argv
[2], &dir
) != TCL_OK
) ||
869 (dir
< -1) || (dir
> 7)) {
872 if ((sprite
= GetSprite(GOD
)) == NULL
) {
874 if ((sprite
= GetSprite(GOD
)) == NULL
) {
878 sprite
->control
= dir
;
888 if ((argc
!= 4) && (argc
!= 5)) {
891 if ((Tcl_GetInt(interp
, argv
[2], &x
) != TCL_OK
) ||
894 (Tcl_GetInt(interp
, argv
[3], &y
) != TCL_OK
) ||
900 if (Tcl_GetInt(interp
, argv
[4], &tile
) != TCL_OK
) {
905 sprintf(interp
->result
, "%d", Map
[x
][y
]);
917 if (Tcl_GetInt(interp
, argv
[2], &tile
) != TCL_OK
) {
920 for (x
= 0; x
< WORLD_X
; x
++) {
921 for (y
= 0; y
< WORLD_Y
; y
++) {
925 sprintf(interp
->result
, "%d", tile
);
930 int SimCmdDynamicData(ARGS
)
934 if ((argc
!= 3) && (argc
!= 4)) {
938 if ((Tcl_GetInt(interp
, argv
[2], &index
) != TCL_OK
) ||
947 if (Tcl_GetInt(interp
, argv
[3], &val
) != TCL_OK
) {
950 DynamicData
[index
] = val
;
951 NewMapFlags
[DYMAP
] = 1;
955 sprintf(interp
->result
, "%d", DynamicData
[index
]);
960 int SimCmdResetDynamic(ARGS
)
964 for (i
= 0; i
< 16; i
++) {
965 DynamicData
[i
] = (i
& 1) ? 99999 : -99999;
967 NewMapFlags
[DYMAP
] = 1;
973 int SimCmdPerformance(ARGS
)
977 PerformanceTiming
= 1;
979 for (view
= sim
->editor
; view
!= NULL
; view
= view
->next
) {
981 view
->update_real
= view
->update_user
= view
->update_system
= 0.0;
987 int SimCmdCollapseMotion(ARGS
)
991 if ((argc
!= 2) && (argc
!= 3)) {
996 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
999 tkCollapseMotion
= val
;
1002 sprintf(interp
->result
, "%d", tkCollapseMotion
);
1007 int SimCmdUpdate(ARGS
)
1014 int SimCmdLandValue(ARGS
)
1020 sprintf(interp
->result
, "%d", LVAverage
);
1025 int SimCmdTraffic(ARGS
)
1031 sprintf(interp
->result
, "%d", AverageTrf());
1036 int SimCmdCrime(ARGS
)
1042 sprintf(interp
->result
, "%d", CrimeAverage
);
1047 int SimCmdUnemployment(ARGS
)
1053 sprintf(interp
->result
, "%d", GetUnemployment());
1058 int SimCmdFires(ARGS
)
1064 sprintf(interp
->result
, "%d", GetFire());
1069 int SimCmdPollution(ARGS
)
1075 sprintf(interp
->result
, "%d", PolluteAverage
);
1080 int SimCmdPolMaxX(ARGS
)
1086 sprintf(interp
->result
, "%d", (PolMaxX
<<4) + 8);
1091 int SimCmdPolMaxY(ARGS
)
1097 sprintf(interp
->result
, "%d", (PolMaxY
<<4) + 8);
1102 int SimCmdTrafMaxX(ARGS
)
1108 sprintf(interp
->result
, "%d", TrafMaxX
);
1113 int SimCmdTrafMaxY(ARGS
)
1119 sprintf(interp
->result
, "%d", TrafMaxY
);
1124 int SimCmdMeltX(ARGS
)
1130 sprintf(interp
->result
, "%d", (MeltX
<<4) + 8);
1135 int SimCmdMeltY(ARGS
)
1141 sprintf(interp
->result
, "%d", (MeltY
<<4) + 8);
1146 int SimCmdCrimeMaxX(ARGS
)
1152 sprintf(interp
->result
, "%d", (CrimeMaxX
<<4) + 8);
1157 int SimCmdCrimeMaxY(ARGS
)
1163 sprintf(interp
->result
, "%d", (CrimeMaxY
<<4) + 8);
1168 int SimCmdCenterX(ARGS
)
1174 sprintf(interp
->result
, "%d", (CCx
<<4) + 8);
1179 int SimCmdCenterY(ARGS
)
1185 sprintf(interp
->result
, "%d", (CCy
<<4) + 8);
1190 int SimCmdFloodX(ARGS
)
1196 sprintf(interp
->result
, "%d", (FloodX
<<4) + 8);
1201 int SimCmdFloodY(ARGS
)
1207 sprintf(interp
->result
, "%d", (FloodY
<<4) + 8);
1212 int SimCmdCrashX(ARGS
)
1218 sprintf(interp
->result
, "%d", (CrashX
<<4) + 8);
1223 int SimCmdCrashY(ARGS
)
1229 sprintf(interp
->result
, "%d", (CrashY
<<4) + 8);
1234 int SimCmdDollars(ARGS
)
1240 makeDollarDecimalStr(argv
[1], interp
->result
);
1245 int SimCmdDoAnimation(ARGS
)
1249 if ((argc
!= 2) && (argc
!= 3)) {
1254 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1258 MustUpdateOptions
= 1; Kick();
1261 sprintf(interp
->result
, "%d", DoAnimation
);
1266 int SimCmdDoMessages(ARGS
)
1270 if ((argc
!= 2) && (argc
!= 3)) {
1275 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1279 MustUpdateOptions
= 1; Kick();
1282 sprintf(interp
->result
, "%d", DoMessages
);
1287 int SimCmdDoNotices(ARGS
)
1291 if ((argc
!= 2) && (argc
!= 3)) {
1296 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1300 MustUpdateOptions
= 1; Kick();
1303 sprintf(interp
->result
, "%d", DoNotices
);
1308 int SimCmdRand(ARGS
)
1312 if ((argc
!= 2) && (argc
!= 3)) {
1317 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1325 sprintf(interp
->result
, "%d", r
);
1330 int SimCmdPlatform(ARGS
)
1334 sprintf(interp
->result
, "msdos");
1336 sprintf(interp
->result
, "unix");
1343 int SimCmdVersion(ARGS
)
1345 strcpy(interp
->result
, MicropolisVersion
);
1351 int SimCmdOpenWebBrowser(ARGS
)
1357 (strlen(argv
[2]) > 255)) {
1362 "netscape -no-about-splash '%s' &",
1365 result
= system(buf
);
1367 sprintf(interp
->result
, "%d", result
);
1373 int SimCmdQuoteURL(ARGS
)
1378 static char *hexDigits
=
1382 (strlen(argv
[2]) > 255)) {
1389 while ((ch
= *(from
++)) != '\0') {
1400 *to
++ = hexDigits
[(ch
>> 4) & 0x0f];
1401 *to
++ = hexDigits
[ch
& 0x0f];
1402 } else if (ch
== 32) {
1411 sprintf(interp
->result
, "%s", buf
);
1417 int SimCmdNeedRest(ARGS
)
1421 if ((argc
!= 2) && (argc
!= 3)) {
1426 if (Tcl_GetInt(interp
, argv
[2], &needRest
) != TCL_OK
) {
1429 NeedRest
= needRest
;
1432 sprintf(interp
->result
, "%d", NeedRest
);
1437 int SimCmdMultiPlayerMode(ARGS
)
1439 /* This is read-only because it's specified on
1440 the command line and effects how the user
1441 interface is initialized. */
1447 sprintf(interp
->result
, "%d", MultiPlayerMode
);
1452 int SimCmdSugarMode(ARGS
)
1454 /* This is read-only because it's specified on
1455 the command line and effects how the user
1456 interface is initialized. */
1462 sprintf(interp
->result
, "%d", SugarMode
);
1466 int SimCmdHasAirCrash(ARGS
)
1478 sprintf(interp
->result
, "%d", aircrash
);
1483 /************************************************************************/
1489 int result
= TCL_OK
;
1496 if ((ent
= Tcl_FindHashEntry(&SimCmds
, argv
[1]))) {
1497 cmd
= (int (*)())ent
->clientData
;
1498 result
= cmd(interp
, argc
, argv
);
1507 sim_command_init(void)
1509 Tcl_CreateCommand(tk_mainInterp
, "sim", SimCmd
,
1510 (ClientData
)MainWindow
, (void (*)()) NULL
);
1512 Tcl_InitHashTable(&SimCmds
, TCL_STRING_KEYS
);
1514 #define SIM_CMD(name) HASHED_CMD(Sim, name)
1516 SIM_CMD(GameStarted
);
1519 SIM_CMD(ReallyQuit
);
1520 SIM_CMD(UpdateHeads
);
1521 SIM_CMD(UpdateMaps
);
1522 SIM_CMD(RedrawEditors
);
1523 SIM_CMD(RedrawMaps
);
1524 SIM_CMD(UpdateEditors
);
1525 SIM_CMD(UpdateGraphs
);
1526 SIM_CMD(UpdateEvaluation
);
1527 SIM_CMD(UpdateBudget
);
1528 SIM_CMD(UpdateBudgetWindow
);
1530 SIM_CMD(DoBudgetFromMenu
);
1533 SIM_CMD(StartBulldozer
);
1534 SIM_CMD(StopBulldozer
);
1537 SIM_CMD(MakeAirCrash
);
1538 SIM_CMD(MakeTornado
);
1539 SIM_CMD(MakeEarthquake
);
1540 SIM_CMD(MakeMonster
);
1541 SIM_CMD(MakeMeltdown
);
1544 SIM_CMD(GenerateNewCity
);
1545 SIM_CMD(GenerateSomeCity
);
1548 SIM_CMD(CurveLevel
);
1549 SIM_CMD(CreateIsland
);
1551 SIM_CMD(ClearUnnatural
);
1552 SIM_CMD(SmoothTrees
);
1553 SIM_CMD(SmoothWater
);
1554 SIM_CMD(SmoothRiver
);
1555 SIM_CMD(LoadScenario
);
1557 SIM_CMD(SaveCityAs
);
1558 SIM_CMD(MakeExplosion
);
1560 SIM_CMD(CityFileName
);
1581 SIM_CMD(PoliceFund
);
1584 SIM_CMD(AutoBudget
);
1586 SIM_CMD(AutoBulldoze
);
1590 SIM_CMD(FlushStyle
);
1593 SIM_CMD(MonsterGoal
);
1594 SIM_CMD(HelicopterGoal
);
1595 SIM_CMD(MonsterDirection
);
1596 SIM_CMD(EraseOverlay
);
1599 SIM_CMD(DynamicData
);
1600 SIM_CMD(ResetDynamic
);
1601 SIM_CMD(Performance
);
1602 SIM_CMD(CollapseMotion
);
1609 SIM_CMD(PendingTool
);
1616 SIM_CMD(Unemployment
);
1634 SIM_CMD(DoAnimation
);
1635 SIM_CMD(DoMessages
);
1640 SIM_CMD(OpenWebBrowser
);
1643 SIM_CMD(MultiPlayerMode
);
1645 SIM_CMD(HasAirCrash
);