Replace an unstructured goto with a two-level break.

This commit is contained in:
Eric S. Raymond 2017-06-09 12:09:47 -04:00
parent 733312bdc7
commit 2c33a29cf1

42
main.c
View file

@ -345,7 +345,25 @@ static bool dwarfmove(void)
continue; continue;
} }
if(TOTING(j)) { if(TOTING(j)) {
goto L6021; if(game.place[CHEST] == 0) {
/* Install chest only once, to insure it is
* the last treasure in the list. */
MOVE(CHEST,game.chloc);
MOVE(MESSAG,game.chloc2);
}
RSPEAK(128);
for (int j=MINTRS; j<=MAXTRS; j++) {
if (!(j == PYRAM && (game.loc == PLAC[PYRAM] || game.loc == PLAC[EMRALD]))) {
if(AT(j) && game.fixed[j] == 0)
CARRY(j,game.loc);
if(TOTING(j))
DROP(j,game.chloc);
}
}
game.dloc[PIRATE]=game.chloc;
game.odloc[PIRATE]=game.chloc;
game.dseen[PIRATE]=false;
goto jumpout;
} }
if(HERE(j)) if(HERE(j))
k=1; k=1;
@ -363,27 +381,6 @@ static bool dwarfmove(void)
if(game.odloc[PIRATE] != game.dloc[PIRATE] && PCT(20)) if(game.odloc[PIRATE] != game.dloc[PIRATE] && PCT(20))
RSPEAK(127); RSPEAK(127);
continue; continue;
L6021:
if(game.place[CHEST] == 0) {
/* Install chest only once, to insure it is the last treasure in
* the list. */
MOVE(CHEST,game.chloc);
MOVE(MESSAG,game.chloc2);
}
RSPEAK(128);
for (int j=MINTRS; j<=MAXTRS; j++) {
if (!(j == PYRAM && (game.loc == PLAC[PYRAM] || game.loc == PLAC[EMRALD]))) {
if(AT(j) && game.fixed[j] == 0)
CARRY(j,game.loc);
if(TOTING(j))
DROP(j,game.chloc);
}
}
game.dloc[PIRATE]=game.chloc;
game.odloc[PIRATE]=game.chloc;
game.dseen[PIRATE]=false;
continue;
} }
/* This threatening little dwarf is in the room with him! */ /* This threatening little dwarf is in the room with him! */
@ -395,6 +392,7 @@ static bool dwarfmove(void)
if(randrange(1000) < 95*(game.dflag-2)) if(randrange(1000) < 95*(game.dflag-2))
++stick; ++stick;
} }
jumpout:;
} }
/* Now we know what's happening. Let's tell the poor sucker about it. /* Now we know what's happening. Let's tell the poor sucker about it.