Add end-of-game dumplogs

This is based on the "new" dumplog patch for 3.6.0, by Maxime Bacoux.

Define DUMPLOG to enable. By default only enabled for the TTY linux.
This commit is contained in:
Pasi Kallinen
2017-02-19 15:30:46 +02:00
parent 8c92d2921f
commit 7d8b4d4f97
18 changed files with 631 additions and 132 deletions

View File

@@ -25,6 +25,7 @@ STATIC_DCL void FDECL(show_map_spot, (int, int));
STATIC_PTR void FDECL(findone, (int, int, genericptr_t));
STATIC_PTR void FDECL(openone, (int, int, genericptr_t));
STATIC_DCL int FDECL(mfind0, (struct monst *, BOOLEAN_P));
STATIC_DCL int FDECL(reveal_terrain_getglyph, (int, int, int, unsigned, int, int));
/* bring hero out from underwater or underground or being engulfed;
return True iff any change occurred */
@@ -1715,6 +1716,111 @@ sokoban_detect()
}
}
STATIC_DCL int
reveal_terrain_getglyph(x,y, full, swallowed, default_glyph, which_subset)
int x,y, full;
unsigned swallowed;
int default_glyph, which_subset;
{
int glyph, levl_glyph;
uchar seenv;
boolean keep_traps = (which_subset & TER_TRP) !=0,
keep_objs = (which_subset & TER_OBJ) != 0,
keep_mons = (which_subset & TER_MON) != 0;
struct monst *mtmp;
struct trap *t;
/* for 'full', show the actual terrain for the entire level,
otherwise what the hero remembers for seen locations with
monsters, objects, and/or traps removed as caller dictates */
seenv = (full || level.flags.hero_memory)
? levl[x][y].seenv : cansee(x, y) ? SVALL : 0;
if (full) {
levl[x][y].seenv = SVALL;
glyph = back_to_glyph(x, y);
levl[x][y].seenv = seenv;
} else {
levl_glyph = level.flags.hero_memory
? levl[x][y].glyph
: seenv
? back_to_glyph(x, y)
: default_glyph;
/* glyph_at() returns the displayed glyph, which might
be a monster. levl[][].glyph contains the remembered
glyph, which will never be a monster (unless it is
the invisible monster glyph, which is handled like
an object, replacing any object or trap at its spot) */
glyph = !swallowed ? glyph_at(x, y) : levl_glyph;
if (keep_mons && x == u.ux && y == u.uy && swallowed)
glyph = mon_to_glyph(u.ustuck);
else if (((glyph_is_monster(glyph)
|| glyph_is_warning(glyph)) && !keep_mons)
|| glyph_is_swallow(glyph))
glyph = levl_glyph;
if (((glyph_is_object(glyph) && !keep_objs)
|| glyph_is_invisible(glyph))
&& keep_traps && !covers_traps(x, y)) {
if ((t = t_at(x, y)) != 0 && t->tseen)
glyph = trap_to_glyph(t);
}
if ((glyph_is_object(glyph) && !keep_objs)
|| (glyph_is_trap(glyph) && !keep_traps)
|| glyph_is_invisible(glyph)) {
if (!seenv) {
glyph = default_glyph;
} else if (lastseentyp[x][y] == levl[x][y].typ) {
glyph = back_to_glyph(x, y);
} else {
/* look for a mimic here posing as furniture;
if we don't find one, we'll have to fake it */
if ((mtmp = m_at(x, y)) != 0
&& mtmp->m_ap_type == M_AP_FURNITURE) {
glyph = cmap_to_glyph(mtmp->mappearance);
} else {
/* we have a topology type but we want a
screen symbol in order to derive a glyph;
some screen symbols need the flags field
of levl[][] in addition to the type
(to disambiguate STAIRS to S_upstair or
S_dnstair, for example; current flags
might not be intended for remembered
type, but we've got no other choice) */
schar save_typ = levl[x][y].typ;
levl[x][y].typ = lastseentyp[x][y];
glyph = back_to_glyph(x, y);
levl[x][y].typ = save_typ;
}
}
}
}
if (glyph == cmap_to_glyph(S_darkroom))
glyph = cmap_to_glyph(S_room); /* FIXME: dirty hack */
return glyph;
}
void
dump_map()
{
int x, y, glyph;
int subset = TER_MAP|TER_TRP|TER_OBJ|TER_MON;
int default_glyph = cmap_to_glyph(level.flags.arboreal ? S_tree : S_stone);
char buf[BUFSZ];
for (y = 0; y < ROWNO; y++) {
for (x = 1; x < COLNO; x++) {
int ch, color;
unsigned special;
glyph = reveal_terrain_getglyph(x,y, FALSE, u.uswallow,
default_glyph, subset);
(void) mapglyph(glyph, &ch, &color, &special, x, y);
buf[x-1] = ch;
}
buf[x-2] = '\0';
putstr(0,0, buf);
}
}
/* idea from crawl; show known portion of map without any monsters,
objects, or traps occluding the view of the underlying terrain */
void
@@ -1725,10 +1831,7 @@ int which_subset; /* when not full, whether to suppress objs and/or traps */
if ((Hallucination || Stunned || Confusion) && !full) {
You("are too disoriented for this.");
} else {
int x, y, glyph, levl_glyph, default_glyph;
uchar seenv;
struct monst *mtmp;
struct trap *t;
int x, y, glyph, default_glyph;
char buf[BUFSZ];
/* there is a TER_MAP bit too; we always show map regardless of it */
boolean keep_traps = (which_subset & TER_TRP) !=0,
@@ -1739,74 +1842,11 @@ int which_subset; /* when not full, whether to suppress objs and/or traps */
if (unconstrain_map())
docrt();
default_glyph = cmap_to_glyph(level.flags.arboreal ? S_tree : S_stone);
/* for 'full', show the actual terrain for the entire level,
otherwise what the hero remembers for seen locations with
monsters, objects, and/or traps removed as caller dictates */
for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++) {
seenv = (full || level.flags.hero_memory)
? levl[x][y].seenv : cansee(x, y) ? SVALL : 0;
if (full) {
levl[x][y].seenv = SVALL;
glyph = back_to_glyph(x, y);
levl[x][y].seenv = seenv;
} else {
levl_glyph = level.flags.hero_memory
? levl[x][y].glyph
: seenv
? back_to_glyph(x, y)
: default_glyph;
/* glyph_at() returns the displayed glyph, which might
be a monster. levl[][].glyph contains the remembered
glyph, which will never be a monster (unless it is
the invisible monster glyph, which is handled like
an object, replacing any object or trap at its spot) */
glyph = !swallowed ? glyph_at(x, y) : levl_glyph;
if (keep_mons && x == u.ux && y == u.uy && swallowed)
glyph = mon_to_glyph(u.ustuck);
else if (((glyph_is_monster(glyph)
|| glyph_is_warning(glyph)) && !keep_mons)
|| glyph_is_swallow(glyph))
glyph = levl_glyph;
if (((glyph_is_object(glyph) && !keep_objs)
|| glyph_is_invisible(glyph))
&& keep_traps && !covers_traps(x, y)) {
if ((t = t_at(x, y)) != 0 && t->tseen)
glyph = trap_to_glyph(t);
}
if ((glyph_is_object(glyph) && !keep_objs)
|| (glyph_is_trap(glyph) && !keep_traps)
|| glyph_is_invisible(glyph)) {
if (!seenv) {
glyph = default_glyph;
} else if (lastseentyp[x][y] == levl[x][y].typ) {
glyph = back_to_glyph(x, y);
} else {
/* look for a mimic here posing as furniture;
if we don't find one, we'll have to fake it */
if ((mtmp = m_at(x, y)) != 0
&& mtmp->m_ap_type == M_AP_FURNITURE) {
glyph = cmap_to_glyph(mtmp->mappearance);
} else {
/* we have a topology type but we want a
screen symbol in order to derive a glyph;
some screen symbols need the flags field
of levl[][] in addition to the type
(to disambiguate STAIRS to S_upstair or
S_dnstair, for example; current flags
might not be intended for remembered
type, but we've got no other choice) */
schar save_typ = levl[x][y].typ;
levl[x][y].typ = lastseentyp[x][y];
glyph = back_to_glyph(x, y);
levl[x][y].typ = save_typ;
}
}
}
}
if (glyph == cmap_to_glyph(S_darkroom))
glyph = cmap_to_glyph(S_room); /* FIXME: dirty hack */
glyph = reveal_terrain_getglyph(x,y, full, swallowed,
default_glyph, which_subset);
show_glyph(x, y, glyph);
}