static int fill(token_t, token_t);
static void state_change(long obj, long state)
+/* Object must have a change-message list for this to be useful; only some do */
{
game.prop[obj] = state;
pspeak(obj, change, state, true);
if (TOTING(VASE))
drop(VASE, game.loc);
state_change(VASE, VASE_BROKEN);
- game.fixed[VASE] = -1;
+ game.fixed[VASE] = IS_FIXED;
return GO_CLEAROBJ;
}
rspeak(actions[verb].message);
return GO_CLEAROBJ;
}
- if (game.fixed[obj] != 0) {
- if (obj == PLANT && game.prop[PLANT] <= 0) {
+ if (game.fixed[obj] != IS_FREE) {
+ /* Next guard tests whether plant is tiny or stashed */
+ if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) {
rspeak(DEEP_ROOTS);
return GO_CLEAROBJ;
}
rspeak(YOU_JOKING);
return GO_CLEAROBJ;
}
- int spk;
+
if (obj == WATER ||
obj == OIL) {
if (!HERE(BOTTLE) ||
obj = BOTTLE;
}
- spk = CARRY_LIMIT;
if (game.holdng >= INVLIMIT) {
- rspeak(spk);
+ rspeak(CARRY_LIMIT);
return GO_CLEAROBJ;
- } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
+
+ }
+
+ if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
DESTROY(BIRD);
rspeak(BIRD_CRAP);
return GO_CLEAROBJ;
}
- if (!TOTING(CAGE))
- spk = CANNOT_CARRY;
- if (TOTING(ROD))
- spk = BIRD_EVADES;
- if (spk == CANNOT_CARRY ||
- spk == BIRD_EVADES) {
- rspeak(spk);
+ if (!TOTING(CAGE)) {
+ rspeak(CANNOT_CARRY);
+ return GO_CLEAROBJ;
+ }
+ if (TOTING(ROD)) {
+ rspeak(BIRD_EVADES);
return GO_CLEAROBJ;
}
game.prop[BIRD] = BIRD_CAGED;
}
- /* FIXME: Arithmetic on state numbers */
if ((obj == BIRD ||
obj == CAGE) &&
- (game.prop[BIRD] == BIRD_CAGED ||
- -1 - game.prop[BIRD] == 1))
+ (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
+ /* expression maps BIRD to CAGE and CAGE to BIRD */
carry(BIRD + CAGE - obj, game.loc);
carry(obj, game.loc);
if (obj == BOTTLE && LIQUID() != NO_OBJECT)
game.place[LIQUID()] = CARRIED;
- if (GSTONE(obj) && game.prop[obj] != 0) {
- game.prop[obj]
- = STATE_GROUND;
+ if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
+ game.prop[obj] = STATE_FOUND;
game.prop[CAVITY] = CAVITY_EMPTY;
}
rspeak(OK_MAN);
return GO_CLEAROBJ;
}
game.prop[CHAIN] = CHAIN_HEAP;
- game.fixed[CHAIN] = CHAIN_HEAP;
+ game.fixed[CHAIN] = IS_FREE;
if (game.prop[BEAR] != BEAR_DEAD)
game.prop[BEAR] = CONTENTED_BEAR;
switch (game.prop[BEAR]) {
case BEAR_DEAD:
- game.fixed[BEAR] = -1;
+ game.fixed[BEAR] = IS_FIXED;
break;
default:
- game.fixed[BEAR] = 0;
+ game.fixed[BEAR] = IS_FREE;
}
rspeak(CHAIN_UNLOCKED);
return GO_CLEAROBJ;
if (TOTING(CHAIN))
drop(CHAIN, game.loc);
- game.fixed[CHAIN] = -1;
+ game.fixed[CHAIN] = IS_FIXED;
rspeak(CHAIN_LOCKED);
return GO_CLEAROBJ;
* bird (might attack snake or dragon) and cage (might contain bird) and vase.
* Drop coins at vending machine for extra batteries. */
{
- int spk = actions[verb].message;
if (!just_do_it) {
if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))
obj = ROD2;
if (!TOTING(obj)) {
- rspeak(spk);
+ rspeak(actions[verb].message);
return GO_CLEAROBJ;
}
if (obj == BIRD && HERE(SNAKE)) {
} else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) {
rspeak(GEM_FITS);
- game.prop[obj] = 1;
+ game.prop[obj] = STATE_IN_CAVITY;
game.prop[CAVITY] = CAVITY_FULL;
if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) ||
(obj == RUBY && game.prop[RUG] == RUG_HOVER))) {
- spk = RUG_RISES;
+ int spk = RUG_RISES;
if (TOTING(RUG))
spk = RUG_WIGGLES;
if (obj == RUBY)
/* FIXME: Arithmetic on state numbers */
int k = 2 - game.prop[RUG];
game.prop[RUG] = k;
- if (k == 2)
+ if (k == RUG_HOVER)
k = objects[SAPPH].plac;
move(RUG + NOBJECTS, k);
}
game.loc == objects[PILLOW].plac) {
rspeak(OK_MAN);
} else {
- game.prop[VASE] = VASE_BROKEN;
- if (AT(PILLOW))
- game.prop[VASE] = VASE_WHOLE;
- pspeak(VASE, look, game.prop[VASE] + 1, true);
+ state_change(VASE, AT(PILLOW)
+ ? VASE_WHOLE
+ : VASE_DROPPED);
if (game.prop[VASE] != VASE_WHOLE)
- game.fixed[VASE] = -1;
+ game.fixed[VASE] = IS_FIXED;
}
}
int k = LIQUID();
if (k == obj)
obj = BOTTLE;
- if (obj == BOTTLE && k != 0)
+ if (obj == BOTTLE && k != NO_OBJECT)
game.place[k] = LOC_NOWHERE;
if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
drop(BIRD, game.loc);
return GO_CLEAROBJ;
}
if (LIQUID() == WATER && HERE(BOTTLE)) {
- game.prop[BOTTLE] = EMPTY_BOTTLE;
game.place[WATER] = LOC_NOWHERE;
- rspeak(BOTTLE_EMPTY);
+ state_change(BOTTLE, EMPTY_BOTTLE);
return GO_CLEAROBJ;
}
if (HERE(FOOD)) {
DESTROY(FOOD);
game.prop[BEAR] = SITTING_BEAR;
- game.fixed[AXE] = 0;
- game.prop[AXE] = 0;
+ game.fixed[AXE] = IS_FREE;
+ game.prop[AXE] = AXE_HERE;
spk = BEAR_TAMED;
}
} else if (obj == OGRE) {
}
rspeak(SHATTER_VASE);
game.prop[VASE] = VASE_BROKEN;
- game.fixed[VASE] = -1;
- return (discard(verb, obj, true));
+ game.fixed[VASE] = IS_FIXED;
+ return (discard(verb, VASE, true));
}
if (obj == URN) {
return GO_CLEAROBJ;
}
- game.prop[BOTTLE] = (LIQLOC(game.loc) == OIL) ? OIL_BOTTLE : WATER_BOTTLE;
+ state_change(BOTTLE, (LIQLOC(game.loc) == OIL)
+ ? OIL_BOTTLE
+ : WATER_BOTTLE);
if (TOTING(BOTTLE))
game.place[LIQUID()] = CARRIED;
- if (LIQUID() == OIL)
- rspeak(BOTTLED_OIL);
- else
- rspeak(BOTTLED_WATER);
return GO_CLEAROBJ;
}
/* FIXME: Arithmetic on location values */
game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
- if (game.prop[SAPPH] >= 0) {
- rspeak(RUG_RETURNS);
- } else {
+ if (game.prop[SAPPH] == STATE_NOTFOUND) {
rspeak(RUG_GOES);
+ } else {
+ rspeak(RUG_RETURNS);
}
return GO_TERMINATE;
}
}
static int listen(void)
-/* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */
+/* Listen. Intransitive only. Print stuff based on object sound proprties. */
{
long sound = locations[game.loc].sound;
if (sound != SILENT) {
long packed_zzword = token_to_packed(game.zzword);
pspeak(i, hear, mi, true, packed_zzword);
rspeak(NO_MESSAGE);
- /* FIXME: Magic number, sensitive to bird state logic */
- if (i == BIRD && game.prop[i] == 5)
+ if (i == BIRD && mi == BIRD_ENDSTATE)
DESTROY(BIRD);
return GO_CLEAROBJ;
}
char word1[TOKLEN + 1];
packed_to_token(command->wd1, word1);
int wd = (int) get_vocab_id(word1);
- /* FIXME: magic numbers */
if (wd == MOTION_WORD(XYZZY) ||
wd == MOTION_WORD(PLUGH) ||
wd == MOTION_WORD(PLOVER) ||
* (Only way to do so!) Axe also special for dragon, bear, and
* troll. Treasures special for troll. */
{
- if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD))
- command->obj = ROD2;
if (!TOTING(command->obj)) {
rspeak(actions[command->verb].message);
return GO_CLEAROBJ;
else 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] = -1;
+ game.fixed[AXE] = IS_FIXED;
juggle(BEAR);
state_change(AXE, AXE_LOST);
return GO_CLEAROBJ;
if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
drop(JADE, game.loc);
- game.prop[JADE] = 0;
+ game.prop[JADE] = STATE_FOUND;
--game.tally;
rspeak(NECKLACE_FLY);
return GO_CLEAROBJ;