]>
cvs.zerfleddert.de Git - micropolis/blob - src/sim/s_msg.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
69 short HaveLastMessage
= 0;
70 char LastMessage
[256];
72 void DoAutoGoto(short x
, short y
, char *msg
);
73 void DoShowPicture(short id
);
74 void DoLoseGame(void);
75 void SetMessageField(char *str
);
76 void DoScenarioScore(int type
);
77 void CheckGrowth(void);
80 /* comefrom: Simulate */
88 if ((ScenarioID
) && (ScoreType
) && (ScoreWait
)) {
91 DoScenarioScore(ScoreType
);
96 TotalZPop
= ResZPop
+ ComZPop
+ IndZPop
;
97 PowerPop
= NuclearPop
+ CoalPop
;
104 if ((TotalZPop
>>2) >= ResZPop
)
105 SendMes(1); /* need Res */
108 if ((TotalZPop
>>3) >= ComZPop
)
109 SendMes(2); /* need Com */
112 if ((TotalZPop
>>3) >= IndZPop
)
113 SendMes(3); /* need Ind */
116 if ((TotalZPop
> 10) && ((TotalZPop
<<1) > RoadTotal
))
120 if ((TotalZPop
> 50) && (TotalZPop
> RailTotal
))
124 if ((TotalZPop
> 10) && (PowerPop
== 0))
125 SendMes(6); /* need Power */
128 if ((ResPop
> 500) && (StadiumPop
== 0)) {
129 SendMes(7); /* need Stad */
136 if ((IndPop
> 70) && (PortPop
== 0)) {
143 if ((ComPop
> 100) && (APortPop
== 0)) {
150 TM
= unPwrdZCnt
+ PwrdZCnt
; /* dec score for unpowered zones */
152 if ((PwrdZCnt
/ TM
) < .7)
156 if (PolluteAverage
> /* 80 */ 60)
160 if (CrimeAverage
> 100)
164 if ((TotalPop
> 60) && (FireStPop
== 0))
168 if ((TotalPop
> 60) && (PolicePop
== 0))
176 if ((RoadEffect
< 20) && (RoadTotal
> 30))
180 if ((FireEffect
< 700) && (TotalPop
> 20))
184 if ((PoliceEffect
< 700) && (TotalPop
> 20))
188 if (TrafficAverage
> 60)
195 /* comefrom: SendMessages */
202 if (!(CityTime
& 3)) {
204 ThisCityPop
= ((ResPop
) + (ComPop
* 8L) + (IndPop
* 8L)) * 20L;
206 if ((LastCityPop
< 2000) && (ThisCityPop
>= 2000)) z
= 35;
207 if ((LastCityPop
< 10000) && (ThisCityPop
>= 10000)) z
= 36;
208 if ((LastCityPop
< 50000L) && (ThisCityPop
>= 50000L)) z
= 37;
209 if ((LastCityPop
< 100000L) && (ThisCityPop
>= 100000L)) z
= 38;
210 if ((LastCityPop
< 500000L) && (ThisCityPop
>= 500000L)) z
= 39;
213 if (z
!= LastCategory
) {
217 LastCityPop
= ThisCityPop
;
222 /* comefrom: SendMessages */
224 DoScenarioScore(int type
)
228 z
= -200; /* you lose */
230 case 1: /* Dullsville */
231 if (CityClass
>= 4) z
= -100;
233 case 2: /* San Francisco */
234 if (CityClass
>= 4) z
= -100;
236 case 3: /* Hamburg */
237 if (CityClass
>= 4) z
= -100;
240 if (TrafficAverage
< 80) z
= -100;
243 if (CityScore
> 500) z
= -100;
245 case 6: /* Detroit */
246 if (CrimeAverage
< 60) z
= -100;
249 if (CityScore
> 500) z
= -100;
251 case 8: /* Rio de Janeiro */
252 if (CityScore
> 500) z
= -100;
273 /* comefrom: MakeEarthquake MakeFire MakeFire MakeFlood SendMessages
274 CheckGrowth DoScenarioScore DoPowerScan */
279 if (Mnum
!= LastPicNum
) {
287 if (!(MessagePort
)) {
298 /* comefrom: DoExplosion DoCopter ExplodeObject */
299 void SendMesAt(short Mnum
, short x
, short y
)
311 char messageStr
[256];
318 MesNum
= MessagePort
;
320 LastMesTime
= TickCount();
324 if (MesNum
== 0) return;
327 LastMesTime
= TickCount();
328 } else if ((TickCount() - LastMesTime
) > (60 * 30)) {
334 switch ((MesNum
< 0) ? -MesNum
: MesNum
) {
337 MakeSound("city", "HonkHonk-Med");
338 } else if (Rand(5) == 1) {
339 MakeSound("city", "HonkHonk-Low");
340 } else if (Rand(5) == 1) {
341 MakeSound("city", "HonkHonk-High");
352 MakeSound("city", "Siren");
355 MakeSound("city", "Monster");
358 MakeSound("city", "Explosion-Low");
359 MakeSound("city", "Siren");
362 MakeSound("city", "Explosion-High");
363 MakeSound("city", "Explosion-Low");
364 MakeSound("city", "Siren");
367 MakeSound("city", "Siren");
381 GetIndString(messageStr
, 301, MesNum
);
383 /* TODO: draw goto button */
386 if (autoGo
&& (MesX
|| MesY
)) {
387 DoAutoGoto(MesX
, MesY
, messageStr
);
391 SetMessageField(messageStr
);
394 } else { /* picture message */
398 GetIndString(messageStr
, 301, pictId
);
400 messageStr
[0] = '\0';
402 DoShowPicture(pictId
);
404 MessagePort
= pictId
; /* resend text message */
406 if (autoGo
&& (MesX
|| MesY
)) {
408 DoAutoGoto(MesX
, MesY
, messageStr
);
417 DoAutoGoto(short x
, short y
, char *msg
)
421 SetMessageField(msg
);
422 sprintf(buf
, "UIAutoGoto %d %d", x
, y
);
428 SetMessageField(char *str
)
432 if (!HaveLastMessage
||
433 strcmp(LastMessage
, str
)) {
434 strcpy(LastMessage
, str
);
436 sprintf(buf
, "UISetMessage {%s}", str
);
443 DoShowPicture(short id
)
447 sprintf(buf
, "UIShowPicture %d", id
);