-/* NetHack 3.6 makedefs.c $NHDT-Date: 1562180226 2019/07/03 18:57:06 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.149 $ */
+/* NetHack 3.6 makedefs.c $NHDT-Date: 1582403492 2020/02/22 20:31:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.177 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */
/* Copyright (c) M. Stephenson, 1990, 1991. */
static unsigned long FDECL(read_rumors_file,
(const char *, int *, long *, unsigned long));
static boolean FDECL(get_gitinfo, (char *, char *));
-static void FDECL(do_rnd_access_file, (const char *));
+static void FDECL(do_rnd_access_file, (const char *, const char *));
static boolean FDECL(d_filter, (char *));
static boolean FDECL(h_filter, (char *));
static void NDECL(build_savebones_compat_string);
break;
case 's':
case 'S':
- do_rnd_access_file(EPITAPHFILE);
- do_rnd_access_file(ENGRAVEFILE);
- do_rnd_access_file(BOGUSMONFILE);
+ /*
+ * post-3.6.5:
+ * File must not be empty to avoid divide by 0
+ * in core's rn2(), so provide a default entry.
+ */
+ do_rnd_access_file(EPITAPHFILE,
+ /* default epitaph: parody of the default engraving */
+ "No matter where I went, here I am.");
+ do_rnd_access_file(ENGRAVEFILE,
+ /* default engraving: popularized by "The Adventures of
+ Buckaroo Bonzai Across the 8th Dimenstion" but predates
+ that 1984 movie; some attribute it to Confucius */
+ "No matter where you go, there you are.");
+ do_rnd_access_file(BOGUSMONFILE,
+ /* default bogusmon: iconic monster that isn't in nethack */
+ "grue");
break;
case 'h':
case 'H':
}
static void
-do_rnd_access_file(fname)
+do_rnd_access_file(fname, deflt_content)
const char *fname;
+const char *deflt_content;
{
char *line;
exit(EXIT_FAILURE);
}
Fprintf(ofp, "%s", Dont_Edit_Data);
+ /* write out the default content entry unconditionally instead of
+ waiting to see whether there are no regular output lines; if it
+ matches a regular entry (bogusmon "grue"), that entry will become
+ more likely to be picked than normal but it's nothing to worry about */
+ (void) fputs(xcrypt(deflt_content), ofp);
tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE);
grep0(ifp, tfp);
while ((line = fgetline(ifp)) != 0) {
if (line[0] != '#' && line[0] != '\n')
(void) fputs(xcrypt(line), ofp);
- free(line);
+ free((genericptr_t) line);
}
Fclose(ifp);
Fclose(ofp);