-/* NetHack 3.6 extern.h $NHDT-Date: 1488075978 2017/02/26 02:26:18 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.582 $ */
+/* NetHack 3.6 extern.h $NHDT-Date: 1489192904 2017/03/11 00:41:44 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.583 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
/* ### pline.c ### */
+#ifdef DUMPLOG
+E void FDECL(dumplogmsg, (const char *));
+E void NDECL(dumplogfreemessages);
+#endif
E void VDECL(pline, (const char *, ...)) PRINTF_F(1, 2);
E void VDECL(Norep, (const char *, ...)) PRINTF_F(1, 2);
E void NDECL(free_youbuf);
-/* NetHack 3.6 pline.c $NHDT-Date: 1461437814 2016/04/23 18:56:54 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.51 $ */
+/* NetHack 3.6 pline.c $NHDT-Date: 1489192905 2017/03/11 00:41:45 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.57 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* also used in end.c */
unsigned saved_pline_index = 0; /* slot in saved_plines[] to use next */
char *saved_plines[DUMPLOG_MSG_COUNT] = { (char *) 0 };
+
+/* keep the most recent DUMPLOG_MSG_COUNT messages */
+void
+dumplogmsg(line)
+const char *line;
+{
+ /*
+ * TODO:
+ * This essentially duplicates message history, which is
+ * currently implemented in an interface-specific manner.
+ * The core should take responsibility for that and have
+ * this share it.
+ */
+ unsigned indx = saved_pline_index; /* next slot to use */
+ char *oldest = saved_plines[indx]; /* current content of that slot */
+
+ if (oldest && strlen(oldest) >= strlen(line)) {
+ /* this buffer will gradually shrink until the 'else' is needed;
+ there's no pressing need to track allocation size instead */
+ Strcpy(oldest, line);
+ } else {
+ if (oldest)
+ free((genericptr_t) oldest);
+ saved_plines[indx] = dupstr(line);
+ }
+ saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT;
+}
+
+/* called during save (unlike the interface-specific message history,
+ this data isn't saved and restored); end-of-game releases saved_pline[]
+ while writing its contents to the final dump log */
+void
+dumplogfreemessages()
+{
+ unsigned indx;
+
+ for (indx = 0; indx < DUMPLOG_MSG_COUNT; ++indx)
+ if (saved_plines[indx])
+ free((genericptr_t) saved_plines[indx]), saved_plines[indx] = 0;
+ saved_pline_index = 0;
+}
#endif
/*VARARGS1*/
pbuf[BUFSZ - 1 - 1] = line[ln - 1];
pbuf[BUFSZ - 1] = '\0';
line = pbuf;
- ln = BUFSZ - 1;
}
if (!iflags.window_inited) {
raw_print(line);
* Unfortunately, that means Norep() isn't honored (general issue) and
* that short lines aren't combined into one longer one (tty behavior).
*/
- {
- /*
- * TODO:
- * This essentially duplicates message history, which is
- * currently implemented in an interface-specific manner.
- * The core should take responsibility for that and have
- * this share it.
- * Ideally history for prompt lines should be augmented
- * with the player's response once that has been specified.
- */
- unsigned indx = saved_pline_index; /* next slot to use */
- char *oldest = saved_plines[indx]; /* current content of that slot */
-
- if (oldest && (int) strlen(oldest) >= ln) { /* ln==strlen(line) */
- /* this buffer will gradually shrink until the 'else' is needed;
- there's no pressing need to track allocation size instead */
- Strcpy(oldest, line);
- } else {
- if (oldest)
- free((genericptr_t) oldest);
- saved_plines[indx] = dupstr(line);
- }
- saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT;
- }
+ dumplogmsg(line);
#endif
msgtyp = msgtype_type(line, no_repeat);
-/* NetHack 3.6 save.c $NHDT-Date: 1450231175 2015/12/16 01:59:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.98 $ */
+/* NetHack 3.6 save.c $NHDT-Date: 1489192905 2017/03/11 00:41:45 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.101 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#ifdef STATUS_VIA_WINDOWPORT
status_finish();
#endif
+#ifdef DUMPLOG
+ dumplogfreemessages();
+#endif
/* last, because it frees data that might be used by panic() to provide
feedback to the user; conceivably other freeing might trigger panic */