]> granicus.if.org Git - nethack/commitdiff
option fixes and missing prototypes
authorPatR <rankin@nethack.org>
Wed, 22 Apr 2020 20:39:38 +0000 (13:39 -0700)
committerPatR <rankin@nethack.org>
Wed, 22 Apr 2020 20:39:38 +0000 (13:39 -0700)
I added -Wmissing-prototypes to my CFLAGS and got a bunch of warnings.
This fixes the core ones (there are more for X11 that I haven't looked
at yet).  While fixing these, I discovered a few option processing
issues:  the non-Amiga 'altmeta' should be settable while the game is
in progress (not sure about the Amiga variation so left that as-is),
'altmeta' and 'menucolor' are booleans so shouldn't have had optfn_XXX
functions; 'MACgraphics' and 'subkeyvalue' were conditionally defined
differently in options.c than in optlist.h.

include/extern.h
include/optlist.h
src/monst.c
src/objects.c
src/options.c
src/sp_lev.c

index 0f98657c261394161e62b91fc47fa8b66b9b5c3f..3c2364828ca0253aafcf7ad15f0ad2bb631d4273 100644 (file)
@@ -2749,8 +2749,10 @@ E void NDECL(port_help);
 #endif
 E void FDECL(sethanguphandler, (void (*)(int)));
 E boolean NDECL(authorize_wizard_mode);
+E void FDECL(append_slash, (char *));
 E boolean FDECL(check_user_string, (char *));
 E char *NDECL(get_login_name);
+E unsigned long NDECL(sys_random_seed);
 #endif /* UNIX */
 
 /* ### unixtty.c ### */
index 0556739b60e36dd6d2ee3849d1bea24a3af60726..e741351eb210ef05fc87577b3f7690a60231ffc1 100644 (file)
@@ -69,7 +69,7 @@ pfx_##a,
  al, z, #a, Off, h, 0 },
 #endif
 
-/* B:nm, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, boolptr */
+/* B:nm, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, bool_p */
 /* C:nm, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc */
 /* P:pfx, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc*/
 
@@ -88,7 +88,7 @@ pfx_##a,
                &sysflags.altmeta)
 #else
 #ifdef ALTMETA
-    NHOPTB(altmeta, 0, opt_out, set_in_config, Off, No, No, No, NoAlias,
+    NHOPTB(altmeta, 0, opt_out, set_in_game, Off, No, No, No, NoAlias,
                &iflags.altmeta)
 #else
     NHOPTB(altmeta, 0, opt_out, set_in_config, Off, No, No, No, NoAlias,
@@ -248,11 +248,9 @@ pfx_##a,
                 &flags.lit_corridor)
     NHOPTB(lootabc, 0, opt_in, set_in_game, Off, Yes, No, No, NoAlias,
                 &flags.lootabc)
-#ifdef BACKWARD_COMPAT
-#ifdef MAC_GRAPHICS_ENV
+#if defined(BACKWARD_COMPAT) && defined(MAC_GRAPHICS_ENV)
     NHOPTC(Macgraphics, 70, opt_in, set_in_config, No, Yes, No, No, NoAlias,
                 "load MACGraphics display symbols")
-#endif
 #endif
     NHOPTB(mail, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
                 &flags.biff)
index f04bc3084cc65e166a4423920763558fa035e027..f964f412fdb1c5e9958624a2f09a7565859a2d70 100644 (file)
@@ -3236,6 +3236,8 @@ struct permonst _mons2[] = {
 
 #ifndef SPLITMON_1
 
+void NDECL(monst_globals_init); /* in hack.h but we're using config.h */
+
 struct permonst mons[SIZE(mons_init)];
 
 void
index b9215a7baaeb401d42276297e60f195d472e1f14..bdef455e4f397bbe95af7fb2bedb53382ea9f461 100644 (file)
@@ -1170,6 +1170,8 @@ OBJECT(OBJ(None, None),
 /* clang-format on */
 /* *INDENT-ON* */
 
+void NDECL(objects_globals_init); /* in hack.h but we're using config.h */
+
 struct objdescr obj_descr[SIZE(obj_descr_init)];
 struct objclass objects[SIZE(obj_init)];
 
index a03ebe0e2639b43ef6c6faf6a5d003f5c5b790db..d76dc127f1b370dfac291e4b7d369a8ddf9ba4a8 100644 (file)
@@ -672,40 +672,6 @@ char *op UNUSED;
     return optn_ok;
 }
 
-int
-optfn_altmeta(optidx, req, negated, opts, op)
-int optidx UNUSED;
-int req;
-boolean negated UNUSED;
-char *opts;
-char *op UNUSED;
-{
-    if (req == do_init) {
-        return optn_ok;
-    }
-    if (req == do_set) {
-        /* Amiga altmeta causes Alt+key to be converted into Meta+key by
-           low level nethack code; on by default, can be toggled off if
-           Alt+key is needed for some ASCII chars on non-ASCII keyboard */
-
-        /* non-Amiga altmeta causes nethack's top level command loop to treat
-           two character sequence "ESC c" as M-c, for terminals or emulators
-           which send "ESC c" when Alt+c is pressed; off by default, enabling
-           this can potentially make trouble if user types ESC when nethack
-           is honoring this conversion request (primarily after starting a
-           count prefix prior to a command and then deciding to cancel it) */
-
-        return optn_ok;
-    }
-    if (req == get_val) {
-        if (!opts)
-            return optn_err;
-        opts[0] = '\0';
-        return optn_err;
-    }
-    return optn_ok;
-}
-
 int
 optfn_boulder(optidx, req, negated, opts, op)
 int optidx UNUSED;
@@ -1467,23 +1433,15 @@ char *op UNUSED;
     return optn_ok;
 }
 
+#if defined(BACKWARD_COMPAT) && defined(MAC_GRAPHICS_ENV)
 int
 optfn_MACgraphics(optidx, req, negated, opts, op)
-#if defined(MAC_GRAPHICS_ENV) && defined(BACKWARD_COMPAT)
 int optidx;
 int req;
 boolean negated;
 char *opts;
 char *op;
-#else
-int optidx UNUSED;
-int req;
-boolean negated UNUSED;
-char *opts UNUSED;
-char *op UNUSED;
-#endif
 {
-#if defined(MAC_GRAPHICS_ENV) && defined(BACKWARD_COMPAT)
     boolean badflag = FALSE;
 
     if (req == do_init) {
@@ -1518,20 +1476,9 @@ char *op UNUSED;
         opts[0] = '\0';
         return optn_ok;
     }
-#else
-    if (req == do_set) {
-        config_error_add("'%s' %s; use 'symset:%s' instead",
-                         allopt[optidx].name,
-#ifdef MAC_GRAPHICS_ENV /* implies BACKWARD_COMPAT is not defined */
-                         "no longer supported",
-#else
-                         "is not supported",
-#endif
-                         allopt[optidx].name);
-    }
-#endif
     return optn_ok;
 }
+#endif /* BACKWARD_COMPAT && MAC_GRAPHICS_ENV */
 
 int
 optfn_map_mode(optidx, req, negated, opts, op)
@@ -1951,36 +1898,6 @@ char *op UNUSED;
     return optn_ok;
 }
 
-int
-optfn_menucolor(optidx, req, negated, opts, op)
-int optidx;
-int req;
-boolean negated UNUSED;
-char *opts;
-char *op;
-{
-    if (req == do_init) {
-        return optn_ok;
-    }
-    if (req == do_set) {
-        /* menucolor:"regex_string"=color */
-        if ((op = string_for_env_opt(allopt[optidx].name, opts, FALSE))
-            != empty_optstr) {
-            if (!add_menu_coloring(op))
-                return optn_err;
-        } else
-            return optn_err;
-        return optn_ok;
-    }
-    if (req == get_val) {
-        if (!opts)
-            return optn_err;
-        opts[0] = '\0';
-        return optn_ok;
-    }
-    return optn_ok;
-}
-
 int
 optfn_menuinvertmode(optidx, req, negated, opts, op)
 int optidx;
@@ -3468,6 +3385,7 @@ char *op;
     return optn_ok;
 }
 
+#ifdef WIN32
 int
 optfn_subkeyvalue(optidx, req, negated, opts, op)
 int optidx UNUSED;
@@ -3480,12 +3398,10 @@ char *op UNUSED;
         return optn_ok;
     }
     if (req == do_set) {
-#if defined(WIN32)
         if (op == empty_optstr)
             return optn_err;
 #ifdef TTY_GRAPHICS
         map_subkeyvalue(op);
-#endif
 #endif
         return optn_ok;
     }
@@ -3497,6 +3413,7 @@ char *op UNUSED;
     }
     return optn_ok;
 }
+#endif /* WIN32 */
 
 int
 optfn_suppress_alert(optidx, req, negated, opts, op)
index 79fb5bbfbd65999ce6d48229adbea801e315e139..9cda8a50fae641f30e4032327951984ce86690a9 100755 (executable)
@@ -23,6 +23,7 @@ typedef void FDECL((*select_iter_func), (int, int, genericptr));
 
 extern void FDECL(mkmap, (lev_init *));
 
+static boolean FDECL(match_maptyps, (XCHAR_P, XCHAR_P));
 static void NDECL(solidify_map);
 static void FDECL(lvlfill_maze_grid, (int, int, int, int, SCHAR_P));
 static void FDECL(lvlfill_solid, (SCHAR_P, SCHAR_P));
@@ -91,9 +92,11 @@ static void NDECL(spo_end_moninvent);
 static void NDECL(spo_pop_container);
 static int FDECL(l_create_stairway, (lua_State *, BOOLEAN_P));
 static void FDECL(spo_endroom, (struct sp_coder *));
-static void FDECL(l_table_getset_feature_flag, (lua_State *, int, int, const char *, int));
+static void FDECL(l_table_getset_feature_flag, (lua_State *, int, int,
+                                                const char *, int));
 static void FDECL(sel_set_lit, (int, int, genericptr_t));
-static void FDECL(selection_iterate, (struct selectionvar *, select_iter_func, genericptr_t));
+static void FDECL(selection_iterate, (struct selectionvar *, select_iter_func,
+                                      genericptr_t));
 static void FDECL(sel_set_ter, (int, int, genericptr_t));
 static void FDECL(sel_set_door, (int, int, genericptr_t));
 static void FDECL(sel_set_feature, (int, int, genericptr_t));
@@ -105,6 +108,8 @@ static int FDECL(get_table_region, (lua_State *, const char *,
 static void FDECL(set_wallprop_in_selection, (lua_State *, int));
 static int FDECL(floodfillchk_match_under, (int, int));
 static int FDECL(floodfillchk_match_accessible, (int, int));
+static boolean FDECL(sel_flood_havepoint, (int, int, xchar *, xchar *, int));
+static long FDECL(line_dist_coord, (long, long, long, long, long, long));
 static void FDECL(l_push_wid_hei_table, (lua_State *, int, int));
 static int FDECL(get_table_align, (lua_State *));
 static int FDECL(get_table_monclass, (lua_State *));
@@ -195,7 +200,7 @@ static struct monst *invent_carrying_monster = (struct monst *) 0;
 
 /* Does typ match with levl[][].typ, considering special types
    MATCH_WALL and MAX_TYPE (aka transparency)? */
-boolean
+static boolean
 match_maptyps(typ, levltyp)
 xchar typ, levltyp;
 {
@@ -4684,7 +4689,7 @@ int xc, yc, a, b, filled;
 }
 
 /* distance from line segment (x1,y1, x2,y2) to point (x3,y3) */
-long
+static long
 line_dist_coord(x1, y1, x2, y2, x3, y3)
 long x1, y1, x2, y2, x3, y3;
 {