This (sort of) documents the fact that, unlike say() and attack(),
read() never scribbles on the interpreter's command block.
What those other functions are doing is unclean - though less so than
fully exposed globals. I don't see a way to fix it that isn't pretty
intrusive, alas.
-static int read(struct command_t *command)
+static int read(struct command_t command)
/* Read. Print stuff based on objtxt. Oyster (?) is special case. */
{
/* Read. Print stuff based on objtxt. Oyster (?) is special case. */
{
- if (command->obj == INTRANSITIVE) {
- command->obj = 0;
+ if (command.obj == INTRANSITIVE) {
+ command.obj = 0;
for (int i = 1; i <= NOBJECTS; i++) {
if (HERE(i) && OBJTXT[i] != 0 && game.prop[i] >= 0)
for (int i = 1; i <= NOBJECTS; i++) {
if (HERE(i) && OBJTXT[i] != 0 && game.prop[i] >= 0)
- command->obj = command->obj * NOBJECTS + i;
+ command.obj = command.obj * NOBJECTS + i;
- if (command->obj > NOBJECTS || command->obj == 0 || DARK(game.loc)) return GO_UNKNOWN;
+ if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc)) return GO_UNKNOWN;
- SETPRM(1, command->wd1, command->wd1x);
+ SETPRM(1, command.wd1, command.wd1x);
RSPEAK(NO_SEE);
return GO_CLEAROBJ;
}
RSPEAK(NO_SEE);
return GO_CLEAROBJ;
}
- if (OBJTXT[command->obj] == 0 || game.prop[command->obj] < 0) {
- RSPEAK(ACTSPK[command->verb]);
+ if (OBJTXT[command.obj] == 0 || game.prop[command.obj] < 0) {
+ RSPEAK(ACTSPK[command.verb]);
- if (command->obj == OYSTER && !game.clshnt) {
+ if (command.obj == OYSTER && !game.clshnt) {
game.clshnt = YES(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
return GO_CLEAROBJ;
}
game.clshnt = YES(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
return GO_CLEAROBJ;
}
- PSPEAK(command->obj, OBJTXT[command->obj] + game.prop[command->obj]);
+ PSPEAK(command.obj, OBJTXT[command.obj] + game.prop[command.obj]);
static int say(struct command_t *command)
/* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
{
static int say(struct command_t *command)
/* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
{
- /* FIXME: ugly use of globals */
SETPRM(1, command->wd2, command->wd2x);
if (command->wd2 <= 0)
SETPRM(1, command->wd1, command->wd1x);
SETPRM(1, command->wd2, command->wd2x);
if (command->wd2 <= 0)
SETPRM(1, command->wd1, command->wd1x);
int wd = VOCAB(command->wd1, -1);
/* FIXME: Magic numbers */
if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
int wd = VOCAB(command->wd1, -1);
/* FIXME: Magic numbers */
if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
+ /* FIXME: scribbles on the interpreter's command block */
+ wordclear(&command->wd2);
return GO_LOOKUP;
}
RSPEAK(OKEY_DOKEY);
return GO_LOOKUP;
}
RSPEAK(OKEY_DOKEY);
return brief();
case 26: /* READ */
command->obj = INTRANSITIVE;
return brief();
case 26: /* READ */
command->obj = INTRANSITIVE;
case 27: /* BREAK */
return GO_UNKNOWN;
case 28: /* WAKE */
case 27: /* BREAK */
return GO_UNKNOWN;
case 28: /* WAKE */
return GO_CLEAROBJ;
}
case 26: /* READ */
return GO_CLEAROBJ;
}
case 26: /* READ */
case 27: /* BREAK */
return vbreak(command->verb, command->obj);
case 28: /* WAKE */
case 27: /* BREAK */
return vbreak(command->verb, command->obj);
case 28: /* WAKE */