Ad-hoc type safety when checking command IDs.

fixes #31
This commit is contained in:
NHOrus 2017-07-18 18:10:58 +03:00
parent cbf03c43a8
commit 4e3a892ee3

9
main.c
View file

@ -1120,7 +1120,8 @@ Lclearobj:
} else
lampcheck();
if (command.id1 == ENTER && (command.id2 == STREAM ||
if (command.id1 == ENTER && command.type1 == ACTION &&
(command.id2 == STREAM ||
command.id2 == WATER)) {
if (LIQLOC(game.loc) == WATER)
rspeak(FEET_WET);
@ -1129,7 +1130,8 @@ Lclearobj:
goto Lclearobj;
}
if (command.id1 == ENTER && command.id2 != WORD_NOT_FOUND && command.id2 != WORD_EMPTY) {
if ((command.id1 == ENTER && command.type1 == ACTION) &&
(command.id2 != WORD_NOT_FOUND && command.id2 != WORD_EMPTY)) {
command.id1 = command.id2;
command.type1 = command.type2;
strncpy(command.raw1, command.raw2, LINESIZE - 1);
@ -1145,7 +1147,8 @@ Lclearobj:
command.wd2 = token_to_packed("POUR");
}
}
if (command.id1 == CAGE && command.id2 == BIRD && HERE(CAGE) && HERE(BIRD)) {
if ((command.id1 == CAGE && command.type1 == OBJECT) &&
(command.id2 == BIRD && HERE(CAGE) && HERE(BIRD))) {
command.id1 = CARRY;
command.type1 = ACTION;
strncpy(command.raw2, "CATCH", LINESIZE - 1);