]>
git.zerfleddert.de Git - micropolis/blob - src/sim/s_msg.c
d82060706a9787a74ac49789eb6b0fdee7ecd8db
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
69 short HaveLastMessage
= 0;
70 char LastMessage
[256];
71 int DoAutoGoto(short x
, short y
, char *msg
);
72 int DoShowPicture(short id
);
74 /* comefrom: Simulate */
81 if ((ScenarioID
) && (ScoreType
) && (ScoreWait
)) {
84 DoScenarioScore(ScoreType
);
89 TotalZPop
= ResZPop
+ ComZPop
+ IndZPop
;
90 PowerPop
= NuclearPop
+ CoalPop
;
97 if ((TotalZPop
>>2) >= ResZPop
)
98 SendMes(1); /* need Res */
101 if ((TotalZPop
>>3) >= ComZPop
)
102 SendMes(2); /* need Com */
105 if ((TotalZPop
>>3) >= IndZPop
)
106 SendMes(3); /* need Ind */
109 if ((TotalZPop
> 10) && ((TotalZPop
<<1) > RoadTotal
))
113 if ((TotalZPop
> 50) && (TotalZPop
> RailTotal
))
117 if ((TotalZPop
> 10) && (PowerPop
== 0))
118 SendMes(6); /* need Power */
121 if ((ResPop
> 500) && (StadiumPop
== 0)) {
122 SendMes(7); /* need Stad */
129 if ((IndPop
> 70) && (PortPop
== 0)) {
136 if ((ComPop
> 100) && (APortPop
== 0)) {
143 TM
= unPwrdZCnt
+ PwrdZCnt
; /* dec score for unpowered zones */
145 if ((PwrdZCnt
/ TM
) < .7)
149 if (PolluteAverage
> /* 80 */ 60)
153 if (CrimeAverage
> 100)
157 if ((TotalPop
> 60) && (FireStPop
== 0))
161 if ((TotalPop
> 60) && (PolicePop
== 0))
169 if ((RoadEffect
< 20) && (RoadTotal
> 30))
173 if ((FireEffect
< 700) && (TotalPop
> 20))
177 if ((PoliceEffect
< 700) && (TotalPop
> 20))
181 if (TrafficAverage
> 60)
188 /* comefrom: SendMessages */
194 if (!(CityTime
& 3)) {
196 ThisCityPop
= ((ResPop
) + (ComPop
* 8L) + (IndPop
* 8L)) * 20L;
198 if ((LastCityPop
< 2000) && (ThisCityPop
>= 2000)) z
= 35;
199 if ((LastCityPop
< 10000) && (ThisCityPop
>= 10000)) z
= 36;
200 if ((LastCityPop
< 50000L) && (ThisCityPop
>= 50000L)) z
= 37;
201 if ((LastCityPop
< 100000L) && (ThisCityPop
>= 100000L)) z
= 38;
202 if ((LastCityPop
< 500000L) && (ThisCityPop
>= 500000L)) z
= 39;
205 if (z
!= LastCategory
) {
209 LastCityPop
= ThisCityPop
;
214 /* comefrom: SendMessages */
215 DoScenarioScore(int type
)
219 z
= -200; /* you lose */
221 case 1: /* Dullsville */
222 if (CityClass
>= 4) z
= -100;
224 case 2: /* San Francisco */
225 if (CityClass
>= 4) z
= -100;
227 case 3: /* Hamburg */
228 if (CityClass
>= 4) z
= -100;
231 if (TrafficAverage
< 80) z
= -100;
234 if (CityScore
> 500) z
= -100;
236 case 6: /* Detroit */
237 if (CrimeAverage
< 60) z
= -100;
240 if (CityScore
> 500) z
= -100;
242 case 8: /* Rio de Janeiro */
243 if (CityScore
> 500) z
= -100;
263 /* comefrom: MakeEarthquake MakeFire MakeFire MakeFlood SendMessages
264 CheckGrowth DoScenarioScore DoPowerScan */
268 if (Mnum
!= LastPicNum
) {
276 if (!(MessagePort
)) {
287 /* comefrom: DoExplosion DoCopter ExplodeObject */
288 void SendMesAt(short Mnum
, short x
, short y
)
299 char messageStr
[256];
306 MesNum
= MessagePort
;
308 LastMesTime
= TickCount();
312 if (MesNum
== 0) return;
315 LastMesTime
= TickCount();
316 } else if ((TickCount() - LastMesTime
) > (60 * 30)) {
322 switch ((MesNum
< 0) ? -MesNum
: MesNum
) {
325 MakeSound("city", "HonkHonk-Med");
326 } else if (Rand(5) == 1) {
327 MakeSound("city", "HonkHonk-Low");
328 } else if (Rand(5) == 1) {
329 MakeSound("city", "HonkHonk-High");
340 MakeSound("city", "Siren");
343 MakeSound("city", "Monster");
346 MakeSound("city", "Explosion-Low");
347 MakeSound("city", "Siren");
350 MakeSound("city", "Explosion-High");
351 MakeSound("city", "Explosion-Low");
352 MakeSound("city", "Siren");
355 MakeSound("city", "Siren");
369 GetIndString(messageStr
, 301, MesNum
);
371 /* TODO: draw goto button */
374 if (autoGo
&& (MesX
|| MesY
)) {
375 DoAutoGoto(MesX
, MesY
, messageStr
);
379 SetMessageField(messageStr
);
382 } else { /* picture message */
386 GetIndString(messageStr
, 301, pictId
);
388 messageStr
[0] = '\0';
390 DoShowPicture(pictId
);
392 MessagePort
= pictId
; /* resend text message */
394 if (autoGo
&& (MesX
|| MesY
)) {
396 DoAutoGoto(MesX
, MesY
, messageStr
);
404 DoAutoGoto(short x
, short y
, char *msg
)
408 SetMessageField(msg
);
409 sprintf(buf
, "UIAutoGoto %d %d", x
, y
);
414 SetMessageField(char *str
)
418 if (!HaveLastMessage
||
419 strcmp(LastMessage
, str
)) {
420 strcpy(LastMessage
, str
);
422 sprintf(buf
, "UISetMessage {%s}", str
);
428 DoShowPicture(short id
)
432 sprintf(buf
, "UIShowPicture %d", id
);