projects
/
open-adventure.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
da1f251
)
Magic-number elimination.
author
Eric S. Raymond
<esr@thyrsus.com>
Thu, 6 Jul 2017 01:45:55 +0000
(21:45 -0400)
committer
Eric S. Raymond
<esr@thyrsus.com>
Thu, 6 Jul 2017 01:45:55 +0000
(21:45 -0400)
actions.c
patch
|
blob
|
history
make_dungeon.py
patch
|
blob
|
history
diff --git
a/actions.c
b/actions.c
index af36ae6a68069212218b5c11076a9d3f74177b31..b1c1ce5c76603f8ead7f188770a5cf8cd912d0fc 100644
(file)
--- a/
actions.c
+++ b/
actions.c
@@
-112,19
+112,22
@@
static int attack(struct command_t *command)
}
state_change(DRAGON, DRAGON_DEAD);
game.prop[RUG] = RUG_FLOOR;
}
state_change(DRAGON, DRAGON_DEAD);
game.prop[RUG] = RUG_FLOOR;
- /* FIXME: Arithmetic on location values */
- int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
+ /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.
+ * The way it was computed before was wirse; it depended on the
+ * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and
+ * LOC_SECRET5 being right between them.
+ */
move(DRAGON + NOBJECTS, -1);
move(RUG + NOBJECTS, 0);
move(DRAGON + NOBJECTS, -1);
move(RUG + NOBJECTS, 0);
- move(DRAGON,
k
);
- move(RUG,
k
);
- drop(BLOOD,
k
);
+ move(DRAGON,
LOC_SECRET5
);
+ move(RUG,
LOC_SECRET5
);
+ drop(BLOOD,
LOC_SECRET5
);
for (obj = 1; obj <= NOBJECTS; obj++) {
if (game.place[obj] == objects[DRAGON].plac ||
game.place[obj] == objects[DRAGON].fixd)
for (obj = 1; obj <= NOBJECTS; obj++) {
if (game.place[obj] == objects[DRAGON].plac ||
game.place[obj] == objects[DRAGON].fixd)
- move(obj,
k
);
+ move(obj,
LOC_SECRET5
);
}
}
- game.loc =
k
;
+ game.loc =
LOC_SECRET5
;
return GO_MOVE;
}
return GO_MOVE;
}
@@
-475,7
+478,6
@@
static int discard(token_t verb, token_t obj, bool just_do_it)
spk = RUG_SETTLES;
rspeak(spk);
if (spk != RUG_WIGGLES) {
spk = RUG_SETTLES;
rspeak(spk);
if (spk != RUG_WIGGLES) {
- /* FIXME: Arithmetic on state numbers */
int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
game.prop[RUG] = k;
if (k == RUG_HOVER)
int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER;
game.prop[RUG] = k;
if (k == RUG_HOVER)
diff --git
a/make_dungeon.py
b/make_dungeon.py
index 9f0193ef00c057822070e64c6aa8e0df4cadea07..836d1483a8480d08616df65323613c61d965fb59 100755
(executable)
--- a/
make_dungeon.py
+++ b/
make_dungeon.py
@@
-444,9
+444,7
@@
def get_objects(obj):
immovable = attr.get("immovable", False)
try:
if type(locs) == str:
immovable = attr.get("immovable", False)
try:
if type(locs) == str:
- locs = [locnames.index(locs), -1 if immovable else 0]
- else:
- locs = [locnames.index(x) for x in locs]
+ locs = [locs, -1 if immovable else 0]
except IndexError:
sys.stderr.write("dungeon: unknown object location in %s\n" % locs)
sys.exit(1)
except IndexError:
sys.stderr.write("dungeon: unknown object location in %s\n" % locs)
sys.exit(1)