]>
cvs.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(MakeTornado
)
149 SIMCMD_CALL(MakeEarthquake
)
150 SIMCMD_CALL(MakeMonster
)
151 SIMCMD_CALL(MakeMeltdown
)
152 SIMCMD_CALL(FireBomb
)
153 SIMCMD_CALL(SoundOff
)
154 SIMCMD_CALL(GenerateNewCity
)
155 SIMCMD_CALL_INT(GenerateSomeCity
)
156 SIMCMD_ACCESS_INT(LakeLevel
)
157 SIMCMD_ACCESS_INT(TreeLevel
)
158 SIMCMD_ACCESS_INT(CurveLevel
)
159 SIMCMD_ACCESS_INT(CreateIsland
)
160 SIMCMD_CALL_KICK(SmoothTrees
)
161 SIMCMD_CALL_KICK(SmoothWater
)
162 SIMCMD_CALL_KICK(SmoothRiver
)
163 SIMCMD_CALL_KICK(ClearMap
)
164 SIMCMD_CALL_KICK(ClearUnnatural
)
165 SIMCMD_CALL_INT(LoadScenario
)
166 SIMCMD_CALL_STR(LoadCity
)
167 SIMCMD_CALL_STR(SaveCityAs
)
168 SIMCMD_CALL_TILEXY(MakeExplosion
)
169 SIMCMD_CALL(EraseOverlay
)
170 SIMCMD_ACCESS_INT(OverRide
)
171 SIMCMD_ACCESS_INT(Expensive
)
172 SIMCMD_ACCESS_INT(Players
)
173 SIMCMD_ACCESS_INT(Votes
)
174 SIMCMD_ACCESS_INT(BobHeight
)
175 SIMCMD_ACCESS_INT(PendingTool
)
176 SIMCMD_ACCESS_INT(PendingX
)
177 SIMCMD_ACCESS_INT(PendingY
)
178 SIMCMD_GET_STR(Displays
)
181 int SimCmdCityName(ARGS
)
183 if ((argc
!= 2) && (argc
!= 3)) {
188 setCityName(argv
[2]);
191 sprintf(interp
->result
, "%s", CityName
);
196 int SimCmdCityFileName(ARGS
)
198 if ((argc
!= 2) && (argc
!= 3)) {
203 if (CityFileName
!= NULL
) {
204 ckfree(CityFileName
);
207 if (argv
[2][0] != '\0') {
208 CityFileName
= (char *)ckalloc(strlen(argv
[0]) + 1);
209 strcpy(CityFileName
, argv
[2]);
213 sprintf(interp
->result
, "%s", CityFileName
? CityFileName
: "");
218 int SimCmdGameLevel(ARGS
)
222 if ((argc
!= 2) && (argc
!= 3)) {
227 if ((Tcl_GetInt(interp
, argv
[2], &level
) != TCL_OK
) ||
228 (level
< 0) || (level
> 2)) {
231 SetGameLevelFunds(level
);
234 sprintf(interp
->result
, "%d", GameLevel
);
239 int SimCmdSpeed(ARGS
)
243 if ((argc
!= 2) && (argc
!= 3)) {
248 if ((Tcl_GetInt(interp
, argv
[2], &speed
) != TCL_OK
) ||
249 (speed
< 0) || (speed
> 7)) {
252 setSpeed(speed
); Kick();
255 sprintf(interp
->result
, "%d", SimSpeed
);
260 int SimCmdSkips(ARGS
)
264 if ((argc
!= 2) && (argc
!= 3)) {
269 if ((Tcl_GetInt(interp
, argv
[2], &skips
) != TCL_OK
) ||
273 setSkips(skips
); Kick();
276 sprintf(interp
->result
, "%d", sim_skips
);
286 if ((argc
!= 2) && (argc
!= 3)) {
291 if ((Tcl_GetInt(interp
, argv
[2], &skip
) != TCL_OK
) ||
298 sprintf(interp
->result
, "%d", sim_skip
);
304 int SimCmdDelay(ARGS
)
308 if ((argc
!= 2) && (argc
!= 3)) {
313 if ((Tcl_GetInt(interp
, argv
[2], &delay
) != TCL_OK
) ||
317 sim_delay
= delay
; Kick();
320 sprintf(interp
->result
, "%d", sim_delay
);
325 int SimCmdWorldX(ARGS
)
333 sprintf(interp
->result
, "%d", WORLD_X
);
338 int SimCmdWorldY(ARGS
)
346 sprintf(interp
->result
, "%d", WORLD_Y
);
351 int SimCmdHeatSteps(ARGS
)
355 if ((argc
!= 2) && (argc
!= 3)) {
360 if ((Tcl_GetInt(interp
, argv
[2], &steps
) != TCL_OK
) ||
364 heat_steps
= steps
; Kick();
367 sprintf(interp
->result
, "%d", heat_steps
);
372 int SimCmdHeatFlow(ARGS
)
376 if ((argc
!= 2) && (argc
!= 3)) {
381 if (Tcl_GetInt(interp
, argv
[2], &flow
) != TCL_OK
) {
387 sprintf(interp
->result
, "%d", heat_flow
);
392 int SimCmdHeatRule(ARGS
)
396 if ((argc
!= 2) && (argc
!= 3)) {
401 if (Tcl_GetInt(interp
, argv
[2], &rule
) != TCL_OK
) {
407 sprintf(interp
->result
, "%d", heat_rule
);
414 int SimCmdJustCam(ARGS
)
418 if ((argc
!= 2) && (argc
!= 3)) {
423 if (Tcl_GetInt(interp
, argv
[2], &cam
) != TCL_OK
) {
429 sprintf(interp
->result
, "%d", sim_just_cam
);
438 int SimCmdListenTo(ARGS
)
446 if (Tcl_GetInt(interp
, argv
[2], &port
) != TCL_OK
) {
451 sock
= udp_listen(port
);
454 sprintf(interp
->result
, "%d", sock
);
460 int SimCmdHearFrom(ARGS
)
468 if ((argv
[2][0] != 'f') ||
469 (argv
[2][1] != 'i') ||
470 (argv
[2][2] != 'l') ||
471 (argv
[2][3] != 'e') ||
472 (Tcl_GetInt(interp
, argv
[2] + 4, &sock
) != TCL_OK
)) {
486 int SimCmdFunds(ARGS
)
490 if ((argc
!= 2) && (argc
!= 3)) {
495 if ((Tcl_GetInt(interp
, argv
[2], &funds
) != TCL_OK
) ||
504 sprintf(interp
->result
, "%d", TotalFunds
);
509 int SimCmdTaxRate(ARGS
)
513 if ((argc
!= 2) && (argc
!= 3)) {
518 if ((Tcl_GetInt(interp
, argv
[2], &tax
) != TCL_OK
) ||
519 (tax
< 0) || (tax
> 20)) {
523 drawBudgetWindow(); Kick();
526 sprintf(interp
->result
, "%d", CityTax
);
531 int SimCmdFireFund(ARGS
)
535 if ((argc
!= 2) && (argc
!= 3)) {
540 if ((Tcl_GetInt(interp
, argv
[2], &percent
) != TCL_OK
) ||
541 (percent
< 0) || (percent
> 100)) {
544 firePercent
= percent
/ 100.0;
545 FireSpend
= (fireMaxValue
* percent
) / 100;
546 UpdateFundEffects(); Kick();
549 sprintf(interp
->result
, "%d", (int)(firePercent
* 100.0));
554 int SimCmdPoliceFund(ARGS
)
558 if ((argc
!= 2) && (argc
!= 3)) {
563 if ((Tcl_GetInt(interp
, argv
[2], &percent
) != TCL_OK
) ||
564 (percent
< 0) || (percent
> 100)) {
567 policePercent
= percent
/ 100.0;
568 PoliceSpend
= (policeMaxValue
* percent
) / 100;
569 UpdateFundEffects(); Kick();
572 sprintf(interp
->result
, "%d", (int)(policePercent
* 100.0));
577 int SimCmdRoadFund(ARGS
)
581 if ((argc
!= 2) && (argc
!= 3)) {
586 if ((Tcl_GetInt(interp
, argv
[2], &percent
) != TCL_OK
) ||
587 (percent
< 0) || (percent
> 100)) {
590 roadPercent
= percent
/ 100.0;
591 RoadSpend
= (roadMaxValue
* percent
) / 100;
592 UpdateFundEffects(); Kick();
595 sprintf(interp
->result
, "%d", (int)(roadPercent
* 100.0));
604 if ((argc
!= 2) && (argc
!= 3)) {
609 if ((Tcl_GetInt(interp
, argv
[2], &year
) != TCL_OK
)) {
615 sprintf(interp
->result
, "%d", CurrentYear());
620 int SimCmdAutoBudget(ARGS
)
624 if ((argc
!= 2) && (argc
!= 3)) {
629 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
630 (val
< 0) || (val
> 1)) {
634 MustUpdateOptions
= 1; Kick();
638 sprintf(interp
->result
, "%d", autoBudget
);
643 int SimCmdAutoGoto(ARGS
)
647 if ((argc
!= 2) && (argc
!= 3)) {
652 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
653 (val
< 0) || (val
> 1)) {
657 MustUpdateOptions
= 1; Kick();
660 sprintf(interp
->result
, "%d", autoGo
);
665 int SimCmdAutoBulldoze(ARGS
)
669 if ((argc
!= 2) && (argc
!= 3)) {
674 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
675 (val
< 0) || (val
> 1)) {
679 MustUpdateOptions
= 1; Kick();
682 sprintf(interp
->result
, "%d", autoBulldoze
);
687 int SimCmdDisasters(ARGS
)
691 if ((argc
!= 2) && (argc
!= 3)) {
696 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
697 (val
< 0) || (val
> 1)) {
700 NoDisasters
= val
? 0 : 1;
701 MustUpdateOptions
= 1; Kick();
704 sprintf(interp
->result
, "%d", NoDisasters
? 0 : 1);
709 int SimCmdSound(ARGS
)
713 if ((argc
!= 2) && (argc
!= 3)) {
718 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
) ||
719 (val
< 0) || (val
> 1)) {
723 MustUpdateOptions
= 1; Kick();
726 sprintf(interp
->result
, "%d", UserSoundOn
);
731 int SimCmdFlush(ARGS
)
743 int SimCmdFlushStyle(ARGS
)
747 if ((argc
!= 2) && (argc
!= 3)) {
752 if ((Tcl_GetInt(interp
, argv
[2], &style
) != TCL_OK
) ||
759 sprintf(interp
->result
, "%d", FlushStyle
);
764 int SimCmdDonDither(ARGS
)
768 if ((argc
!= 2) && (argc
!= 3)) {
773 if ((Tcl_GetInt(interp
, argv
[2], &dd
) != TCL_OK
) ||
780 sprintf(interp
->result
, "%d", DonDither
);
785 int SimCmdDoOverlay(ARGS
)
789 if ((argc
!= 2) && (argc
!= 3)) {
794 if ((Tcl_GetInt(interp
, argv
[2], &dd
) != TCL_OK
) ||
801 sprintf(interp
->result
, "%d", DoOverlay
);
806 int SimCmdMonsterGoal(ARGS
)
815 if (Tcl_GetInt(interp
, argv
[2], &x
) != TCL_OK
) {
818 if (Tcl_GetInt(interp
, argv
[3], &y
) != TCL_OK
) {
821 if ((sprite
= GetSprite(GOD
)) == NULL
) {
823 if ((sprite
= GetSprite(GOD
)) == NULL
)
828 sprite
->control
= -2;
835 int SimCmdHelicopterGoal(ARGS
)
844 if (Tcl_GetInt(interp
, argv
[2], &x
) != TCL_OK
) {
847 if (Tcl_GetInt(interp
, argv
[3], &y
) != TCL_OK
) {
851 if ((sprite
= GetSprite(COP
)) == NULL
) {
852 GenerateCopter(x
, y
);
853 if ((sprite
= GetSprite(COP
)) == NULL
) {
864 int SimCmdMonsterDirection(ARGS
)
873 if ((Tcl_GetInt(interp
, argv
[2], &dir
) != TCL_OK
) ||
874 (dir
< -1) || (dir
> 7)) {
877 if ((sprite
= GetSprite(GOD
)) == NULL
) {
879 if ((sprite
= GetSprite(GOD
)) == NULL
) {
883 sprite
->control
= dir
;
893 if ((argc
!= 4) && (argc
!= 5)) {
896 if ((Tcl_GetInt(interp
, argv
[2], &x
) != TCL_OK
) ||
899 (Tcl_GetInt(interp
, argv
[3], &y
) != TCL_OK
) ||
905 if (Tcl_GetInt(interp
, argv
[4], &tile
) != TCL_OK
) {
910 sprintf(interp
->result
, "%d", Map
[x
][y
]);
922 if (Tcl_GetInt(interp
, argv
[2], &tile
) != TCL_OK
) {
925 for (x
= 0; x
< WORLD_X
; x
++) {
926 for (y
= 0; y
< WORLD_Y
; y
++) {
930 sprintf(interp
->result
, "%d", tile
);
935 int SimCmdDynamicData(ARGS
)
939 if ((argc
!= 3) && (argc
!= 4)) {
943 if ((Tcl_GetInt(interp
, argv
[2], &index
) != TCL_OK
) ||
952 if (Tcl_GetInt(interp
, argv
[3], &val
) != TCL_OK
) {
955 DynamicData
[index
] = val
;
956 NewMapFlags
[DYMAP
] = 1;
960 sprintf(interp
->result
, "%d", DynamicData
[index
]);
965 int SimCmdResetDynamic(ARGS
)
969 for (i
= 0; i
< 16; i
++) {
970 DynamicData
[i
] = (i
& 1) ? 99999 : -99999;
972 NewMapFlags
[DYMAP
] = 1;
978 int SimCmdPerformance(ARGS
)
982 PerformanceTiming
= 1;
984 for (view
= sim
->editor
; view
!= NULL
; view
= view
->next
) {
986 view
->update_real
= view
->update_user
= view
->update_system
= 0.0;
992 int SimCmdCollapseMotion(ARGS
)
996 if ((argc
!= 2) && (argc
!= 3)) {
1001 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1004 tkCollapseMotion
= val
;
1007 sprintf(interp
->result
, "%d", tkCollapseMotion
);
1012 int SimCmdUpdate(ARGS
)
1019 int SimCmdLandValue(ARGS
)
1027 sprintf(interp
->result
, "%d", LVAverage
);
1032 int SimCmdTraffic(ARGS
)
1040 sprintf(interp
->result
, "%d", AverageTrf());
1045 int SimCmdCrime(ARGS
)
1053 sprintf(interp
->result
, "%d", CrimeAverage
);
1058 int SimCmdUnemployment(ARGS
)
1066 sprintf(interp
->result
, "%d", GetUnemployment());
1071 int SimCmdFires(ARGS
)
1079 sprintf(interp
->result
, "%d", GetFire());
1084 int SimCmdPollution(ARGS
)
1092 sprintf(interp
->result
, "%d", PolluteAverage
);
1097 int SimCmdPolMaxX(ARGS
)
1105 sprintf(interp
->result
, "%d", (PolMaxX
<<4) + 8);
1110 int SimCmdPolMaxY(ARGS
)
1118 sprintf(interp
->result
, "%d", (PolMaxY
<<4) + 8);
1123 int SimCmdTrafMaxX(ARGS
)
1131 sprintf(interp
->result
, "%d", TrafMaxX
);
1136 int SimCmdTrafMaxY(ARGS
)
1144 sprintf(interp
->result
, "%d", TrafMaxY
);
1149 int SimCmdMeltX(ARGS
)
1157 sprintf(interp
->result
, "%d", (MeltX
<<4) + 8);
1162 int SimCmdMeltY(ARGS
)
1170 sprintf(interp
->result
, "%d", (MeltY
<<4) + 8);
1175 int SimCmdCrimeMaxX(ARGS
)
1183 sprintf(interp
->result
, "%d", (CrimeMaxX
<<4) + 8);
1188 int SimCmdCrimeMaxY(ARGS
)
1196 sprintf(interp
->result
, "%d", (CrimeMaxY
<<4) + 8);
1201 int SimCmdCenterX(ARGS
)
1209 sprintf(interp
->result
, "%d", (CCx
<<4) + 8);
1214 int SimCmdCenterY(ARGS
)
1222 sprintf(interp
->result
, "%d", (CCy
<<4) + 8);
1227 int SimCmdFloodX(ARGS
)
1235 sprintf(interp
->result
, "%d", (FloodX
<<4) + 8);
1240 int SimCmdFloodY(ARGS
)
1248 sprintf(interp
->result
, "%d", (FloodY
<<4) + 8);
1253 int SimCmdCrashX(ARGS
)
1261 sprintf(interp
->result
, "%d", (CrashX
<<4) + 8);
1266 int SimCmdCrashY(ARGS
)
1274 sprintf(interp
->result
, "%d", (CrashY
<<4) + 8);
1279 int SimCmdDollars(ARGS
)
1287 makeDollarDecimalStr(argv
[1], interp
->result
);
1292 int SimCmdDoAnimation(ARGS
)
1296 if ((argc
!= 2) && (argc
!= 3)) {
1301 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1305 MustUpdateOptions
= 1; Kick();
1308 sprintf(interp
->result
, "%d", DoAnimation
);
1313 int SimCmdDoMessages(ARGS
)
1317 if ((argc
!= 2) && (argc
!= 3)) {
1322 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1326 MustUpdateOptions
= 1; Kick();
1329 sprintf(interp
->result
, "%d", DoMessages
);
1334 int SimCmdDoNotices(ARGS
)
1338 if ((argc
!= 2) && (argc
!= 3)) {
1343 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1347 MustUpdateOptions
= 1; Kick();
1350 sprintf(interp
->result
, "%d", DoNotices
);
1355 int SimCmdRand(ARGS
)
1359 if ((argc
!= 2) && (argc
!= 3)) {
1364 if ((Tcl_GetInt(interp
, argv
[2], &val
) != TCL_OK
)) {
1372 sprintf(interp
->result
, "%d", r
);
1377 int SimCmdPlatform(ARGS
)
1381 sprintf(interp
->result
, "msdos");
1383 sprintf(interp
->result
, "unix");
1390 int SimCmdVersion(ARGS
)
1392 sprintf(interp
->result
, MicropolisVersion
);
1398 int SimCmdOpenWebBrowser(ARGS
)
1404 (strlen(argv
[2]) > 255)) {
1409 "netscape -no-about-splash '%s' &",
1412 result
= system(buf
);
1414 sprintf(interp
->result
, "%d", result
);
1420 int SimCmdQuoteURL(ARGS
)
1426 static char *hexDigits
=
1430 (strlen(argv
[2]) > 255)) {
1437 while ((ch
= *(from
++)) != '\0') {
1448 *to
++ = hexDigits
[(ch
>> 4) & 0x0f];
1449 *to
++ = hexDigits
[ch
& 0x0f];
1450 } else if (ch
== 32) {
1459 sprintf(interp
->result
, "%s", buf
);
1465 int SimCmdNeedRest(ARGS
)
1469 if ((argc
!= 2) && (argc
!= 3)) {
1474 if (Tcl_GetInt(interp
, argv
[2], &needRest
) != TCL_OK
) {
1477 NeedRest
= needRest
;
1480 sprintf(interp
->result
, "%d", NeedRest
);
1485 int SimCmdMultiPlayerMode(ARGS
)
1487 /* This is read-only because it's specified on
1488 the command line and effects how the user
1489 interface is initialized. */
1495 sprintf(interp
->result
, "%d", MultiPlayerMode
);
1500 int SimCmdSugarMode(ARGS
)
1502 /* This is read-only because it's specified on
1503 the command line and effects how the user
1504 interface is initialized. */
1510 sprintf(interp
->result
, "%d", SugarMode
);
1515 /************************************************************************/
1521 int result
= TCL_OK
;
1528 if (ent
= Tcl_FindHashEntry(&SimCmds
, argv
[1])) {
1529 cmd
= (int (*)())ent
->clientData
;
1530 result
= cmd(interp
, argc
, argv
);
1542 Tcl_CreateCommand(tk_mainInterp
, "sim", SimCmd
,
1543 (ClientData
)MainWindow
, (void (*)()) NULL
);
1545 Tcl_InitHashTable(&SimCmds
, TCL_STRING_KEYS
);
1547 #define SIM_CMD(name) HASHED_CMD(Sim, name)
1549 SIM_CMD(GameStarted
);
1552 SIM_CMD(ReallyQuit
);
1553 SIM_CMD(UpdateHeads
);
1554 SIM_CMD(UpdateMaps
);
1555 SIM_CMD(RedrawEditors
);
1556 SIM_CMD(RedrawMaps
);
1557 SIM_CMD(UpdateEditors
);
1558 SIM_CMD(UpdateGraphs
);
1559 SIM_CMD(UpdateEvaluation
);
1560 SIM_CMD(UpdateBudget
);
1561 SIM_CMD(UpdateBudgetWindow
);
1563 SIM_CMD(DoBudgetFromMenu
);
1566 SIM_CMD(StartBulldozer
);
1567 SIM_CMD(StopBulldozer
);
1570 SIM_CMD(MakeTornado
);
1571 SIM_CMD(MakeEarthquake
);
1572 SIM_CMD(MakeMonster
);
1573 SIM_CMD(MakeMeltdown
);
1576 SIM_CMD(GenerateNewCity
);
1577 SIM_CMD(GenerateSomeCity
);
1580 SIM_CMD(CurveLevel
);
1581 SIM_CMD(CreateIsland
);
1583 SIM_CMD(ClearUnnatural
);
1584 SIM_CMD(SmoothTrees
);
1585 SIM_CMD(SmoothWater
);
1586 SIM_CMD(SmoothRiver
);
1587 SIM_CMD(LoadScenario
);
1589 SIM_CMD(SaveCityAs
);
1590 SIM_CMD(MakeExplosion
);
1592 SIM_CMD(CityFileName
);
1613 SIM_CMD(PoliceFund
);
1616 SIM_CMD(AutoBudget
);
1618 SIM_CMD(AutoBulldoze
);
1622 SIM_CMD(FlushStyle
);
1625 SIM_CMD(MonsterGoal
);
1626 SIM_CMD(HelicopterGoal
);
1627 SIM_CMD(MonsterDirection
);
1628 SIM_CMD(EraseOverlay
);
1631 SIM_CMD(DynamicData
);
1632 SIM_CMD(ResetDynamic
);
1633 SIM_CMD(Performance
);
1634 SIM_CMD(CollapseMotion
);
1641 SIM_CMD(PendingTool
);
1648 SIM_CMD(Unemployment
);
1666 SIM_CMD(DoAnimation
);
1667 SIM_CMD(DoMessages
);
1672 SIM_CMD(OpenWebBrowser
);
1675 SIM_CMD(MultiPlayerMode
);