-/* NetHack 3.6 makedefs.c $NHDT-Date: 1434151372 2015/06/12 23:22:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.103 $ */
+/* NetHack 3.6 makedefs.c $NHDT-Date: 1447062431 2015/11/09 09:47:11 $ $NHDT-Branch: master $:$NHDT-Revision: 1.105 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
-/* Copyright (c) M. Stephenson, 1990, 1991. */
-/* Copyright (c) Dean Luick, 1990. */
+/* Copyright (c) M. Stephenson, 1990, 1991. */
+/* Copyright (c) Dean Luick, 1990. */
/* NetHack may be freely redistributed. See license for details. */
#define MAKEDEFS_C /* use to conditionally include file sections */
#include "config.h"
+#ifdef MONITOR_HEAP
+#undef free /* makedefs doesn't use the alloc and free in src/alloc.c */
+#endif
#include "permonst.h"
#include "objclass.h"
#include "monsym.h"
if (buf[0] == '-' && buf[1] == '-') {
#if 0
- split up buf into words
- do_ext_makedefs(fakeargc, fakeargv);
+ split up buf into words
+ do_ext_makedefs(fakeargc, fakeargv);
#else
printf("extended makedefs not implemented for Mac OS9\n");
exit(EXIT_FAILURE);
existing lines in the docs look like that)
Control lines:
- ^^ a line starting with a (single) literal caret
- ^# a comment - the line is ignored
- ^?ID if defined(ID)
- ^!ID if !defined(ID)
- ^: else
- ^. endif
+ ^^ a line starting with a (single) literal caret
+ ^# a comment - the line is ignored
+ ^?ID if defined(ID)
+ ^!ID if !defined(ID)
+ ^: else
+ ^. endif
*/
#define GREP_MAGIC '^'
we ameliorate the latter by padding the shortest lines,
increasing the chance of the random seek landing in them */
int len = (int) strlen(line);
+
if (len <= PAD_RUMORS_TO) {
char *base = index(line, '\n');
/* this is only safe because fgetline() overallocates */
#endif
(*rumor_count)++;
#if 0
- /*[if we forced binary output, this would be sufficient]*/
- *rumor_size += strlen(line); /* includes newline */
+ /*[if we forced binary output, this would be sufficient]*/
+ *rumor_size += strlen(line); /* includes newline */
#endif
(void) fputs(xcrypt(line), tfp);
free(line);
version_string(versbuf, "."), PORT_ID, subbuf, &build_date[4]);
#if 0
Sprintf(outbuf, "%s NetHack%s %s Copyright 1985-%s (built %s)",
- PORT_ID, subbuf, version_string(versbuf,"."), RELEASE_YEAR,
- &build_date[4]);
+ PORT_ID, subbuf, version_string(versbuf,"."), RELEASE_YEAR,
+ &build_date[4]);
#endif
return outbuf;
}
/*
*
New format (v3.1) of 'data' file which allows much faster lookups [pr]
-"do not edit" first record is a comment line
-01234567 hexadecimal formatted offset to text area
-name-a first name of interest
-123,4 offset to name's text, and number of lines for it
-name-b next name of interest
-name-c multiple names which share same description also
-456,7 share a single offset,count line
-. sentinel to mark end of names
-789,0 dummy record containing offset, count of EOF
-text-a 4 lines of descriptive text for name-a
-text-a at file position 0x01234567L + 123L
+"do not edit" first record is a comment line
+01234567 hexadecimal formatted offset to text area
+name-a first name of interest
+123,4 offset to name's text, and number of lines for it
+name-b next name of interest
+name-c multiple names which share same description also
+456,7 share a single offset,count line
+. sentinel to mark end of names
+789,0 dummy record containing offset, count of EOF
+text-a 4 lines of descriptive text for name-a
+text-a at file position 0x01234567L + 123L
text-a
text-a
-text-b/text-c 7 lines of text for names-b and -c
-text-b/text-c at fseek(0x01234567L + 456L)
+text-b/text-c 7 lines of text for names-b and -c
+text-b/text-c at fseek(0x01234567L + 456L)
...
*
*/
return TRUE;
}
- return (FALSE);
+ return FALSE;
}
/* This routine is designed to return an integer value which represents
if (tmp > 49) /* special fixed hp monster */
tmp = 2 * (tmp - 6) / 4;
- /* For creation in groups */
+ /* For creation in groups */
n = (!!(ptr->geno & G_SGROUP));
n += (!!(ptr->geno & G_LGROUP)) << 1;
- /* For ranged attacks */
+ /* For ranged attacks */
if (ranged_attk(ptr))
n++;
- /* For higher ac values */
+ /* For higher ac values */
n += (ptr->ac < 4);
n += (ptr->ac < 0);
- /* For very fast monsters */
+ /* For very fast monsters */
n += (ptr->mmove >= 18);
- /* For each attack and "special" attack */
+ /* For each attack and "special" attack */
for (i = 0; i < NATTK; i++) {
tmp2 = ptr->mattk[i].aatyp;
n += (tmp2 > 0);
n += (tmp2 == AT_WEAP && (ptr->mflags2 & M2_STRONG));
}
- /* For each "special" damage type */
+ /* For each "special" damage type */
for (i = 0; i < NATTK; i++) {
tmp2 = ptr->mattk[i].adtyp;
if ((tmp2 == AD_DRLI) || (tmp2 == AD_STON) || (tmp2 == AD_DRST)
n += ((int) (ptr->mattk[i].damd * ptr->mattk[i].damn) > 23);
}
- /* Leprechauns are special cases. They have many hit dice so they
- can hit and are hard to kill, but they don't really do much
- damage. */
+ /* Leprechauns are special cases. They have many hit dice so they can
+ hit and are hard to kill, but they don't really do much damage. */
if (!strcmp(ptr->mname, "leprechaun"))
n -= 2;
- /* Finally, adjust the monster level 0 <= n <= 24 (approx.) */
+ /* Finally, adjust the monster level 0 <= n <= 24 (approx.) */
if (n == 0)
tmp--;
else if (n >= 6)
else
tmp += (n / 3 + 1);
- return ((tmp >= 0) ? tmp : 0);
+ return (tmp >= 0) ? tmp : 0;
}
void
return;
}
-/* Start of Quest text file processing. */
+/* Start of Quest text file processing. */
#include "qtext.h"
static struct qthdr qt_hdr;
char *s;
{
if (s[0] == '#')
- return (TRUE);
- return ((boolean)(!in_msg && strlen(s) == NO_MSG));
+ return TRUE;
+ return (boolean) (!in_msg && strlen(s) == NO_MSG);
}
static boolean
qt_control(s)
char *s;
{
- return ((boolean)(s[0] == '%' && (s[1] == 'C' || s[1] == 'E')));
+ return (boolean) (s[0] == '%' && (s[1] == 'C' || s[1] == 'E'));
}
static int
for (i = 0; i < qt_hdr.n_hdr; i++)
if (!strncmp(code, qt_hdr.id[i], LEN_HDR))
- return (++i);
+ return ++i;
- return (0);
+ return 0;
}
static boolean
{
if (qt_hdr.n_hdr >= N_HDR) {
Fprintf(stderr, OUT_OF_HEADERS, qt_line);
- return (FALSE);
+ return FALSE;
}
strncpy(&qt_hdr.id[qt_hdr.n_hdr][0], code, LEN_HDR);
msg_hdr[qt_hdr.n_hdr].n_msg = 0;
qt_hdr.offset[qt_hdr.n_hdr++] = 0L;
- return (TRUE);
+ return TRUE;
}
static boolean
for (i = 0; i < msg_hdr[num].n_msg; i++)
if (msg_hdr[num].qt_msg[i].msgnum == id)
- return (TRUE);
+ return TRUE;
- return (FALSE);
+ return FALSE;
}
static void
int i;
/*
- * The main header record.
+ * The main header record.
*/
if (debug)
Fprintf(stderr, "%ld: header info.\n", ftell(ofp));
}
/*
- * The individual class headers.
+ * The individual class headers.
*/
for (i = 0; i < qt_hdr.n_hdr; i++) {
if (debug)
sizeof(struct qtmsg), msg_hdr[i].n_msg, ofp);
if (debug) {
int j;
+
for (j = 0; j < msg_hdr[i].n_msg; j++) {
- Fprintf(
- stderr, "msg %d @ %ld (%ld)", msg_hdr[i].qt_msg[j].msgnum,
- msg_hdr[i].qt_msg[j].offset, msg_hdr[i].qt_msg[j].size);
+ Fprintf(stderr, "msg %d @ %ld (%ld)",
+ msg_hdr[i].qt_msg[j].msgnum,
+ msg_hdr[i].qt_msg[j].offset,
+ msg_hdr[i].qt_msg[j].size);
if (msg_hdr[i].qt_msg[j].summary_size)
Fprintf(stderr, " [%ld]",
msg_hdr[i].qt_msg[j].summary_size);