obj = SNAKE;
++changes;
}
- if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
+ if (AT(DRAGON) && game.objects[DRAGON].prop == DRAGON_BARS) {
obj = DRAGON;
++changes;
}
obj = OGRE;
++changes;
}
- if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
+ if (HERE(BEAR) && game.objects[BEAR].prop == UNTAMED_BEAR) {
obj = BEAR;
++changes;
}
}
if (obj == VEND) {
state_change(VEND,
- game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
+ game.objects[VEND].prop == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
return GO_CLEAROBJ;
}
if (obj == BEAR) {
- switch (game.prop[BEAR]) {
+ switch (game.objects[BEAR].prop) {
case UNTAMED_BEAR:
rspeak(BEAR_HANDS);
break;
}
return GO_CLEAROBJ;
}
- if (obj == DRAGON && game.prop[DRAGON] == DRAGON_BARS) {
+ if (obj == DRAGON && game.objects[DRAGON].prop == DRAGON_BARS) {
/* Fun stuff for dragon. If he insists on attacking it, win!
* Set game.prop to dead, move dragon to central loc (still
* fixed), move rug there (not fixed), and move him there,
return GO_MOVE;
}
state_change(DRAGON, DRAGON_DEAD);
- game.prop[RUG] = RUG_FLOOR;
+ game.objects[RUG].prop = RUG_FLOOR;
/* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
* The way it was computed before was worse; it depended on the
* two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
move(RUG, LOC_SECRET5);
drop(BLOOD, LOC_SECRET5);
for (obj_t i = 1; i <= NOBJECTS; i++) {
- if (game.place[i] == objects[DRAGON].plac ||
- game.place[i] == objects[DRAGON].fixd)
+ if (game.objects[i].place == objects[DRAGON].plac ||
+ game.objects[i].place == objects[DRAGON].fixd)
move(i, LOC_SECRET5);
}
game.loc = LOC_SECRET5;
return GO_CLEAROBJ;
}
game.foobar = WORD_EMPTY;
- if (game.place[EGGS] == objects[EGGS].plac ||
+ if (game.objects[EGGS].place == objects[EGGS].plac ||
(TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
rspeak(NOTHING_HAPPENS);
return GO_CLEAROBJ;
} else {
/* Bring back troll if we steal the eggs back from him before
* crossing. */
- if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
- game.prop[TROLL] = TROLL_PAIDONCE;
+ if (game.objects[EGGS].place == LOC_NOWHERE && game.objects[TROLL].place == LOC_NOWHERE
+ && game.objects[TROLL].prop == TROLL_UNPAID)
+ game.objects[TROLL].prop = TROLL_PAIDONCE;
if (HERE(EGGS))
pspeak(EGGS, look, true, EGGS_VANISHED);
else if (game.loc == objects[EGGS].plac)
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.objects[ROD2].prop == STATE_NOTFOUND || !game.closed)
rspeak(REQUIRES_DYNAMITE);
else {
if (HERE(ROD2)) {
break;
}
case VASE:
- if (game.prop[VASE] == VASE_WHOLE) {
+ if (game.objects[VASE].prop == VASE_WHOLE) {
if (TOTING(VASE))
drop(VASE, game.loc);
state_change(VASE, VASE_BROKEN);
- game.fixed[VASE] = IS_FIXED;
+ game.objects[VASE].fixed = IS_FIXED;
break;
}
/* FALLTHRU */
return GO_CLEAROBJ;
}
- if (game.fixed[obj] != IS_FREE) {
+ if (game.objects[obj].fixed != IS_FREE) {
switch (obj) {
case PLANT:
/* Next guard tests whether plant is tiny or stashed */
- rspeak(game.prop[PLANT] <= PLANT_THIRSTY ? DEEP_ROOTS : YOU_JOKING);
+ rspeak(game.objects[PLANT].prop <= PLANT_THIRSTY ? DEEP_ROOTS : YOU_JOKING);
break;
case BEAR:
- rspeak( game.prop[BEAR] == SITTING_BEAR ? BEAR_CHAINED : YOU_JOKING);
+ rspeak( game.objects[BEAR].prop == SITTING_BEAR ? BEAR_CHAINED : YOU_JOKING);
break;
case CHAIN:
- rspeak( game.prop[BEAR] != UNTAMED_BEAR ? STILL_LOCKED : YOU_JOKING);
+ rspeak( game.objects[BEAR].prop != UNTAMED_BEAR ? STILL_LOCKED : YOU_JOKING);
break;
case RUG:
- rspeak(game.prop[RUG] == RUG_HOVER ? RUG_HOVERS : YOU_JOKING);
+ rspeak(game.objects[RUG].prop == RUG_HOVER ? RUG_HOVERS : YOU_JOKING);
break;
case URN:
rspeak(URN_NOBUDGE);
rspeak(NO_CONTAINER);
return GO_CLEAROBJ;
}
- if (game.prop[BOTTLE] == EMPTY_BOTTLE) {
+ if (game.objects[BOTTLE].prop == EMPTY_BOTTLE) {
return (fill(verb, BOTTLE));
} else
rspeak(BOTTLE_FULL);
}
- if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
- if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
+ if (obj == BIRD && game.objects[BIRD].prop != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
+ if (game.objects[BIRD].prop == BIRD_FOREST_UNCAGED) {
DESTROY(BIRD);
rspeak(BIRD_CRAP);
return GO_CLEAROBJ;
rspeak(BIRD_EVADES);
return GO_CLEAROBJ;
}
- game.prop[BIRD] = BIRD_CAGED;
+ game.objects[BIRD].prop = BIRD_CAGED;
}
if ((obj == BIRD || obj == CAGE) &&
- (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
+ (game.objects[BIRD].prop == 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;
+ game.objects[LIQUID()].place = CARRIED;
- if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) {
- game.prop[obj] = STATE_FOUND;
- game.prop[CAVITY] = CAVITY_EMPTY;
+ if (GSTONE(obj) && game.objects[obj].prop != STATE_FOUND) {
+ game.objects[obj].prop = STATE_FOUND;
+ game.objects[CAVITY].prop = CAVITY_EMPTY;
}
rspeak(OK_MAN);
return GO_CLEAROBJ;
/* Do something to the bear's chain */
{
if (verb != LOCK) {
- if (game.prop[BEAR] == UNTAMED_BEAR) {
+ if (game.objects[BEAR].prop == UNTAMED_BEAR) {
rspeak(BEAR_BLOCKS);
return GO_CLEAROBJ;
}
- if (game.prop[CHAIN] == CHAIN_HEAP) {
+ if (game.objects[CHAIN].prop == CHAIN_HEAP) {
rspeak(ALREADY_UNLOCKED);
return GO_CLEAROBJ;
}
- game.prop[CHAIN] = CHAIN_HEAP;
- game.fixed[CHAIN] = IS_FREE;
- if (game.prop[BEAR] != BEAR_DEAD)
- game.prop[BEAR] = CONTENTED_BEAR;
+ game.objects[CHAIN].prop = CHAIN_HEAP;
+ game.objects[CHAIN].fixed = IS_FREE;
+ if (game.objects[BEAR].prop != BEAR_DEAD)
+ game.objects[BEAR].prop = CONTENTED_BEAR;
- switch (game.prop[BEAR]) {
+ switch (game.objects[BEAR].prop) {
// LCOV_EXCL_START
case BEAR_DEAD:
/* Can't be reached until the bear can die in some way other
* than a bridge collapse. Leave in in case this changes, but
* exclude from coverage testing. */
- game.fixed[BEAR] = IS_FIXED;
+ game.objects[BEAR].fixed = IS_FIXED;
break;
// LCOV_EXCL_STOP
default:
- game.fixed[BEAR] = IS_FREE;
+ game.objects[BEAR].fixed = IS_FREE;
}
rspeak(CHAIN_UNLOCKED);
return GO_CLEAROBJ;
}
- if (game.prop[CHAIN] != CHAIN_HEAP) {
+ if (game.objects[CHAIN].prop != CHAIN_HEAP) {
rspeak(ALREADY_LOCKED);
return GO_CLEAROBJ;
}
return GO_CLEAROBJ;
}
- game.prop[CHAIN] = CHAIN_FIXED;
+ game.objects[CHAIN].prop = CHAIN_FIXED;
if (TOTING(CHAIN))
drop(CHAIN, game.loc);
- game.fixed[CHAIN] = IS_FIXED;
+ game.objects[CHAIN].fixed = IS_FIXED;
rspeak(CHAIN_LOCKED);
return GO_CLEAROBJ;
return GO_CLEAROBJ;
}
- if (GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL) {
+ if (GSTONE(obj) && AT(CAVITY) && game.objects[CAVITY].prop != CAVITY_FULL) {
rspeak(GEM_FITS);
- 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))) {
+ game.objects[obj].prop = STATE_IN_CAVITY;
+ game.objects[CAVITY].prop = CAVITY_FULL;
+ if (HERE(RUG) && ((obj == EMERALD && game.objects[RUG].prop != RUG_HOVER) ||
+ (obj == RUBY && game.objects[RUG].prop == RUG_HOVER))) {
if (obj == RUBY)
rspeak(RUG_SETTLES);
else if (TOTING(RUG))
else
rspeak(RUG_RISES);
if (!TOTING(RUG) || obj == RUBY) {
- int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
- game.prop[RUG] = k;
+ int k = (game.objects[RUG].prop == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
+ game.objects[RUG].prop = k;
if (k == RUG_HOVER)
k = objects[SAPPH].plac;
move(RUG + NOBJECTS, k);
if (LIQUID() == obj)
obj = BOTTLE;
if (obj == BOTTLE && LIQUID() != NO_OBJECT) {
- game.place[LIQUID()] = LOC_NOWHERE;
+ game.objects[LIQUID()].place = LOC_NOWHERE;
}
if (obj == BEAR && AT(TROLL)) {
state_change(VASE, AT(PILLOW)
? VASE_WHOLE
: VASE_DROPPED);
- if (game.prop[VASE] != VASE_WHOLE)
- game.fixed[VASE] = IS_FIXED;
+ if (game.objects[VASE].prop != VASE_WHOLE)
+ game.objects[VASE].fixed = IS_FIXED;
drop(obj, game.loc);
return GO_CLEAROBJ;
}
}
- if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) {
+ if (obj == CAGE && game.objects[BIRD].prop == BIRD_CAGED) {
drop(BIRD, game.loc);
}
if (obj == BIRD) {
- if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
+ if (AT(DRAGON) && game.objects[DRAGON].prop == DRAGON_BARS) {
rspeak(BIRD_BURNT);
DESTROY(BIRD);
return GO_CLEAROBJ;
return GO_DWARFWAKE;
DESTROY(SNAKE);
/* Set game.prop for use by travel options */
- game.prop[SNAKE] = SNAKE_CHASED;
+ game.objects[SNAKE].prop = SNAKE_CHASED;
} else
rspeak(OK_MAN);
- game.prop[BIRD] = FOREST(game.loc) ? BIRD_FOREST_UNCAGED : BIRD_UNCAGED;
+ game.objects[BIRD].prop = FOREST(game.loc) ? BIRD_FOREST_UNCAGED : BIRD_UNCAGED;
drop(obj, game.loc);
return GO_CLEAROBJ;
}
return GO_CLEAROBJ;
}
if (LIQUID() == WATER && HERE(BOTTLE)) {
- game.place[WATER] = LOC_NOWHERE;
+ game.objects[WATER].place = LOC_NOWHERE;
state_change(BOTTLE, EMPTY_BOTTLE);
return GO_CLEAROBJ;
}
/* Extinguish. Lamp, urn, dragon/volcano (nice try). */
{
if (obj == INTRANSITIVE) {
- if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
+ if (HERE(LAMP) && game.objects[LAMP].prop == LAMP_BRIGHT)
obj = LAMP;
- if (HERE(URN) && game.prop[URN] == URN_LIT)
+ if (HERE(URN) && game.objects[URN].prop == URN_LIT)
obj = URN;
if (obj == INTRANSITIVE)
return GO_UNKNOWN;
switch (obj) {
case URN:
- if (game.prop[URN] != URN_EMPTY) {
+ if (game.objects[URN].prop != URN_EMPTY) {
state_change(URN, URN_DARK);
} else {
pspeak(URN, change, true, URN_DARK);
rspeak(BIRD_PINING);
break;
case DRAGON:
- if (game.prop[DRAGON] != DRAGON_BARS)
+ if (game.objects[DRAGON].prop != DRAGON_BARS)
rspeak(RIDICULOUS_ATTEMPT);
else
rspeak(NOTHING_EDIBLE);
speak(actions[verb].message);
break;
case BEAR:
- if (game.prop[BEAR] == BEAR_DEAD) {
+ if (game.objects[BEAR].prop == BEAR_DEAD) {
rspeak(RIDICULOUS_ATTEMPT);
break;
}
- if (game.prop[BEAR] == UNTAMED_BEAR) {
+ if (game.objects[BEAR].prop == UNTAMED_BEAR) {
if (HERE(FOOD)) {
DESTROY(FOOD);
- game.fixed[AXE] = IS_FREE;
- game.prop[AXE] = AXE_HERE;
+ game.objects[AXE].fixed = IS_FREE;
+ game.objects[AXE].prop = AXE_HERE;
state_change(BEAR, SITTING_BEAR);
} else
rspeak(NOTHING_EDIBLE);
return GO_CLEAROBJ;
}
rspeak(SHATTER_VASE);
- game.prop[VASE] = VASE_BROKEN;
- game.fixed[VASE] = IS_FIXED;
+ game.objects[VASE].prop = VASE_BROKEN;
+ game.objects[VASE].fixed = IS_FIXED;
drop(VASE, game.loc);
return GO_CLEAROBJ;
}
if (obj == URN) {
- if (game.prop[URN] != URN_EMPTY) {
+ if (game.objects[URN].prop != URN_EMPTY) {
rspeak(FULL_URN);
return GO_CLEAROBJ;
}
int k = LIQUID();
switch (k) {
case WATER:
- game.prop[BOTTLE] = EMPTY_BOTTLE;
+ game.objects[BOTTLE].prop = EMPTY_BOTTLE;
rspeak(WATER_URN);
break;
case OIL:
- game.prop[URN] = URN_DARK;
- game.prop[BOTTLE] = EMPTY_BOTTLE;
+ game.objects[URN].prop = URN_DARK;
+ game.objects[BOTTLE].prop = EMPTY_BOTTLE;
rspeak(OIL_URN);
break;
case NO_OBJECT:
rspeak(FILL_INVALID);
return GO_CLEAROBJ;
}
- game.place[k] = LOC_NOWHERE;
+ game.objects[k].place = LOC_NOWHERE;
return GO_CLEAROBJ;
}
if (obj != INTRANSITIVE && obj != BOTTLE) {
if (obj == INTRANSITIVE && !HERE(BOTTLE))
return GO_UNKNOWN;
- if (HERE(URN) && game.prop[URN] != URN_EMPTY) {
+ if (HERE(URN) && game.objects[URN].prop != URN_EMPTY) {
rspeak(URN_NOPOUR);
return GO_CLEAROBJ;
}
? OIL_BOTTLE
: WATER_BOTTLE);
if (TOTING(BOTTLE))
- game.place[LIQUID()] = CARRIED;
+ game.objects[LIQUID()].place = CARRIED;
return GO_CLEAROBJ;
}
rspeak(FLAP_ARMS);
return GO_CLEAROBJ;
}
- if (game.prop[RUG] != RUG_HOVER) {
+ if (game.objects[RUG].prop != RUG_HOVER) {
rspeak(RUG_NOTHING2);
return GO_CLEAROBJ;
}
speak(actions[verb].message);
return GO_CLEAROBJ;
}
- if (game.prop[RUG] != RUG_HOVER) {
+ if (game.objects[RUG].prop != RUG_HOVER) {
rspeak(RUG_NOTHING1);
return GO_CLEAROBJ;
}
{
if (obj == INTRANSITIVE) {
int selects = 0;
- if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) {
+ if (HERE(LAMP) && game.objects[LAMP].prop == LAMP_DARK && game.limit >= 0) {
obj = LAMP;
selects++;
}
- if (HERE(URN) && game.prop[URN] == URN_DARK) {
+ if (HERE(URN) && game.objects[URN].prop == URN_DARK) {
obj = URN;
selects++;
}
switch (obj) {
case URN:
- state_change(URN, game.prop[URN] == URN_EMPTY ?
+ state_change(URN, game.objects[URN].prop == URN_EMPTY ?
URN_EMPTY :
URN_LIT);
break;
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.objects[i].prop < 0)
continue;
- int mi = game.prop[i];
+ int mi = game.objects[i].prop;
/* (ESR) Some unpleasant magic on object states here. Ideally
* we'd have liked the bird to be a normal object that we can
* use state_change() on; can't do it, because there are
rspeak(OYSTER_OPENS);
break;
case DOOR:
- rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
+ rspeak((game.objects[DOOR].prop == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
break;
case CAGE:
rspeak( NO_LOCK);
rspeak(CANT_POUR);
return GO_CLEAROBJ;
}
- if (HERE(URN) && game.prop[URN] == URN_EMPTY)
+ if (HERE(URN) && game.objects[URN].prop == URN_EMPTY)
return fill(verb, URN);
- game.prop[BOTTLE] = EMPTY_BOTTLE;
- game.place[obj] = LOC_NOWHERE;
+ game.objects[BOTTLE].prop = EMPTY_BOTTLE;
+ game.objects[obj].place = LOC_NOWHERE;
if (!(AT(PLANT) || AT(DOOR))) {
rspeak(GROUND_WET);
return GO_CLEAROBJ;
if (!AT(DOOR)) {
if (obj == WATER) {
/* cycle through the three plant states */
- state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
- game.prop[PLANT2] = game.prop[PLANT];
+ state_change(PLANT, MOD(game.objects[PLANT].prop + 1, 3));
+ game.objects[PLANT2].prop = game.objects[PLANT].prop;
return GO_MOVE;
} else {
rspeak(SHAKING_LEAVES);
if (command.obj == INTRANSITIVE) {
command.obj = NO_OBJECT;
for (int i = 1; i <= NOBJECTS; i++) {
- if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
+ if (HERE(i) && objects[i].texts[0] != NULL && game.objects[i].prop >= 0)
command.obj = command.obj * NOBJECTS + i;
}
if (command.obj > NOBJECTS || command.obj == NO_OBJECT || DARK(game.loc))
pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well.
}
} else if (objects[command.obj].texts[0] == NULL ||
- game.prop[command.obj] == STATE_NOTFOUND) {
+ game.objects[command.obj].prop == STATE_NOTFOUND) {
speak(actions[command.verb].message);
} else
- pspeak(command.obj, study, true, game.prop[command.obj]);
+ pspeak(command.obj, study, true, game.objects[command.obj].prop);
return GO_CLEAROBJ;
}
return GO_CLEAROBJ;
} else {
state_change(RESER,
- game.prop[RESER] == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
+ game.objects[RESER].prop == WATERS_PARTED ? WATERS_UNPARTED : WATERS_PARTED);
if (AT(RESER))
return GO_CLEAROBJ;
else {
static phase_codes_t rub(verb_t verb, obj_t obj)
/* Rub. Yields various snide remarks except for lit urn. */
{
- if (obj == URN && game.prop[URN] == URN_LIT) {
+ if (obj == URN && game.objects[URN].prop == URN_LIT) {
DESTROY(URN);
drop(AMBER, game.loc);
- game.prop[AMBER] = AMBER_IN_ROCK;
+ game.objects[AMBER].prop = AMBER_IN_ROCK;
--game.tally;
drop(CAVITY, game.loc);
rspeak(URN_GENIES);
return (discard(command.verb, command.obj));
else {
if (atdwrf(game.loc) <= 0) {
- if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS)
+ if (AT(DRAGON) && game.objects[DRAGON].prop == DRAGON_BARS)
return throw_support(DRAGON_SCALES);
if (AT(TROLL))
return throw_support(TROLL_RETURNS);
if (AT(OGRE))
return throw_support(OGRE_DODGE);
- if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) {
+ if (HERE(BEAR) && game.objects[BEAR].prop == UNTAMED_BEAR) {
/* This'll teach him to throw the axe at the bear! */
drop(AXE, game.loc);
- game.fixed[AXE] = IS_FIXED;
+ game.objects[AXE].fixed = IS_FIXED;
juggle(BEAR);
state_change(AXE, AXE_LOST);
return GO_CLEAROBJ;
return GO_CLEAROBJ;
}
- if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] == STATE_NOTFOUND) {
+ if (game.objects[BIRD].prop == BIRD_UNCAGED && game.loc == game.objects[STEPS].place
+ && game.objects[JADE].prop == STATE_NOTFOUND) {
drop(JADE, game.loc);
- game.prop[JADE] = STATE_FOUND;
+ game.objects[JADE].prop = STATE_FOUND;
--game.tally;
rspeak(NECKLACE_FLY);
return GO_CLEAROBJ;
} else {
if (game.closed) {
- rspeak((game.prop[BIRD] == BIRD_CAGED) ?
+ rspeak((game.objects[BIRD].prop == BIRD_CAGED) ?
CAGE_FLY :
FREE_FLY);
return GO_DWARFWAKE;
}
if (game.closng || !AT(FISSURE)) {
- rspeak((game.prop[BIRD] == BIRD_CAGED) ?
+ rspeak((game.objects[BIRD].prop == BIRD_CAGED) ?
CAGE_FLY :
FREE_FLY);
return GO_CLEAROBJ;
}
if (HERE(BIRD))
- rspeak((game.prop[BIRD] == BIRD_CAGED) ?
+ rspeak((game.objects[BIRD].prop == BIRD_CAGED) ?
CAGE_FLY :
FREE_FLY);
state_change(FISSURE,
- game.prop[FISSURE] == BRIDGED ? UNBRIDGED : BRIDGED);
+ game.objects[FISSURE].prop == BRIDGED ? UNBRIDGED : BRIDGED);
return GO_CLEAROBJ;
}
}
else if (!game.closed && ((LIQUID() == command.obj && HERE(BOTTLE)) ||
command.obj == LIQLOC(game.loc)))
/* FALL THROUGH */;
- else if (command.obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) {
+ else if (command.obj == OIL && HERE(URN) && game.objects[URN].prop != URN_EMPTY) {
command.obj = URN;
/* FALL THROUGH */;
- } else if (command.obj == PLANT && AT(PLANT2) && game.prop[PLANT2] != PLANT_THIRSTY) {
+ } else if (command.obj == PLANT && AT(PLANT2) && game.objects[PLANT2].prop != PLANT_THIRSTY) {
command.obj = PLANT2;
/* FALL THROUGH */;
} else if (command.obj == KNIFE && game.knfloc == game.loc) {
/* Map a state property value to a negative range, where the object cannot be
* picked up but the value can be recovered later. Avoid colliding with -1,
* which has its own meaning as STATE_NOTFOUND. */
-#define STASHED(obj) (-1 - game.prop[obj])
+#define STASHED(obj) (-1 - game.objects[obj].prop)
#define PROMPT "> "
*/
#define DESTROY(N) move(N, LOC_NOWHERE)
#define MOD(N,M) ((N) % (M))
-#define TOTING(OBJ) (game.place[OBJ] == CARRIED)
-#define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
+#define TOTING(OBJ) (game.objects[OBJ].place == CARRIED)
+#define AT(OBJ) (game.objects[OBJ].place == game.loc || game.objects[OBJ].fixed == game.loc)
#define HERE(OBJ) (AT(OBJ) || TOTING(OBJ))
#define CNDBIT(L,N) (tstbit(conditions[L],N))
-#define LIQUID() (game.prop[BOTTLE] == WATER_BOTTLE? WATER : game.prop[BOTTLE] == OIL_BOTTLE ? OIL : NO_OBJECT )
+#define LIQUID() (game.objects[BOTTLE].prop == WATER_BOTTLE? WATER : game.objects[BOTTLE].prop == OIL_BOTTLE ? OIL : NO_OBJECT )
#define LIQLOC(LOC) (CNDBIT((LOC),COND_FLUID)? CNDBIT((LOC),COND_OILY) ? OIL : WATER : NO_OBJECT)
#define FORCED(LOC) CNDBIT(LOC, COND_FORCED)
-#define DARK(DUMMY) (!CNDBIT(game.loc,COND_LIT) && (game.prop[LAMP] == LAMP_DARK || !HERE(LAMP)))
+#define DARK(DUMMY) (!CNDBIT(game.loc,COND_LIT) && (game.objects[LAMP].prop == LAMP_DARK || !HERE(LAMP)))
#define PCT(N) (randrange(100) < (N))
#define GSTONE(OBJ) ((OBJ) == EMERALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
#define FOREST(LOC) CNDBIT(LOC, COND_FOREST)
loc_t loc; // location of dwarves, initially hard-wired in
loc_t oldloc; // prior loc of each dwarf, initially garbage
} dwarves[NDWARVES + 1];
- loc_t fixed[NOBJECTS + 1]; // fixed location of object (if not IS_FREE)
+ struct object {
+ loc_t fixed; // fixed location of object (if not IS_FREE)
+ int prop; // object state */
+ loc_t place; // location of object
+ } objects[NOBJECTS + 1];
obj_t link[NOBJECTS * 2 + 1];// object-list links
- loc_t place[NOBJECTS + 1]; // location of object
bool hinted[NHINTS]; // hinted[i] = true iff hint i has been used.
int hintlc[NHINTS]; // hintlc[i] = show int at LOC with cond bit i
- int prop[NOBJECTS + 1]; // object state array */
};
/*
set_seed(seedval);
for (int i = 1; i <= NOBJECTS; i++) {
- game.place[i] = LOC_NOWHERE;
+ game.objects[i].place = LOC_NOWHERE;
}
for (int i = 1; i <= NLOCATIONS; i++) {
for (int i = 1; i <= NOBJECTS; i++) {
int k = NOBJECTS + 1 - i;
- game.fixed[k] = objects[k].fixd;
+ game.objects[k].fixed = objects[k].fixd;
if (objects[k].plac != 0 && objects[k].fixd <= 0)
drop(k, objects[k].plac);
}
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
if (objects[treasure].is_treasure) {
if (objects[treasure].inventory != 0)
- game.prop[treasure] = STATE_NOTFOUND;
- game.tally = game.tally - game.prop[treasure];
+ game.objects[treasure].prop = STATE_NOTFOUND;
+ game.tally = game.tally - game.objects[treasure].prop;
}
}
game.conds = setbit(COND_HBASE);
switch (hint) {
case 0:
/* cave */
- if (game.prop[GRATE] == GRATE_CLOSED && !HERE(KEYS))
+ if (game.objects[GRATE].prop == GRATE_CLOSED && !HERE(KEYS))
break;
game.hintlc[hint] = 0;
return;
case 1: /* bird */
- if (game.place[BIRD] == game.loc && TOTING(ROD) && game.oldobj == BIRD)
+ if (game.objects[BIRD].place == game.loc && TOTING(ROD) && game.oldobj == BIRD)
break;
return;
case 2: /* snake */
game.hintlc[hint] = 0;
return;
case 4: /* dark */
- if (game.prop[EMERALD] != STATE_NOTFOUND && game.prop[PYRAMID] == STATE_NOTFOUND)
+ if (game.objects[EMERALD].prop != STATE_NOTFOUND && game.objects[PYRAMID].prop == STATE_NOTFOUND)
break;
game.hintlc[hint] = 0;
return;
break;
return;
case 9: /* jade */
- if (game.tally == 1 && game.prop[JADE] < 0)
+ if (game.tally == 1 && game.objects[JADE].prop < 0)
break;
game.hintlc[hint] = 0;
return;
* that game.place[CHEST] = LOC_NOWHERE might mean that he's thrown
* it to the troll, but in that case he's seen the chest
* (game.prop[CHEST] == STATE_FOUND). */
- if (game.loc == game.chloc || game.prop[CHEST] != STATE_NOTFOUND)
+ if (game.loc == game.chloc || game.objects[CHEST].prop != STATE_NOTFOUND)
return true;
int snarfed = 0;
bool movechest = false, robplayer = false;
}
}
/* Force chest placement before player finds last treasure */
- if (game.tally == 1 && snarfed == 0 && game.place[CHEST] == LOC_NOWHERE && HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT) {
+ if (game.tally == 1 && snarfed == 0 && game.objects[CHEST].place == LOC_NOWHERE && HERE(LAMP) && game.objects[LAMP].prop == LAMP_BRIGHT) {
rspeak(PIRATE_SPOTTED);
movechest = true;
}
continue;
if (!(treasure == PYRAMID && (game.loc == objects[PYRAMID].plac ||
game.loc == objects[EMERALD].plac))) {
- if (AT(treasure) && game.fixed[treasure] == IS_FREE)
+ if (AT(treasure) && game.objects[treasure].fixed == IS_FREE)
carry(treasure, game.loc);
if (TOTING(treasure))
drop(treasure, game.chloc);
/* If player wishes to continue, we empty the liquids in the
* user's inventory, turn off the lamp, and drop all items
* where he died. */
- game.place[WATER] = game.place[OIL] = LOC_NOWHERE;
+ game.objects[WATER].place = game.objects[OIL].place = LOC_NOWHERE;
if (TOTING(LAMP))
- game.prop[LAMP] = LAMP_DARK;
+ game.objects[LAMP].prop = LAMP_DARK;
for (int j = 1; j <= NOBJECTS; j++) {
int i = NOBJECTS + 1 - j;
if (TOTING(i)) {
else if (TOTING(condarg1) || (condtype == cond_with && AT(condarg1)))
break;
/* else fall through to check [not OBJ STATE] */
- } else if (game.prop[condarg1] != condarg2)
+ } else if (game.objects[condarg1].prop != condarg2)
break;
/* We arrive here on conditional failure.
* (standard travel entries check for
* game.prop[TROLL]=TROLL_UNPAID.) Special stuff
* for bear. */
- if (game.prop[TROLL] == TROLL_PAIDONCE) {
+ if (game.objects[TROLL].prop == TROLL_PAIDONCE) {
pspeak(TROLL, look, true, TROLL_PAIDONCE);
- game.prop[TROLL] = TROLL_UNPAID;
+ game.objects[TROLL].prop = TROLL_UNPAID;
DESTROY(TROLL2);
move(TROLL2 + NOBJECTS, IS_FREE);
move(TROLL, objects[TROLL].plac);
return;
} else {
game.newloc = objects[TROLL].plac + objects[TROLL].fixd - game.loc;
- if (game.prop[TROLL] == TROLL_UNPAID)
- game.prop[TROLL] = TROLL_PAIDONCE;
+ if (game.objects[TROLL].prop == TROLL_UNPAID)
+ game.objects[TROLL].prop = TROLL_PAIDONCE;
if (!TOTING(BEAR))
return;
state_change(CHASM, BRIDGE_WRECKED);
- game.prop[TROLL] = TROLL_GONE;
+ game.objects[TROLL].prop = TROLL_GONE;
drop(BEAR, game.newloc);
- game.fixed[BEAR] = IS_FIXED;
- game.prop[BEAR] = BEAR_DEAD;
+ game.objects[BEAR].fixed = IS_FIXED;
+ game.objects[BEAR].prop = BEAR_DEAD;
game.oldlc2 = game.newloc;
croak();
return;
static void lampcheck(void)
/* Check game limit and lamp timers */
{
- if (game.prop[LAMP] == LAMP_BRIGHT)
+ if (game.objects[LAMP].prop == LAMP_BRIGHT)
--game.limit;
/* Another way we can force an end to things is by having the
* Second is for other cases of lamp dying. Even after it goes
* out, he can explore outside for a while if desired. */
if (game.limit <= WARNTIME) {
- if (HERE(BATTERY) && game.prop[BATTERY] == FRESH_BATTERIES && HERE(LAMP)) {
+ if (HERE(BATTERY) && game.objects[BATTERY].prop == FRESH_BATTERIES && HERE(LAMP)) {
rspeak(REPLACE_BATTERIES);
- game.prop[BATTERY] = DEAD_BATTERIES;
+ game.objects[BATTERY].prop = DEAD_BATTERIES;
#ifdef __unused__
/* This code from the original game seems to have been faulty.
* No tests ever passed the guard, and with the guard removed
game.lmwarn = false;
} else if (!game.lmwarn && HERE(LAMP)) {
game.lmwarn = true;
- if (game.prop[BATTERY] == DEAD_BATTERIES)
+ if (game.objects[BATTERY].prop == DEAD_BATTERIES)
rspeak(MISSING_BATTERIES);
- else if (game.place[BATTERY] == LOC_NOWHERE)
+ else if (game.objects[BATTERY].place == LOC_NOWHERE)
rspeak(LAMP_DIM);
else
rspeak(GET_BATTERIES);
}
if (game.limit == 0) {
game.limit = -1;
- game.prop[LAMP] = LAMP_DARK;
+ game.objects[LAMP].prop = LAMP_DARK;
if (HERE(LAMP))
rspeak(LAMP_OUT);
}
* know the bivalve is an oyster. *And*, the dwarves must
* have been activated, since we've found chest. */
if (game.clock1 == 0) {
- game.prop[GRATE] = GRATE_CLOSED;
- game.prop[FISSURE] = UNBRIDGED;
+ game.objects[GRATE].prop = GRATE_CLOSED;
+ game.objects[FISSURE].prop = UNBRIDGED;
for (int i = 1; i <= NDWARVES; i++) {
game.dwarves[i].seen = false;
game.dwarves[i].loc = LOC_NOWHERE;
move(TROLL2, objects[TROLL].plac);
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM);
- if (game.prop[BEAR] != BEAR_DEAD)
+ if (game.objects[BEAR].prop != BEAR_DEAD)
DESTROY(BEAR);
- game.prop[CHAIN] = CHAIN_HEAP;
- game.fixed[CHAIN] = IS_FREE;
- game.prop[AXE] = AXE_HERE;
- game.fixed[AXE] = IS_FREE;
+ game.objects[CHAIN].prop = CHAIN_HEAP;
+ game.objects[CHAIN].fixed = IS_FREE;
+ game.objects[AXE].prop = AXE_HERE;
+ game.objects[AXE].fixed = IS_FREE;
rspeak(CAVE_CLOSING);
game.clock1 = -1;
game.closng = true;
* objects he might be carrying (lest he have some which
* could cause trouble, such as the keys). We describe the
* flash of light and trundle back. */
- game.prop[BOTTLE] = put(BOTTLE, LOC_NE, EMPTY_BOTTLE);
- game.prop[PLANT] = put(PLANT, LOC_NE, PLANT_THIRSTY);
- game.prop[OYSTER] = put(OYSTER, LOC_NE, STATE_FOUND);
- game.prop[LAMP] = put(LAMP, LOC_NE, LAMP_DARK);
- game.prop[ROD] = put(ROD, LOC_NE, STATE_FOUND);
- game.prop[DWARF] = put(DWARF, LOC_NE, 0);
+ game.objects[BOTTLE].prop = put(BOTTLE, LOC_NE, EMPTY_BOTTLE);
+ game.objects[PLANT].prop = put(PLANT, LOC_NE, PLANT_THIRSTY);
+ game.objects[OYSTER].prop = put(OYSTER, LOC_NE, STATE_FOUND);
+ game.objects[LAMP].prop = put(LAMP, LOC_NE, LAMP_DARK);
+ game.objects[ROD].prop = put(ROD, LOC_NE, STATE_FOUND);
+ game.objects[DWARF].prop = put(DWARF, LOC_NE, 0);
game.loc = LOC_NE;
game.oldloc = LOC_NE;
game.newloc = LOC_NE;
* Reuse sign. */
put(GRATE, LOC_SW, 0);
put(SIGN, LOC_SW, 0);
- game.prop[SIGN] = ENDGAME_SIGN;
- game.prop[SNAKE] = put(SNAKE, LOC_SW, SNAKE_CHASED);
- game.prop[BIRD] = put(BIRD, LOC_SW, BIRD_CAGED);
- game.prop[CAGE] = put(CAGE, LOC_SW, STATE_FOUND);
- game.prop[ROD2] = put(ROD2, LOC_SW, STATE_FOUND);
- game.prop[PILLOW] = put(PILLOW, LOC_SW, STATE_FOUND);
+ game.objects[SIGN].prop = ENDGAME_SIGN;
+ game.objects[SNAKE].prop = put(SNAKE, LOC_SW, SNAKE_CHASED);
+ game.objects[BIRD].prop = put(BIRD, LOC_SW, BIRD_CAGED);
+ game.objects[CAGE].prop = put(CAGE, LOC_SW, STATE_FOUND);
+ game.objects[ROD2].prop = put(ROD2, LOC_SW, STATE_FOUND);
+ game.objects[PILLOW].prop = put(PILLOW, LOC_SW, STATE_FOUND);
- game.prop[MIRROR] = put(MIRROR, LOC_NE, STATE_FOUND);
- game.fixed[MIRROR] = LOC_SW;
+ game.objects[MIRROR].prop = put(MIRROR, LOC_NE, STATE_FOUND);
+ game.objects[MIRROR].fixed = LOC_SW;
for (int i = 1; i <= NOBJECTS; i++) {
if (TOTING(i))
obj = obj - NOBJECTS;
if (obj == STEPS && TOTING(NUGGET))
continue;
- if (game.prop[obj] < 0) {
+ if (game.objects[obj].prop < 0) {
if (game.closed)
continue;
- game.prop[obj] = STATE_FOUND;
+ game.objects[obj].prop = STATE_FOUND;
if (obj == RUG)
- game.prop[RUG] = RUG_DRAGON;
+ game.objects[RUG].prop = RUG_DRAGON;
if (obj == CHAIN)
- game.prop[CHAIN] = CHAINING_BEAR;
+ game.objects[CHAIN].prop = CHAINING_BEAR;
if (obj == EGGS)
game.seenbigwords = true;
--game.tally;
* gross blunder isn't likely to find everything else anyway
* (so goes the rationalisation). */
}
- int kk = game.prop[obj];
+ int kk = game.objects[obj].prop;
if (obj == STEPS)
- kk = (game.loc == game.fixed[STEPS])
+ kk = (game.loc == game.objects[STEPS].fixed)
? STEPS_UP
: STEPS_DOWN;
pspeak(obj, look, true, kk);
* game.prop < 0 and stash them. This way objects won't be
* described until they've been picked up and put down
* separate from their respective piles. */
- if (game.prop[OYSTER] < 0 && TOTING(OYSTER))
+ if (game.objects[OYSTER].prop < 0 && TOTING(OYSTER))
pspeak(OYSTER, look, true, 1);
for (size_t i = 1; i <= NOBJECTS; i++) {
- if (TOTING(i) && game.prop[i] < 0)
- game.prop[i] = STASHED(i);
+ if (TOTING(i) && game.objects[i].prop < 0)
+ game.objects[i].prop = STASHED(i);
}
}
{
loc_t i, j;
- i = game.place[object];
- j = game.fixed[object];
+ i = game.objects[object].place;
+ j = game.objects[object].fixed;
move(object, i);
move(object + NOBJECTS, j);
}
loc_t from;
if (object > NOBJECTS)
- from = game.fixed[object - NOBJECTS];
+ from = game.objects[object - NOBJECTS].fixed;
else
- from = game.place[object];
+ from = game.objects[object].place;
/* (ESR) Used to check for !SPECIAL(from). I *think* that was wrong... */
if (from != LOC_NOWHERE && from != CARRIED)
carry(object, from);
int temp;
if (object <= NOBJECTS) {
- if (game.place[object] == CARRIED)
+ if (game.objects[object].place == CARRIED)
return;
- game.place[object] = CARRIED;
+ game.objects[object].place = CARRIED;
/*
* Without this conditional your inventory is overcounted
* game.holdng if the object was being toted. No state change on the object. */
{
if (object > NOBJECTS)
- game.fixed[object - NOBJECTS] = where;
+ game.objects[object - NOBJECTS].fixed = where;
else {
- if (game.place[object] == CARRIED)
+ if (game.objects[object].place == CARRIED)
if (object != BIRD)
/* The bird has to be weightless. This ugly hack (and the
* corresponding code in the carry function) brought to you
* happen.
*/
--game.holdng;
- game.place[object] = where;
+ game.objects[object].place = where;
}
if (where == LOC_NOWHERE || where == CARRIED)
return;
void state_change(obj_t obj, int state)
/* Object must have a change-message list for this to be useful; only some do */
{
- game.prop[obj] = state;
+ game.objects[obj].prop = state;
pspeak(obj, change, true, state);
}
}
for (int i = 0; i <= NOBJECTS; i++) {
- if (valgame.place[i] < -1 || valgame.place[i] > NLOCATIONS ||
- valgame.fixed[i] < -1 || valgame.fixed[i] > NLOCATIONS) {
+ if (valgame.objects[i].place < -1 || valgame.objects[i].place > NLOCATIONS ||
+ valgame.objects[i].fixed < -1 || valgame.objects[i].fixed > NLOCATIONS) {
return false; // LCOV_EXCL_LINE
}
}
int temp_tally = 0;
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
if (objects[treasure].is_treasure) {
- if (valgame.prop[treasure] == STATE_NOTFOUND) {
+ if (valgame.objects[treasure].prop == STATE_NOTFOUND) {
++temp_tally;
}
}
/* Check that properties of objects aren't beyond expected */
for (obj_t obj = 0; obj <= NOBJECTS; obj++) {
/* Magic number -2 allows a STASHED version of state 1 */
- if (valgame.prop[obj] < -2 || valgame.prop[obj] > 1) {
+ if (valgame.objects[obj].prop < -2 || valgame.objects[obj].prop > 1) {
switch (obj) {
case RUG:
case DRAGON:
case EGGS:
case VASE:
case CHAIN:
- if (valgame.prop[obj] == 2) // There are multiple different states, but it's convenient to clump them together
+ if (valgame.objects[obj].prop == 2) // There are multiple different states, but it's convenient to clump them together
continue; // LCOV_EXCL_LINE
/* FALLTHRU */
case BEAR:
- if (valgame.prop[BEAR] == CONTENTED_BEAR || valgame.prop[BEAR] == BEAR_DEAD)
+ if (valgame.objects[BEAR].prop == CONTENTED_BEAR || valgame.objects[BEAR].prop == BEAR_DEAD)
continue;
/* FALLTHRU */
default:
k = 14;
if (i > CHEST)
k = 16;
- if (game.prop[i] > STATE_NOTFOUND)
+ if (game.objects[i].prop > STATE_NOTFOUND)
score += 2;
- if (game.place[i] == LOC_BUILDING && game.prop[i] == STATE_FOUND)
+ if (game.objects[i].place == LOC_BUILDING && game.objects[i].prop == STATE_FOUND)
score += k - 2;
mxscor += k;
}
mxscor += 45;
/* Did he come to Witt's End as he should? */
- if (game.place[MAGAZINE] == LOC_WITTSEND)
+ if (game.objects[MAGAZINE].place == LOC_WITTSEND)
score += 1;
mxscor += 1;