projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Magic-number elimination.
[open-adventure.git]
/
actions.c
diff --git
a/actions.c
b/actions.c
index 4a7c514207ae74235e2a84fa9170e9fc1990436e..a384e61431e96f1531397f159e2e2e723bcd27d5 100644
(file)
--- a/
actions.c
+++ b/
actions.c
@@
-594,30
+594,27
@@
static int extinguish(token_t verb, obj_t obj)
return GO_UNKNOWN;
}
return GO_UNKNOWN;
}
- if (obj == URN) {
+ switch (obj) {
+ case URN:
if (game.prop[URN] != URN_EMPTY) {
state_change(URN, URN_DARK);
} else {
pspeak(URN, change, URN_DARK, true);
}
if (game.prop[URN] != URN_EMPTY) {
state_change(URN, URN_DARK);
} else {
pspeak(URN, change, URN_DARK, true);
}
- return GO_CLEAROBJ;
- }
-
- if (obj == LAMP) {
+ break;
+ case LAMP:
state_change(LAMP, LAMP_DARK);
rspeak(DARK(game.loc) ?
PITCH_DARK :
NO_MESSAGE);
state_change(LAMP, LAMP_DARK);
rspeak(DARK(game.loc) ?
PITCH_DARK :
NO_MESSAGE);
- return GO_CLEAROBJ;
- }
-
- if (obj == DRAGON ||
- obj == VOLCANO) {
+ break;
+ case DRAGON:
+ case VOLCANO:
rspeak(BEYOND_POWER);
rspeak(BEYOND_POWER);
- return GO_CLEAROBJ;
+ break;
+ default:
+ speak(actions[verb].message);
}
}
-
- speak(actions[verb].message);
return GO_CLEAROBJ;
}
return GO_CLEAROBJ;
}
@@
-844,36
+841,38
@@
static int light(token_t verb, obj_t obj)
/* Light. Applicable only to lamp and urn. */
{
if (obj == INTRANSITIVE) {
/* Light. Applicable only to lamp and urn. */
{
if (obj == INTRANSITIVE) {
- if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
+ int selects = 0;
+ if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
obj = LAMP;
obj = LAMP;
- if (HERE(URN) && game.prop[URN] == URN_DARK)
+ selects++;
+ }
+ if (HERE(URN) && game.prop[URN] == URN_DARK) {
obj = URN;
obj = URN;
- if (obj == INTRANSITIVE ||
- (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 &&
-
HERE(URN) && game.prop[URN] == URN_DARK)
)
+ selects++;
+ }
+
if (selects != 1
)
return GO_UNKNOWN;
}
return GO_UNKNOWN;
}
- if (obj == URN) {
+ switch (obj) {
+ case URN:
state_change(URN, game.prop[URN] == URN_EMPTY ?
URN_EMPTY :
URN_LIT);
state_change(URN, game.prop[URN] == URN_EMPTY ?
URN_EMPTY :
URN_LIT);
- return GO_CLEAROBJ;
- } else {
- if (obj != LAMP) {
- speak(actions[verb].message);
- return GO_CLEAROBJ;
- }
+ break;
+ case LAMP:
if (game.limit < 0) {
rspeak(LAMP_OUT);
if (game.limit < 0) {
rspeak(LAMP_OUT);
-
return GO_CLEAROBJ
;
+
break
;
}
state_change(LAMP, LAMP_BRIGHT);
if (game.wzdark)
return GO_TOP;
}
state_change(LAMP, LAMP_BRIGHT);
if (game.wzdark)
return GO_TOP;
- else
- return GO_CLEAROBJ;
+ break;
+ default:
+ speak(actions[verb].message);
}
}
+ return GO_CLEAROBJ;
}
static int listen(void)
}
static int listen(void)
@@
-1171,9
+1170,9
@@
static int throw (struct command_t *command)
return throw_support(DRAGON_SCALES);
if (AT(TROLL))
return throw_support(TROLL_RETURNS);
return throw_support(DRAGON_SCALES);
if (AT(TROLL))
return throw_support(TROLL_RETURNS);
-
else
if (AT(OGRE))
+ if (AT(OGRE))
return throw_support(OGRE_DODGE);
return throw_support(OGRE_DODGE);
-
else
if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
+ if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
/* This'll teach him to throw the axe at the bear! */
drop(AXE, game.loc);
game.fixed[AXE] = IS_FIXED;
/* This'll teach him to throw the axe at the bear! */
drop(AXE, game.loc);
game.fixed[AXE] = IS_FIXED;
@@
-1290,10
+1289,10
@@
int action(struct command_t *command)
else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
command->obj == LIQLOC(game.loc))
/* FALL THROUGH */;
else if ((LIQUID() == command->obj && HERE(BOTTLE)) ||
command->obj == LIQLOC(game.loc))
/* FALL THROUGH */;
- else if (command->obj == OIL && HERE(URN) && game.prop[URN] !=
0
) {
+ else if (command->obj == OIL && HERE(URN) && game.prop[URN] !=
URN_EMPTY
) {
command->obj = URN;
/* FALL THROUGH */;
command->obj = URN;
/* FALL THROUGH */;
- } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] !=
0
) {
+ } else if (command->obj == PLANT && AT(PLANT2) && game.prop[PLANT2] !=
PLANT_THIRSTY
) {
command->obj = PLANT2;
/* FALL THROUGH */;
} else if (command->obj == KNIFE && game.knfloc == game.loc) {
command->obj = PLANT2;
/* FALL THROUGH */;
} else if (command->obj == KNIFE && game.knfloc == game.loc) {