Saying "get knife" after second and subsequent dwarf attacks results in repeated caveat message
Note: This issue is just a minor nitpick about messages, it does not affect game play.
The follow code in main.c is commented incorrectly and the if condition is slightly wrong:
/* Check to see if the room is dark. If the knife is
* here, and it's dark, the knife permanently disappears
*/
game.wzdark = DARK(game.loc);
if (game.knfloc != LOC_NOWHERE &&
game.knfloc != game.loc) {
game.knfloc = LOC_NOWHERE;
}
The first line simply sets the wzdark variable, ie, "whether the loc he's leaving was dark" from advent.h. The if condition here does not depend on whether or not the room is dark. It should be checking to see if the player has already seen the one-time caveat, "The dwarves' knives vanish as they strike the walls of the cave." If the player has already seen the caveat, the message, "I see no knife here." should appear instead.
The caveat is handled in actions.c:
} else if (command.obj == KNIFE && game.knfloc == game.loc) {
game.knfloc = -1;
rspeak(KNIVES_VANISH);
As can been seen, knfloc is set to -1 before the caveat appears, but the if condition above is only checking if knfloc is not 0 (LOC_NOWHERE). To correct this, it should be if(game.knfloc > LOC_NOWHERE && game.knfloc != game.loc)
instead.
In other words, if knfloc is > 0 and the knife is not in the room with the player, reply to "get knife" with "I see no knife here." Otherwise, reply with the one-time caveat.
See knife.log to demonstrate/test this.
Also for reference, in the original game code, the if condition appears in main.c as:
L2605: WZDARK=DARK(0);
if(KNFLOC > 0 && KNFLOC != LOC)KNFLOC=0;
and the one-time caveat appears in actions1.c as:
L5130: if(OBJ != KNIFE || KNFLOC != LOC) goto L5140;
KNFLOC= -1;
SPK=116;