'nethack --dumpweights' tweak

In the generated comments accompanying weights, show /* a novel */
rather than /* a spellbook of novel */.
This commit is contained in:
PatR
2025-03-18 11:53:58 -07:00
parent a64796e64d
commit ec6632352f
+17 -21
View File
@@ -4309,8 +4309,8 @@ dump_weights(void)
int i, cnt = 0, nmwidth = 49, mcount = NUMMONS, ocount = NUM_OBJECTS; int i, cnt = 0, nmwidth = 49, mcount = NUMMONS, ocount = NUM_OBJECTS;
char nmbuf[BUFSZ], nmbufbase[BUFSZ]; char nmbuf[BUFSZ], nmbufbase[BUFSZ];
weightlist = (struct weight_table_entry *) alloc(sizeof(struct weight_table_entry) weightlist = (struct weight_table_entry *)
* (mcount + ocount)); alloc(sizeof (struct weight_table_entry) * (mcount + ocount));
decl_globals_init(); decl_globals_init();
init_objects(); init_objects();
for (i = 0; i < mcount; ++i) { for (i = 0; i < mcount; ++i) {
@@ -4332,33 +4332,29 @@ dump_weights(void)
} }
} }
for (i = 0; i < ocount; ++i) { for (i = 0; i < ocount; ++i) {
int wt = (int) objects[i].oc_weight; int wt = (int) objects[i].oc_weight,
ocls = objects[i].oc_class;
if (wt && i != SLIME_MOLD && obj_descr[i].oc_name) { if (wt && i != SLIME_MOLD && obj_descr[i].oc_name) {
weightlist[cnt].idx = i; weightlist[cnt].idx = i;
weightlist[cnt].wt = wt; weightlist[cnt].wt = wt;
weightlist[cnt].wtyp = 2; weightlist[cnt].wtyp = 2;
weightlist[cnt].wt = wt;
weightlist[cnt].unique = (objects[i].oc_unique != 0); weightlist[cnt].unique = (objects[i].oc_unique != 0);
Snprintf( Snprintf(nmbufbase, sizeof nmbufbase, "%s%s",
nmbufbase, sizeof nmbufbase, "%s%s", (ocls == POTION_CLASS) ? "potion of "
objects[weightlist[cnt].idx].oc_class == POTION_CLASS : (ocls == WAND_CLASS) ? "wand of "
? "potion of " : (ocls == SCROLL_CLASS) ? "scroll of "
: objects[weightlist[cnt].idx].oc_class == WAND_CLASS : (ocls == RING_CLASS) ? "ring of "
? "wand of " : (ocls == SPBOOK_CLASS
: objects[weightlist[cnt].idx].oc_class == SCROLL_CLASS && objects[i].oc_name_idx != SPE_BOOK_OF_THE_DEAD
? "scroll of " && objects[i].oc_name_idx != SPE_NOVEL)
: objects[weightlist[cnt].idx].oc_class == RING_CLASS ? "spellbook of "
? "ring of " : "",
: (objects[weightlist[cnt].idx].oc_class == SPBOOK_CLASS obj_descr[i].oc_name);
&& objects[weightlist[cnt].idx].oc_name_idx != SPE_BOOK_OF_THE_DEAD)
? "spellbook of "
: "",
obj_descr[weightlist[cnt].idx].oc_name);
Snprintf(nmbuf, sizeof nmbuf, "%07u", wt); Snprintf(nmbuf, sizeof nmbuf, "%07u", wt);
Snprintf(&nmbuf[7], sizeof nmbuf - 7, "%s", Snprintf(&nmbuf[7], sizeof nmbuf - 7, "%s",
(weightlist[cnt].unique) ? the(nmbufbase) (weightlist[cnt].unique) ? the(nmbufbase)
: an(nmbufbase)); : an(nmbufbase));
weightlist[cnt].nm = dupstr(nmbuf); weightlist[cnt].nm = dupstr(nmbuf);
cnt++; cnt++;
} }