MCPcopy Create free account
hub / github.com/NetHack/NetHack / do_permonst

Function do_permonst

util/makedefs.c:2107–2162  ·  view source on GitHub ↗

obsolete */

Source from the content-addressed store, hash-verified

2105
2106/* obsolete */
2107void
2108do_permonst(void)
2109{
2110 int i;
2111 char *c, *nam;
2112
2113 filename[0] = '\0';
2114#ifdef FILE_PREFIX
2115 Strcat(filename, file_prefix);
2116#endif
2117 Sprintf(eos(filename), INCLUDE_TEMPLATE, MONST_FILE);
2118 if (!(ofp = fopen(filename, WRTMODE))) {
2119 perror(filename);
2120 makedefs_exit(EXIT_FAILURE);
2121 /*NOTREACHED*/
2122 }
2123 Fprintf(ofp, "%s", Reference_file);
2124 Fprintf(ofp, "#ifndef PM_H\n#define PM_H\n");
2125
2126 if (use_enum) {
2127 Fprintf(ofp, "\nenum monnums {");
2128#if 0
2129 /* need #define ENUM_PM for the full NetHack build to include these */
2130 Fprintf(ofp, "\n NON_PM = -1,");
2131 Fprintf(ofp, "\n LOW_PM = 0,");
2132#endif
2133 }
2134 for (i = 0; mons[i].mlet; i++) {
2135 SpinCursor(3);
2136 if (use_enum)
2137 Fprintf(ofp, "\n PM_");
2138 else
2139 Fprintf(ofp, "\n#define\tPM_");
2140 if (mons[i].mlet == S_HUMAN
2141 && !strncmp(mons[i].pmnames[NEUTRAL], "were", 4))
2142 Fprintf(ofp, "HUMAN_");
2143 for (nam = c = tmpdup(mons[i].pmnames[NEUTRAL]); *c; c++)
2144 if (*c >= 'a' && *c <= 'z')
2145 *c -= (char) ('a' - 'A');
2146 else if (*c < 'A' || *c > 'Z')
2147 *c = '_';
2148 if (use_enum)
2149 Fprintf(ofp, "%s = %d,", nam, i);
2150 else
2151 Fprintf(ofp, "%s\t%d", nam, i);
2152 }
2153 if (use_enum) {
2154 Fprintf(ofp, "\n\n NUMMONS = %d", i);
2155 Fprintf(ofp, "\n};\n");
2156 } else {
2157 Fprintf(ofp, "\n\n#define\tNUMMONS\t%d\n", i);
2158 }
2159 Fprintf(ofp, "\n#endif /* PM_H */\n");
2160 Fclose(ofp);
2161 return;
2162}
2163
2164/* Start of Quest text file processing. */

Callers 1

do_makedefsFunction · 0.85

Calls 3

eosFunction · 0.85
makedefs_exitFunction · 0.85
tmpdupFunction · 0.85

Tested by

no test coverage detected