/*
* Actions for the dungeon-running code.
*
- * Copyright (c) 1977, 2005 by Will Crowther and Don Woods
- * Copyright (c) 2017 by Eric S. Raymond
- * SPDX-License-Identifier: BSD-2-clause
+ * SPDX-FileCopyrightText: 1977, 2005 by Will Crowther and Don Woods
+ * SPDX-FileCopyrightText 2017 by Eric S. Raymond
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include <stdlib.h>
* word we've got. Last word zips the eggs back to the giant room (unless
* already there). */
{
- if ((game.foobar == WORD_EMPTY && id == FEE) ||
- (game.foobar == FEE && id == FIE) ||
- (game.foobar == FIE && id == FOE) ||
- (game.foobar == FOE && id == FOO) ||
- (game.foobar == FOE && id == FUM)) {
+ int foobar = abs(game.foobar);
+
+ /* Only FEE can start a magic-word sequence. */
+ if ((foobar == WORD_EMPTY) && (id == FIE || id == FOE || id == FOO || id == FUM)) {
+ rspeak(NOTHING_HAPPENS);
+ return GO_CLEAROBJ;
+ }
+
+ if ((foobar == WORD_EMPTY && id == FEE) ||
+ (foobar == FEE && id == FIE) ||
+ (foobar == FIE && id == FOE) ||
+ (foobar == FOE && id == FOO)) {
game.foobar = id;
- if ((id != FOO) && (id != FUM)) {
+ if (id != FOO) {
rspeak(OK_MAN);
return GO_CLEAROBJ;
}
(TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
rspeak(NOTHING_HAPPENS);
return GO_CLEAROBJ;
- } else if (id == FUM) {
- goto fum;
} else {
/* Bring back troll if we steal the eggs back from him before
* crossing. */
return GO_CLEAROBJ;
}
} else {
-fum:
- if (game.loc == LOC_GIANTROOM) {
- rspeak(START_OVER);
- } else {
- /* This is new behavior in Open Adventure - sounds better when
- * player isn't in the Giant Room. */
- rspeak(NOTHING_HAPPENS);
- }
+ /* Magic-word sequence was started but is incorrect */
+ if (settings.oldstyle || game.seenbigwords)
+ rspeak(START_OVER);
+ else
+ rspeak(WELL_POINTLESS);
game.foobar = WORD_EMPTY;
return GO_CLEAROBJ;
}
static void blast(void)
/* Blast. No effect unless you've got dynamite, which is a neat trick! */
{
- if (game.prop[ROD2] == STATE_NOTFOUND ||
- !game.closed)
+ if (game.prop[ROD2] == STATE_NOTFOUND || !game.closed)
rspeak(REQUIRES_DYNAMITE);
else {
if (HERE(ROD2)) {
return GO_CLEAROBJ;
}
- if (obj == WATER ||
- obj == OIL) {
- if (!HERE(BOTTLE) ||
- LIQUID() != obj) {
+ if (obj == WATER || obj == OIL) {
+ if (!HERE(BOTTLE) || LIQUID() != obj) {
if (!TOTING(BOTTLE)) {
rspeak(NO_CONTAINER);
return GO_CLEAROBJ;
}
game.prop[BIRD] = BIRD_CAGED;
}
- if ((obj == BIRD ||
- obj == CAGE) &&
+ if ((obj == BIRD || obj == CAGE) &&
(game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
/* expression maps BIRD to CAGE and CAGE to BIRD */
carry(BIRD + CAGE - obj, game.loc);
return GO_CLEAROBJ;
}
- if (AT(obj) ||
- (LIQUID() == obj && AT(BOTTLE)) ||
- obj == LIQLOC(game.loc) ||
- (obj == DWARF && atdwrf(game.loc) > 0)) {
+ if (AT(obj) || (LIQUID() == obj && AT(BOTTLE)) ||
+ obj == LIQLOC(game.loc) || (obj == DWARF && atdwrf(game.loc) > 0)) {
rspeak(YOU_HAVEIT);
return GO_CLEAROBJ;
}
{
bool empty = true;
for (obj_t i = 1; i <= NOBJECTS; i++) {
- if (i == BEAR ||
- !TOTING(i))
+ if (i == BEAR || !TOTING(i))
continue;
if (empty) {
rspeak(NOW_HOLDING);
soundlatch = true;
}
for (obj_t i = 1; i <= NOBJECTS; i++) {
- if (!HERE(i) ||
- objects[i].sounds[0] == NULL ||
- game.prop[i] < 0)
+ if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
continue;
int mi = game.prop[i];
/* (ESR) Some unpleasant magic on object states here. Ideally
/* Pour. If no object, or object is bottle, assume contents of bottle.
* special tests for pouring water or oil on plant or rusty door. */
{
- if (obj == BOTTLE ||
- obj == INTRANSITIVE)
- obj = LIQUID();
+ if (obj == BOTTLE || obj == INTRANSITIVE)
+ obj = LIQUID();
if (obj == NO_OBJECT)
return GO_UNKNOWN;
if (!TOTING(obj)) {
return fill(verb, URN);
game.prop[BOTTLE] = EMPTY_BOTTLE;
game.place[obj] = LOC_NOWHERE;
- if (!(AT(PLANT) ||
- AT(DOOR))) {
+ if (!(AT(PLANT) || AT(DOOR))) {
rspeak(GROUND_WET);
return GO_CLEAROBJ;
}
if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
command.obj = command.obj * NOBJECTS + i;
}
- if (command.obj > NOBJECTS ||
- command.obj == NO_OBJECT ||
- DARK(game.loc))
+ if (command.obj > NOBJECTS || command.obj == NO_OBJECT || DARK(game.loc))
return GO_UNKNOWN;
}
static phase_codes_t wake(verb_t verb, obj_t obj)
/* Wake. Only use is to disturb the dwarves. */
{
- if (obj != DWARF ||
- !game.closed) {
+ if (obj != DWARF || !game.closed) {
speak(actions[verb].message);
return GO_CLEAROBJ;
} else {
static phase_codes_t wave(verb_t verb, obj_t obj)
/* Wave. No effect unless waving rod at fissure or at bird. */
{
- if (obj != ROD ||
- !TOTING(obj) ||
- (!HERE(BIRD) &&
- (game.closng ||
- !AT(FISSURE)))) {
+ if (obj != ROD || !TOTING(obj) || (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
speak(((!TOTING(obj)) && (obj != ROD ||
!TOTING(ROD2))) ?
arbitrary_messages[ARENT_CARRYING] :
FREE_FLY);
return GO_DWARFWAKE;
}
- if (game.closng ||
- !AT(FISSURE)) {
+ if (game.closng || !AT(FISSURE)) {
rspeak((game.prop[BIRD] == BIRD_CAGED) ?
CAGE_FLY :
FREE_FLY);
* will do here. We're preventing interpretation as an intransitive
* verb when the word is unknown. */
command.obj = command.word[1].raw[0] != '\0' ? KEYS : NO_OBJECT;
- if (command.obj == NO_OBJECT ||
- command.obj == INTRANSITIVE) {
+ if (command.obj == NO_OBJECT || command.obj == INTRANSITIVE) {
/* Analyse an intransitive verb (ie, no object given yet). */
switch (command.verb) {
case CARRY: