From 9d9783568605a5884a39d1830223c31293a945d2 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 16 Mar 2024 16:59:55 +0200 Subject: [PATCH 1/4] Minor wishing alias improvement Previously when wishing for "ring of protection from shape shifters", you got a random ring instead of the protection from shape changers, because the string matching alias was "protection from shape shifters" without the object class. Now, we'll check if the wish matched any object class, but not existing object or alias, and try matching the aliases again, but only those of the already matching obj class. Add an alias for the ring of increase accuracy: "ring of accuracy", and tests for it. --- src/objnam.c | 16 ++++++++++++++++ test/testwish.lua | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/objnam.c b/src/objnam.c index 617bc1f7a..b2422de54 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -3306,6 +3306,7 @@ static const struct alt_spellings { { "grapnel", GRAPPLING_HOOK }, { "grapple", GRAPPLING_HOOK }, { "protection from shape shifters", RIN_PROTECTION_FROM_SHAPE_CHAN }, + { "accuracy", RIN_INCREASE_ACCURACY }, /* if we ever add other sizes, move this to o_ranges[] with "bag" */ { "box", LARGE_BOX }, /* normally we wouldn't have to worry about unnecessary , but @@ -4746,6 +4747,21 @@ readobjnam_postparse3(struct _readobjnam_data *d) } } + /* got a class, but not specific type; + check alternate spellings of items with matching classes */ + if (d->oclass && !d->typ) { + const struct alt_spellings *as = spellings; + + while (as->sp) { + if (objects[as->ob].oc_class == d->oclass + && wishymatch(d->bp, as->sp, TRUE)) { + d->typ = as->ob; + return 2; /*goto typfnd;*/ + } + as++; + } + } + return 0; } diff --git a/test/testwish.lua b/test/testwish.lua index 2fe5d869b..3220ef9ed 100644 --- a/test/testwish.lua +++ b/test/testwish.lua @@ -60,6 +60,9 @@ local wishtest_objects = { ["blessed fireproof +2 pair of speed boots"] = { otyp_name = "speed boots", oclass = "[", oerodeproof = 1, blessed = 1, spe = 2 }, ["tooled horn"] = { otyp_name = "tooled horn", oclass = "(" }, ["meat ring"] = { otyp_name = "meat ring", oclass = "%" }, + ["cursed +3 ring of increase accuracy"] = { otyp_name = "increase accuracy", oclass = "=", spe = 3, cursed = 1 }, + ["ring of accuracy"] = { otyp_name = "increase accuracy", oclass = "=", spe = 5 }, + ["accuracy"] = { otyp_name = "increase accuracy", oclass = "=" }, ["beartrap"] = { otyp_name = "beartrap", oclass = "(" }, ["bear trap"] = { otyp_name = "beartrap", oclass = "(" }, ["landmine"] = { otyp_name = "land mine", oclass = "(" }, @@ -94,3 +97,4 @@ for str, tbl in pairs(wishtest_objects) do end end end +pline("testwish: OK"); From cad4d871012fb63eb19aa1f2b1565270676237b7 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 16 Mar 2024 17:09:50 +0200 Subject: [PATCH 2/4] wishtest fix left-over bit from testing --- test/testwish.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testwish.lua b/test/testwish.lua index 3220ef9ed..dc9bbca51 100644 --- a/test/testwish.lua +++ b/test/testwish.lua @@ -61,7 +61,7 @@ local wishtest_objects = { ["tooled horn"] = { otyp_name = "tooled horn", oclass = "(" }, ["meat ring"] = { otyp_name = "meat ring", oclass = "%" }, ["cursed +3 ring of increase accuracy"] = { otyp_name = "increase accuracy", oclass = "=", spe = 3, cursed = 1 }, - ["ring of accuracy"] = { otyp_name = "increase accuracy", oclass = "=", spe = 5 }, + ["ring of accuracy"] = { otyp_name = "increase accuracy", oclass = "=" }, ["accuracy"] = { otyp_name = "increase accuracy", oclass = "=" }, ["beartrap"] = { otyp_name = "beartrap", oclass = "(" }, ["bear trap"] = { otyp_name = "beartrap", oclass = "(" }, From 295d6e257c1fdba94911be4d174b4f455f631393 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 16 Mar 2024 12:53:58 -0400 Subject: [PATCH 3/4] used, unused variables some variables marked as unused, are now actually used some unused variables are eliminated or commented out --- src/allmain.c | 8 +++++++- src/botl.c | 3 +-- src/invent.c | 4 ---- src/music.c | 3 ++- src/options.c | 6 +++--- src/sp_lev.c | 4 ++-- src/uhitm.c | 4 ++-- util/makedefs.c | 6 +++--- win/curses/cursinit.c | 4 ++-- win/curses/cursstat.c | 3 ++- 10 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/allmain.c b/src/allmain.c index 9e40a6a91..9f8430dbd 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -26,9 +26,15 @@ staticfn void debug_fields(const char *); staticfn void dump_enums(void); #endif +#ifdef CRASHREPORT +#define USED_FOR_CRASHREPORT +#else +#define USED_FOR_CRASHREPORT UNUSED +#endif + /*ARGSUSED*/ void -early_init(int argc UNUSED, char *argv[] UNUSED) +early_init(int argc USED_FOR_CRASHREPORT, char *argv[] USED_FOR_CRASHREPORT) { #ifdef CRASHREPORT /* Do this as early as possible, but let ports do other things first. */ diff --git a/src/botl.c b/src/botl.c index c5ff5156e..07579358a 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1370,7 +1370,7 @@ evaluate_and_notify_windowport( boolean *valsetlist, int idx) { - int i, fld, updated = 0, notpresent UNUSED = 0; + int i, fld, updated = 0; /* * Now pass the changed values to window port. @@ -1384,7 +1384,6 @@ evaluate_and_notify_windowport( || ((fld == BL_XP || i == BL_EXP) && Upolyd) || ((fld == BL_VERS) && !flags.showvers) ) { - notpresent++; continue; } if (eval_notify_windowport_field(fld, valsetlist, idx)) diff --git a/src/invent.c b/src/invent.c index baee7a1c1..9cd06a2e4 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2048,11 +2048,7 @@ DISABLE_WARNING_FORMAT_NONLITERAL void silly_thing(const char *word, -#ifdef OBSOLETE_HANDLING struct obj *otmp) -#else - struct obj *otmp UNUSED) -#endif { #ifdef OBSOLETE_HANDLING /* 'P','R' vs 'W','T' handling is obsolete */ diff --git a/src/music.c b/src/music.c index 65d153b9f..ce4510321 100644 --- a/src/music.c +++ b/src/music.c @@ -487,7 +487,7 @@ do_improvisation(struct obj *instr) struct obj itmp; boolean mundane = FALSE, same_old_song = FALSE; static char my_goto_song[] = {'C', '\0'}, - *improvisation SOUNDLIBONLY = my_goto_song; + *improvisation = my_goto_song; itmp = *instr; itmp.oextra = (struct oextra *) 0; /* ok on this copy as instr maintains @@ -706,6 +706,7 @@ do_improvisation(struct obj *instr) impossible("What a weird instrument (%d)!", instr->otyp); return 0; } + nhUse(improvisation); return 2; /* That takes time */ } diff --git a/src/options.c b/src/options.c index d631ca3f1..ccd541fed 100644 --- a/src/options.c +++ b/src/options.c @@ -1970,7 +1970,7 @@ optfn_map_mode(int optidx, int req, boolean negated, char *opts, char *op) /* all the key assignment options for menu_* commands are identical but optlist.h treats them as distinct rather than sharing one */ staticfn int -shared_menu_optfn(int optidx UNUSED, int req, boolean negated UNUSED, +shared_menu_optfn(int optidx UNUSED, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -3969,7 +3969,7 @@ extern const char *const known_restrictions[]; /* symbols.c */ staticfn int optfn_symset( - int optidx UNUSED, + int optidx, int req, boolean negated UNUSED, char *opts, @@ -8621,7 +8621,7 @@ doset(void) /* changing options via menu by Per Liboriussen */ (void) parseoptions(buf, setinitial, fromfile); } else { /* compound option */ - int k = opt_indx, reslt UNUSED; + int k = opt_indx, reslt; if (allopt[k].has_handler && allopt[k].optfn) { reslt = (*allopt[k].optfn)(allopt[k].idx, do_handler, diff --git a/src/sp_lev.c b/src/sp_lev.c index 8ea15c0d7..444407e63 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -5890,7 +5890,7 @@ lspo_wallify(lua_State *L) /* reset_level is only needed for testing purposes */ int -lspo_reset_level(lua_State *L UNUSED) +lspo_reset_level(lua_State *L) { boolean wtower = In_W_tower(u.ux, u.uy, &u.uz); @@ -5906,7 +5906,7 @@ lspo_reset_level(lua_State *L UNUSED) /* finalize_level is only needed for testing purposes */ int -lspo_finalize_level(lua_State *L UNUSED) +lspo_finalize_level(lua_State *L) { boolean wtower = In_W_tower(u.ux, u.uy, &u.uz); int i; diff --git a/src/uhitm.c b/src/uhitm.c index 3c01e7258..2fdb59841 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -3724,7 +3724,7 @@ mhitm_ad_pest( void mhitm_ad_deth( struct monst *magr, - struct attack *mattk UNUSED, + struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm) { struct permonst *pd = mdef->data; @@ -3831,7 +3831,7 @@ do_stone_u(struct monst *mtmp) void do_stone_mon( struct monst *magr, - struct attack *mattk UNUSED, + struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm) { struct permonst *pd = mdef->data; diff --git a/util/makedefs.c b/util/makedefs.c index d9ce2225b..9e58c3832 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -2176,7 +2176,7 @@ macronamelimit(char *name, int pref) void do_objs(void) { - int i, sum UNUSED = 0; + int i /*, sum = 0 */; char *c, *objnam; int nspell = 0; int prefix = 0; @@ -2216,7 +2216,7 @@ do_objs(void) } #endif /*0*/ class = objects[i].oc_class; - sum = 0; + /* sum = 0; */ } for (c = objnam; *c; c++) @@ -2289,7 +2289,7 @@ do_objs(void) Fprintf(ofp, "%s\t%d\n", macronamelimit(objnam, prefix), i); prefix = 0; - sum += objects[i].oc_prob; + /* sum += objects[i].oc_prob; */ if (sumerr) break; diff --git a/win/curses/cursinit.c b/win/curses/cursinit.c index 9b2380bb4..196a56c18 100644 --- a/win/curses/cursinit.c +++ b/win/curses/cursinit.c @@ -99,7 +99,7 @@ set_window_position(int *winx, int *winy, int *winw, int *winh, void curses_create_main_windows(void) { - int min_message_height UNUSED = 1; + /* int min_message_height = 1; */ int message_orientation = 0; int status_orientation = 0; int border_space = 0; @@ -133,7 +133,7 @@ curses_create_main_windows(void) } if ((term_cols - border_space) < COLNO) { - min_message_height++; + /* min_message_height++; */ } /* Determine status window orientation */ diff --git a/win/curses/cursstat.c b/win/curses/cursstat.c index 3f53fd103..c7258d6b9 100644 --- a/win/curses/cursstat.c +++ b/win/curses/cursstat.c @@ -301,7 +301,7 @@ draw_horizontal(boolean border) cap_and_hunger, exp_points, sho_score, sho_vers, /* both height and width get their values set, * but only width gets used in this function */ - height UNUSED, width, w, xtra, clen, x, y, t, ex, ey, + height, width, w, xtra, clen, x, y, t, ex, ey, condstart = 0, conddummy = 0, versstart = 0; #ifdef STATUS_HILITES int coloridx = NO_COLOR, attrmask = 0; @@ -672,6 +672,7 @@ draw_horizontal(boolean border) } /* i (fld) */ wclrtoeol(win); /* [superfluous? draw_status() calls werase()] */ } /* j (line) */ + nhUse(height); return; } From a9fd04013ac3b65921439502ad1e496a6d01ae08 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 16 Mar 2024 15:23:47 -0400 Subject: [PATCH 4/4] remove some obsolete code from options.c --- src/options.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/options.c b/src/options.c index ccd541fed..2d63f2294 100644 --- a/src/options.c +++ b/src/options.c @@ -7992,12 +7992,6 @@ fruitadd(char *str, struct fruit *replace_fruit) */ -#if defined(MICRO) || defined(MAC) || defined(WIN32) -#define OPTIONS_HEADING "OPTIONS" -#else -#define OPTIONS_HEADING "NETHACKOPTIONS" -#endif - static const char n_currently_set[] = "(%d currently set)"; DISABLE_WARNING_FORMAT_NONLITERAL /* RESTORE is after show_menucontrols() */