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

Function do_objs

util/makedefs.c:2195–2361  ·  view source on GitHub ↗

obsolete */

Source from the content-addressed store, hash-verified

2193
2194/* obsolete */
2195void
2196do_objs(void)
2197{
2198 int i /*, sum = 0 */;
2199 char *c, *objnam;
2200 int nspell = 0;
2201 int prefix = 0;
2202 char class = '\0';
2203 boolean sumerr = FALSE;
2204 int n_glass_gems = 0;
2205 int start_glass_gems = 0;
2206
2207 filename[0] = '\0';
2208#ifdef FILE_PREFIX
2209 Strcat(filename, file_prefix);
2210#endif
2211 Sprintf(eos(filename), INCLUDE_TEMPLATE, ONAME_FILE);
2212 if (!(ofp = fopen(filename, WRTMODE))) {
2213 perror(filename);
2214 makedefs_exit(EXIT_FAILURE);
2215 /*NOTREACHED*/
2216 }
2217 Fprintf(ofp, "%s", Reference_file);
2218 Fprintf(ofp, "#ifndef ONAMES_H\n#define ONAMES_H\n\n");
2219
2220 for (i = 0; !i || objects[i].oc_class != ILLOBJ_CLASS; i++) {
2221 SpinCursor(3);
2222
2223 objects[i].oc_name_idx = objects[i].oc_descr_idx = (short) i;
2224 if (!(objnam = tmpdup(OBJ_NAME(objects[i]))))
2225 continue;
2226
2227 /* done with current class? */
2228 if (objects[i].oc_class != class) {
2229#if 0 /* [class total oc_prob of 1000 is no longer enforced] */
2230 /* make sure probabilities add up to 1000 */
2231 if (sum && sum != 1000) {
2232 Fprintf(stderr, "prob error for class %d (%d%%)", class, sum);
2233 (void) fflush(stderr);
2234 sumerr = TRUE;
2235 }
2236#endif /*0*/
2237 class = objects[i].oc_class;
2238 /* sum = 0; */
2239 }
2240
2241 for (c = objnam; *c; c++)
2242 if (*c >= 'a' && *c <= 'z')
2243 *c -= (char) ('a' - 'A');
2244 else if (*c < 'A' || *c > 'Z')
2245 *c = '_';
2246
2247 switch (class) {
2248 case WAND_CLASS:
2249 Fprintf(ofp, "#define\tWAN_");
2250 prefix = 1;
2251 break;
2252 case RING_CLASS:

Callers 1

do_makedefsFunction · 0.85

Calls 5

eosFunction · 0.85
makedefs_exitFunction · 0.85
tmpdupFunction · 0.85
fflushFunction · 0.85
macronamelimitFunction · 0.85

Tested by

no test coverage detected