MCPcopy Index your code
hub / github.com/NetHack/NetHack / dumplogmsg

Function dumplogmsg

src/pline.c:21–46  ·  view source on GitHub ↗

keep the most recent DUMPLOG_MSG_COUNT messages */

Source from the content-addressed store, hash-verified

19
20/* keep the most recent DUMPLOG_MSG_COUNT messages */
21void
22dumplogmsg(const char *line)
23{
24 /*
25 * TODO:
26 * This essentially duplicates message history, which is
27 * currently implemented in an interface-specific manner.
28 * The core should take responsibility for that and have
29 * this share it.
30 */
31 unsigned indx = gs.saved_pline_index; /* next slot to use */
32 char *oldest = gs.saved_plines[indx]; /* current content of that slot */
33
34 if (!strncmp(line, "Unknown command", 15))
35 return;
36 if (oldest && strlen(oldest) >= strlen(line)) {
37 /* this buffer will gradually shrink until the 'else' is needed;
38 there's no pressing need to track allocation size instead */
39 Strcpy(oldest, line);
40 } else {
41 if (oldest)
42 free((genericptr_t) oldest);
43 gs.saved_plines[indx] = dupstr(line);
44 }
45 gs.saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT;
46}
47
48/* called during save (unlike the interface-specific message history,
49 this data isn't saved and restored); end-of-game releases saved_plines[]

Callers 8

tty_yn_functionFunction · 0.85
tty_putmsghistoryFunction · 0.85
hooked_tty_getlinFunction · 0.85
qt_putmsghistoryMethod · 0.85
curses_putmsghistoryFunction · 0.85
vplineFunction · 0.85
do_lookFunction · 0.85
yn_functionFunction · 0.85

Calls 1

dupstrFunction · 0.85

Tested by

no test coverage detected