| 4418 | static struct weight_table_entry *weightlist; |
| 4419 | |
| 4420 | void |
| 4421 | dump_weights(void) |
| 4422 | { |
| 4423 | int i, cnt = 0, nmwidth = 49, mcount = NUMMONS, ocount = NUM_OBJECTS; |
| 4424 | char nmbuf[BUFSZ], nmbufbase[BUFSZ]; |
| 4425 | size_t num_entries = (size_t) (mcount + ocount); |
| 4426 | |
| 4427 | weightlist = (struct weight_table_entry *) |
| 4428 | alloc(sizeof (struct weight_table_entry) * num_entries); |
| 4429 | decl_globals_init(); |
| 4430 | init_objects(); |
| 4431 | for (i = 0; i < mcount; ++i) { |
| 4432 | if (i != PM_LONG_WORM_TAIL) { |
| 4433 | boolean cm; |
| 4434 | |
| 4435 | weightlist[cnt].wt = (int) mons[i].cwt; |
| 4436 | weightlist[cnt].idx = i; |
| 4437 | weightlist[cnt].wtyp = 1; |
| 4438 | weightlist[cnt].unique = ((mons[i].geno & G_UNIQ) != 0); |
| 4439 | Snprintf(nmbuf, sizeof nmbuf, "%07u", weightlist[cnt].wt); |
| 4440 | cm = CapitalMon(mons[i].pmnames[NEUTRAL]); |
| 4441 | Snprintf(&nmbuf[7], sizeof nmbuf - 7, "%s%s", "the body of ", |
| 4442 | (cm) ? the(mons[i].pmnames[NEUTRAL]) |
| 4443 | : weightlist[cnt].unique ? mons[i].pmnames[NEUTRAL] |
| 4444 | : an(mons[i].pmnames[NEUTRAL])); |
| 4445 | weightlist[cnt].nm = dupstr(nmbuf); |
| 4446 | cnt++; |
| 4447 | } |
| 4448 | } |
| 4449 | for (i = 0; i < ocount; ++i) { |
| 4450 | const char *oc_name = (i == SLIME_MOLD) ? "slime mold" |
| 4451 | : obj_descr[i].oc_name; |
| 4452 | int wt = (int) objects[i].oc_weight; |
| 4453 | |
| 4454 | if (wt && oc_name) { |
| 4455 | weightlist[cnt].idx = i; |
| 4456 | weightlist[cnt].wt = wt; |
| 4457 | weightlist[cnt].wtyp = 2; |
| 4458 | weightlist[cnt].unique = (objects[i].oc_unique != 0); |
| 4459 | objects[i].oc_name_known = 1; |
| 4460 | Strcpy(nmbufbase, simple_typename(i)); |
| 4461 | Snprintf(nmbuf, sizeof nmbuf, "%07u%s", wt, |
| 4462 | (weightlist[cnt].unique) ? the(nmbufbase) |
| 4463 | : an(nmbufbase)); |
| 4464 | weightlist[cnt].nm = dupstr(nmbuf); |
| 4465 | cnt++; |
| 4466 | } |
| 4467 | } |
| 4468 | qsort((genericptr_t) weightlist, cnt, |
| 4469 | sizeof (struct weight_table_entry), cmp_weights); |
| 4470 | raw_printf("int all_weights[] = {"); |
| 4471 | for (i = 0; i < cnt; ++i) { |
| 4472 | if (weightlist[i].nm) { |
| 4473 | raw_printf(" %7u%s /* %*s */", weightlist[i].wt, |
| 4474 | (i == cnt - 1) ? " " : ",", -nmwidth, |
| 4475 | &weightlist[i].nm[7]); |
| 4476 | free((genericptr_t) weightlist[i].nm), weightlist[i].nm = 0; |
| 4477 | } |
no test coverage detected