Convert L2000/goto L2000 to while(true)

Convert L2004 to for loop
Copy L8 code to where it's used
This commit is contained in:
Peje Nilsson 2017-06-12 17:58:08 +02:00
parent b0eb54b125
commit ddaf975e91

61
main.c
View file

@ -709,7 +709,8 @@ static bool do_command(FILE *cmdin)
/* Print text for current loc. */
L2000: if (game.loc == 0)
while (true) {
if (game.loc == 0)
croak(cmdin);
char* msg = short_location_descriptions[game.loc];
if (MOD(game.abbrev[game.loc],game.abbnum) == 0 || msg == 0)
@ -721,7 +722,7 @@ L2000: if (game.loc == 0)
RSPEAK(23);
game.oldlc2 = game.loc;
croak(cmdin);
goto L2000;
continue;
}
msg=arbitrary_messages[16];
}
@ -729,7 +730,10 @@ L2000: if (game.loc == 0)
newspeak(msg);
KMOD=1;
if (FORCED(game.loc)) {
goto L8;
/* Figure out the new location */
if (playermove(cmdin, VERB, KMOD))
return true;
continue;
}
if (game.loc == 33 && PCT(25) && !game.closng)RSPEAK(7);
@ -743,16 +747,17 @@ L2000: if (game.loc == 0)
if (DARK(game.loc)) goto L2012;
++game.abbrev[game.loc];
i=game.atloc[game.loc];
L2004: if (i == 0) goto L2012;
obj=i;
if (obj > NOBJECTS)obj=obj-NOBJECTS;
if (obj == STEPS && TOTING(NUGGET)) goto L2008;
if (game.prop[obj] >= 0) goto L2006;
if (game.closed) goto L2008;
game.prop[obj]=0;
if (obj == RUG || obj == CHAIN)game.prop[obj]=1;
--game.tally;
for(i=game.atloc[game.loc]; i != 0; i=game.link[i]) {
obj=i;
if (obj > NOBJECTS)obj=obj-NOBJECTS;
if (obj == STEPS && TOTING(NUGGET)) continue;
if (game.prop[obj] < 0) {
if (game.closed) continue;
game.prop[obj]=0;
if (obj == RUG || obj == CHAIN)game.prop[obj]=1;
--game.tally;
}
/* Note: There used to be a test here to see whether the player had blown it
* so badly that he could never ever see the remaining treasures, and if so
* the lamp was zapped to 35 turns. But the tests were too simple-minded;
@ -764,11 +769,10 @@ L2004: if (i == 0) goto L2012;
* or trident, and the effects propagate. So the whole thing was flushed.
* anyone who makes such a gross blunder isn't likely to find everything
* else anyway (so goes the rationalisation). */
L2006: KK=game.prop[obj];
if (obj == STEPS && game.loc == game.fixed[STEPS])KK=1;
PSPEAK(obj,KK);
L2008: i=game.link[i];
goto L2004;
KK=game.prop[obj];
if (obj == STEPS && game.loc == game.fixed[STEPS])KK=1;
PSPEAK(obj,KK);
}
L2012: VERB=0;
game.oldobj=obj;
@ -1016,7 +1020,11 @@ L2630:
KQ=i/1000+1;
switch (KQ-1)
{
case 0: goto L8;
case 0:
/* Figure out the new location */
if (playermove(cmdin, VERB, KMOD))
return true;
continue;
case 1: part=unknown; obj = KMOD; break;
case 2: part=intransitive; VERB = KMOD; break;
case 3: RSPEAK(KMOD); goto L2012;
@ -1026,8 +1034,13 @@ L2630:
Laction:
switch (action(cmdin, part, VERB, obj)) {
case 2: return true;
case 8: KMOD=NUL; goto L8;
case 2000: goto L2000;
case 8:
KMOD=NUL;
/* Figure out the new location */
if (playermove(cmdin, VERB, KMOD))
return true;
continue;
case 2000: continue;
case 2012: goto L2012;
case 2600: goto L2600;
case 2607: goto L2607;
@ -1056,9 +1069,5 @@ Laction:
/* no fallthrough here */
/* Figure out the new location */
L8: if (playermove(cmdin, VERB, KMOD))
return true;
else
goto L2000;
}
}