static void blast(void)
/* Blast. No effect unless you've got dynamite, which is a neat trick! */
{
- if (game.objects[ROD2].prop == STATE_NOTFOUND || !game.closed)
+ if (PROP_IS_NOTFOUND(ROD2) || !game.closed)
rspeak(REQUIRES_DYNAMITE);
else {
if (HERE(ROD2)) {
}
- if (obj == BIRD && game.objects[BIRD].prop != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) {
+ if (obj == BIRD && game.objects[BIRD].prop != BIRD_CAGED && !PROP_IS_STASHED(BIRD)) {
if (game.objects[BIRD].prop == BIRD_FOREST_UNCAGED) {
DESTROY(BIRD);
rspeak(BIRD_CRAP);
game.objects[BIRD].prop = BIRD_CAGED;
}
if ((obj == BIRD || obj == CAGE) &&
- (game.objects[BIRD].prop == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) {
+ (game.objects[BIRD].prop == BIRD_CAGED || PROP_STASHED(BIRD) == BIRD_CAGED)) {
/* expression maps BIRD to CAGE and CAGE to BIRD */
carry(BIRD + CAGE - obj, game.loc);
}
if (obj == BOTTLE && LIQUID() != NO_OBJECT)
game.objects[LIQUID()].place = CARRIED;
- if (GSTONE(obj) && game.objects[obj].prop != STATE_FOUND) {
- game.objects[obj].prop = STATE_FOUND;
+ if (GSTONE(obj) && !PROP_IS_FOUND(obj)) {
+ PROP_SET_FOUND(obj);
game.objects[CAVITY].prop = CAVITY_EMPTY;
}
rspeak(OK_MAN);
soundlatch = true;
}
for (obj_t i = 1; i <= NOBJECTS; i++) {
- if (!HERE(i) || objects[i].sounds[0] == NULL || game.objects[i].prop < 0)
+ if (!HERE(i) || objects[i].sounds[0] == NULL || PROP_IS_STASHED_OR_UNSEEN(i))
continue;
int mi = game.objects[i].prop;
/* (ESR) Some unpleasant magic on object states here. Ideally
} else {
pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well.
}
- } else if (objects[command.obj].texts[0] == NULL ||
- game.objects[command.obj].prop == STATE_NOTFOUND) {
+ } else if (objects[command.obj].texts[0] == NULL || PROP_IS_NOTFOUND(command.obj)) {
speak(actions[command.verb].message);
} else
pspeak(command.obj, study, true, game.objects[command.obj].prop);
}
if (game.objects[BIRD].prop == BIRD_UNCAGED && game.loc == game.objects[STEPS].place
- && game.objects[JADE].prop == STATE_NOTFOUND) {
+ && PROP_IS_NOTFOUND(JADE)) {
drop(JADE, game.loc);
- game.objects[JADE].prop = STATE_FOUND;
+ PROP_SET_FOUND(JADE);
--game.tally;
rspeak(NECKLACE_FLY);
return GO_CLEAROBJ;
#define IS_FIXED -1
#define IS_FREE 0
-/* Map a state property value to a negative range, where the object cannot be
+/* STASH 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.objects[obj].prop)
+#define PROP_STASHED(obj) (STATE_NOTFOUND - game.objects[obj].prop)
+#define PROP_IS_STASHED(obj) (game.objects[obj].prop < STATE_NOTFOUND)
+#define PROP_IS_NOTFOUND(obj) (game.objects[obj].prop == STATE_NOTFOUND)
+/* Don't use this on an object wi nore thab 2 (unstashed) states */
+#define PROP_IS_FOUND(obj) (game.objects[obj].prop == STATE_FOUND)
+/* Magic number -2 allows a PROP_STASHED version of state 1 */
+#define PROP_IS_INVALID(val) (val < -2 || val > 1)
+#define PROP_IS_STASHED_OR_UNSEEN(obj) (game.objects[obj].prop < 0)
+#define PROP_SET_FOUND(obj) (game.objects[obj].prop = STATE_FOUND)
+#define PROP_SET_NOT_FOUND(obj) (game.objects[obj].prop = STATE_NOTFOUND)
#define PROMPT "> "
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
if (objects[treasure].is_treasure) {
if (objects[treasure].inventory != 0)
- game.objects[treasure].prop = STATE_NOTFOUND;
+ PROP_SET_NOT_FOUND(treasure);
game.tally = game.tally - game.objects[treasure].prop;
}
}
game.hints[hint].lc = 0;
return;
case 4: /* dark */
- if (game.objects[EMERALD].prop != STATE_NOTFOUND && game.objects[PYRAMID].prop == STATE_NOTFOUND)
+ if (!PROP_IS_NOTFOUND(EMERALD) && PROP_IS_NOTFOUND(PYRAMID))
break;
game.hints[hint].lc = 0;
return;
break;
return;
case 9: /* jade */
- if (game.tally == 1 && game.objects[JADE].prop < 0)
+ if (game.tally == 1 && PROP_IS_STASHED_OR_UNSEEN(JADE))
break;
game.hints[hint].lc = 0;
return;
/* The pirate's spotted him. Pirate leaves him alone once we've
* found chest. K counts if a treasure is here. If not, and
* tally=1 for an unseen chest, let the pirate be spotted. Note
- * that game.place[CHEST] = LOC_NOWHERE might mean that he's thrown
+ * that game.objexts,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.objects[CHEST].prop != STATE_NOTFOUND)
+ * PROP_IS_FOUND(CHEST) == true. */
+ if (game.loc == game.chloc || !PROP_IS_NOTFOUND(CHEST))
return true;
int snarfed = 0;
bool movechest = false, robplayer = false;
obj = obj - NOBJECTS;
if (obj == STEPS && TOTING(NUGGET))
continue;
- if (game.objects[obj].prop < 0) {
+ if (PROP_IS_STASHED_OR_UNSEEN(obj)) {
if (game.closed)
continue;
- game.objects[obj].prop = STATE_FOUND;
+ PROP_SET_FOUND(obj);
if (obj == RUG)
game.objects[RUG].prop = RUG_DRAGON;
if (obj == CHAIN)
pspeak(OYSTER, look, true, 1);
for (size_t i = 1; i <= NOBJECTS; i++) {
if (TOTING(i) && game.objects[i].prop < 0)
- game.objects[i].prop = STASHED(i);
+ game.objects[i].prop = PROP_STASHED(i);
}
}
* negated game.prop values for the repository objects. */
{
move(object, where);
- game.objects[object].prop = (-1) - pval;; // Needs to stay synchronized with STASHED
+ game.objects[object].prop = (-1) - pval;; // Needs to stay synchronized with PROP_STASHED
}
void carry(obj_t object, loc_t where)
/* 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.objects[obj].prop < -2 || valgame.objects[obj].prop > 1) {
+ if (PROP_IS_INVALID(valgame.objects[obj].prop)) {
switch (obj) {
case RUG:
case DRAGON:
k = 16;
if (game.objects[i].prop > STATE_NOTFOUND)
score += 2;
- if (game.objects[i].place == LOC_BUILDING && game.objects[i].prop == STATE_FOUND)
+ if (game.objects[i].place == LOC_BUILDING && PROP_IS_FOUND(i))
score += k - 2;
mxscor += k;
}