Refactor main command loop to eliminate L2000.
This commit is contained in:
parent
1c4097314a
commit
d85ef403af
1 changed files with 171 additions and 172 deletions
31
main.c
31
main.c
|
@ -712,7 +712,6 @@ static bool closecheck(void)
|
||||||
if (game.tally == 0 && INDEEP(game.loc) && game.loc != 33)
|
if (game.tally == 0 && INDEEP(game.loc) && game.loc != 33)
|
||||||
--game.clock1;
|
--game.clock1;
|
||||||
|
|
||||||
|
|
||||||
/* When the first warning comes, we lock the grate, destroy
|
/* When the first warning comes, we lock the grate, destroy
|
||||||
* the bridge, kill all the dwarves (and the pirate), remove
|
* the bridge, kill all the dwarves (and the pirate), remove
|
||||||
* the troll and bear (unless dead), and set "closng" to
|
* the troll and bear (unless dead), and set "closng" to
|
||||||
|
@ -888,6 +887,7 @@ static void listobjects(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool do_command(FILE *cmdin)
|
static bool do_command(FILE *cmdin)
|
||||||
|
/* Get and execute a command */
|
||||||
{
|
{
|
||||||
long KQ, VERB, KK, V1, V2;
|
long KQ, VERB, KK, V1, V2;
|
||||||
long i, k, KMOD;
|
long i, k, KMOD;
|
||||||
|
@ -923,9 +923,7 @@ static bool do_command(FILE *cmdin)
|
||||||
|
|
||||||
/* Describe the current location and (maybe) get next command. */
|
/* Describe the current location and (maybe) get next command. */
|
||||||
|
|
||||||
/* Print text for current loc. */
|
for (;;) {
|
||||||
|
|
||||||
L2000:
|
|
||||||
if (game.loc == 0)
|
if (game.loc == 0)
|
||||||
croak(cmdin);
|
croak(cmdin);
|
||||||
char* msg = short_location_descriptions[game.loc];
|
char* msg = short_location_descriptions[game.loc];
|
||||||
|
@ -938,7 +936,7 @@ L2000:
|
||||||
RSPEAK(23);
|
RSPEAK(23);
|
||||||
game.oldlc2 = game.loc;
|
game.oldlc2 = game.loc;
|
||||||
croak(cmdin);
|
croak(cmdin);
|
||||||
goto L2000;
|
continue; /* back to top of main interpreter loop */
|
||||||
}
|
}
|
||||||
msg=arbitrary_messages[16];
|
msg=arbitrary_messages[16];
|
||||||
}
|
}
|
||||||
|
@ -948,18 +946,18 @@ L2000:
|
||||||
if (playermove(cmdin, VERB, 1))
|
if (playermove(cmdin, VERB, 1))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
goto L2000;
|
continue; /* back to top of main interpreter loop */
|
||||||
}
|
}
|
||||||
if (game.loc == 33 && PCT(25) && !game.closng)RSPEAK(7);
|
if (game.loc == 33 && PCT(25) && !game.closng)RSPEAK(7);
|
||||||
|
|
||||||
listobjects();
|
listobjects();
|
||||||
|
|
||||||
L2012:
|
L2012:
|
||||||
VERB=0;
|
VERB=0;
|
||||||
game.oldobj=obj;
|
game.oldobj=obj;
|
||||||
obj=0;
|
obj=0;
|
||||||
|
|
||||||
L2600:
|
L2600:
|
||||||
checkhints(cmdin);
|
checkhints(cmdin);
|
||||||
|
|
||||||
/* If closing time, check for any objects being toted with
|
/* If closing time, check for any objects being toted with
|
||||||
|
@ -986,7 +984,7 @@ L2600:
|
||||||
/* Every input, check "game.foobar" flag. If zero, nothing's
|
/* Every input, check "game.foobar" flag. If zero, nothing's
|
||||||
* going on. If pos, make neg. If neg, he skipped a word,
|
* going on. If pos, make neg. If neg, he skipped a word,
|
||||||
* so make it zero. */
|
* so make it zero. */
|
||||||
L2607:
|
L2607:
|
||||||
game.foobar=(game.foobar>0 ? -game.foobar : 0);
|
game.foobar=(game.foobar>0 ? -game.foobar : 0);
|
||||||
++game.turns;
|
++game.turns;
|
||||||
if (game.turns == game.thresh) {
|
if (game.turns == game.thresh) {
|
||||||
|
@ -1011,7 +1009,7 @@ L2607:
|
||||||
|
|
||||||
lampcheck();
|
lampcheck();
|
||||||
|
|
||||||
L19999:
|
L19999:
|
||||||
k=43;
|
k=43;
|
||||||
if (LIQLOC(game.loc) == WATER)k=70;
|
if (LIQLOC(game.loc) == WATER)k=70;
|
||||||
V1=VOCAB(WD1,-1);
|
V1=VOCAB(WD1,-1);
|
||||||
|
@ -1033,7 +1031,7 @@ L19999:
|
||||||
if (V1 == 1000+CAGE && V2 == 1000+BIRD && HERE(CAGE) && HERE(BIRD))
|
if (V1 == 1000+CAGE && V2 == 1000+BIRD && HERE(CAGE) && HERE(BIRD))
|
||||||
WD1=MAKEWD(301200308);
|
WD1=MAKEWD(301200308);
|
||||||
}
|
}
|
||||||
L2620:
|
L2620:
|
||||||
if (WD1 == MAKEWD(23051920)) {
|
if (WD1 == MAKEWD(23051920)) {
|
||||||
++game.iwest;
|
++game.iwest;
|
||||||
if (game.iwest == 10)
|
if (game.iwest == 10)
|
||||||
|
@ -1043,7 +1041,7 @@ L2620:
|
||||||
if (++igo == 10)
|
if (++igo == 10)
|
||||||
RSPEAK(276);
|
RSPEAK(276);
|
||||||
}
|
}
|
||||||
L2630:
|
L2630:
|
||||||
i=VOCAB(WD1,-1);
|
i=VOCAB(WD1,-1);
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
/* Gee, I don't understand. */
|
/* Gee, I don't understand. */
|
||||||
|
@ -1061,21 +1059,21 @@ L2630:
|
||||||
if (playermove(cmdin, VERB, KMOD))
|
if (playermove(cmdin, VERB, KMOD))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
goto L2000;
|
continue; /* back to top of main interpreter loop */
|
||||||
case 1: part=unknown; obj = KMOD; break;
|
case 1: part=unknown; obj = KMOD; break;
|
||||||
case 2: part=intransitive; VERB = KMOD; break;
|
case 2: part=intransitive; VERB = KMOD; break;
|
||||||
case 3: RSPEAK(KMOD); goto L2012;
|
case 3: RSPEAK(KMOD); goto L2012;
|
||||||
default: BUG(22);
|
default: BUG(22);
|
||||||
}
|
}
|
||||||
|
|
||||||
Laction:
|
Laction:
|
||||||
switch (action(cmdin, part, VERB, obj)) {
|
switch (action(cmdin, part, VERB, obj)) {
|
||||||
case 2:
|
case 2:
|
||||||
return true;
|
return true;
|
||||||
case 8:
|
case 8:
|
||||||
playermove(cmdin, VERB, NUL);
|
playermove(cmdin, VERB, NUL);
|
||||||
return true;
|
return true;
|
||||||
case 2000: goto L2000;
|
case 2000: continue; /* back to top of main interpreter loop */
|
||||||
case 2012: goto L2012;
|
case 2012: goto L2012;
|
||||||
case 2600: goto L2600;
|
case 2600: goto L2600;
|
||||||
case 2607: goto L2607;
|
case 2607: goto L2607;
|
||||||
|
@ -1101,6 +1099,7 @@ Laction:
|
||||||
default:
|
default:
|
||||||
BUG(99);
|
BUG(99);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EMD */
|
/* end */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue