Eliminated "Lookup" label
This commit is contained in:
parent
eb49f4d0d2
commit
16545a5765
1 changed files with 86 additions and 77 deletions
159
main.c
159
main.c
|
@ -983,6 +983,7 @@ static bool do_command()
|
||||||
/* Get and execute a command */
|
/* Get and execute a command */
|
||||||
{
|
{
|
||||||
static command_t command;
|
static command_t command;
|
||||||
|
bool words_processed = false;
|
||||||
|
|
||||||
/* Can't leave cave once it's closing (except by main office). */
|
/* Can't leave cave once it's closing (except by main office). */
|
||||||
if (OUTSID(game.newloc) && game.newloc != 0 && game.closng) {
|
if (OUTSID(game.newloc) && game.newloc != 0 && game.closng) {
|
||||||
|
@ -1042,7 +1043,7 @@ static bool do_command()
|
||||||
rspeak(SAYS_PLUGH);
|
rspeak(SAYS_PLUGH);
|
||||||
|
|
||||||
listobjects();
|
listobjects();
|
||||||
clear_command(&command);
|
clear_command(&command);
|
||||||
|
|
||||||
Lcheckhint:
|
Lcheckhint:
|
||||||
checkhints();
|
checkhints();
|
||||||
|
@ -1096,7 +1097,7 @@ Lclosecheck:
|
||||||
else
|
else
|
||||||
rspeak(WHERE_QUERY);
|
rspeak(WHERE_QUERY);
|
||||||
|
|
||||||
clear_command(&command);
|
clear_command(&command);
|
||||||
goto Lcheckhint;
|
goto Lcheckhint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,81 +1139,89 @@ Lclosecheck:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Lookup:
|
// loop until all words in command are procesed
|
||||||
if (strncasecmp(command.word[0].raw, "west", sizeof("west")) == 0) {
|
do {
|
||||||
if (++game.iwest == 10)
|
// assume all words in command are processed, until proven otherwise
|
||||||
rspeak(W_IS_WEST);
|
words_processed = true;
|
||||||
}
|
|
||||||
if (strncasecmp(command.word[0].raw, "go", sizeof("go")) == 0 && command.word[1].id != WORD_EMPTY) {
|
if (strncasecmp(command.word[0].raw, "west", sizeof("west")) == 0) {
|
||||||
if (++game.igo == 10)
|
if (++game.iwest == 10)
|
||||||
rspeak(GO_UNNEEDED);
|
rspeak(W_IS_WEST);
|
||||||
}
|
}
|
||||||
if (command.word[0].id == WORD_NOT_FOUND) {
|
if (strncasecmp(command.word[0].raw, "go", sizeof("go")) == 0 && command.word[1].id != WORD_EMPTY) {
|
||||||
/* Gee, I don't understand. */
|
if (++game.igo == 10)
|
||||||
sspeak(DONT_KNOW, command.word[0].raw);
|
rspeak(GO_UNNEEDED);
|
||||||
clear_command(&command);
|
}
|
||||||
goto Lcheckhint;
|
if (command.word[0].id == WORD_NOT_FOUND) {
|
||||||
}
|
/* Gee, I don't understand. */
|
||||||
switch (command.word[0].type) {
|
sspeak(DONT_KNOW, command.word[0].raw);
|
||||||
case NO_WORD_TYPE: // FIXME: treating NO_WORD_TYPE as a motion word is confusing
|
clear_command(&command);
|
||||||
case MOTION:
|
goto Lcheckhint;
|
||||||
playermove(command.word[0].id);
|
}
|
||||||
return true;
|
|
||||||
case OBJECT:
|
switch (command.word[0].type) {
|
||||||
command.part = unknown;
|
case NO_WORD_TYPE: // FIXME: treating NO_WORD_TYPE as a motion word is confusing
|
||||||
command.obj = command.word[0].id;
|
case MOTION:
|
||||||
break;
|
playermove(command.word[0].id);
|
||||||
case ACTION:
|
return true;
|
||||||
if (command.word[1].type == NUMERIC)
|
case OBJECT:
|
||||||
command.part = transitive;
|
command.part = unknown;
|
||||||
else
|
command.obj = command.word[0].id;
|
||||||
command.part = intransitive;
|
break;
|
||||||
command.verb = command.word[0].id;
|
case ACTION:
|
||||||
break;
|
if (command.word[1].type == NUMERIC)
|
||||||
case NUMERIC:
|
command.part = transitive;
|
||||||
if (!settings.oldstyle) {
|
else
|
||||||
sspeak(DONT_KNOW, command.word[0].raw);
|
command.part = intransitive;
|
||||||
clear_command(&command);
|
command.verb = command.word[0].id;
|
||||||
goto Lcheckhint;
|
break;
|
||||||
}
|
case NUMERIC:
|
||||||
default: // LCOV_EXCL_LINE
|
if (!settings.oldstyle) {
|
||||||
BUG(VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3); // LCOV_EXCL_LINE
|
sspeak(DONT_KNOW, command.word[0].raw);
|
||||||
}
|
clear_command(&command);
|
||||||
switch (action(command)) {
|
goto Lcheckhint;
|
||||||
case GO_TERMINATE:
|
}
|
||||||
return true;
|
default: // LCOV_EXCL_LINE
|
||||||
case GO_MOVE:
|
BUG(VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3); // LCOV_EXCL_LINE
|
||||||
playermove(NUL);
|
}
|
||||||
return true;
|
|
||||||
case GO_TOP:
|
switch (action(command)) {
|
||||||
continue; /* back to top of main interpreter loop */
|
case GO_TERMINATE:
|
||||||
case GO_CLEAROBJ:
|
return true;
|
||||||
clear_command(&command);
|
case GO_MOVE:
|
||||||
/* FALL THROUGH */
|
playermove(NUL);
|
||||||
case GO_CHECKHINT:
|
return true;
|
||||||
goto Lcheckhint;
|
case GO_TOP:
|
||||||
case GO_WORD2:
|
continue; /* back to top of main interpreter loop */
|
||||||
|
case GO_CLEAROBJ:
|
||||||
|
clear_command(&command);
|
||||||
|
/* FALL THROUGH */
|
||||||
|
case GO_CHECKHINT:
|
||||||
|
goto Lcheckhint;
|
||||||
|
case GO_WORD2:
|
||||||
#ifdef GDEBUG
|
#ifdef GDEBUG
|
||||||
printf("Word shift\n");
|
printf("Word shift\n");
|
||||||
#endif /* GDEBUG */
|
#endif /* GDEBUG */
|
||||||
/* Get second word for analysis. */
|
/* Get second word for analysis. */
|
||||||
command.word[0] = command.word[1];
|
command.word[0] = command.word[1];
|
||||||
command.word[1] = empty_command_word;
|
command.word[1] = empty_command_word;
|
||||||
goto Lookup;
|
words_processed = false;
|
||||||
case GO_UNKNOWN:
|
break;
|
||||||
/* Random intransitive verbs come here. Clear obj just in case
|
case GO_UNKNOWN:
|
||||||
* (see attack()). */
|
/* Random intransitive verbs come here. Clear obj just in case
|
||||||
command.word[0].raw[0] = toupper(command.word[0].raw[0]);
|
* (see attack()). */
|
||||||
sspeak(DO_WHAT, command.word[0].raw);
|
command.word[0].raw[0] = toupper(command.word[0].raw[0]);
|
||||||
command.obj = 0;
|
sspeak(DO_WHAT, command.word[0].raw);
|
||||||
goto Lcheckhint;
|
command.obj = 0;
|
||||||
case GO_DWARFWAKE:
|
goto Lcheckhint;
|
||||||
/* Oh dear, he's disturbed the dwarves. */
|
case GO_DWARFWAKE:
|
||||||
rspeak(DWARVES_AWAKEN);
|
/* Oh dear, he's disturbed the dwarves. */
|
||||||
terminate(endgame);
|
rspeak(DWARVES_AWAKEN);
|
||||||
default: // LCOV_EXCL_LINE
|
terminate(endgame);
|
||||||
BUG(ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH); // LCOV_EXCL_LINE
|
default: // LCOV_EXCL_LINE
|
||||||
}
|
BUG(ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH); // LCOV_EXCL_LINE
|
||||||
|
}
|
||||||
|
} while (!words_processed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue