Cleanups and clarifications in do_command()

This commit is contained in:
Aaron Traas 2017-07-10 17:43:59 -04:00
parent 9056fa7a2c
commit 12b2ff74f6

28
main.c
View file

@ -788,6 +788,15 @@ static bool closecheck(void)
* problems arise from the use of negative prop numbers to suppress * problems arise from the use of negative prop numbers to suppress
* the object descriptions until he's actually moved the objects. */ * the object descriptions until he's actually moved the objects. */
{ {
/* If a turn threshold has been met, apply penalties and tell
* the player about it. */
for (int i = 0; i < NTHRESHOLDS; ++i) {
if (game.turns == turn_thresholds[i].threshold + 1) {
game.trnluz += turn_thresholds[i].point_loss;
speak(turn_thresholds[i].message);
}
}
/* Don't tick game.clock1 unless well into cave (and not at Y2). */ /* Don't tick game.clock1 unless well into cave (and not at Y2). */
if (game.tally == 0 && INDEEP(game.loc) && game.loc != LOC_Y2) if (game.tally == 0 && INDEEP(game.loc) && game.loc != LOC_Y2)
--game.clock1; --game.clock1;
@ -1097,18 +1106,9 @@ Lclearobj:
if(!get_command_input(&command)) if(!get_command_input(&command))
return false; return false;
Lthreshold: Lclosecheck:
++game.turns; ++game.turns;
/* If a turn threshold has been met, apply penalties and tell
* the player about it. */
for (int i = 0; i < NTHRESHOLDS; ++i) {
if (game.turns == turn_thresholds[i].threshold + 1) {
game.trnluz += turn_thresholds[i].point_loss;
speak(turn_thresholds[i].message);
}
}
if (closecheck()) { if (closecheck()) {
if (game.closed) if (game.closed)
return true; return true;
@ -1117,11 +1117,11 @@ Lthreshold:
if (command.id1 == ENTER && (command.id2 == STREAM || if (command.id1 == ENTER && (command.id2 == STREAM ||
command.id2 == PROMOTE_WORD(WATER))) { command.id2 == PROMOTE_WORD(WATER))) {
if (LIQLOC(game.loc) == WATER) { if (LIQLOC(game.loc) == WATER)
rspeak(FEET_WET); rspeak(FEET_WET);
} else { else
rspeak(WHERE_QUERY); rspeak(WHERE_QUERY);
}
goto Lclearobj; goto Lclearobj;
} }
if (command.id1 == ENTER && command.id2 != WORD_NOT_FOUND && command.id2 != WORD_EMPTY) { if (command.id1 == ENTER && command.id2 != WORD_NOT_FOUND && command.id2 != WORD_EMPTY) {
@ -1185,7 +1185,7 @@ Lookup:
case GO_TOP: case GO_TOP:
continue; /* back to top of main interpreter loop */ continue; /* back to top of main interpreter loop */
case GO_CHECKFOO: case GO_CHECKFOO:
goto Lthreshold; goto Lclosecheck;
case GO_LOOKUP: case GO_LOOKUP:
goto Lookup; goto Lookup;
case GO_WORD2: case GO_WORD2: