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

171
src/end.c
View File

@@ -667,6 +667,88 @@ char *defquery;
return TRUE;
}
#ifdef DUMPLOG
STATIC_OVL void
dump_plines()
{
int i;
char* str;
extern char* saved_plines[];
putstr(0, 0, "");
putstr(0, 0, "Latest messages:");
for (i = 0; i < DUMPLOG_MSG_COUNT; ++i)
{
str = saved_plines[DUMPLOG_MSG_COUNT - 1 - i];
if (str) {
char buf[BUFSZ];
Sprintf(buf, " %s", str);
putstr(0, 0, buf);
}
#ifdef FREE_ALL_MEMORY
free(str);
#endif
}
}
#endif
STATIC_OVL void
dump_everything(how, taken)
int how;
boolean taken;
{
#ifdef DUMPLOG
struct obj* obj;
struct topl* topl;
char pbuf[BUFSZ];
dump_redirect(TRUE);
if (!iflags.in_dumplog)
return;
init_symbols();
for (obj = invent; obj; obj = obj->nobj) {
makeknown(obj->otyp);
obj->known = obj->bknown = obj->dknown = obj->rknown = 1;
if (Is_container(obj) || obj->otyp == STATUE)
obj->cknown = obj->lknown = 1;
}
Sprintf(pbuf, "%s, %s %s %s %s", plname,
aligns[1 - u.ualign.type].adj,
genders[flags.female].adj,
urace.adj,
(flags.female && urole.name.f) ? urole.name.f : urole.name.m);
putstr(0, 0, pbuf);
putstr(0, 0, "");
dump_map();
putstr(0, 0, do_statusline1());
putstr(0, 0, do_statusline2());
putstr(0, 0, "");
dump_plines();
putstr(0, 0, "");
putstr(0, 0, "Inventory:");
display_inventory((char *) 0, TRUE);
container_contents(invent, TRUE, TRUE, FALSE);
enlightenment((BASICENLIGHTENMENT | MAGICENLIGHTENMENT),
(how >= PANICKED) ? ENL_GAMEOVERALIVE
: ENL_GAMEOVERDEAD);
putstr(0, 0, "");
list_vanquished('y', FALSE);
putstr(0, 0, "");
list_genocided('a', FALSE);
putstr(0, 0, "");
show_conduct((how >= PANICKED) ? 1 : 2);
putstr(0, 0, "");
show_overview((how >= PANICKED) ? 1 : 2, how);
putstr(0, 0, "");
dump_redirect(FALSE);
#endif
}
STATIC_OVL void
disclose(how, taken)
int how;
@@ -1016,6 +1098,7 @@ int how;
urealtime.finish_time = endtime = getnow();
urealtime.realtime += (long) (endtime - urealtime.start_timing);
dump_open_log(endtime);
/* Sometimes you die on the first move. Life's not fair.
* On those rare occasions you get hosed immediately, go out
* smiling... :-) -3.
@@ -1081,6 +1164,7 @@ int how;
if (strcmp(flags.end_disclose, "none") && how != PANICKED)
disclose(how, taken);
dump_everything(how, taken);
/* finish_paybill should be called after disclosure but before bones */
if (bones_ok && taken)
@@ -1179,6 +1263,11 @@ int how;
} else
done_stopprint = 1; /* just avoid any more output */
#ifdef DUMPLOG
dump_redirect(TRUE);
genl_outrip(0, how, endtime);
dump_redirect(FALSE);
#endif
if (u.uhave.amulet) {
Strcat(killer.name, " (with the Amulet)");
} else if (how == ESCAPED) {
@@ -1189,16 +1278,14 @@ int how;
/* don't bother counting to see whether it should be plural */
}
if (!done_stopprint) {
Sprintf(pbuf, "%s %s the %s...", Goodbye(), plname,
(how != ASCENDED)
? (const char *) ((flags.female && urole.name.f)
? urole.name.f
: urole.name.m)
: (const char *) (flags.female ? "Demigoddess" : "Demigod"));
putstr(endwin, 0, pbuf);
putstr(endwin, 0, "");
}
Sprintf(pbuf, "%s %s the %s...", Goodbye(), plname,
(how != ASCENDED)
? (const char *) ((flags.female && urole.name.f)
? urole.name.f
: urole.name.m)
: (const char *) (flags.female ? "Demigoddess" : "Demigod"));
dump_forward_putstr(endwin, 0, pbuf, done_stopprint);
dump_forward_putstr(endwin, 0, "", done_stopprint);
if (how == ESCAPED || how == ASCENDED) {
struct monst *mtmp;
@@ -1223,45 +1310,48 @@ int how;
/* count the points for artifacts */
artifact_score(invent, TRUE, endwin);
#ifdef DUMPLOG
dump_redirect(TRUE);
artifact_score(invent, TRUE, endwin);
dump_redirect(FALSE);
#endif
viz_array[0][0] |= IN_SIGHT; /* need visibility for naming */
mtmp = mydogs;
if (!done_stopprint)
Strcpy(pbuf, "You");
Strcpy(pbuf, "You");
if (!Schroedingers_cat) /* check here in case disclosure was off */
Schroedingers_cat = odds_and_ends(invent, CAT_CHECK);
if (Schroedingers_cat) {
int mhp, m_lev = adj_lev(&mons[PM_HOUSECAT]);
mhp = d(m_lev, 8);
nowrap_add(u.urexp, mhp);
if (!done_stopprint)
Strcat(eos(pbuf), " and Schroedinger's cat");
Strcat(eos(pbuf), " and Schroedinger's cat");
}
if (mtmp) {
while (mtmp) {
if (!done_stopprint)
Sprintf(eos(pbuf), " and %s", mon_nam(mtmp));
Sprintf(eos(pbuf), " and %s", mon_nam(mtmp));
if (mtmp->mtame)
nowrap_add(u.urexp, mtmp->mhp);
mtmp = mtmp->nmon;
}
if (!done_stopprint)
putstr(endwin, 0, pbuf);
dump_forward_putstr(endwin, 0, pbuf, done_stopprint);
pbuf[0] = '\0';
} else {
if (!done_stopprint)
Strcat(pbuf, " ");
}
if (!done_stopprint) {
Sprintf(eos(pbuf), "%s with %ld point%s,",
how == ASCENDED ? "went to your reward"
: "escaped from the dungeon",
u.urexp, plur(u.urexp));
putstr(endwin, 0, pbuf);
Strcat(pbuf, " ");
}
Sprintf(eos(pbuf), "%s with %ld point%s,",
how == ASCENDED ? "went to your reward"
: "escaped from the dungeon",
u.urexp, plur(u.urexp));
dump_forward_putstr(endwin, 0, pbuf, done_stopprint);
if (!done_stopprint)
artifact_score(invent, FALSE, endwin); /* list artifacts */
#if DUMPLOG
dump_redirect(TRUE);
artifact_score(invent, FALSE, 0);
dump_redirect(FALSE);
#endif
/* list valuables here */
for (val = valuables; val->list; val++) {
@@ -1288,11 +1378,11 @@ int how;
Sprintf(pbuf, "%8ld worthless piece%s of colored glass,",
count, plur(count));
}
putstr(endwin, 0, pbuf);
dump_forward_putstr(endwin, 0, pbuf, 0);
}
}
} else if (!done_stopprint) {
} else {
/* did not escape or ascend */
if (u.uz.dnum == 0 && u.uz.dlevel <= 0) {
/* level teleported out of the dungeon; `how' is DIED,
@@ -1312,26 +1402,23 @@ int how;
}
Sprintf(eos(pbuf), " with %ld point%s,", u.urexp, plur(u.urexp));
putstr(endwin, 0, pbuf);
dump_forward_putstr(endwin, 0, pbuf, done_stopprint);
}
if (!done_stopprint) {
Sprintf(pbuf, "and %ld piece%s of gold, after %ld move%s.", umoney,
plur(umoney), moves, plur(moves));
putstr(endwin, 0, pbuf);
}
if (!done_stopprint) {
Sprintf(pbuf,
"You were level %d with a maximum of %d hit point%s when you %s.",
u.ulevel, u.uhpmax, plur(u.uhpmax), ends[how]);
putstr(endwin, 0, pbuf);
putstr(endwin, 0, "");
}
Sprintf(pbuf, "and %ld piece%s of gold, after %ld move%s.", umoney,
plur(umoney), moves, plur(moves));
dump_forward_putstr(endwin, 0, pbuf, done_stopprint);
Sprintf(pbuf,
"You were level %d with a maximum of %d hit point%s when you %s.",
u.ulevel, u.uhpmax, plur(u.uhpmax), ends[how]);
dump_forward_putstr(endwin, 0, pbuf, done_stopprint);
dump_forward_putstr(endwin, 0, "", done_stopprint);
if (!done_stopprint)
display_nhwindow(endwin, TRUE);
if (endwin != WIN_ERR)
destroy_nhwindow(endwin);
dump_close_log();
/* "So when I die, the first thing I will see in Heaven is a
* score list?" */
if (have_windows && !iflags.toptenwin)