Dear all, I think we have to fix all the warnings.
C assumes all functions not defined the type of return values as integers.
So a void function call without definition might get a stack pop by the caller
which mess up the stack.
However, normally it won't be that stupid, but
it could be a compiler optimizer bug. So with -O0 or -O3, I don't get a crash.
I've made a stupid patch which solves the crash at loading scenarios compiled
by -O2. It just modify
"return;" to "return 0;" around DoZone() and the function calls inside DoZone();
Please try the attachment (quilt patch, last one in series).
My arch is i386, not amd64.
Yours Sincerely,
Paul.
--
PaulLiu(劉穎駿)
E-mail address: [email protected]
Index: micropolis-activity-0.0.20071228/src/sim/s_sim.c
===================================================================
--- micropolis-activity-0.0.20071228.orig/src/sim/s_sim.c 2009-06-25 01:41:18.396541888 +0800
+++ micropolis-activity-0.0.20071228/src/sim/s_sim.c 2009-06-25 01:43:23.328537760 +0800
@@ -1024,18 +1024,18 @@
RepairZone(POWERPLANT, 4); /* post */
PushPowerStack();
CoalSmoke(SMapX, SMapY);
- return;
+ return 0;
case NUCLEAR:
if (!NoDisasters && !Rand(MltdwnTab[GameLevel])) {
DoMeltdown(SMapX, SMapY);
- return;
+ return 0;
}
NuclearPop++;
if (!(CityTime & 7))
RepairZone(NUCLEAR, 4); /* post */
PushPowerStack();
- return;
+ return 0;
case FIRESTATION:
FireStPop++;
@@ -1051,7 +1051,7 @@
z = z >>1; /* post FD's need roads */
FireStMap[SMapX >>3][SMapY >>3] += z;
- return;
+ return 0;
case POLICESTATION:
PolicePop++;
@@ -1067,7 +1067,7 @@
z = z >>1; /* post PD's need roads */
PoliceMap[SMapX >>3][SMapY >>3] += z;
- return;
+ return 0;
case STADIUM:
StadiumPop++;
@@ -1079,13 +1079,13 @@
Map[SMapX + 1][SMapY] = FOOTBALLGAME1 + ANIMBIT;
Map[SMapX + 1][SMapY + 1] = FOOTBALLGAME2 + ANIMBIT;
}
- return;
+ return 0;
case FULLSTADIUM:
StadiumPop++;
if (!((CityTime + SMapX + SMapY) & 7)) /* post release */
DrawStadium(STADIUM);
- return;
+ return 0;
case AIRPORT:
APortPop++;
@@ -1100,7 +1100,7 @@
if (PwrOn)
DoAirport();
- return;
+ return 0;
case PORT:
PortPop++;
@@ -1111,8 +1111,9 @@
(GetSprite(SHI) == NULL)) {
GenerateShip();
}
- return;
+ return 0;
}
+ return 0;
}
Index: micropolis-activity-0.0.20071228/src/sim/s_zone.c
===================================================================
--- micropolis-activity-0.0.20071228.orig/src/sim/s_zone.c 2009-06-25 01:41:15.496540968 +0800
+++ micropolis-activity-0.0.20071228/src/sim/s_zone.c 2009-06-25 01:42:55.080538167 +0800
@@ -75,22 +75,22 @@
if (CChr9 > PORTBASE) { /* do Special Zones */
DoSPZone(ZonePwrFlg);
- return;
+ return 0;
}
if (CChr9 < HOSPITAL) {
DoResidential(ZonePwrFlg);
- return;
+ return 0;
}
if (CChr9 < COMBASE) {
DoHospChur();
- return;
+ return 0;
}
if (CChr9 < INDBASE) {
DoCommercial(ZonePwrFlg);
- return;
+ return 0;
}
DoIndustrial(ZonePwrFlg);
- return;
+ return 0;
}
@@ -110,6 +110,7 @@
if (!Rand(20))
ZonePlop(RESBASE);
}
+ return 0;
}
@@ -171,7 +172,7 @@
if (TrfGood == -1) {
DoIndOut(tpop, Rand16() & 1);
- return;
+ return 0;
}
if (!(Rand16() & 7)) {
@@ -180,12 +181,13 @@
if ((zscore > -350) &&
(((short)(zscore - 26380)) > ((short)Rand16Signed()))) {
DoIndIn(tpop, Rand16() & 1);
- return;
+ return 0;
}
if ((zscore < 350) &&
(((short)(zscore + 26380)) < ((short)Rand16Signed())))
DoIndOut(tpop, Rand16() & 1);
}
+ return 0;
}
@@ -203,7 +205,7 @@
if (TrfGood == -1) {
value = GetCRVal();
DoComOut(tpop, value);
- return;
+ return 0;
}
if (!(Rand16() & 7)) {
@@ -216,7 +218,7 @@
(((short)(zscore - 26380)) > ((short)Rand16Signed()))) {
value = GetCRVal();
DoComIn(tpop, value);
- return;
+ return 0;
}
if ((zscore < 350) &&
(((short)(zscore + 26380)) < ((short)Rand16Signed()))) {
@@ -224,6 +226,7 @@
DoComOut(tpop, value);
}
}
+ return 0;
}
@@ -242,7 +245,7 @@
if (TrfGood == -1) {
value = GetCRVal();
DoResOut(tpop, value);
- return;
+ return 0;
}
if ((CChr9 == FREEZ) || (!(Rand16() & 7))) {
@@ -254,11 +257,11 @@
(((short)(zscore - 26380)) > ((short)Rand16Signed()))) {
if ((!tpop) && (!(Rand16() & 3))) {
MakeHosp();
- return;
+ return 0;
}
value = GetCRVal();
DoResIn(tpop, value);
- return;
+ return 0;
}
if ((zscore < 350) &&
(((short)(zscore + 26380)) < ((short)Rand16Signed()))) {
@@ -266,6 +269,7 @@
DoResOut(tpop, value);
}
}
+ return 0;
}
signature.asc
Description: OpenPGP digital signature

