Permalink
Browse files

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.
  • Loading branch information...
paxed committed Feb 19, 2017
1 parent 8c92d29 commit 7d8b4d4f972918a25a416bba27424d7ae7e32983
Showing with 631 additions and 132 deletions.
  1. +18 −0 doc/Guidebook.mn
  2. +18 −0 doc/Guidebook.tex
  3. +1 −0 doc/fixes36.1
  4. +26 −0 include/config.h
  5. +8 −0 include/extern.h
  6. +1 −0 include/flag.h
  7. +3 −0 include/sys.h
  8. +18 −19 src/botl.c
  9. +110 −70 src/detect.c
  10. +129 −42 src/end.c
  11. +8 −1 src/files.c
  12. +13 −0 src/pline.c
  13. +7 −0 src/sys.c
  14. +239 −0 src/windows.c
  15. +1 −0 sys/unix/hints/linux
  16. +14 −0 sys/unix/sysconf
  17. +14 −0 sys/winnt/sysconf
  18. +3 −0 util/makedefs.c
@@ -3776,6 +3776,24 @@ to identify unique people for the score file.
.lp
MAX_STATUENAME_RANK\ =\ Maximum number of score file entries to use for
random statue names (default is 10).
.lp
DUMPLOGFILE\ =\ A filename where the end-of-game dumplog is saved.
Not defining this will prevent dumplog from being created. Only available
if your game is compiled with DUMPLOG. Allows the following placeholders:
.sd
.si
%% - literal '%'
%v - version (eg. "3.6.1-0")
%u - game UID
%t - game start time, UNIX timestamp format
%T - current time, UNIX timestamp format
%d - game start time, YYYYMMDDhhmmss format
%D - current time, YYYYMMDDhhmmss format
%n - player name
%N - first character of player name
.ei
.ed
.hn 1
Scoring
.pg
@@ -4589,6 +4589,24 @@ \subsection*{Global Configuration for System Administrators}
\item[\ib{PERS\verb+_+IS\verb+_+UID}]
0 or 1 to use user names or numeric userids, respectively, to identify
unique people for the score file
%.lp
\item[\ib{DUMPLOGFILE}]
A filename where the end-of-game dumplog is saved.
Not defining this will prevent dumplog from being created. Only available
if your game is compiled with DUMPLOG. Allows the following placeholders:
%.sd
%.si
{\tt \%\%} --- literal `{\tt \%}'\\
{\tt \%v} --- version (eg. "3.6.1-0")\\
{\tt \%u} --- game UID\\
{\tt \%t} --- game start time, UNIX timestamp format\\
{\tt \%T} --- current time, UNIX timestamp format\\
{\tt \%d} --- game start time, YYYYMMDDhhmmss format\\
{\tt \%D} --- current time, YYYYMMDDhhmmss format\\
{\tt \%n} --- player name\\
{\tt \%N} --- first character of player name
%.ei
%.ed
\elist
%.hn 1
@@ -562,6 +562,7 @@ Ray Chason's MS-DOS port restored to functionality with credit to Reddit user
Ray Chason's MSDOS port support for some VESA modes
Darshan Shaligram's pet ranged attack
Jason Dorje Short's key rebinding
Maxime Bacoux's new dumplog
Code Cleanup and Reorganization
@@ -508,6 +508,32 @@ typedef unsigned char uchar;
but it isn't necessary for successful operation of the program */
#define FREE_ALL_MEMORY /* free all memory at exit */
/* #define DUMPLOG */ /* End-of-game dump logs */
#ifdef DUMPLOG
#ifndef DUMPLOG_MSG_COUNT
#define DUMPLOG_MSG_COUNT 50
#endif
#ifndef DUMPLOG_FILE
#define DUMPLOG_FILE "/tmp/nethack.%n.%d.log"
/* DUMPLOG_FILE allows following placeholders:
%% literal '%'
%v version (eg. "3.6.1-0")
%u game UID
%t game start time, UNIX timestamp format
%T current time, UNIX timestamp format
%d game start time, YYYYMMDDhhmmss format
%D current time, YYYYMMDDhhmmss format
%n player name
%N first character of player name
DUMPLOG_FILE is not used if SYSCF is defined
*/
#endif
#endif
/* End of Section 4 */
#ifdef TTY_TILES_ESCCODES
@@ -141,6 +141,8 @@ E int NDECL(getbones);
/* ### botl.c ### */
E char *NDECL(do_statusline1);
E char *NDECL(do_statusline2);
E int FDECL(xlev_to_rank, (int));
E int FDECL(title_to_mon, (const char *, int *, int *));
E void NDECL(max_rank_sz);
@@ -268,6 +270,7 @@ E void NDECL(warnreveal);
E int FDECL(dosearch0, (int));
E int NDECL(dosearch);
E void NDECL(sokoban_detect);
E void NDECL(dump_map);
E void FDECL(reveal_terrain, (int, int));
/* ### dig.c ### */
@@ -2711,6 +2714,11 @@ E void FDECL(genl_status_threshold, (int, int, anything, int, int, int));
#endif
#endif
E void FDECL(dump_open_log, (time_t));
E void NDECL(dump_close_log);
E void FDECL(dump_redirect, (boolean));
E void FDECL(dump_forward_putstr, (winid, int, const char*, int));
/* ### wizard.c ### */
E void NDECL(amulet);
@@ -201,6 +201,7 @@ struct instance_flags {
boolean vision_inited; /* true if vision is ready */
boolean sanity_check; /* run sanity checks */
boolean mon_polycontrol; /* debug: control monster polymorphs */
boolean in_dumplog; /* doing the dumplog right now? */
/* stuff that is related to options and/or user or platform preferences
*/
@@ -15,6 +15,9 @@ struct sysopt {
char *shellers; /* like wizards, for ! command (-DSHELL); also ^Z */
char *genericusers; /* usernames that prompt for user name */
char *debugfiles; /* files to show debugplines in. '*' is all. */
#ifdef DUMPLOG
char *dumplogfile; /* where the dump file is saved */
#endif
int env_dbgfl; /* 1: debugfiles comes from getenv("DEBUGFILES")
* so sysconf's DEBUGFILES shouldn't override it;
* 0: getenv() hasn't been attempted yet;
@@ -13,15 +13,12 @@ const char *const enc_stat[] = { "", "Burdened", "Stressed",
STATIC_OVL NEARDATA int mrank_sz = 0; /* loaded by max_rank_sz (from u_init) */
STATIC_DCL const char *NDECL(rank);
#ifndef STATUS_VIA_WINDOWPORT
STATIC_DCL void NDECL(bot1);
STATIC_DCL void NDECL(bot2);
#if !defined(STATUS_VIA_WINDOWPORT) || defined(DUMPLOG)
STATIC_OVL void
bot1()
char *
do_statusline1()
{
char newbot1[MAXCO];
static char newbot1[BUFSZ];
register char *nb;
register int i, j;
@@ -71,14 +68,13 @@ bot1()
if (flags.showscore)
Sprintf(nb = eos(nb), " S:%ld", botl_score());
#endif
curs(WIN_STATUS, 1, 0);
putstr(WIN_STATUS, 0, newbot1);
return newbot1;
}
STATIC_OVL void
bot2()
char *
do_statusline2()
{
char newbot2[MAXCO], /* MAXCO: botl.h */
static char newbot2[BUFSZ], /* MAXCO: botl.h */
/* dungeon location (and gold), hero health (HP, PW, AC),
experience (HD if poly'd, else Exp level and maybe Exp points),
time (in moves), varying number of status conditions */
@@ -102,7 +98,8 @@ bot2()
if ((money = money_cnt(invent)) < 0L)
money = 0L; /* ought to issue impossible() and then discard gold */
Sprintf(eos(dloc), "%s:%-2ld", /* strongest hero can lift ~300000 gold */
encglyph(objnum_to_glyph(GOLD_PIECE)), min(money, 999999L));
iflags.in_dumplog ? "$" : encglyph(objnum_to_glyph(GOLD_PIECE)),
min(money, 999999L));
dln = strlen(dloc);
/* '$' encoded as \GXXXXNNNN is 9 chars longer than display will need */
dx = strstri(dloc, "\\G") ? 9 : 0;
@@ -205,23 +202,25 @@ bot2()
/* only two or three consecutive spaces available to squeeze out */
mungspaces(newbot2);
}
curs(WIN_STATUS, 1, 1);
putmixed(WIN_STATUS, 0, newbot2);
return newbot2;
}
#ifndef STATUS_VIA_WINDOWPORT
void
bot()
{
if (youmonst.data && iflags.status_updates) {
bot1();
bot2();
curs(WIN_STATUS, 1, 0);
putstr(WIN_STATUS, 0, do_statusline1());
curs(WIN_STATUS, 1, 1);
putmixed(WIN_STATUS, 0, do_statusline2());
}
context.botl = context.botlx = 0;
}
#endif /* !STATUS_VIA_WINDOWPORT */
#endif /* !STATUS_VIA_WINDOWPORT || DUMPLOG */
/* convert experience level (1..30) to rank index (0..8) */
int
xlev_to_rank(xlev)
Oops, something went wrong.

0 comments on commit 7d8b4d4

Please sign in to comment.