X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=blobdiff_plain;f=actions.c;h=d2eb46ba2320f76f449c5a3a5a60f2a52e2a9272;hp=ffb52f6036e41661f639f35da14816a99bed7515;hb=f5719f1abaab6728c098756c2441d21801b4b6a3;hpb=a76cbeccbb1e7d957cf7036a7125abb48f22eb9d diff --git a/actions.c b/actions.c index ffb52f6..d2eb46b 100644 --- a/actions.c +++ b/actions.c @@ -816,7 +816,7 @@ static int read(struct command_t command) } else if (command.obj == OYSTER && !game.clshnt && game.closed) { game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) { - rspeak(actspk[command.verb]); + rspeak(actions[command.verb].message); } else pspeak(command.obj, study, game.prop[command.obj]); return GO_CLEAROBJ; @@ -893,7 +893,7 @@ static int throw (FILE *cmdin, struct command_t *command) * (Only way to do so!) Axe also special for dragon, bear, and * troll. Treasures special for troll. */ { - int spk = actspk[command->verb]; + int spk = actions[command->verb].message; if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))command->obj = ROD2; if (!TOTING(command->obj)) { rspeak(spk); @@ -1005,7 +1005,7 @@ int action(FILE *input, struct command_t *command) * unless verb is "say", which snarfs arbitrary second word. */ { - token_t spk = actspk[command->verb]; + token_t spk = actions[command->verb].message; if (command->part == unknown) { /* Analyse an object word. See if the thing is here, whether @@ -1041,7 +1041,7 @@ int action(FILE *input, struct command_t *command) } else if (command->obj == ROD && HERE(ROD2)) { command->obj = ROD2; /* FALL THROUGH */; - } else if ((command->verb == FIND || command->verb == INVENT) && command->wd2 <= 0) + } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0) /* FALL THROUGH */; else { rspeak(NO_SEE, command->wd1, command->wd1x); @@ -1061,180 +1061,182 @@ int action(FILE *input, struct command_t *command) if (command->verb == SAY)command->obj = command->wd2; if (command->obj == 0 || command->obj == INTRANSITIVE) { /* Analyse an intransitive verb (ie, no object given yet). */ - switch (command->verb - 1) { - case 0: /* CARRY */ + switch (command->verb) { + case CARRY: return vcarry(command->verb, INTRANSITIVE); - case 1: /* DROP */ + case DROP: return GO_UNKNOWN; - case 2: /* SAY */ + case SAY: return GO_UNKNOWN; - case 3: /* UNLOC */ + case UNLOCK: return lock(command->verb, INTRANSITIVE); - case 4: { /* NOTHI */ + case NOTHING: { rspeak(OK_MAN); return (GO_CLEAROBJ); } - case 5: /* LOCK */ + case LOCK: return lock(command->verb, INTRANSITIVE); - case 6: /* LIGHT */ + case LIGHT: return light(command->verb, INTRANSITIVE); - case 7: /* EXTIN */ + case EXTINGUISH: return extinguish(command->verb, INTRANSITIVE); - case 8: /* WAVE */ + case WAVE: return GO_UNKNOWN; - case 9: /* CALM */ + case TAME: return GO_UNKNOWN; - case 10: { /* WALK */ + case GO: { rspeak(spk); return GO_CLEAROBJ; } - case 11: /* ATTAC */ + case ATTACK: return attack(input, command); - case 12: /* POUR */ + case POUR: return pour(command->verb, command->obj); - case 13: /* EAT */ + case EAT: return eat(command->verb, INTRANSITIVE); - case 14: /* DRINK */ + case DRINK: return drink(command->verb, command->obj); - case 15: /* RUB */ + case RUB: return GO_UNKNOWN; - case 16: /* TOSS */ + case THROW: return GO_UNKNOWN; - case 17: /* QUIT */ + case QUIT: return quit(); - case 18: /* FIND */ + case FIND: return GO_UNKNOWN; - case 19: /* INVEN */ + case INVENTORY: return inven(); - case 20: /* FEED */ + case FEED: return GO_UNKNOWN; - case 21: /* FILL */ + case FILL: return fill(command->verb, command->obj); - case 22: /* BLAST */ + case BLAST: blast(); return GO_CLEAROBJ; - case 23: /* SCOR */ + case SCORE: score(scoregame); return GO_CLEAROBJ; - case 24: /* FOO */ + case GIANTWORDS: return bigwords(command->wd1); - case 25: /* BRIEF */ + case BRIEF: return brief(); - case 26: /* READ */ + case READ: command->obj = INTRANSITIVE; return read(*command); - case 27: /* BREAK */ + case BREAK: return GO_UNKNOWN; - case 28: /* WAKE */ + case WAKE: return GO_UNKNOWN; - case 29: /* SUSP */ + case SAVE: return suspend(); - case 30: /* RESU */ + case RESUME: return resume(); - case 31: /* FLY */ + case FLY: return fly(command->verb, INTRANSITIVE); - case 32: /* LISTE */ + case LISTEN: return listen(); - case 33: /* ZZZZ */ + case PART: return reservoir(); + default: + BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); } - BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); } /* FALLTHRU */ case transitive: /* Analyse a transitive verb. */ - switch (command->verb - 1) { - case 0: /* CARRY */ + switch (command->verb) { + case CARRY: return vcarry(command->verb, command->obj); - case 1: /* DROP */ + case DROP: return discard(command->verb, command->obj, false); - case 2: /* SAY */ + case SAY: return say(command); - case 3: /* UNLOC */ + case UNLOCK: return lock(command->verb, command->obj); - case 4: { /* NOTHI */ + case NOTHING: { rspeak(OK_MAN); return (GO_CLEAROBJ); } - case 5: /* LOCK */ + case LOCK: return lock(command->verb, command->obj); - case 6: /* LIGHT */ + case LIGHT: return light(command->verb, command->obj); - case 7: /* EXTI */ + case EXTINGUISH: return extinguish(command->verb, command->obj); - case 8: /* WAVE */ + case WAVE: return wave(command->verb, command->obj); - case 9: { /* CALM */ + case TAME: { rspeak(spk); return GO_CLEAROBJ; } - case 10: { /* WALK */ + case GO: { rspeak(spk); return GO_CLEAROBJ; } - case 11: /* ATTAC */ + case ATTACK: return attack(input, command); - case 12: /* POUR */ + case POUR: return pour(command->verb, command->obj); - case 13: /* EAT */ + case EAT: return eat(command->verb, command->obj); - case 14: /* DRINK */ + case DRINK: return drink(command->verb, command->obj); - case 15: /* RUB */ + case RUB: return rub(command->verb, command->obj); - case 16: /* TOSS */ + case THROW: return throw(input, command); - case 17: { /* QUIT */ + case QUIT: { rspeak(spk); return GO_CLEAROBJ; } - case 18: /* FIND */ + case FIND: return find(command->verb, command->obj); - case 19: /* INVEN */ + case INVENTORY: return find(command->verb, command->obj); - case 20: /* FEED */ + case FEED: return feed(command->verb, command->obj); - case 21: /* FILL */ + case FILL: return fill(command->verb, command->obj); - case 22: /* BLAST */ + case BLAST: blast(); return GO_CLEAROBJ; - case 23: { /* SCOR */ + case SCORE: { rspeak(spk); return GO_CLEAROBJ; } - case 24: { /* FOO */ + case GIANTWORDS: { rspeak(spk); return GO_CLEAROBJ; } - case 25: { /* BRIEF */ + case BRIEF: { rspeak(spk); return GO_CLEAROBJ; } - case 26: /* READ */ + case READ: return read(*command); - case 27: /* BREAK */ + case BREAK: return vbreak(command->verb, command->obj); - case 28: /* WAKE */ + case WAKE: return wake(command->verb, command->obj); - case 29: { /* SUSP */ + case SAVE: { rspeak(spk); return GO_CLEAROBJ; } - case 30: { /* RESU */ + case RESUME: { rspeak(spk); return GO_CLEAROBJ; } - case 31: /* FLY */ + case FLY: return fly(command->verb, command->obj); - case 32: { /* LISTE */ + case LISTEN: { rspeak(spk); return GO_CLEAROBJ; } - case 33: /* ZZZZ */ + case PART: return reservoir(); - } + default: BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); + } case unknown: /* Unknown verb, couldn't deduce object - might need hint */ rspeak(WHAT_DO, command->wd1, command->wd1x);