Abstract out some state arithmetic.
This commit is contained in:
parent
4ac9df527b
commit
a8ac2f477a
3 changed files with 8 additions and 4 deletions
|
@ -361,7 +361,7 @@ static int vcarry(token_t verb, token_t obj)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
|
||||||
DESTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
rspeak(BIRD_CRAP);
|
rspeak(BIRD_CRAP);
|
||||||
|
@ -380,8 +380,7 @@ static int vcarry(token_t verb, token_t obj)
|
||||||
/* FIXME: Arithmetic on state numbers */
|
/* FIXME: Arithmetic on state numbers */
|
||||||
if ((obj == BIRD ||
|
if ((obj == BIRD ||
|
||||||
obj == CAGE) &&
|
obj == CAGE) &&
|
||||||
(game.prop[BIRD] == BIRD_CAGED ||
|
(game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED))
|
||||||
-1 - game.prop[BIRD] == 1))
|
|
||||||
carry(BIRD + CAGE - obj, game.loc);
|
carry(BIRD + CAGE - obj, game.loc);
|
||||||
carry(obj, game.loc);
|
carry(obj, game.loc);
|
||||||
if (obj == BOTTLE && LIQUID() != NO_OBJECT)
|
if (obj == BOTTLE && LIQUID() != NO_OBJECT)
|
||||||
|
|
5
advent.h
5
advent.h
|
@ -29,6 +29,11 @@
|
||||||
#define STATE_NOTFOUND -1 // 'Not found" state of treasures */
|
#define STATE_NOTFOUND -1 // 'Not found" state of treasures */
|
||||||
#define STATE_GROUND 0 // After discovered, before messed with
|
#define STATE_GROUND 0 // After discovered, before messed with
|
||||||
|
|
||||||
|
/* 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. */
|
||||||
|
#define STASHED(obj) (-1 - game.prop[obj])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MOD(N,M) = Arithmetic modulus
|
* MOD(N,M) = Arithmetic modulus
|
||||||
* AT(OBJ) = true if on either side of two-placed object
|
* AT(OBJ) = true if on either side of two-placed object
|
||||||
|
|
2
main.c
2
main.c
|
@ -1028,7 +1028,7 @@ L2600:
|
||||||
pspeak(OYSTER, look, 1, true);
|
pspeak(OYSTER, look, 1, true);
|
||||||
for (size_t i = 1; i <= NOBJECTS; i++) {
|
for (size_t i = 1; i <= NOBJECTS; i++) {
|
||||||
if (TOTING(i) && game.prop[i] < 0)
|
if (TOTING(i) && game.prop[i] < 0)
|
||||||
game.prop[i] = -1 - game.prop[i];
|
game.prop[i] = STASHED(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
game.wzdark = DARK(game.loc);
|
game.wzdark = DARK(game.loc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue