Skip to content

Commit 7d8b4d4

Browse files
committed
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.
1 parent 8c92d29 commit 7d8b4d4

File tree

18 files changed

+631
-132
lines changed

18 files changed

+631
-132
lines changed

doc/Guidebook.mn

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3776,6 +3776,24 @@ to identify unique people for the score file.
37763776
.lp
37773777
MAX_STATUENAME_RANK\ =\ Maximum number of score file entries to use for
37783778
random statue names (default is 10).
3779+
.lp
3780+
DUMPLOGFILE\ =\ A filename where the end-of-game dumplog is saved.
3781+
Not defining this will prevent dumplog from being created. Only available
3782+
if your game is compiled with DUMPLOG. Allows the following placeholders:
3783+
.sd
3784+
.si
3785+
%% - literal '%'
3786+
%v - version (eg. "3.6.1-0")
3787+
%u - game UID
3788+
%t - game start time, UNIX timestamp format
3789+
%T - current time, UNIX timestamp format
3790+
%d - game start time, YYYYMMDDhhmmss format
3791+
%D - current time, YYYYMMDDhhmmss format
3792+
%n - player name
3793+
%N - first character of player name
3794+
.ei
3795+
.ed
3796+
37793797
.hn 1
37803798
Scoring
37813799
.pg

doc/Guidebook.tex

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,6 +4589,24 @@ \subsection*{Global Configuration for System Administrators}
45894589
\item[\ib{PERS\verb+_+IS\verb+_+UID}]
45904590
0 or 1 to use user names or numeric userids, respectively, to identify
45914591
unique people for the score file
4592+
%.lp
4593+
\item[\ib{DUMPLOGFILE}]
4594+
A filename where the end-of-game dumplog is saved.
4595+
Not defining this will prevent dumplog from being created. Only available
4596+
if your game is compiled with DUMPLOG. Allows the following placeholders:
4597+
%.sd
4598+
%.si
4599+
{\tt \%\%} --- literal `{\tt \%}'\\
4600+
{\tt \%v} --- version (eg. "3.6.1-0")\\
4601+
{\tt \%u} --- game UID\\
4602+
{\tt \%t} --- game start time, UNIX timestamp format\\
4603+
{\tt \%T} --- current time, UNIX timestamp format\\
4604+
{\tt \%d} --- game start time, YYYYMMDDhhmmss format\\
4605+
{\tt \%D} --- current time, YYYYMMDDhhmmss format\\
4606+
{\tt \%n} --- player name\\
4607+
{\tt \%N} --- first character of player name
4608+
%.ei
4609+
%.ed
45924610
\elist
45934611

45944612
%.hn 1

doc/fixes36.1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ Ray Chason's MS-DOS port restored to functionality with credit to Reddit user
562562
Ray Chason's MSDOS port support for some VESA modes
563563
Darshan Shaligram's pet ranged attack
564564
Jason Dorje Short's key rebinding
565+
Maxime Bacoux's new dumplog
565566

566567

567568
Code Cleanup and Reorganization

include/config.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,32 @@ typedef unsigned char uchar;
508508
but it isn't necessary for successful operation of the program */
509509
#define FREE_ALL_MEMORY /* free all memory at exit */
510510

511+
/* #define DUMPLOG */ /* End-of-game dump logs */
512+
#ifdef DUMPLOG
513+
514+
#ifndef DUMPLOG_MSG_COUNT
515+
#define DUMPLOG_MSG_COUNT 50
516+
#endif
517+
518+
#ifndef DUMPLOG_FILE
519+
#define DUMPLOG_FILE "/tmp/nethack.%n.%d.log"
520+
/* DUMPLOG_FILE allows following placeholders:
521+
%% literal '%'
522+
%v version (eg. "3.6.1-0")
523+
%u game UID
524+
%t game start time, UNIX timestamp format
525+
%T current time, UNIX timestamp format
526+
%d game start time, YYYYMMDDhhmmss format
527+
%D current time, YYYYMMDDhhmmss format
528+
%n player name
529+
%N first character of player name
530+
DUMPLOG_FILE is not used if SYSCF is defined
531+
*/
532+
#endif
533+
534+
#endif
535+
536+
511537
/* End of Section 4 */
512538

513539
#ifdef TTY_TILES_ESCCODES

include/extern.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ E int NDECL(getbones);
141141

142142
/* ### botl.c ### */
143143

144+
E char *NDECL(do_statusline1);
145+
E char *NDECL(do_statusline2);
144146
E int FDECL(xlev_to_rank, (int));
145147
E int FDECL(title_to_mon, (const char *, int *, int *));
146148
E void NDECL(max_rank_sz);
@@ -268,6 +270,7 @@ E void NDECL(warnreveal);
268270
E int FDECL(dosearch0, (int));
269271
E int NDECL(dosearch);
270272
E void NDECL(sokoban_detect);
273+
E void NDECL(dump_map);
271274
E void FDECL(reveal_terrain, (int, int));
272275

273276
/* ### dig.c ### */
@@ -2711,6 +2714,11 @@ E void FDECL(genl_status_threshold, (int, int, anything, int, int, int));
27112714
#endif
27122715
#endif
27132716

2717+
E void FDECL(dump_open_log, (time_t));
2718+
E void NDECL(dump_close_log);
2719+
E void FDECL(dump_redirect, (boolean));
2720+
E void FDECL(dump_forward_putstr, (winid, int, const char*, int));
2721+
27142722
/* ### wizard.c ### */
27152723

27162724
E void NDECL(amulet);

include/flag.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ struct instance_flags {
201201
boolean vision_inited; /* true if vision is ready */
202202
boolean sanity_check; /* run sanity checks */
203203
boolean mon_polycontrol; /* debug: control monster polymorphs */
204+
boolean in_dumplog; /* doing the dumplog right now? */
204205

205206
/* stuff that is related to options and/or user or platform preferences
206207
*/

include/sys.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ struct sysopt {
1515
char *shellers; /* like wizards, for ! command (-DSHELL); also ^Z */
1616
char *genericusers; /* usernames that prompt for user name */
1717
char *debugfiles; /* files to show debugplines in. '*' is all. */
18+
#ifdef DUMPLOG
19+
char *dumplogfile; /* where the dump file is saved */
20+
#endif
1821
int env_dbgfl; /* 1: debugfiles comes from getenv("DEBUGFILES")
1922
* so sysconf's DEBUGFILES shouldn't override it;
2023
* 0: getenv() hasn't been attempted yet;

src/botl.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ const char *const enc_stat[] = { "", "Burdened", "Stressed",
1313
STATIC_OVL NEARDATA int mrank_sz = 0; /* loaded by max_rank_sz (from u_init) */
1414
STATIC_DCL const char *NDECL(rank);
1515

16-
#ifndef STATUS_VIA_WINDOWPORT
17-
18-
STATIC_DCL void NDECL(bot1);
19-
STATIC_DCL void NDECL(bot2);
16+
#if !defined(STATUS_VIA_WINDOWPORT) || defined(DUMPLOG)
2017

21-
STATIC_OVL void
22-
bot1()
18+
char *
19+
do_statusline1()
2320
{
24-
char newbot1[MAXCO];
21+
static char newbot1[BUFSZ];
2522
register char *nb;
2623
register int i, j;
2724

@@ -71,14 +68,13 @@ bot1()
7168
if (flags.showscore)
7269
Sprintf(nb = eos(nb), " S:%ld", botl_score());
7370
#endif
74-
curs(WIN_STATUS, 1, 0);
75-
putstr(WIN_STATUS, 0, newbot1);
71+
return newbot1;
7672
}
7773

78-
STATIC_OVL void
79-
bot2()
74+
char *
75+
do_statusline2()
8076
{
81-
char newbot2[MAXCO], /* MAXCO: botl.h */
77+
static char newbot2[BUFSZ], /* MAXCO: botl.h */
8278
/* dungeon location (and gold), hero health (HP, PW, AC),
8379
experience (HD if poly'd, else Exp level and maybe Exp points),
8480
time (in moves), varying number of status conditions */
@@ -102,7 +98,8 @@ bot2()
10298
if ((money = money_cnt(invent)) < 0L)
10399
money = 0L; /* ought to issue impossible() and then discard gold */
104100
Sprintf(eos(dloc), "%s:%-2ld", /* strongest hero can lift ~300000 gold */
105-
encglyph(objnum_to_glyph(GOLD_PIECE)), min(money, 999999L));
101+
iflags.in_dumplog ? "$" : encglyph(objnum_to_glyph(GOLD_PIECE)),
102+
min(money, 999999L));
106103
dln = strlen(dloc);
107104
/* '$' encoded as \GXXXXNNNN is 9 chars longer than display will need */
108105
dx = strstri(dloc, "\\G") ? 9 : 0;
@@ -205,23 +202,25 @@ bot2()
205202
/* only two or three consecutive spaces available to squeeze out */
206203
mungspaces(newbot2);
207204
}
208-
209-
curs(WIN_STATUS, 1, 1);
210-
putmixed(WIN_STATUS, 0, newbot2);
205+
return newbot2;
211206
}
212207

208+
#ifndef STATUS_VIA_WINDOWPORT
213209
void
214210
bot()
215211
{
216212
if (youmonst.data && iflags.status_updates) {
217-
bot1();
218-
bot2();
213+
curs(WIN_STATUS, 1, 0);
214+
putstr(WIN_STATUS, 0, do_statusline1());
215+
curs(WIN_STATUS, 1, 1);
216+
putmixed(WIN_STATUS, 0, do_statusline2());
219217
}
220218
context.botl = context.botlx = 0;
221219
}
222-
223220
#endif /* !STATUS_VIA_WINDOWPORT */
224221

222+
#endif /* !STATUS_VIA_WINDOWPORT || DUMPLOG */
223+
225224
/* convert experience level (1..30) to rank index (0..8) */
226225
int
227226
xlev_to_rank(xlev)

0 commit comments

Comments
 (0)