diff --git a/DEVEL/code_style.txt b/DEVEL/code_style.txt index 593f0a9fc..574af2cc8 100644 --- a/DEVEL/code_style.txt +++ b/DEVEL/code_style.txt @@ -170,6 +170,19 @@ Variable names to avoid processors with segmented architectures may treat those as keywords. It is safest to just avoid them. + NEARDATA Some data is marked with this define; the Amiga port uses + it to mark data items to be used with a short addressing mode. + You don't need to use this. + +static vs staticfn +------------------ + +The staticfn macro evaluates to either "static" or to nothing (see config.h). +If possible, functions in src/*.c that would otherwise be marked static should +be marked staticfn so platforms that do not name static functions in their +stack traces can be forced to do so; this means function names cannot be +reused. Never use staticfn with data. + Spaces in Expressions --------------------- @@ -240,7 +253,6 @@ the final newline for every file, prior to release if not always maintained day-to-day. The name at the end can still be worthwhile when editing or browsing multiple files. - Vim Configuration ================= diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 400b0b47e..d392be936 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -4996,7 +4996,7 @@ plus widen each inventory line by two columns. .lp windowcolors If NetHack can, it should display windows with the specified foreground/background colors. -Windows GUI only. +Windows GUI and curses windowport only. The format is .si .lp "OPTION=windowcolors:wintype foreground/background" diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 695893306..07cec032c 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -5513,7 +5513,7 @@ plus widen each inventory line by two columns. \item[\ib{windowcolors}] If {\it NetHack\/} can, it should display windows with the specified foreground/background colors. -Windows GUI only. +Windows GUI and curses windowport only. The format is \begin{verbatim} OPTION=windowcolors:wintype foreground/background diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 5695d5946..9aeacef1a 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2043,6 +2043,7 @@ curses: if user's terminal was set to 'application keypad mode' (DEC VTxxx entry told the terminal to send 8-bit escape sequences (via 3 char "ESC SPC G"), nethack wasn't recognizing number pad keys curses: change petattr attributes, dropping support for curses-only ones +curses: swap the grey and no-color color initialization macOS: Xcode project was failing to build if the path to the NetHack source tree contained a space; the issue was within some shell script code contained within the project @@ -2538,6 +2539,7 @@ curses: if panictrace is triggered, reset the terminal before giving backtrace curses: if a message is marked urgent, override message suppression initiated by user having typed ESC at previous More>> prompt curses: implement a dialog for the windowborders option +curses: implement the windowcolors option Qt: the "paper doll" inventory subset can be controlled via the "Qt Settings" dialog box ("Preferences..." on macOS) Qt: draw a border around each tile in the paper doll inventory; when BUC is diff --git a/doc/window.txt b/doc/window.txt index 0d24b67c9..0bad7062c 100644 --- a/doc/window.txt +++ b/doc/window.txt @@ -681,7 +681,7 @@ getmsghistory(init) with the most recent. If init is TRUE, start over again from most recent message. -putmsghistory(msg) +putmsghistory(const char *msg, boolean restoring) -- This is the counterpart to getmsghistory() for restores used to reload the port's message recall buffer. The routine is called repeatedly from the core restore @@ -690,14 +690,16 @@ putmsghistory(msg) savefile. The window port routine is expected to load the message recall buffers in such a way that the ordering remains correct. The window port routine should make no - assumptions about how - many messages are forthcoming, nor should it assume that - another message will follow this one, so it must be careful - to keep all pointers/indexes intact at the end of each call. + assumptions about how many messages are forthcoming, nor + should it assume that another message will follow this one, + so it must be careful to keep all pointers/indexes intact + at the end of each call. If the window port receives more messages that can fit in its buffers, it is expected to scroll away the oldest from its buffers, much like it would with new messages being produced. + At the end of restoring messages, this will be called + one more time with msg NULL. III. Global variables diff --git a/include/config.h b/include/config.h index ba49103f1..7774eef3f 100644 --- a/include/config.h +++ b/include/config.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 config.h $NHDT-Date: 1704043695 2023/12/31 17:28:15 $ $NHDT-Branch: keni-luabits2 $:$NHDT-Revision: 1.181 $ */ +/* NetHack 3.7 config.h $NHDT-Date: 1710344316 2024/03/13 15:38:36 $ $NHDT-Branch: keni-staticfn $:$NHDT-Revision: 1.188 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2016. */ /* NetHack may be freely redistributed. See license for details. */ @@ -272,12 +272,24 @@ # define PANICTRACE # endif # ifdef __linux__ - # define PANICTRACE +# define PANICTRACE +# define NOSTATICFN # endif // This test isn't quite right: CNG is only available from Windows 2000 on. // But we'll check that at runtime. # ifdef WIN32 # define PANICTRACE +# define NOSTATICFN +# endif +#endif + +#ifdef NONOSTATICFN +# define staticfn static +#else +# ifdef NOSTATICFN +# define staticfn +# else +# define staticfn static # endif #endif diff --git a/include/extern.h b/include/extern.h index 4733f1246..0e1a922e8 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 extern.h $NHDT-Date: 1710008870 2024/03/09 18:27:50 $ $NHDT-Branch: keni-regex $:$NHDT-Revision: 1.1397 $ */ +/* NetHack 3.7 extern.h $NHDT-Date: 1710792423 2024/03/18 20:07:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1398 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -317,6 +317,7 @@ extern void free_one_menu_coloring(int); extern void free_menu_coloring(void); extern int count_menucolors(void); extern int32 check_enhanced_colors(char *) NONNULLARG1; +extern const char *wc_color_name(int32) NONNULL; /* ### cmd.c ### */ diff --git a/include/flag.h b/include/flag.h index 9c660f83b..680e19954 100644 --- a/include/flag.h +++ b/include/flag.h @@ -195,6 +195,16 @@ struct debug_flags { #endif }; +enum windowcolors_windows { + wcolor_menu, wcolor_message, wcolor_status, wcolor_text, + WC_COUNT +}; + +struct windowcolors_struct { + char *fg; + char *bg; +}; + struct accessibility_data { boolean accessiblemsg; /* use msg_loc for plined messages */ coord msg_loc; /* accessiblemsg: location */ @@ -379,6 +389,7 @@ struct instance_flags { int wc_align_status; /* status win at top|bot|right|left */ int wc_align_message; /* message win at top|bot|right|left */ int wc_vary_msgcount; /* show more old messages at a time */ +#if 0 char *wc_foregrnd_menu; /* points to foregrnd color name for menu win */ char *wc_backgrnd_menu; /* points to backgrnd color name for menu win */ char *wc_foregrnd_message; /* points to foregrnd color name for msg win */ @@ -387,6 +398,9 @@ struct instance_flags { char *wc_backgrnd_status; /* points to backgrnd color name for status */ char *wc_foregrnd_text; /* points to foregrnd color name for text win */ char *wc_backgrnd_text; /* points to backgrnd color name for text win */ +#else + struct windowcolors_struct wcolors[WC_COUNT]; +#endif char *wc_font_map; /* points to font name for the map win */ char *wc_font_message; /* points to font name for message win */ char *wc_font_status; /* points to font name for status win */ diff --git a/include/optlist.h b/include/optlist.h index a2919ed84..b757f1b71 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -96,10 +96,12 @@ static int optfn_##a(int, int, boolean, char *, char *); #endif #endif -/* B:nm, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, bool_p, term */ -/* C:nm, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc */ -/* P:pfx, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc*/ - +/* B:nm, sec, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, + bool_p, term */ +/* C:nm, sec, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, + desc */ +/* P:pfx, sec, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, + desc*/ /* * Most of the options are in alphabetical order; a few are forced * to the top of list so that doset() will list them first and @@ -850,7 +852,7 @@ static int optfn_##a(int, int, boolean, char *, char *); No, Yes, No, No, NoAlias, "window processor to use") #endif NHOPTC(windowcolors, Advanced, 80, opt_in, set_gameview, - No, Yes, No, No, NoAlias, + No, Yes, Yes, No, NoAlias, "the foreground/background colors of windows") /* NHOPTC(windowtype) -- moved to top */ NHOPTB(wizmgender, Advanced, 0, opt_in, set_wizonly, diff --git a/include/sym.h b/include/sym.h index 4292236eb..15884d404 100644 --- a/include/sym.h +++ b/include/sym.h @@ -56,6 +56,7 @@ struct symdef { }; enum symparse_range { + SYM_INVALID = 0, SYM_CONTROL = 1, /* start/finish markers */ SYM_PCHAR = 2, /* index into showsyms */ SYM_OC = 3, /* index into oc_syms */ diff --git a/include/wincurs.h b/include/wincurs.h index ee7c5c5a2..d9042ed2d 100644 --- a/include/wincurs.h +++ b/include/wincurs.h @@ -32,7 +32,9 @@ extern WINDOW *activemenu; /* curses window for menu requesting a #define STATUS_WIN 2 #define MAP_WIN 3 #define INV_WIN 4 -#define NHWIN_MAX 5 +#define TEXT_WIN 5 +#define MENU_WIN 6 +#define NHWIN_MAX 7 #if !defined(__APPLE__) || !defined(NCURSES_VERSION) # define USE_DARKGRAY /* Allow "bright" black; delete if not visible */ #endif /* !__APPLE__ && !PDCURSES */ @@ -117,7 +119,9 @@ extern win_request_info *curses_ctrl_nhwindow(winid, int, win_request_info *); /* curswins.c */ -extern WINDOW *curses_create_window(int width, int height, orient orientation); +extern WINDOW *curses_create_window(int wid, int width, int height, orient orientation); +extern void curses_set_wid_colors(int wid, WINDOW *win); +extern void curses_parse_wid_colors(int wid, char *fg, char *bg); extern void curses_destroy_win(WINDOW *win); extern WINDOW *curses_get_nhwin(winid wid); extern void curses_add_nhwin(winid wid, int height, int width, int y, @@ -211,6 +215,8 @@ extern void curs_add_invt(int, char, attr_t, int, const char *); /* cursinit.c */ extern void curses_create_main_windows(void); +extern int curses_init_rgb(int r, int g, int b); +extern int curses_init_pair(int fg, int bg); extern void curses_init_nhcolors(void); extern void curses_choose_character(void); extern int curses_character_dialog(const char **choices, const char *prompt); diff --git a/include/wintype.h b/include/wintype.h index 794be9ad3..f00fb08ce 100644 --- a/include/wintype.h +++ b/include/wintype.h @@ -208,6 +208,7 @@ enum to_core_flags { }; enum from_core_requests { + invalid_core_request = 0, set_mode = 1, request_settings = 2, set_menu_promptstyle = 3, diff --git a/src/allmain.c b/src/allmain.c index a0dfd803f..9f8430dbd 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -12,23 +12,29 @@ #include #endif -static void moveloop_preamble(boolean); -static void u_calc_moveamt(int); -static void maybe_do_tutorial(void); +staticfn void moveloop_preamble(boolean); +staticfn void u_calc_moveamt(int); +staticfn void maybe_do_tutorial(void); #ifdef POSITIONBAR -static void do_positionbar(void); +staticfn void do_positionbar(void); #endif -static void regen_pw(int); -static void regen_hp(int); -static void interrupt_multi(const char *); -static void debug_fields(const char *); +staticfn void regen_pw(int); +staticfn void regen_hp(int); +staticfn void interrupt_multi(const char *); +staticfn void debug_fields(const char *); #ifndef NODUMPENUMS -static void dump_enums(void); +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. */ @@ -41,7 +47,7 @@ early_init(int argc UNUSED, char *argv[] UNUSED) runtime_info_init(); } -static void +staticfn void moveloop_preamble(boolean resuming) { /* if a save file created in normal mode is now being restored in @@ -101,7 +107,7 @@ moveloop_preamble(boolean resuming) update_inventory(); } -static void +staticfn void u_calc_moveamt(int wtcap) { int moveamt = 0; @@ -516,7 +522,7 @@ moveloop_core(void) } } -static void +staticfn void maybe_do_tutorial(void) { s_level *sp = find_level("tut-1"); @@ -549,7 +555,7 @@ moveloop(boolean resuming) } } -static void +staticfn void regen_pw(int wtcap) { if (u.uen < u.uenmax @@ -571,7 +577,7 @@ regen_pw(int wtcap) #define U_CAN_REGEN() (Regeneration || (Sleepy && u.usleep)) /* maybe recover some lost health (or lose some when an eel out of water) */ -static void +staticfn void regen_hp(int wtcap) { int heal = 0; @@ -832,7 +838,7 @@ welcome(boolean new_game) /* false => restoring an old game */ } #ifdef POSITIONBAR -static void +staticfn void do_positionbar(void) { /* FIXME: this will break if any coordinate is too big for (char); @@ -875,7 +881,7 @@ do_positionbar(void) } #endif -static void +staticfn void interrupt_multi(const char *msg) { if (gm.multi > 0 && !gc.context.travel && !gc.context.run) { @@ -1043,7 +1049,7 @@ argcheck(int argc, char *argv[], enum earlyarg e_arg) * optimization so that display output * can be debugged without buffering. */ -static void +staticfn void debug_fields(const char *opts) { char *op; @@ -1109,6 +1115,7 @@ timet_delta(time_t etim, time_t stim) /* end and start times */ #if !defined(NODUMPENUMS) || defined(ENHANCED_SYMBOLS) /* monsdump[] and objdump[] are also used in utf8map.c */ + #define DUMP_ENUMS struct enum_dump monsdump[] = { #include "monsters.h" @@ -1124,46 +1131,46 @@ struct enum_dump objdump[] = { }; #define DUMP_ENUMS_PCHAR -struct enum_dump defsym_cmap_dump[] = { +static struct enum_dump defsym_cmap_dump[] = { #include "defsym.h" { MAXPCHARS, "MAXPCHARS" }, }; #undef DUMP_ENUMS_PCHAR #define DUMP_ENUMS_MONSYMS -struct enum_dump defsym_mon_syms_dump[] = { +static struct enum_dump defsym_mon_syms_dump[] = { #include "defsym.h" { MAXMCLASSES, "MAXMCLASSES" }, }; #undef DUMP_ENUMS_MONSYMS #define DUMP_ENUMS_MONSYMS_DEFCHAR -struct enum_dump defsym_mon_defchars_dump[] = { +static struct enum_dump defsym_mon_defchars_dump[] = { #include "defsym.h" }; #undef DUMP_ENUMS_MONSYMS_DEFCHAR #define DUMP_ENUMS_OBJCLASS_DEFCHARS -struct enum_dump objclass_defchars_dump[] = { +static struct enum_dump objclass_defchars_dump[] = { #include "defsym.h" }; #undef DUMP_ENUMS_OBJCLASS_DEFCHARS #define DUMP_ENUMS_OBJCLASS_CLASSES -struct enum_dump objclass_classes_dump[] = { +static struct enum_dump objclass_classes_dump[] = { #include "defsym.h" { MAXOCLASSES, "MAXOCLASSES" }, }; #undef DUMP_ENUMS_OBJCLASS_CLASSES #define DUMP_ENUMS_OBJCLASS_SYMS -struct enum_dump objclass_syms_dump[] = { +static struct enum_dump objclass_syms_dump[] = { #include "defsym.h" }; #undef DUMP_ENUMS_OBJCLASS_SYMS #define DUMP_ARTI_ENUM -struct enum_dump arti_enum_dump[] = { +static struct enum_dump arti_enum_dump[] = { #include "artilist.h" { AFTER_LAST_ARTIFACT, "AFTER_LAST_ARTIFACT" } }; @@ -1174,7 +1181,7 @@ struct enum_dump arti_enum_dump[] = { #ifndef NODUMPENUMS -static void +staticfn void dump_enums(void) { enum enum_dumps { diff --git a/src/alloc.c b/src/alloc.c index 796ab7ade..f8f89a952 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -26,7 +26,7 @@ char *fmt_ptr(const genericptr) NONNULL; #undef re_alloc #undef free extern void free(genericptr_t); -static void heapmon_init(void); +staticfn void heapmon_init(void); static FILE *heaplog = 0; static boolean tried_heaplog = FALSE; @@ -138,7 +138,7 @@ fmt_ptr(const genericptr ptr) /* If ${NH_HEAPLOG} is defined and we can create a file by that name, then we'll log the allocation and release information to that file. */ -static void +staticfn void heapmon_init(void) { char *logname = getenv("NH_HEAPLOG"); diff --git a/src/apply.c b/src/apply.c index 106132bfc..4a7db4897 100644 --- a/src/apply.c +++ b/src/apply.c @@ -5,56 +5,56 @@ #include "hack.h" -static int use_camera(struct obj *); -static int use_towel(struct obj *); -static boolean its_dead(coordxy, coordxy, int *); -static int use_stethoscope(struct obj *); -static void use_whistle(struct obj *); -static void use_magic_whistle(struct obj *); -static void magic_whistled(struct obj *); -static int use_leash(struct obj *); -static boolean mleashed_next2u(struct monst *); -static int use_mirror(struct obj *); -static void use_bell(struct obj **); -static void use_candelabrum(struct obj *); -static void use_candle(struct obj **); -static void use_lamp(struct obj *); -static void light_cocktail(struct obj **); -static int rub_ok(struct obj *); -static void display_jump_positions(boolean); -static void use_tinning_kit(struct obj *); -static int use_figurine(struct obj **); -static int grease_ok(struct obj *); -static int use_grease(struct obj *); -static void use_trap(struct obj *); -static int touchstone_ok(struct obj *); -static int use_stone(struct obj *); -static int set_trap(void); /* occupation callback */ -static void display_polearm_positions(boolean); -static int use_cream_pie(struct obj *); -static int jelly_ok(struct obj *); -static int use_royal_jelly(struct obj **); -static int grapple_range(void); -static boolean can_grapple_location(coordxy, coordxy); -static void display_grapple_positions(boolean); -static int use_grapple(struct obj *); -static void discard_broken_wand(void); -static void broken_wand_explode(struct obj *, int, int); -static int do_break_wand(struct obj *); -static int apply_ok(struct obj *); -static int flip_through_book(struct obj *); -static int flip_coin(struct obj *); -static boolean figurine_location_checks(struct obj *, coord *, boolean); -static boolean check_jump(genericptr_t, coordxy, coordxy); -static boolean is_valid_jump_pos(coordxy, coordxy, int, boolean); -static boolean get_valid_jump_position(coordxy, coordxy); -static boolean get_valid_polearm_position(coordxy, coordxy); -static boolean find_poleable_mon(coord *, int, int); +staticfn int use_camera(struct obj *); +staticfn int use_towel(struct obj *); +staticfn boolean its_dead(coordxy, coordxy, int *); +staticfn int use_stethoscope(struct obj *); +staticfn void use_whistle(struct obj *); +staticfn void use_magic_whistle(struct obj *); +staticfn void magic_whistled(struct obj *); +staticfn int use_leash(struct obj *); +staticfn boolean mleashed_next2u(struct monst *); +staticfn int use_mirror(struct obj *); +staticfn void use_bell(struct obj **); +staticfn void use_candelabrum(struct obj *); +staticfn void use_candle(struct obj **); +staticfn void use_lamp(struct obj *); +staticfn void light_cocktail(struct obj **); +staticfn int rub_ok(struct obj *); +staticfn void display_jump_positions(boolean); +staticfn void use_tinning_kit(struct obj *); +staticfn int use_figurine(struct obj **); +staticfn int grease_ok(struct obj *); +staticfn int use_grease(struct obj *); +staticfn void use_trap(struct obj *); +staticfn int touchstone_ok(struct obj *); +staticfn int use_stone(struct obj *); +staticfn int set_trap(void); /* occupation callback */ +staticfn void display_polearm_positions(boolean); +staticfn int use_cream_pie(struct obj *); +staticfn int jelly_ok(struct obj *); +staticfn int use_royal_jelly(struct obj **); +staticfn int grapple_range(void); +staticfn boolean can_grapple_location(coordxy, coordxy); +staticfn void display_grapple_positions(boolean); +staticfn int use_grapple(struct obj *); +staticfn void discard_broken_wand(void); +staticfn void broken_wand_explode(struct obj *, int, int); +staticfn int do_break_wand(struct obj *); +staticfn int apply_ok(struct obj *); +staticfn int flip_through_book(struct obj *); +staticfn int flip_coin(struct obj *); +staticfn boolean figurine_location_checks(struct obj *, coord *, boolean); +staticfn boolean check_jump(genericptr_t, coordxy, coordxy); +staticfn boolean is_valid_jump_pos(coordxy, coordxy, int, boolean); +staticfn boolean get_valid_jump_position(coordxy, coordxy); +staticfn boolean get_valid_polearm_position(coordxy, coordxy); +staticfn boolean find_poleable_mon(coord *, int, int); static const char no_elbow_room[] = "don't have enough elbow-room to maneuver."; -static int +staticfn int use_camera(struct obj *obj) { struct monst *mtmp; @@ -96,7 +96,7 @@ use_camera(struct obj *obj) return ECMD_TIME; } -static int +staticfn int use_towel(struct obj *obj) { boolean drying_feedback = (obj == uwep); @@ -182,7 +182,7 @@ use_towel(struct obj *obj) } /* maybe give a stethoscope message based on floor objects */ -static boolean +staticfn boolean its_dead(coordxy rx, coordxy ry, int *resp) { char buf[BUFSZ]; @@ -303,7 +303,7 @@ static const char hollow_str[] = "a hollow sound. This must be a secret %s!"; not take any time; however, unless it did, the stethoscope would be almost useless. As a compromise, one use per turn is free, another uses up the turn; this makes curse status have a tangible effect. */ -static int +staticfn int use_stethoscope(struct obj *obj) { struct monst *mtmp; @@ -460,7 +460,7 @@ use_stethoscope(struct obj *obj) static const char whistle_str[] = "produce a %s whistling sound.", alt_whistle_str[] = "produce a %s, sharp vibration."; -static void +staticfn void use_whistle(struct obj *obj) { if (!can_blow(&gy.youmonst)) { @@ -479,7 +479,7 @@ use_whistle(struct obj *obj) } } -static void +staticfn void use_magic_whistle(struct obj *obj) { if (!can_blow(&gy.youmonst)) { @@ -500,7 +500,7 @@ use_magic_whistle(struct obj *obj) } /* 'obj' is assumed to be a magic whistle */ -static void +staticfn void magic_whistled(struct obj *obj) { struct monst *mtmp, *nextmon; @@ -747,7 +747,7 @@ leashable(struct monst *mtmp) } /* ARGSUSED */ -static int +staticfn int use_leash(struct obj *obj) { coord cc; @@ -867,7 +867,7 @@ get_mleash(struct monst *mtmp) return otmp; } -static boolean +staticfn boolean mleashed_next2u(struct monst *mtmp) { if (mtmp->mleashed) { @@ -993,7 +993,7 @@ beautiful(void) static const char look_str[] = "look %s."; -static int +staticfn int use_mirror(struct obj *obj) { const char *mirror, *uvisage; @@ -1177,7 +1177,7 @@ use_mirror(struct obj *obj) #undef SEENMON } -static void +staticfn void use_bell(struct obj **optr) { struct obj *obj = *optr; @@ -1294,7 +1294,7 @@ use_bell(struct obj **optr) wake_nearby(); } -static void +staticfn void use_candelabrum(struct obj *obj) { const char *s = (obj->spe != 1) ? "candles" : "candle"; @@ -1362,7 +1362,7 @@ use_candelabrum(struct obj *obj) begin_burn(obj, FALSE); } -static void +staticfn void use_candle(struct obj **optr) { struct obj *obj = *optr; @@ -1596,7 +1596,7 @@ catch_lit(struct obj *obj) } /* light a lamp or candle */ -static void +staticfn void use_lamp(struct obj *obj) { char buf[BUFSZ]; @@ -1670,7 +1670,7 @@ use_lamp(struct obj *obj) } } -static void +staticfn void light_cocktail(struct obj **optr) { struct obj *obj = *optr; /* obj is a potion of oil */ @@ -1737,7 +1737,7 @@ light_cocktail(struct obj **optr) /* getobj callback for object to be rubbed - not selecting a secondary object to rub on a gray stone or rub jelly on */ -static int +staticfn int rub_ok(struct obj *obj) { if (!obj) @@ -1829,7 +1829,7 @@ enum jump_trajectory { }; /* callback routine for walk_path() */ -static boolean +staticfn boolean check_jump(genericptr arg, coordxy x, coordxy y) { int traj = *(int *) arg; @@ -1860,7 +1860,7 @@ check_jump(genericptr arg, coordxy x, coordxy y) return TRUE; } -static boolean +staticfn boolean is_valid_jump_pos(coordxy x, coordxy y, int magic, boolean showmsg) { if (!magic && !(HJumping & ~INTRINSIC) && !EJumping && distu(x, y) != 5) { @@ -1926,7 +1926,7 @@ is_valid_jump_pos(coordxy x, coordxy y, int magic, boolean showmsg) return TRUE; } -static boolean +staticfn boolean get_valid_jump_position(coordxy x, coordxy y) { return (isok(x, y) @@ -1934,7 +1934,7 @@ get_valid_jump_position(coordxy x, coordxy y) && is_valid_jump_pos(x, y, gj.jumping_is_magic, FALSE)); } -static void +staticfn void display_jump_positions(boolean on_off) { coordxy x, y, dx, dy; @@ -2145,7 +2145,7 @@ tinnable(struct obj *corpse) return 1; } -static void +staticfn void use_tinning_kit(struct obj *obj) { struct obj *corpse, *can; @@ -2478,7 +2478,7 @@ fig_transform(anything *arg, long timeout) newsym(cc.x, cc.y); } -static boolean +staticfn boolean figurine_location_checks(struct obj *obj, coord *cc, boolean quietly) { coordxy x, y; @@ -2511,7 +2511,7 @@ figurine_location_checks(struct obj *obj, coord *cc, boolean quietly) return TRUE; } -static int +staticfn int use_figurine(struct obj **optr) { struct obj *obj = *optr; @@ -2552,7 +2552,7 @@ use_figurine(struct obj **optr) } /* getobj callback for object to apply grease to */ -static int +staticfn int grease_ok(struct obj *obj) { if (!obj) @@ -2569,7 +2569,7 @@ grease_ok(struct obj *obj) return GETOBJ_SUGGEST; } -static int +staticfn int use_grease(struct obj *obj) { struct obj *otmp; @@ -2623,7 +2623,7 @@ use_grease(struct obj *obj) } /* getobj callback for object to rub on a known touchstone */ -static int +staticfn int touchstone_ok(struct obj *obj) { if (!obj) @@ -2645,7 +2645,7 @@ touchstone_ok(struct obj *obj) /* touchstones - by Ken Arnold */ -static int +staticfn int use_stone(struct obj *tstone) { static const char scritch[] = "\"scritch, scritch\""; @@ -2786,7 +2786,7 @@ reset_trapset(void) } /* Place a landmine/bear trap. Helge Hafting */ -static void +staticfn void use_trap(struct obj *otmp) { int ttyp, tmp; @@ -2880,7 +2880,7 @@ use_trap(struct obj *otmp) } /* occupation routine called each turn while arming a beartrap or landmine */ -static int +staticfn int set_trap(void) { struct obj *otmp = gt.trapinfo.tobj; @@ -3247,7 +3247,7 @@ static const char (glyph_is_monster(G) || glyph_is_invisible(G) || glyph_is_statue(G)) /* find pos of monster in range, if only one monster */ -static boolean +staticfn boolean find_poleable_mon(coord *pos, int min_range, int max_range) { struct monst *mtmp; @@ -3285,7 +3285,7 @@ find_poleable_mon(coord *pos, int min_range, int max_range) return TRUE; } -static boolean +staticfn boolean get_valid_polearm_position(coordxy x, coordxy y) { int glyph; @@ -3298,7 +3298,7 @@ get_valid_polearm_position(coordxy x, coordxy y) && glyph_is_poleable(glyph)))); } -static void +staticfn void display_polearm_positions(boolean on_off) { coordxy x, y, dx, dy; @@ -3470,7 +3470,7 @@ use_pole(struct obj *obj, boolean autohit) #undef glyph_is_poleable -static int +staticfn int use_cream_pie(struct obj *obj) { boolean wasblind = Blind; @@ -3509,7 +3509,7 @@ use_cream_pie(struct obj *obj) } /* getobj callback for object to rub royal jelly on */ -static int +staticfn int jelly_ok(struct obj *obj) { if (obj && obj->otyp == EGG) @@ -3518,7 +3518,7 @@ jelly_ok(struct obj *obj) return GETOBJ_EXCLUDE; } -static int +staticfn int use_royal_jelly(struct obj **optr) { int oldcorpsenm; @@ -3588,7 +3588,7 @@ use_royal_jelly(struct obj **optr) return ECMD_TIME; } -static int +staticfn int grapple_range(void) { int typ = uwep_skill_type(); @@ -3603,13 +3603,13 @@ grapple_range(void) return max_range; } -static boolean +staticfn boolean can_grapple_location(coordxy x, coordxy y) { return (isok(x, y) && cansee(x, y) && distu(x, y) <= grapple_range()); } -static void +staticfn void display_grapple_positions(boolean on_off) { coordxy x, y, dx, dy; @@ -3631,7 +3631,7 @@ display_grapple_positions(boolean on_off) } } -static int +staticfn int use_grapple(struct obj *obj) { int res = ECMD_OK, typ, tohit; @@ -3777,7 +3777,7 @@ use_grapple(struct obj *obj) return ECMD_TIME; } -static void +staticfn void discard_broken_wand(void) { struct obj *obj; @@ -3789,7 +3789,7 @@ discard_broken_wand(void) nomul(0); } -static void +staticfn void broken_wand_explode(struct obj *obj, int dmg, int expltype) { explode(u.ux, u.uy, -(obj->otyp), dmg, WAND_CLASS, expltype); @@ -3798,7 +3798,7 @@ broken_wand_explode(struct obj *obj, int dmg, int expltype) } /* return 1 if the wand is broken, hence some time elapsed */ -static int +staticfn int do_break_wand(struct obj *obj) { #define BY_OBJECT ((struct monst *) 0) @@ -4031,7 +4031,7 @@ do_break_wand(struct obj *obj) /* getobj callback for object to apply - this is more complex than most other * callbacks because there are a lot of appliables */ -static int +staticfn int apply_ok(struct obj *obj) { if (!obj) @@ -4343,7 +4343,7 @@ unfixable_trouble_count(boolean is_horn) return unfixable_trbl; } -static int +staticfn int flip_through_book(struct obj *obj) { if (Underwater) { @@ -4397,7 +4397,7 @@ flip_through_book(struct obj *obj) return ECMD_TIME; } -static int +staticfn int flip_coin(struct obj *obj) { struct obj *otmp = obj; diff --git a/src/artifact.c b/src/artifact.c index 84685a4db..1e65131cd 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -21,17 +21,18 @@ static struct artifact *get_artifact(struct obj *) NONNULL; /* never returns nul ? &artilist[(int) (o)->oartifact] \ : &artilist[ART_NONARTIFACT]) */ -static boolean bane_applies(const struct artifact *, struct monst *) NONNULLARG12; -static int spec_applies(const struct artifact *, struct monst *) NONNULLARG12; -static int invoke_ok(struct obj *); -static int arti_invoke(struct obj *); -static boolean Mb_hit(struct monst * magr, struct monst *mdef, +staticfn boolean bane_applies(const struct artifact *, struct monst *) + NONNULLARG12; +staticfn int spec_applies(const struct artifact *, struct monst *) NONNULLARG12; +staticfn int invoke_ok(struct obj *); +staticfn int arti_invoke(struct obj *); +staticfn boolean Mb_hit(struct monst * magr, struct monst *mdef, struct obj *, int *, int, boolean, char *); -static unsigned long abil_to_spfx(long *) NONNULLARG1; -static uchar abil_to_adtyp(long *) NONNULLARG1; -static int glow_strength(int); -static boolean untouchable(struct obj *, boolean); -static int count_surround_traps(coordxy, coordxy); +staticfn unsigned long abil_to_spfx(long *) NONNULLARG1; +staticfn uchar abil_to_adtyp(long *) NONNULLARG1; +staticfn int glow_strength(int); +staticfn boolean untouchable(struct obj *, boolean); +staticfn int count_surround_traps(coordxy, coordxy); /* The amount added to the victim's total hit points to insure that the victim will be killed even after damage bonus/penalty adjustments. @@ -69,10 +70,10 @@ static xint16 artidisco[NROFARTIFACTS]; */ static const struct arti_info zero_artiexist = {0}; /* all bits zero */ -static void hack_artifacts(void); +staticfn void hack_artifacts(void); /* handle some special cases; must be called after u_init() */ -static void +staticfn void hack_artifacts(void) { struct artifact *art; @@ -891,7 +892,7 @@ arti_immune(struct obj *obj, int dtyp) || weap->cary.adtyp == dtyp); } -static boolean +staticfn boolean bane_applies(const struct artifact *oart, struct monst *mon) { struct artifact atmp; @@ -907,7 +908,7 @@ bane_applies(const struct artifact *oart, struct monst *mon) } /* decide whether an artifact's special attacks apply against mtmp */ -static int +staticfn int spec_applies(const struct artifact *weap, struct monst *mtmp) { struct permonst *ptr; @@ -1147,7 +1148,7 @@ static const char *const mb_verb[2][NUM_MB_INDICES] = { }; /* called when someone is being hit by Magicbane */ -static boolean +staticfn boolean Mb_hit(struct monst *magr, /* attacker */ struct monst *mdef, /* defender */ struct obj *mb, /* Magicbane */ @@ -1629,7 +1630,7 @@ artifact_hit( RESTORE_WARNING_FORMAT_NONLITERAL /* getobj callback for object to be invoked */ -static int +staticfn int invoke_ok(struct obj *obj) { if (!obj) @@ -1664,7 +1665,7 @@ doinvoke(void) return arti_invoke(obj); } -static int +staticfn int arti_invoke(struct obj *obj) { const struct artifact *oart = get_artifact(obj); @@ -2056,7 +2057,7 @@ arti_cost(struct obj *otmp) return (100L * (long) objects[otmp->otyp].oc_cost); } -static uchar +staticfn uchar abil_to_adtyp(long *abil) { struct abil2adtyp_tag { @@ -2080,7 +2081,7 @@ abil_to_adtyp(long *abil) return 0; } -static unsigned long +staticfn unsigned long abil_to_spfx(long *abil) { static const struct abil2spfx_tag { @@ -2174,7 +2175,7 @@ static const char *const glow_verbs[] = { }; /* relative strength that Sting is glowing (0..3), to select verb */ -static int +staticfn int glow_strength(int count) { /* glow strength should also be proportional to proximity and @@ -2328,7 +2329,7 @@ retouch_object( or an artifact which conveys something via being carried or which has an #invoke effect currently in operation undergoes a touch test; if it fails, it will be unworn/unwielded and maybe dropped */ -static boolean +staticfn boolean untouchable( struct obj *obj, /* object to test; in invent or is steed's saddle */ boolean drop_untouchable) /* whether to drop it if it can't be touched */ @@ -2438,7 +2439,7 @@ retouch_equipment( clear_bypasses(); /* reset upon final exit */ } -static int +staticfn int count_surround_traps(coordxy x, coordxy y) { struct rm *levp; @@ -2552,7 +2553,7 @@ is_art(struct obj *obj, int art) ? &artilist[(int) (o)->oartifact] \ : &artilist[ART_NONARTIFACT]) */ -static struct artifact * +staticfn struct artifact * get_artifact(struct obj *obj) { if (obj) { diff --git a/src/attrib.c b/src/attrib.c index f2b997209..8ab5618d7 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -14,7 +14,9 @@ static const char *const minusattr[] = { "weak", "stupid", "foolish", "clumsy", "fragile", "repulsive" }; -/* also used by enlightenment for non-abbreviated status info */ +/* also used by enlightenment in insight.c for non-abbreviated status info */ +extern const char *const attrname[6]; + const char *const attrname[] = { "strength", "intelligence", "wisdom", "dexterity", "constitution", "charisma" }; @@ -103,13 +105,13 @@ static const struct innate { hum_abil[] = { { 0, 0, 0, 0 } }; -static void exerper(void); -static int rnd_attr(void); -static int init_attr_role_redist(int, boolean); -static void postadjabil(long *); -static const struct innate *role_abil(int); -static const struct innate *check_innate_abil(long *, long); -static int innately(long *); +staticfn void exerper(void); +staticfn int rnd_attr(void); +staticfn int init_attr_role_redist(int, boolean); +staticfn void postadjabil(long *); +staticfn const struct innate *role_abil(int); +staticfn const struct innate *check_innate_abil(long *, long); +staticfn int innately(long *); /* adjust an attribute; return TRUE if change is made, FALSE otherwise */ boolean @@ -503,7 +505,7 @@ exercise(int i, boolean inc_or_dec) (void) encumber_msg(); } -static void +staticfn void exerper(void) { if (!(gm.moves % 10)) { @@ -664,7 +666,7 @@ exerchk(void) /* return random hero attribute (by role's attr distribution). returns A_MAX if failed. */ -static int +staticfn int rnd_attr(void) { int i, x = rn2(100); @@ -681,7 +683,7 @@ rnd_attr(void) adjusting the base and maximum values of the attributes. if subtracting, np must be negative. returns the left over points. */ -static int +staticfn int init_attr_role_redist(int np, boolean addition) { int tryct = 0; @@ -759,7 +761,7 @@ vary_init_attr(void) } } -static +staticfn void postadjabil(long *ability) { @@ -769,7 +771,7 @@ postadjabil(long *ability) see_monsters(); } -static const struct innate * +staticfn const struct innate * role_abil(int r) { const struct { @@ -798,7 +800,7 @@ role_abil(int r) return roleabils[i].abil; } -static const struct innate * +staticfn const struct innate * check_innate_abil(long *ability, long frommask) { const struct innate *abil = 0; @@ -844,7 +846,7 @@ check_innate_abil(long *ability, long frommask) #define FROM_LYCN 6 /* check whether particular ability has been obtained via innate attribute */ -static int +staticfn int innately(long *ability) { const struct innate *iptr; diff --git a/src/ball.c b/src/ball.c index 1cbfb1d7c..fe264eaf8 100644 --- a/src/ball.c +++ b/src/ball.c @@ -8,11 +8,11 @@ #include "hack.h" -static int bc_order(void); -static void litter(void); -static void placebc_core(void); -static void unplacebc_core(void); -static boolean check_restriction(int); +staticfn int bc_order(void); +staticfn void litter(void); +staticfn void placebc_core(void); +staticfn void unplacebc_core(void); +staticfn boolean check_restriction(int); static int bcrestriction = 0; #ifdef BREADCRUMBS @@ -116,7 +116,7 @@ ballfall(void) * * Should not be called while swallowed except on waterlevel. */ -static void +staticfn void placebc_core(void) { if (!uchain || !uball) { @@ -143,7 +143,7 @@ placebc_core(void) bcrestriction = 0; } -static void +staticfn void unplacebc_core(void) { if (u.uswallow) { @@ -176,7 +176,7 @@ unplacebc_core(void) u.bc_felt = 0; /* feel nothing */ } -static boolean +staticfn boolean check_restriction(int restriction) { boolean ret = FALSE; @@ -350,7 +350,7 @@ Lift_covet_and_placebc(int pin, char *funcnm, int linenum) * Return the stacking of the hero's ball & chain. This assumes that the * hero is being punished. */ -static int +staticfn int bc_order(void) { struct obj *obj; @@ -964,7 +964,7 @@ drop_ball(coordxy x, coordxy y) RESTORE_WARNING_FORMAT_NONLITERAL /* ball&chain cause hero to randomly lose stuff from inventory */ -static void +staticfn void litter(void) { struct obj *otmp, *nextobj = 0; diff --git a/src/bones.c b/src/bones.c index 00e89b3fd..2ed70ad91 100644 --- a/src/bones.c +++ b/src/bones.c @@ -5,15 +5,15 @@ #include "hack.h" -static boolean no_bones_level(d_level *); -static void goodfruit(int); -static void resetobjs(struct obj *, boolean); -static void give_to_nearby_mon(struct obj *, coordxy, coordxy) NONNULLARG1; -static boolean fixuporacle(struct monst *) NONNULLARG1; -static void remove_mon_from_bones(struct monst *) NONNULLARG1; -static void set_ghostly_objlist(struct obj *objchain); +staticfn boolean no_bones_level(d_level *); +staticfn void goodfruit(int); +staticfn void resetobjs(struct obj *, boolean); +staticfn void give_to_nearby_mon(struct obj *, coordxy, coordxy) NONNULLARG1; +staticfn boolean fixuporacle(struct monst *) NONNULLARG1; +staticfn void remove_mon_from_bones(struct monst *) NONNULLARG1; +staticfn void set_ghostly_objlist(struct obj *objchain); -static boolean +staticfn boolean no_bones_level(d_level *lev) { s_level *sptr; @@ -37,7 +37,7 @@ no_bones_level(d_level *lev) * ID is positive instead of negative). This way, when we later save the * chain of fruit types, we know to only save the types that exist. */ -static void +staticfn void goodfruit(int id) { struct fruit *f = fruit_from_indx(-id); @@ -46,7 +46,7 @@ goodfruit(int id) f->fid = id; } -static void +staticfn void resetobjs(struct obj *ochain, boolean restore) { struct obj *otmp, *nobj; @@ -220,7 +220,7 @@ sanitize_name(char *namebuf) /* Give object to a random object-liking monster on or adjacent to x,y but skipping hero's location. If no such monster, place object on floor at x,y. */ -static void +staticfn void give_to_nearby_mon(struct obj *otmp, coordxy x, coordxy y) { struct monst *mtmp; @@ -302,7 +302,7 @@ drop_upon_death( /* possibly restore oracle's room and/or put her back inside it; returns False if she's on the wrong level and should be removed, True otherwise */ -static boolean +staticfn boolean fixuporacle(struct monst *oracle) { coord cc; @@ -384,7 +384,7 @@ can_make_bones(void) /* monster might need to be removed before saving a bones file, in case these characters are not in their home bases */ -static void +staticfn void remove_mon_from_bones(struct monst *mtmp) { struct permonst *mptr = mtmp->data; @@ -740,7 +740,7 @@ bones_include_name(const char *name) } /* set the ghostly bit in a list of objects */ -static void +staticfn void set_ghostly_objlist(struct obj *objchain) { while (objchain) { diff --git a/src/botl.c b/src/botl.c index e37ffd8a8..07579358a 100644 --- a/src/botl.c +++ b/src/botl.c @@ -10,17 +10,18 @@ extern const char *const hu_stat[]; /* defined in eat.c */ +/* also used in insight.c */ const char *const enc_stat[] = { "", "Burdened", "Stressed", "Strained", "Overtaxed", "Overloaded" }; -static const char *rank(void); -static void bot_via_windowport(void); -static void stat_update_time(void); -static char *get_strength_str(void); +staticfn const char *rank(void); +staticfn void bot_via_windowport(void); +staticfn void stat_update_time(void); +staticfn char *get_strength_str(void); -static char * +staticfn char * get_strength_str(void) { static char buf[32]; @@ -360,7 +361,7 @@ rank_of(int lev, short monnum, boolean female) return "Player"; } -static const char * +staticfn const char * rank(void) { return rank_of(u.ulevel, Role_switch, flags.female); @@ -484,52 +485,52 @@ describe_level( #ifdef STATUS_HILITES #endif /* STATUS_HILITES */ -static boolean eval_notify_windowport_field(int, boolean *, int); -static void evaluate_and_notify_windowport(boolean *, int); -static void init_blstats(void); -static int compare_blstats(struct istat_s *, struct istat_s *); -static char *anything_to_s(char *, anything *, int); -static int percentage(struct istat_s *, struct istat_s *); -static int exp_percentage(void); -static int QSORTCALLBACK cond_cmp(const genericptr, const genericptr); -static int QSORTCALLBACK menualpha_cmp(const genericptr, const genericptr); +staticfn boolean eval_notify_windowport_field(int, boolean *, int); +staticfn void evaluate_and_notify_windowport(boolean *, int); +staticfn void init_blstats(void); +staticfn int compare_blstats(struct istat_s *, struct istat_s *); +staticfn char *anything_to_s(char *, anything *, int); +staticfn int percentage(struct istat_s *, struct istat_s *); +staticfn int exp_percentage(void); +staticfn int QSORTCALLBACK cond_cmp(const genericptr, const genericptr); +staticfn int QSORTCALLBACK menualpha_cmp(const genericptr, const genericptr); #ifdef STATUS_HILITES -static void s_to_anything(anything *, char *, int); -static enum statusfields fldname_to_bl_indx(const char *); -static boolean hilite_reset_needed(struct istat_s *, long); -static boolean noneoftheabove(const char *); -static struct hilite_s *get_hilite(int, int, genericptr_t, int, int, int *); -static void split_clridx(int, int *, int *); -static boolean is_ltgt_percentnumber(const char *); -static boolean has_ltgt_percentnumber(const char *); -static int splitsubfields(char *, char ***, int); -static boolean is_fld_arrayvalues(const char *, const char *const *, int, int, +staticfn void s_to_anything(anything *, char *, int); +staticfn enum statusfields fldname_to_bl_indx(const char *); +staticfn boolean hilite_reset_needed(struct istat_s *, long); +staticfn boolean noneoftheabove(const char *); +staticfn struct hilite_s *get_hilite(int, int, genericptr_t, int, int, int *); +staticfn void split_clridx(int, int *, int *); +staticfn boolean is_ltgt_percentnumber(const char *); +staticfn boolean has_ltgt_percentnumber(const char *); +staticfn int splitsubfields(char *, char ***, int); +staticfn boolean is_fld_arrayvalues(const char *, const char *const *, int, int, int *); -static int query_arrayvalue(const char *, const char *const *, int, int); -static void status_hilite_add_threshold(int, struct hilite_s *); -static boolean parse_status_hl2(char (*)[QBUFSZ], boolean); -static unsigned long query_conditions(void); -static char *conditionbitmask2str(unsigned long); -static unsigned long match_str2conditionbitmask(const char *); -static unsigned long str2conditionbitmask(char *); -static boolean parse_condition(char (*)[QBUFSZ], int); -static char *hlattr2attrname(int, char *, size_t); -static void status_hilite_linestr_add(int, struct hilite_s *, unsigned long, +staticfn int query_arrayvalue(const char *, const char *const *, int, int); +staticfn void status_hilite_add_threshold(int, struct hilite_s *); +staticfn boolean parse_status_hl2(char (*)[QBUFSZ], boolean); +staticfn unsigned long query_conditions(void); +staticfn char *conditionbitmask2str(unsigned long); +staticfn unsigned long match_str2conditionbitmask(const char *); +staticfn unsigned long str2conditionbitmask(char *); +staticfn boolean parse_condition(char (*)[QBUFSZ], int); +staticfn char *hlattr2attrname(int, char *, size_t); +staticfn void status_hilite_linestr_add(int, struct hilite_s *, unsigned long, const char *); -static void status_hilite_linestr_done(void); -static int status_hilite_linestr_countfield(int); -static void status_hilite_linestr_gather_conditions(void); -static void status_hilite_linestr_gather(void); -static char *status_hilite2str(struct hilite_s *); -static int status_hilite_menu_choose_field(void); -static int status_hilite_menu_choose_behavior(int); -static int status_hilite_menu_choose_updownboth(int, const char *, boolean, +staticfn void status_hilite_linestr_done(void); +staticfn int status_hilite_linestr_countfield(int); +staticfn void status_hilite_linestr_gather_conditions(void); +staticfn void status_hilite_linestr_gather(void); +staticfn char *status_hilite2str(struct hilite_s *); +staticfn int status_hilite_menu_choose_field(void); +staticfn int status_hilite_menu_choose_behavior(int); +staticfn int status_hilite_menu_choose_updownboth(int, const char *, boolean, boolean); -static boolean status_hilite_menu_add(int); -static boolean status_hilite_remove(int); -static boolean status_hilite_menu_fld(int); -static void status_hilites_viewall(void); +staticfn boolean status_hilite_menu_add(int); +staticfn boolean status_hilite_remove(int); +staticfn boolean status_hilite_menu_fld(int); +staticfn void status_hilites_viewall(void); #define has_hilite(i) (gb.blstats[0][(i)].thresholds) /* TH_UPDOWN encompasses specific 'up' and 'down' also general 'changed' */ @@ -591,7 +592,7 @@ static struct istat_s initblstats[MAXBLSTATS] = { #ifdef STATUS_HILITES -const struct condmap condition_aliases[] = { +static const struct condmap condition_aliases[] = { { "strangled", BL_MASK_STRNGL }, { "all", BL_MASK_BAREH | BL_MASK_BLIND | BL_MASK_BUSY | BL_MASK_CONF | BL_MASK_DEAF | BL_MASK_ELF_IRON @@ -737,7 +738,7 @@ do { \ * without STATUS_HILITES. */ -static void +staticfn void bot_via_windowport(void) { char buf[BUFSZ]; @@ -1031,7 +1032,7 @@ bot_via_windowport(void) #undef cond_cache_prepA /* update just the status lines' 'time' field */ -static void +staticfn void stat_update_time(void) { int idx = gn.now_or_before_idx; /* no 0/1 toggle */ @@ -1079,7 +1080,7 @@ condopt(int idx, boolean *addr, boolean negated) } /* qsort callback routine for sorting the condition index */ -static int QSORTCALLBACK +staticfn int QSORTCALLBACK cond_cmp(const genericptr vptr1, const genericptr vptr2) { int indx1 = *(int *) vptr1, indx2 = *(int *) vptr2, @@ -1092,7 +1093,7 @@ cond_cmp(const genericptr vptr1, const genericptr vptr2) } /* qsort callback routine for alphabetical sorting of index */ -static int QSORTCALLBACK +staticfn int QSORTCALLBACK menualpha_cmp(const genericptr vptr1, const genericptr vptr2) { int indx1 = *(int *) vptr1, indx2 = *(int *) vptr2; @@ -1239,7 +1240,7 @@ opt_next_cond(int indx, char *outbuf) return TRUE; } -static boolean +staticfn boolean eval_notify_windowport_field( int fld, boolean *valsetlist, @@ -1364,12 +1365,12 @@ eval_notify_windowport_field( return updated; } -static void +staticfn void 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. @@ -1383,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)) @@ -1497,7 +1497,7 @@ status_finish(void) } } -static void +staticfn void init_blstats(void) { static boolean initalready = FALSE; @@ -1547,7 +1547,7 @@ init_blstats(void) * - for strings, 0 = stayed the same, 1 = changed * */ -static int +staticfn int compare_blstats(struct istat_s *bl1, struct istat_s *bl2) { anything *a1, *a2; @@ -1620,7 +1620,7 @@ compare_blstats(struct istat_s *bl1, struct istat_s *bl2) return result; } -static char * +staticfn char * anything_to_s(char *buf, anything *a, int anytype) { if (!buf) @@ -1664,7 +1664,7 @@ anything_to_s(char *buf, anything *a, int anytype) } #ifdef STATUS_HILITES -static void +staticfn void s_to_anything(anything *a, char *buf, int anytype) { if (!buf || !a) @@ -1711,7 +1711,7 @@ s_to_anything(anything *a, char *buf, int anytype) #endif /* STATUS_HILITES */ /* integer percentage is 100 * bl->a / maxbl->a */ -static int +staticfn int percentage(struct istat_s *bl, struct istat_s *maxbl) { int result = 0; @@ -1786,7 +1786,7 @@ percentage(struct istat_s *bl, struct istat_s *maxbl) /* percentage for both xp (level) and exp (points) is the percentage for (curr_exp - this_level_start) in (next_level_start - this_level_start) */ -static int +staticfn int exp_percentage(void) { int res = 0; @@ -1942,7 +1942,7 @@ static const char threshold_value[] = "hilite_status threshold ", /* field name to bottom line index */ -static enum statusfields +staticfn enum statusfields fldname_to_bl_indx(const char *name) { int i, nmatches = 0, fld = 0; @@ -1978,7 +1978,7 @@ fldname_to_bl_indx(const char *name) return (nmatches == 1) ? fld : BL_FLUSH; } -static boolean +staticfn boolean hilite_reset_needed( struct istat_s *bl_p, long augmented_time) /* no longer augmented; it once encoded fractional @@ -2057,7 +2057,7 @@ reset_status_hilites(void) /* test whether the text from a title rule matches the string for title-while-polymorphed in the 'textmatch' menu */ -static boolean +staticfn boolean noneoftheabove(const char *hl_text) { if (fuzzymatch(hl_text, "none of the above", "\" -_", TRUE) @@ -2085,7 +2085,7 @@ noneoftheabove(const char *hl_text) * Get back: * pointer to rule that applies; Null if no rule does. */ -static struct hilite_s * +staticfn struct hilite_s * get_hilite( int idx, int fldidx, genericptr_t vp, @@ -2297,7 +2297,7 @@ get_hilite( #undef has_hilite #undef Is_Temp_Hilite -static void +staticfn void split_clridx(int idx, int *coloridx, int *attrib) { if (coloridx) @@ -2373,7 +2373,7 @@ parse_status_hl1(char *op, boolean from_configfile) } /* is str in the format of "[<>]?=?[-+]?[0-9]+%?" regex */ -static boolean +staticfn boolean is_ltgt_percentnumber(const char *str) { const char *s = str; @@ -2394,7 +2394,7 @@ is_ltgt_percentnumber(const char *str) } /* does str only contain "<>=-+0-9%" chars */ -static boolean +staticfn boolean has_ltgt_percentnumber(const char *str) { const char *s = str; @@ -2410,7 +2410,7 @@ has_ltgt_percentnumber(const char *str) /* splitsubfields(): splits str in place into '+' or '&' separated strings. * returns number of strings, or -1 if more than maxsf or MAX_SUBFIELDS */ -static int +staticfn int splitsubfields(char *str, char ***sfarr, int maxsf) { #define MAX_SUBFIELDS 16 @@ -2452,7 +2452,7 @@ splitsubfields(char *str, char ***sfarr, int maxsf) #undef MAX_SUBFIELDS } -static boolean +staticfn boolean is_fld_arrayvalues( const char *str, const char *const *arr, @@ -2469,7 +2469,7 @@ is_fld_arrayvalues( return FALSE; } -static int +staticfn int query_arrayvalue( const char *querystr, const char *const *arr, @@ -2504,7 +2504,7 @@ query_arrayvalue( return ret; } -static void +staticfn void status_hilite_add_threshold(int fld, struct hilite_s *hilite) { struct hilite_s *new_hilite, *old_hilite; @@ -2534,7 +2534,7 @@ status_hilite_add_threshold(int fld, struct hilite_s *hilite) gb.blstats[1][fld].thresholds = gb.blstats[0][fld].thresholds; } -static boolean +staticfn boolean parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile) { static const char *const aligntxt[] = { "chaotic", "neutral", "lawful" }; @@ -2829,7 +2829,7 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile) return (successes > 0); } -static unsigned long +staticfn unsigned long query_conditions(void) { int i,res; @@ -2861,7 +2861,7 @@ query_conditions(void) return ret; } -static char * +staticfn char * conditionbitmask2str(unsigned long ul) { static char buf[BUFSZ]; @@ -2891,7 +2891,7 @@ conditionbitmask2str(unsigned long ul) return buf; } -static unsigned long +staticfn unsigned long match_str2conditionbitmask(const char *str) { int i, nmatches = 0; @@ -2929,7 +2929,7 @@ match_str2conditionbitmask(const char *str) return mask; } -static unsigned long +staticfn unsigned long str2conditionbitmask(char *str) { unsigned long conditions_bitmask = 0UL; @@ -2953,7 +2953,7 @@ str2conditionbitmask(char *str) return conditions_bitmask; } -static boolean +staticfn boolean parse_condition(char (*s)[QBUFSZ], int sidx) { int i; @@ -3089,7 +3089,7 @@ clear_status_hilites(void) } } -static char * +staticfn char * hlattr2attrname(int attrib, char *buf, size_t bufsz) { if (attrib && buf) { @@ -3137,7 +3137,7 @@ struct _status_hilite_line_str { static struct _status_hilite_line_str *status_hilite_str = 0; static int status_hilite_str_id = 0; -static void +staticfn void status_hilite_linestr_add( int fld, struct hilite_s *hl, @@ -3168,7 +3168,7 @@ status_hilite_linestr_add( } } -static void +staticfn void status_hilite_linestr_done(void) { struct _status_hilite_line_str *nxt, *tmp = status_hilite_str; @@ -3182,7 +3182,7 @@ status_hilite_linestr_done(void) status_hilite_str_id = 0; } -static int +staticfn int status_hilite_linestr_countfield(int fld) { struct _status_hilite_line_str *tmp; @@ -3208,7 +3208,7 @@ count_status_hilites(void) return count; } -static void +staticfn void status_hilite_linestr_gather_conditions(void) { int i; @@ -3290,7 +3290,7 @@ status_hilite_linestr_gather_conditions(void) } } -static void +staticfn void status_hilite_linestr_gather(void) { int i; @@ -3310,7 +3310,7 @@ status_hilite_linestr_gather(void) } -static char * +staticfn char * status_hilite2str(struct hilite_s *hl) { static char buf[BUFSZ]; @@ -3392,7 +3392,7 @@ status_hilite2str(struct hilite_s *hl) return buf; } -static int +staticfn int status_hilite_menu_choose_field(void) { winid tmpwin; @@ -3427,7 +3427,7 @@ status_hilite_menu_choose_field(void) return fld; } -static int +staticfn int status_hilite_menu_choose_behavior(int fld) { winid tmpwin; @@ -3530,7 +3530,7 @@ status_hilite_menu_choose_behavior(int fld) return beh; } -static int +staticfn int status_hilite_menu_choose_updownboth( int fld, const char *str, @@ -3609,7 +3609,7 @@ status_hilite_menu_choose_updownboth( return ret; } -static boolean +staticfn boolean status_hilite_menu_add(int origfld) { int fld; @@ -4019,7 +4019,7 @@ status_hilite_menu_add(int origfld) return TRUE; } -static boolean +staticfn boolean status_hilite_remove(int id) { struct _status_hilite_line_str *hlstr = status_hilite_str; @@ -4071,7 +4071,7 @@ status_hilite_remove(int id) return FALSE; } -static boolean +staticfn boolean status_hilite_menu_fld(int fld) { winid tmpwin; @@ -4170,7 +4170,7 @@ status_hilite_menu_fld(int fld) return acted; } -static void +staticfn void status_hilites_viewall(void) { winid datawin; diff --git a/src/calendar.c b/src/calendar.c index 9021881df..857232782 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -26,7 +26,7 @@ #define LOCALTIME_type time_t * #endif -static struct tm *getlt(void); +staticfn struct tm *getlt(void); time_t getnow(void) @@ -37,7 +37,7 @@ getnow(void) return datetime; } -static struct tm * +staticfn struct tm * getlt(void) { time_t date = getnow(); diff --git a/src/cmd.c b/src/cmd.c index 27c8ed2ab..a29af2bad 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -94,63 +94,65 @@ extern int dozap(void); /**/ extern int doorganize(void); /**/ #endif /* DUMB */ -static int dosuspend_core(void); -static int dosh_core(void); -static int doherecmdmenu(void); -static int dotherecmdmenu(void); -static int doprev_message(void); -static int timed_occupation(void); -static boolean can_do_extcmd(const struct ext_func_tab *); -static int dotravel(void); -static int dotravel_target(void); -static int doclicklook(void); -static int domouseaction(void); -static int doterrain(void); -static boolean u_have_seen_whole_selection(struct selectionvar *); -static boolean u_have_seen_bounds_selection(struct selectionvar *); -static boolean u_can_see_whole_selection(struct selectionvar *); -static int dolookaround_floodfill_findroom(coordxy, coordxy); -static void lookaround_known_room(coordxy, coordxy); +staticfn int dosuspend_core(void); +staticfn int dosh_core(void); +staticfn int doherecmdmenu(void); +staticfn int dotherecmdmenu(void); +staticfn int doprev_message(void); +staticfn int timed_occupation(void); +staticfn boolean can_do_extcmd(const struct ext_func_tab *); +staticfn int dotravel(void); +staticfn int dotravel_target(void); +staticfn int doclicklook(void); +staticfn int domouseaction(void); +staticfn int doterrain(void); +staticfn boolean u_have_seen_whole_selection(struct selectionvar *); +staticfn boolean u_have_seen_bounds_selection(struct selectionvar *); +staticfn boolean u_can_see_whole_selection(struct selectionvar *); +staticfn int dolookaround_floodfill_findroom(coordxy, coordxy); +staticfn void lookaround_known_room(coordxy, coordxy); #if defined(__BORLANDC__) && !defined(_WIN32) extern void show_borlandc_stats(winid); #endif -static boolean accept_menu_prefix(const struct ext_func_tab *); -static void reset_cmd_vars(boolean); +staticfn boolean accept_menu_prefix(const struct ext_func_tab *); +staticfn void reset_cmd_vars(boolean); -static void mcmd_addmenu(winid, int, const char *); -static int there_cmd_menu_self(winid, coordxy, coordxy, int *); -static int there_cmd_menu_next2u(winid, coordxy, coordxy, int, int *); -static int there_cmd_menu_far(winid, coordxy, coordxy, int); -static int there_cmd_menu_common(winid, coordxy, coordxy, int, int *); -static void act_on_act(int, coordxy, coordxy); -static char there_cmd_menu(coordxy, coordxy, int); -static char here_cmd_menu(void); +staticfn void mcmd_addmenu(winid, int, const char *); +staticfn int there_cmd_menu_self(winid, coordxy, coordxy, int *); +staticfn int there_cmd_menu_next2u(winid, coordxy, coordxy, int, int *); +staticfn int there_cmd_menu_far(winid, coordxy, coordxy, int); +staticfn int there_cmd_menu_common(winid, coordxy, coordxy, int, int *); +staticfn void act_on_act(int, coordxy, coordxy); +staticfn char there_cmd_menu(coordxy, coordxy, int); +staticfn char here_cmd_menu(void); -static char readchar_core(coordxy *, coordxy *, int *); -static int parse(void); -static void show_direction_keys(winid, char, boolean); -static boolean help_dir(char, uchar, const char *); +staticfn char readchar_core(coordxy *, coordxy *, int *); +staticfn int parse(void); +staticfn void show_direction_keys(winid, char, boolean); +staticfn boolean help_dir(char, uchar, const char *); -static void handler_rebind_keys_add(boolean); -static boolean bind_key_fn(uchar, int (*)(void)); -static void commands_init(void); -static boolean keylist_func_has_key(const struct ext_func_tab *, boolean *); -static int keylist_putcmds(winid, boolean, int, int, boolean *); -static const char *spkey_name(int); +staticfn void handler_rebind_keys_add(boolean); +staticfn boolean bind_key_fn(uchar, int (*)(void)); +staticfn void commands_init(void); +staticfn boolean keylist_func_has_key(const struct ext_func_tab *, boolean *); +staticfn int keylist_putcmds(winid, boolean, int, int, boolean *); +staticfn const char *spkey_name(int); -static int (*timed_occ_fn)(void); -static char *doc_extcmd_flagstr(winid, const struct ext_func_tab *); +staticfn int (*timed_occ_fn)(void); +staticfn char *doc_extcmd_flagstr(winid, const struct ext_func_tab *); static const char *readchar_queue = ""; -/* for rejecting attempts to use wizard mode commands */ +/* for rejecting attempts to use wizard mode commands + * Also used in wizcmds.c */ const char unavailcmd[] = "Unavailable command '%s'."; + /* for rejecting #if !SHELL, !SUSPEND */ static const char cmdnotavail[] = "'%s' command not available."; /* the #prevmsg command */ -static int +staticfn int doprev_message(void) { (void) nh_doprev_message(); @@ -158,7 +160,7 @@ doprev_message(void) } /* Count down by decrementing multi */ -static int +staticfn int timed_occupation(void) { (*timed_occ_fn)(); @@ -437,7 +439,7 @@ extcmd_initiator(void) return gc.Cmd.extcmd_char; } -static boolean +staticfn boolean can_do_extcmd(const struct ext_func_tab *extcmd) { int ecflags = extcmd->flags; @@ -498,7 +500,7 @@ doextcmd(void) } /* format extended command flags for display */ -static char * +staticfn char * doc_extcmd_flagstr( winid menuwin, const struct ext_func_tab *efp) /* if Null, add a footnote to the menu */ @@ -1038,7 +1040,8 @@ makemap_prepost(boolean pre, boolean wiztower) } /* temporary? hack, since level type codes aren't the same as screen - symbols and only the latter have easily accessible descriptions */ + symbols and only the latter have easily accessible descriptions. + Also used by wizcmds.c */ const char *levltyp[MAX_TYPE + 2] = { "stone", "vertical wall", "horizontal wall", "top-left corner wall", "top-right corner wall", "bottom-left corner wall", @@ -1064,7 +1067,7 @@ levltyp_to_name(int typ) } /* #terrain command -- show known map, inspired by crawl's '|' command */ -static int +staticfn int doterrain(void) { winid men; @@ -1161,7 +1164,7 @@ doterrain(void) } /* has hero seen all locations in selection? */ -static boolean +staticfn boolean u_have_seen_whole_selection(struct selectionvar *sel) { coordxy x, y; @@ -1179,7 +1182,7 @@ u_have_seen_whole_selection(struct selectionvar *sel) } /* has hero seen all location of the rectangular outline in the selection */ -static boolean +staticfn boolean u_have_seen_bounds_selection(struct selectionvar *sel) { coordxy x, y; @@ -1212,7 +1215,7 @@ u_have_seen_bounds_selection(struct selectionvar *sel) } /* can hero currently see all locations in the selection */ -static boolean +staticfn boolean u_can_see_whole_selection(struct selectionvar *sel) { coordxy x, y; @@ -1229,7 +1232,7 @@ u_can_see_whole_selection(struct selectionvar *sel) } /* selection_floofill callback to get all locations in a room */ -static int +staticfn int dolookaround_floodfill_findroom(coordxy x, coordxy y) { schar typ = levl[x][y].typ; @@ -1242,7 +1245,7 @@ dolookaround_floodfill_findroom(coordxy x, coordxy y) } /* describe the room at x,y */ -static void +staticfn void lookaround_known_room(coordxy x, coordxy y) { struct selectionvar *sel = selection_new(); @@ -2029,7 +2032,7 @@ static const struct { { 0, (const char *) 0, FALSE } }; -int extcmdlist_length = SIZE(extcmdlist) - 1; +static int extcmdlist_length = SIZE(extcmdlist) - 1; /* get entry i in the extended commands list. for windowport use. */ struct ext_func_tab * @@ -2085,7 +2088,7 @@ get_changed_key_binds(strbuf_t *sbuf) } /* interactive key binding */ -static void +staticfn void handler_rebind_keys_add(boolean keyfirst) { struct ext_func_tab *ec; @@ -2400,7 +2403,7 @@ bind_key(uchar key, const char *command) } /* bind key by ext cmd function */ -static boolean +staticfn boolean bind_key_fn(uchar key, int (*fn)(void)) { struct ext_func_tab *extcmd; @@ -2418,7 +2421,7 @@ bind_key_fn(uchar key, int (*fn)(void)) } /* initialize all keyboard commands */ -static void +staticfn void commands_init(void) { struct ext_func_tab *extcmd; @@ -2453,7 +2456,7 @@ commands_init(void) #endif } -static boolean +staticfn boolean keylist_func_has_key(const struct ext_func_tab *extcmd, boolean *skip_keys_used) /* boolean keys_used[256] */ { @@ -2469,7 +2472,7 @@ keylist_func_has_key(const struct ext_func_tab *extcmd, return FALSE; } -static int +staticfn int keylist_putcmds(winid datawin, boolean docount, int incl_flags, int excl_flags, boolean *keys_used) /* boolean keys_used[256] */ @@ -2866,7 +2869,7 @@ bind_specialkey(uchar key, const char *command) return FALSE; } -static const char * +staticfn const char * spkey_name(int nhkf) { const char *name = 0; @@ -3134,7 +3137,7 @@ update_rest_on_space(void) /* commands which accept 'm' prefix to request menu operation or other alternate behavior; it's also overloaded for move-without-autopickup; there is no overlap between the two groups of commands */ -static boolean +staticfn boolean accept_menu_prefix(const struct ext_func_tab *ec) { return (ec && ((ec->flags & CMD_M_PREFIX) != 0)); @@ -3222,7 +3225,7 @@ rnd_extcmd_idx(void) return rn2(extcmdlist_length + 1) - 1; } -static void +staticfn void reset_cmd_vars(boolean reset_cmdq) { gc.context.run = 0; @@ -3700,7 +3703,7 @@ getdir(const char *s) return 1; } -static void +staticfn void show_direction_keys( winid win, /* should specify a window which is using a fixed-width font */ char centerchar, /* '.' or '@' or ' ' */ @@ -3749,7 +3752,7 @@ show_direction_keys( /* explain choices if player has asked for getdir() help or has given an invalid direction after a prefix key ('F', 'g', 'm', &c), which might be bogus but could be up, down, or self when not applicable */ -static boolean +staticfn boolean help_dir( char sym, uchar spkey, /* actual key; either prefix or ESC */ @@ -3912,7 +3915,7 @@ isok(coordxy x, coordxy y) } /* #herecmdmenu command */ -static int +staticfn int doherecmdmenu(void) { char ch = here_cmd_menu(); @@ -3921,7 +3924,7 @@ doherecmdmenu(void) } /* #therecmdmenu command, a way to test there_cmd_menu without mouse */ -static int +staticfn int dotherecmdmenu(void) { char ch; @@ -3999,7 +4002,7 @@ enum menucmd { MCMD_TRAVEL, }; -static void +staticfn void mcmd_addmenu(winid win, int act, const char *txt) { anything any; @@ -4013,7 +4016,7 @@ mcmd_addmenu(winid win, int act, const char *txt) } /* command menu entries when targeting self */ -static int +staticfn int there_cmd_menu_self(winid win, coordxy x, coordxy y, int *act UNUSED) { int K = 0; @@ -4102,7 +4105,7 @@ there_cmd_menu_self(winid win, coordxy x, coordxy y, int *act UNUSED) } /* add entries to there_cmd_menu, when x,y is next to hero */ -static int +staticfn int there_cmd_menu_next2u( winid win, coordxy x, coordxy y, @@ -4202,7 +4205,7 @@ there_cmd_menu_next2u( return K; } -static int +staticfn int there_cmd_menu_far(winid win, coordxy x, coordxy y, int mod) { int K = 0; @@ -4217,7 +4220,7 @@ there_cmd_menu_far(winid win, coordxy x, coordxy y, int mod) return K; } -static int +staticfn int there_cmd_menu_common( winid win, coordxy x, coordxy y, @@ -4236,7 +4239,7 @@ there_cmd_menu_common( } /* queue up command(s) to perform #therecmdmenu action */ -static void +staticfn void act_on_act( int act, /* action */ coordxy dx, coordxy dy) /* delta to adjacent spot (farther sometimes) */ @@ -4421,7 +4424,7 @@ act_on_act( /* offer choice of actions to perform at adjacent location ; a few choices can be farther away */ -static char +staticfn char there_cmd_menu(coordxy x, coordxy y, int mod) { winid win; @@ -4477,7 +4480,7 @@ there_cmd_menu(coordxy x, coordxy y, int mod) return ch; } -static char +staticfn char here_cmd_menu(void) { there_cmd_menu(u.ux, u.uy, CLICK_1); @@ -4494,7 +4497,7 @@ click_to_cmd(coordxy x, coordxy y, int mod) cmdq_add_ec(CQ_CANNED, gc.Cmd.mousebtn[mod-1]->ef_funct); } -static int +staticfn int domouseaction(void) { coordxy x, y; @@ -4669,7 +4672,7 @@ get_count( } -static int +staticfn int parse(void) { int foo; @@ -4773,7 +4776,7 @@ end_of_input(void) } #endif /* HANGUPHANDLING */ -static char +staticfn char readchar_core(coordxy *x, coordxy *y, int *mod) { int sym; @@ -4859,7 +4862,7 @@ readchar_poskey(coordxy *x, coordxy *y, int *mod) } /* '_' command, #travel, via keyboard rather than mouse click */ -static int +staticfn int dotravel(void) { coord cc; @@ -4908,7 +4911,7 @@ dotravel(void) } /* #retravel, travel to iflags.travelcc, which must be set */ -static int +staticfn int dotravel_target(void) { if (!isok(iflags.travelcc.x, iflags.travelcc.y)) { @@ -4941,7 +4944,7 @@ dotravel_target(void) } /* mouse click look command */ -static int +staticfn int doclicklook(void) { if (!isok(gc.clicklook_cc.x, gc.clicklook_cc.y)) @@ -5098,7 +5101,7 @@ paranoid_query(boolean be_paranoid, const char *prompt) } /* ^Z command, #suspend */ -static int +staticfn int dosuspend_core(void) { #ifdef SUSPEND @@ -5118,7 +5121,7 @@ dosuspend_core(void) } /* '!' command, #shell */ -static int +staticfn int dosh_core(void) { #ifdef SHELL diff --git a/src/coloratt.c b/src/coloratt.c index a50b7a0c2..7fb0237b5 100644 --- a/src/coloratt.c +++ b/src/coloratt.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 coloratt.c $NHDT-Date: 1709559438 2024/03/04 13:37:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1 $ */ +/* NetHack 3.7 coloratt.c $NHDT-Date: 1710792438 2024/03/18 20:07:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.2 $ */ /* Copyright (c) Pasi Kallinen, 2024 */ /* NetHack may be freely redistributed. See license for details. */ @@ -507,13 +507,16 @@ DISABLE_WARNING_FORMAT_NONLITERAL extern const char regex_id[]; /* from sys/share/regex.{c,cpp} */ -/* True: temporarily replace menu color entries with a fake set of menu - colors, { "light blue"=light_blue, "blue"=blue, "red"=red, &c }, that - illustrates most colors for use when the pick-a-color menu is rendered; - suppresses black and white because one of those will likely be invisible - due to matching the background; False: restore user-specified colorings */ +/* set up a menu for picking a color, one that shows each name in its color; + overrides player's MENUCOLORS with a set of "blue"=blue, "red"=red, and + so forth; suppresses color for black and white because one of those will + likely be invisible due to matching the background; the alternate set of + MENUCOLORS is kept around for potential re-use */ void -basic_menu_colors(boolean load_colors) +basic_menu_colors( + boolean load_colors) /* True: temporarily replace menu color entries with + * a fake set of menu colors which match their names; + * False: restore user-specified colorings */ { if (load_colors) { /* replace normal menu colors with a set specifically for colors */ @@ -537,7 +540,9 @@ basic_menu_colors(boolean load_colors) /* this orders the patterns last-in/first-out; that means that the "light " variations come before the basic - "" ones, which is exactly what we want */ + "" ones, which is exactly what we want (so that the + shorter basic names won't get false matches as substrings + of the longer ones) */ for (i = 0; i < SIZE(colornames); ++i) { if (!colornames[i].name) /* first alias entry has no name */ break; @@ -703,17 +708,78 @@ count_menucolors(void) int32 check_enhanced_colors(char *buf) { + char xtra = '\0'; /* used to catch trailing junk after "#rrggbb" */ + unsigned r, g, b; int32 retcolor = -1, color; if ((color = match_str2clr(buf, TRUE)) != CLR_MAX) { retcolor = color | NH_BASIC_COLOR; + } else if (sscanf(buf, "#%02x%02x%02x%c", &r, &g, &b, &xtra) >= 3) { + retcolor = !xtra ? (int32) ((r << 16) | (g << 8) | b) : -1; } else { - for (color = 0; color < SIZE(colortable); ++color) { - if (!strcmpi(buf, colortable[color].name)) - retcolor = colortable_to_int32(&colortable[color]); + /* altbuf: allow user's "grey" to match colortable[]'s "gray"; + * fuzzymatch(): ignore spaces, hyphens, and underscores so that + * space or underscore in user-supplied name will match hyphen + * [note: caller splits text at spaces so we won't see any here] + */ + char *altbuf = NULL, *grey = strstri(buf, "grey"); + ptrdiff_t greyoffset = grey ? (grey - buf) : -1; + + if (greyoffset >= 0) { + altbuf = dupstr(buf); + /* use direct copy because strsubst() is case-sensitive */ + /*(void) strncpy(&altbuf[greyoffset], "gray", 4);*/ + (void) memcpy(altbuf + greyoffset, "gray", 4); } + for (color = 0; color < SIZE(colortable); ++color) { + if (fuzzymatch(buf, colortable[color].name, " -_", TRUE) + || (altbuf && fuzzymatch(altbuf, colortable[color].name, + " -_", TRUE))) { + retcolor = colortable_to_int32(&colortable[color]); + break; + } + } + if (altbuf) + free(altbuf); } return retcolor; } +/* return the canonical name of a particular color */ +const char * +wc_color_name(int32 colorindx) +{ + static char hexcolor[sizeof "#rrggbb"]; /* includes room for '\0' */ + const char *result = "no-color"; + if (colorindx >= 0) { + int32 basicindx = colorindx & ~NH_BASIC_COLOR; + + /* if colorindx has NH_BASIC_COLOR bit set, basicindx won't, + so differing implies a basic color */ + if (basicindx != colorindx) { + assert(basicindx < 16); + result = colortable[basicindx].name; + } else { + int indx; + long r = (colorindx >> 16) & 0x0000ff, /* shift rrXXXX to rr */ + g = (colorindx >> 8) & 0x0000ff, /* shift XXggXX to gg */ + b = colorindx & 0x0000ff; /* mask XXXXbb to bb */ + + Snprintf(hexcolor, sizeof hexcolor, "#%02x%02x%02x", + (uint8) r, (uint8) g, (uint8) b); + result = hexcolor; + /* override hex value if this is a named color */ + for (indx = 16; indx < SIZE(colortable); ++indx) + if (colortable[indx].r == r + && colortable[indx].g == g + && colortable[indx].b == b) { + result = colortable[indx].name; + break; + } + } + } + return result; +} + +/*coloratt.c*/ diff --git a/src/dbridge.c b/src/dbridge.c index 462e1c4da..f5ee2403e 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -19,20 +19,20 @@ #include "hack.h" -static void get_wall_for_db(coordxy *, coordxy *); -static struct entity *e_at(coordxy, coordxy); -static void m_to_e(struct monst *, coordxy, coordxy, struct entity *); -static void u_to_e(struct entity *); -static void set_entity(coordxy, coordxy, struct entity *); -static const char *e_nam(struct entity *); -static const char *E_phrase(struct entity *, const char *); -static boolean e_survives_at(struct entity *, coordxy, coordxy); -static void e_died(struct entity *, int, int); -static boolean automiss(struct entity *); -static boolean e_missed(struct entity *, boolean); -static boolean e_jumps(struct entity *); -static void do_entity(struct entity *); -static void nokiller(void); +staticfn void get_wall_for_db(coordxy *, coordxy *); +staticfn struct entity *e_at(coordxy, coordxy); +staticfn void m_to_e(struct monst *, coordxy, coordxy, struct entity *); +staticfn void u_to_e(struct entity *); +staticfn void set_entity(coordxy, coordxy, struct entity *); +staticfn const char *e_nam(struct entity *); +staticfn const char *E_phrase(struct entity *, const char *); +staticfn boolean e_survives_at(struct entity *, coordxy, coordxy); +staticfn void e_died(struct entity *, int, int); +staticfn boolean automiss(struct entity *); +staticfn boolean e_missed(struct entity *, boolean); +staticfn boolean e_jumps(struct entity *); +staticfn void do_entity(struct entity *); +staticfn void nokiller(void); boolean is_waterwall(coordxy x, coordxy y) @@ -205,7 +205,7 @@ find_drawbridge(coordxy *x, coordxy *y) /* * Find the drawbridge wall associated with a drawbridge. */ -static void +staticfn void get_wall_for_db(coordxy *x, coordxy *y) { switch (levl[*x][*y].drawbridgemask & DB_DIR) { @@ -279,7 +279,7 @@ create_drawbridge(coordxy x, coordxy y, int dir, boolean flag) return TRUE; } -static struct entity * +staticfn struct entity * e_at(coordxy x, coordxy y) { int entitycnt; @@ -296,7 +296,7 @@ e_at(coordxy x, coordxy y) : &(go.occupants[entitycnt]); } -static void +staticfn void m_to_e(struct monst *mtmp, coordxy x, coordxy y, struct entity *etmp) { etmp->emon = mtmp; @@ -313,7 +313,7 @@ m_to_e(struct monst *mtmp, coordxy x, coordxy y, struct entity *etmp) } } -static void +staticfn void u_to_e(struct entity *etmp) { etmp->emon = &gy.youmonst; @@ -322,7 +322,7 @@ u_to_e(struct entity *etmp) etmp->edata = gy.youmonst.data; } -static void +staticfn void set_entity( coordxy x, coordxy y, /* location of span or portcullis */ struct entity *etmp) /* pointer to occupants[0] or occupants[1] */ @@ -343,7 +343,7 @@ set_entity( /* #define e_strg(etmp, func) (is_u(etmp) ? (char *) 0 : func(etmp->emon)) */ -static const char * +staticfn const char * e_nam(struct entity *etmp) { return is_u(etmp) ? "you" : mon_nam(etmp->emon); @@ -353,7 +353,7 @@ e_nam(struct entity *etmp) * Generates capitalized entity name, makes 2nd -> 3rd person conversion on * verb, where necessary. */ -static const char * +staticfn const char * E_phrase(struct entity *etmp, const char *verb) { static char wholebuf[80]; @@ -372,7 +372,7 @@ E_phrase(struct entity *etmp, const char *verb) /* * Simple-minded "can it be here?" routine */ -static boolean +staticfn boolean e_survives_at(struct entity *etmp, coordxy x, coordxy y) { if (noncorporeal(etmp->edata)) @@ -394,7 +394,7 @@ e_survives_at(struct entity *etmp, coordxy x, coordxy y) return TRUE; } -static void +staticfn void e_died(struct entity *etmp, int xkill_flags, int how) { if (is_u(etmp)) { @@ -456,7 +456,7 @@ e_died(struct entity *etmp, int xkill_flags, int how) /* * These are never directly affected by a bridge or portcullis. */ -static boolean +staticfn boolean automiss(struct entity *etmp) { return (boolean) ((is_u(etmp) ? Passes_walls : passes_walls(etmp->edata)) @@ -466,7 +466,7 @@ automiss(struct entity *etmp) /* * Does falling drawbridge or portcullis miss etmp? */ -static boolean +staticfn boolean e_missed(struct entity *etmp, boolean chunks) { int misses; @@ -501,7 +501,7 @@ e_missed(struct entity *etmp, boolean chunks) /* * Can etmp jump from death? */ -static boolean +staticfn boolean e_jumps(struct entity *etmp) { int tmp = 4; /* out of 10 */ @@ -524,7 +524,7 @@ e_jumps(struct entity *etmp) return (tmp >= rnd(10)) ? TRUE : FALSE; } -static void +staticfn void do_entity(struct entity *etmp) { coordxy newx, newy, oldx, oldy; @@ -733,7 +733,7 @@ do_entity(struct entity *etmp) } /* clear stale reason for death and both 'entities' before returning */ -static void +staticfn void nokiller(void) { gk.killer.name[0] = '\0'; diff --git a/src/decl.c b/src/decl.c index 2f8af0349..7b11846f8 100644 --- a/src/decl.c +++ b/src/decl.c @@ -51,7 +51,7 @@ const struct c_common_strings c_common_strings = { "mon", "you" } }; -const struct savefile_info default_sfinfo = { +static const struct savefile_info default_sfinfo = { #ifdef NHSTDC 0x00000000UL #else @@ -143,7 +143,7 @@ const char *ARGV0; #define IVMAGIC 0xdeadbeef -const struct Role urole_init_data = { +static const struct Role urole_init_data = { { "Undefined", 0 }, { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }, @@ -168,7 +168,7 @@ const struct Role urole_init_data = { -3 }; -const struct Race urace_init_data = { +static const struct Race urace_init_data = { "something", "undefined", "something", @@ -191,7 +191,7 @@ const struct Race urace_init_data = { struct display_hints disp = { 0 }; -const struct instance_globals_a g_init_a = { +static const struct instance_globals_a g_init_a = { /* artifact.c */ /* decl.c */ UNDEFINED_PTR, /* afternmv */ @@ -221,7 +221,7 @@ const struct instance_globals_a g_init_a = { IVMAGIC /* a_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_b g_init_b = { +static const struct instance_globals_b g_init_b = { /* botl.c */ { { { NULL, NULL, 0L, FALSE, FALSE, 0, 0U, { 0 }, { 0 }, NULL, 0, 0, 0 #ifdef STATUS_HILITES @@ -258,7 +258,7 @@ const struct instance_globals_b g_init_b = { IVMAGIC /* b_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_c g_init_c = { +static const struct instance_globals_c g_init_c = { UNDEFINED_VALUES, /* command_queue */ /* botl.c */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -310,7 +310,7 @@ const struct instance_globals_c g_init_c = { IVMAGIC /* c_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_d g_init_d = { +static const struct instance_globals_d g_init_d = { /* decl.c */ 0, /* doorindex */ 0L, /* done_money */ @@ -349,7 +349,7 @@ const struct instance_globals_d g_init_d = { IVMAGIC /* d_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_e g_init_e = { +static const struct instance_globals_e g_init_e = { /* cmd.c */ WIN_ERR, /* en_win */ FALSE, /* en_via_menu */ @@ -365,7 +365,7 @@ const struct instance_globals_e g_init_e = { IVMAGIC /* e_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_f g_init_f = { +static const struct instance_globals_f g_init_f = { /* decl.c */ UNDEFINED_PTR, /* ftrap */ { NULL }, /* fqn_prefix */ @@ -384,7 +384,7 @@ const struct instance_globals_f g_init_f = { IVMAGIC /* f_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_g g_init_g = { +static const struct instance_globals_g g_init_g = { /* display.c */ { { { 0 } } }, /* gbuf */ UNDEFINED_VALUES, /* gbuf_start */ @@ -416,7 +416,7 @@ const struct instance_globals_g g_init_g = { IVMAGIC /* g_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_h g_init_h = { +static const struct instance_globals_h g_init_h = { /* decl.c */ NULL, /* hname */ 0, /* hackpid */ @@ -436,7 +436,7 @@ const struct instance_globals_h g_init_h = { IVMAGIC /* h_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_i g_init_i = { +static const struct instance_globals_i g_init_i = { /* decl.c */ 0, /* in_doagain */ { 0, 0 } , /* inv_pos */ @@ -460,14 +460,14 @@ const struct instance_globals_i g_init_i = { IVMAGIC /* i_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_j g_init_j = { +static const struct instance_globals_j g_init_j = { /* apply.c */ 0, /* jumping_is_magic */ TRUE, /* havestate*/ IVMAGIC /* j_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_k g_init_k = { +static const struct instance_globals_k g_init_k = { /* decl.c */ UNDEFINED_PTR, /* kickedobj */ DUMMY, /* killer */ @@ -477,7 +477,7 @@ const struct instance_globals_k g_init_k = { IVMAGIC /* k_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_l g_init_l = { +static const struct instance_globals_l g_init_l = { /* cmd.c */ UNDEFINED_VALUE, /* last_command_count */ /* decl.c */ @@ -533,7 +533,7 @@ const struct instance_globals_l g_init_l = { IVMAGIC /* l_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_m g_init_m = { +static const struct instance_globals_m g_init_m = { /* apply.c */ 0, /* mkot_trap_warn_count */ /* botl.c */ @@ -586,7 +586,7 @@ const struct instance_globals_m g_init_m = { IVMAGIC /* m_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_n g_init_n = { +static const struct instance_globals_n g_init_n = { /* botl.c */ 0, /* now_or_before_idx */ /* decl.c */ @@ -626,7 +626,7 @@ const struct instance_globals_n g_init_n = { IVMAGIC /* n_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_o g_init_o = { +static const struct instance_globals_o g_init_o = { /* dbridge.c */ { { 0 } }, /* occupants */ /* decl.c */ @@ -666,7 +666,7 @@ const struct instance_globals_o g_init_o = { IVMAGIC /* o_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_p g_init_p = { +static const struct instance_globals_p g_init_p = { /* apply.c */ -1, /* polearm_range_min */ -1, /* polearm_range_max */ @@ -706,14 +706,14 @@ const struct instance_globals_p g_init_p = { IVMAGIC /* p_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_q g_init_q = { +static const struct instance_globals_q g_init_q = { /* quest.c */ DUMMY, /* quest_status */ TRUE, /* havestate*/ IVMAGIC /* q_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_r g_init_r = { +static const struct instance_globals_r g_init_r = { /* decl.c */ { DUMMY }, /* rooms */ /* symbols.c */ @@ -736,7 +736,7 @@ const struct instance_globals_r g_init_r = { IVMAGIC /* r_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_s g_init_s = { +static const struct instance_globals_s g_init_s = { /* artifact.c */ 0, /* spec_dbon_applies */ /* decl.c */ @@ -796,7 +796,7 @@ const struct instance_globals_s g_init_s = { IVMAGIC /* s_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_t g_init_t = { +static const struct instance_globals_t g_init_t = { /* apply.c */ UNDEFINED_VALUES, /* trapinfo */ /* decl.c */ @@ -833,7 +833,7 @@ const struct instance_globals_t g_init_t = { IVMAGIC /* t_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_u g_init_u = { +static const struct instance_globals_u g_init_u = { /* botl.c */ FALSE, /* update_all */ /* decl.c */ @@ -848,7 +848,7 @@ const struct instance_globals_u g_init_u = { IVMAGIC /* u_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_v g_init_v = { +static const struct instance_globals_v g_init_v = { /* botl.c */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* valset */ @@ -874,7 +874,7 @@ const struct instance_globals_v g_init_v = { IVMAGIC /* v_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_w g_init_w = { +static const struct instance_globals_w g_init_w = { /* decl.c */ 0, /* warn_obj_cnt */ 0L, /* wailmsg */ @@ -892,7 +892,7 @@ const struct instance_globals_w g_init_w = { IVMAGIC /* w_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_x g_init_x = { +static const struct instance_globals_x g_init_x = { /* decl.c */ (COLNO - 1) & ~1, /* x_maze_max */ /* lock.c */ @@ -909,7 +909,7 @@ const struct instance_globals_x g_init_x = { IVMAGIC /* x_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_y g_init_y = { +static const struct instance_globals_y g_init_y = { /* decl.c */ (ROWNO - 1) & ~1, /* y_maze_max */ DUMMY, /* youmonst */ @@ -926,7 +926,7 @@ const struct instance_globals_y g_init_y = { IVMAGIC /* y_magic to validate that structure layout has been preserved */ }; -const struct instance_globals_z g_init_z = { +static const struct instance_globals_z g_init_z = { /* mon.c */ FALSE, /* zombify */ /* muse.c */ diff --git a/src/detect.c b/src/detect.c index 101ef2fe7..47ee007ce 100644 --- a/src/detect.c +++ b/src/detect.c @@ -11,22 +11,22 @@ #include "hack.h" #include "artifact.h" -static boolean unconstrain_map(void); -static void reconstrain_map(void); -static void map_redisplay(void); -static void browse_map(unsigned, const char *); -static void map_monst(struct monst *, boolean); -static void do_dknown_of(struct obj *); -static boolean check_map_spot(coordxy, coordxy, char, unsigned); -static boolean clear_stale_map(char, unsigned); -static void sense_trap(struct trap *, coordxy, coordxy, int); -static int detect_obj_traps(struct obj *, boolean, int); -static void display_trap_map(int); -static int furniture_detect(void); -static void findone(coordxy, coordxy, genericptr_t); -static void openone(coordxy, coordxy, genericptr_t); -static int mfind0(struct monst *, boolean); -static int reveal_terrain_getglyph(coordxy, coordxy, unsigned, int, unsigned); +staticfn boolean unconstrain_map(void); +staticfn void reconstrain_map(void); +staticfn void map_redisplay(void); +staticfn void browse_map(unsigned, const char *); +staticfn void map_monst(struct monst *, boolean); +staticfn void do_dknown_of(struct obj *); +staticfn boolean check_map_spot(coordxy, coordxy, char, unsigned); +staticfn boolean clear_stale_map(char, unsigned); +staticfn void sense_trap(struct trap *, coordxy, coordxy, int); +staticfn int detect_obj_traps(struct obj *, boolean, int); +staticfn void display_trap_map(int); +staticfn int furniture_detect(void); +staticfn void findone(coordxy, coordxy, genericptr_t); +staticfn void openone(coordxy, coordxy, genericptr_t); +staticfn int mfind0(struct monst *, boolean); +staticfn int reveal_terrain_getglyph(coordxy, coordxy, unsigned, int, unsigned); /* dummytrap: used when detecting traps finds a door or chest trap; the couple of fields that matter are always re-initialized during use so @@ -51,7 +51,7 @@ struct found_things { /* bring hero out from underwater or underground or being engulfed; return True iff any change occurred */ -static boolean +staticfn boolean unconstrain_map(void) { boolean res = u.uinwater || u.uburied || u.uswallow; @@ -66,7 +66,7 @@ unconstrain_map(void) } /* put hero back underwater or underground or engulfed */ -static void +staticfn void reconstrain_map(void) { /* if was in water and taken out, put back; bypass set_uinwater() */ @@ -75,7 +75,7 @@ reconstrain_map(void) u.uswallow = iflags.save_uswallow, iflags.save_uswallow = 0; } -static void +staticfn void map_redisplay(void) { reconstrain_map(); @@ -87,7 +87,7 @@ map_redisplay(void) } /* use getpos()'s 'autodescribe' to view whatever is currently shown on map */ -static void +staticfn void browse_map(unsigned ter_typ, const char *ter_explain) { coord dummy_pos; /* don't care whether player actually picks a spot */ @@ -103,7 +103,7 @@ browse_map(unsigned ter_typ, const char *ter_explain) } /* extracted from monster_detection() so can be shared by do_vicinity_map() */ -static void +staticfn void map_monst(struct monst *mtmp, boolean showtail) { int glyph = (monsym(mtmp->data) == ' ') @@ -230,7 +230,7 @@ o_material(struct obj *obj, unsigned material) return (struct obj *) 0; } -static void +staticfn void do_dknown_of(struct obj *obj) { struct obj *otmp; @@ -243,7 +243,7 @@ do_dknown_of(struct obj *obj) } /* Check whether the location has an outdated object displayed on it. */ -static boolean +staticfn boolean check_map_spot(coordxy x, coordxy y, char oclass, unsigned material) { int glyph; @@ -297,7 +297,7 @@ check_map_spot(coordxy x, coordxy y, char oclass, unsigned material) * reappear after the detection has completed. Return true if noticeable * change occurs. */ -static boolean +staticfn boolean clear_stale_map(char oclass, unsigned material) { coordxy zx, zy; @@ -844,7 +844,7 @@ monster_detect(struct obj *otmp, /* detecting object (if any) */ return 0; } -static void +staticfn void sense_trap(struct trap *trap, coordxy x, coordxy y, int src_cursed) { if (Hallucination || src_cursed) { @@ -886,7 +886,7 @@ sense_trap(struct trap *trap, coordxy x, coordxy y, int src_cursed) /* check a list of objects for chest traps; return 1 if found at , 2 if found at some other spot, 3 if both, 0 otherwise; optionally update the map to show where such traps were found */ -static int +staticfn int detect_obj_traps( struct obj *objlist, boolean show_them, @@ -917,7 +917,7 @@ detect_obj_traps( return result; } -static void +staticfn void display_trap_map(int cursed_src) { struct monst *mon; @@ -1051,7 +1051,7 @@ trap_detect( return 0; } -static int +staticfn int furniture_detect(void) { struct monst *mon; @@ -1563,7 +1563,7 @@ cvt_sdoor_to_door(struct rm *lev) /* find something at one location; it should find all somethings there since it is used for magical detection rather than physical searching */ -static void +staticfn void findone(coordxy zx, coordxy zy, genericptr_t whatfound) { struct trap *ttmp; @@ -1624,7 +1624,7 @@ findone(coordxy zx, coordxy zy, genericptr_t whatfound) } } -static void +staticfn void openone(coordxy zx, coordxy zy, genericptr_t num) { struct trap *ttmp; @@ -1831,7 +1831,7 @@ find_trap(struct trap *trap) } } -static int +staticfn int mfind0(struct monst *mtmp, boolean via_warning) { coordxy x = mtmp->mx, y = mtmp->my; @@ -2015,7 +2015,7 @@ premap_detect(void) } } -static int +staticfn int reveal_terrain_getglyph( coordxy x, coordxy y, unsigned swallowed, diff --git a/src/dig.c b/src/dig.c index 2d65e93fa..d66027e5a 100644 --- a/src/dig.c +++ b/src/dig.c @@ -5,16 +5,16 @@ #include "hack.h" -static boolean rm_waslit(void); -static void mkcavepos(coordxy, coordxy, int, boolean, boolean); -static void mkcavearea(boolean); -static boolean pick_can_reach(struct obj *, coordxy, coordxy) NONNULLARG1; -static int dig(void); -static void dig_up_grave(coord *); -static boolean watchman_canseeu(struct monst *) NONNULLARG1; -static int adj_pit_checks(coord *, char *) NONNULLARG2; -static void pit_flow(struct trap *, schar); -static boolean furniture_handled(coordxy, coordxy, boolean); +staticfn boolean rm_waslit(void); +staticfn void mkcavepos(coordxy, coordxy, int, boolean, boolean); +staticfn void mkcavearea(boolean); +staticfn boolean pick_can_reach(struct obj *, coordxy, coordxy) NONNULLARG1; +staticfn int dig(void); +staticfn void dig_up_grave(coord *); +staticfn boolean watchman_canseeu(struct monst *) NONNULLARG1; +staticfn int adj_pit_checks(coord *, char *) NONNULLARG2; +staticfn void pit_flow(struct trap *, schar); +staticfn boolean furniture_handled(coordxy, coordxy, boolean); /* Indices returned by dig_typ() */ enum dig_types { @@ -26,7 +26,7 @@ enum dig_types { DIGTYP_TREE }; -static boolean +staticfn boolean rm_waslit(void) { coordxy x, y; @@ -44,7 +44,7 @@ rm_waslit(void) * boulders in the name of a nice effect. Vision will get fixed up again * immediately after the effect is complete. */ -static void +staticfn void mkcavepos(coordxy x, coordxy y, int dist, boolean waslit, boolean rockit) { struct rm *lev; @@ -84,7 +84,7 @@ mkcavepos(coordxy x, coordxy y, int dist, boolean waslit, boolean rockit) feel_newsym(x, y); } -static void +staticfn void mkcavearea(boolean rockit) { int dist; @@ -137,7 +137,7 @@ mkcavearea(boolean rockit) } /* called when attempting to break a statue or boulder with a pick */ -static boolean +staticfn boolean pick_can_reach(struct obj *pick, coordxy x, coordxy y) { struct trap *t = t_at(x, y); @@ -260,7 +260,7 @@ dig_check(struct monst *madeby, boolean verbose, coordxy x, coordxy y) return TRUE; } -static int +staticfn int dig(void) { struct rm *lev; @@ -518,7 +518,7 @@ dig(void) return 1; } -static boolean +staticfn boolean furniture_handled(coordxy x, coordxy y, boolean madeby_u) { struct rm *lev = &levl[x][y]; @@ -963,7 +963,7 @@ dighole(boolean pit_only, boolean by_magic, coord *cc) return retval; } -static void +staticfn void dig_up_grave(coord *cc) { struct obj *otmp; @@ -1296,7 +1296,7 @@ use_pick_axe2(struct obj *obj) return ECMD_TIME; } -static boolean +staticfn boolean watchman_canseeu(struct monst *mtmp) { if (is_watch(mtmp->data) && mtmp->mcansee && m_canseeu(mtmp) @@ -1696,7 +1696,7 @@ zap_dig(void) * you're zapping a wand of digging laterally while * down in the pit. */ -static int +staticfn int adj_pit_checks(coord *cc, char *msg) { int ltyp; @@ -1777,7 +1777,7 @@ adj_pit_checks(coord *cc, char *msg) /* * Ensure that all conjoined pits fill up. */ -static void +staticfn void pit_flow(struct trap *trap, schar filltyp) { /* diff --git a/src/display.c b/src/display.c index c875394a1..ac0428642 100644 --- a/src/display.c +++ b/src/display.c @@ -123,32 +123,32 @@ */ #include "hack.h" -static void show_mon_or_warn(coordxy, coordxy, int); -static void display_monster(coordxy, coordxy, +staticfn void show_mon_or_warn(coordxy, coordxy, int); +staticfn void display_monster(coordxy, coordxy, struct monst *, int, boolean) NONNULLPTRS; -static int swallow_to_glyph(int, int); -static void display_warning(struct monst *) NONNULLARG1; -static boolean next_to_gas(struct monst *, coordxy, coordxy) NONNULLARG1; +staticfn int swallow_to_glyph(int, int); +staticfn void display_warning(struct monst *) NONNULLARG1; +staticfn boolean next_to_gas(struct monst *, coordxy, coordxy) NONNULLARG1; -static int check_pos(coordxy, coordxy, int); -static void get_bkglyph_and_framecolor(coordxy x, coordxy y, int *, uint32 *); -static int tether_glyph(coordxy, coordxy); -static void mimic_light_blocking(struct monst *) NONNULLARG1; +staticfn int check_pos(coordxy, coordxy, int); +staticfn void get_bkglyph_and_framecolor(coordxy x, coordxy y, int *, uint32 *); +staticfn int tether_glyph(coordxy, coordxy); +staticfn void mimic_light_blocking(struct monst *) NONNULLARG1; /*#define WA_VERBOSE*/ /* give (x,y) locations for all "bad" spots */ #ifdef WA_VERBOSE -static boolean more_than_one(coordxy, coordxy, coordxy, coordxy, coordxy); +staticfn boolean more_than_one(coordxy, coordxy, coordxy, coordxy, coordxy); #endif -static int set_twall(coordxy, coordxy, coordxy, coordxy, +staticfn int set_twall(coordxy, coordxy, coordxy, coordxy, coordxy, coordxy, coordxy, coordxy); -static int set_wall(coordxy, coordxy, int); -static int set_corn(coordxy, coordxy, coordxy, coordxy, +staticfn int set_wall(coordxy, coordxy, int); +staticfn int set_corn(coordxy, coordxy, coordxy, coordxy, coordxy, coordxy, coordxy, coordxy); -static int set_crosswall(coordxy, coordxy); -static void set_seenv(struct rm *, coordxy, coordxy, coordxy, coordxy); -static void t_warn(struct rm *); -static int wall_angle(struct rm *); +staticfn int set_crosswall(coordxy, coordxy); +staticfn void set_seenv(struct rm *, coordxy, coordxy, coordxy, coordxy); +staticfn void t_warn(struct rm *); +staticfn int wall_angle(struct rm *); #define _glyph_at(x, y) gg.gbuf[y][x].glyphinfo.glyph @@ -468,7 +468,7 @@ map_location(coordxy x, coordxy y, int show) } /* display something on monster layer; may need to fixup object layer */ -static void +staticfn void show_mon_or_warn(coordxy x, coordxy y, int monglyph) { struct obj *o; @@ -500,7 +500,7 @@ show_mon_or_warn(coordxy x, coordxy y, int monglyph) * a worm tail. * */ -static void +staticfn void display_monster( coordxy x, coordxy y, /* display position */ struct monst *mon, /* monster to display */ @@ -619,7 +619,7 @@ display_monster( * * Do not call for worm tails. */ -static void +staticfn void display_warning(struct monst *mon) { coordxy x = mon->mx, y = mon->my; @@ -653,7 +653,7 @@ warning_of(struct monst *mon) /* returns True if mon is adjacent and would be seen if vision wasn't blocked by being in a gas cloud (implicit; caller has already checked) */ -static boolean +staticfn boolean next_to_gas( struct monst *mon, coordxy mx, coordxy my) /* won't match mon->mx,my if long worm's tail */ @@ -1072,7 +1072,7 @@ shieldeff(coordxy x, coordxy y) } } -static int +staticfn int tether_glyph(coordxy x, coordxy y) { int tdx, tdy; @@ -1473,7 +1473,7 @@ see_monsters(void) newsym(u.ux, u.uy); } -static void +staticfn void mimic_light_blocking(struct monst *mtmp) { if (mtmp->minvis && is_lightblocker_mappear(mtmp)) { @@ -1583,7 +1583,7 @@ static glyph_info no_ginfo = { : &gg.gbuf[(y)][(x)].glyphinfo) #else static glyph_info ginfo; -static glyph_info *glyphinfo_at(coordxy, coordxy, int); +staticfn glyph_info *glyphinfo_at(coordxy, coordxy, int); #define Glyphinfo_at(x, y, glyph) glyphinfo_at((x), (y), (glyph)) #endif @@ -2343,7 +2343,7 @@ back_to_glyph(coordxy x, coordxy y) * If you don't want a patchwork monster while hallucinating, decide on * a random monster in swallowed() and don't use what_mon() here. */ -static int +staticfn int swallow_to_glyph(int mnum, int loc) { int m_3 = what_mon(mnum, rn2_on_display_rng) << 3; @@ -2413,7 +2413,7 @@ glyphinfo_at(coordxy x, coordxy y, int glyph) * */ -static void +staticfn void get_bkglyph_and_framecolor( coordxy x, coordxy y, int *bkglyph, @@ -2609,9 +2609,9 @@ int wallcolors[sokoban_walls + 1] = { && gl.level.objects[(x)][(y)]->nexthere) #endif -static int cmap_to_roguecolor(int); +staticfn int cmap_to_roguecolor(int); -static int +staticfn int cmap_to_roguecolor(int cmap) { int color = NO_COLOR; @@ -3006,8 +3006,8 @@ reset_glyphmap(enum glyphmap_change_triggers trigger) #ifdef WA_VERBOSE -static const char *type_to_name(int); -static void error4(coordxy, coordxy, int, int, int, int); +staticfn const char *type_to_name(int); +staticfn void error4(coordxy, coordxy, int, int, int, int); static int bad_count[MAX_TYPE]; /* count of positions flagged as bad */ static const char *const type_names[MAX_TYPE] = { @@ -3020,13 +3020,13 @@ static const char *const type_names[MAX_TYPE] = { "CLOUD" }; -static const char * +staticfn const char * type_to_name(int type) { return (type < 0 || type >= MAX_TYPE) ? "unknown" : type_names[type]; } -static void +staticfn void error4(coordxy x, coordxy y, int a, int b, int c, int dd) { pline("set_wall_state: %s @ (%d,%d) %s%s%s%s", @@ -3042,7 +3042,7 @@ error4(coordxy x, coordxy y, int a, int b, int c, int dd) * * Things that are ambiguous: lava */ -static int +staticfn int check_pos(coordxy x, coordxy y, int which) { int type; @@ -3058,7 +3058,7 @@ check_pos(coordxy x, coordxy y, int which) /* Return TRUE if more than one is non-zero. */ /*ARGSUSED*/ #ifdef WA_VERBOSE -static boolean +staticfn boolean more_than_one(coordxy x, coordxy y, coordxy a, coordxy b, coordxy c) { if ((a && (b | c)) || (b && (a | c)) || (c && (a | b))) { @@ -3073,7 +3073,7 @@ more_than_one(coordxy x, coordxy y, coordxy a, coordxy b, coordxy c) #endif /* Return the wall mode for a T wall. */ -static int +staticfn int set_twall( #ifdef WA_VERBOSE coordxy x0, coordxy y0, /* used #if WA_VERBOSE */ @@ -3096,7 +3096,7 @@ set_twall( } /* Return wall mode for a horizontal or vertical wall. */ -static int +staticfn int set_wall(coordxy x, coordxy y, int horiz) { int wmode, is_1, is_2; @@ -3117,7 +3117,7 @@ set_wall(coordxy x, coordxy y, int horiz) } /* Return a wall mode for a corner wall. (x4,y4) is the "inner" position. */ -static int +staticfn int set_corn(coordxy x1, coordxy y1, coordxy x2, coordxy y2, coordxy x3, coordxy y3, coordxy x4, coordxy y4) { coordxy wmode, is_1, is_2, is_3, is_4; @@ -3145,7 +3145,7 @@ set_corn(coordxy x1, coordxy y1, coordxy x2, coordxy y2, coordxy x3, coordxy y3, } /* Return mode for a crosswall. */ -static int +staticfn int set_crosswall(coordxy x, coordxy y) { coordxy wmode, is_1, is_2, is_3, is_4; @@ -3274,7 +3274,7 @@ const seenV seenv_matrix[3][3] = { #define sign(z) ((z) < 0 ? -1 : ((z) != 0)) /* Set the seen vector of lev as if seen from (x0,y0) to (x,y). */ -static void +staticfn void set_seenv( struct rm *lev, coordxy x0, coordxy y0, /* from */ @@ -3358,7 +3358,7 @@ static const int cross_matrix[4][6] = { }; /* Print out a T wall warning and all interesting info. */ -static void +staticfn void t_warn(struct rm *lev) { static const char warn_str[] = "wall_angle: %s: case %d: seenv = 0x%x"; @@ -3418,7 +3418,7 @@ t_warn(struct rm *lev) * draw diagrams. See rm.h for more details on the wall modes and * seen vector (SV). */ -static int +staticfn int wall_angle(struct rm *lev) { unsigned int seenv = lev->seenv & 0xff; diff --git a/src/dlb.c b/src/dlb.c index cbcaa7bad..d6551fe06 100644 --- a/src/dlb.c +++ b/src/dlb.c @@ -59,20 +59,20 @@ extern unsigned FITSuint_(unsigned long long, const char *, int); */ #define MAX_LIBS 4 -static library dlb_libs[MAX_LIBS]; +staticfn library dlb_libs[MAX_LIBS]; -static boolean readlibdir(library * lp); -static boolean find_file(const char *name, library **lib, long *startp, +staticfn boolean readlibdir(library * lp); +staticfn boolean find_file(const char *name, library **lib, long *startp, long *sizep); -static boolean lib_dlb_init(void); -static void lib_dlb_cleanup(void); -static boolean lib_dlb_fopen(dlb *, const char *, const char *); -static int lib_dlb_fclose(dlb *); -static int lib_dlb_fread(char *, int, int, dlb *); -static int lib_dlb_fseek(dlb *, long, int); -static char *lib_dlb_fgets(char *, int, dlb *); -static int lib_dlb_fgetc(dlb *); -static long lib_dlb_ftell(dlb *); +staticfn boolean lib_dlb_init(void); +staticfn void lib_dlb_cleanup(void); +staticfn boolean lib_dlb_fopen(dlb *, const char *, const char *); +staticfn int lib_dlb_fclose(dlb *); +staticfn int lib_dlb_fread(char *, int, int, dlb *); +staticfn int lib_dlb_fseek(dlb *, long, int); +staticfn char *lib_dlb_fgets(char *, int, dlb *); +staticfn int lib_dlb_fgetc(dlb *); +staticfn long lib_dlb_ftell(dlb *); /* not static because shared with dlb_main.c */ boolean open_library(const char *lib_name, library *lp); @@ -123,7 +123,7 @@ extern char *eos(char *); * * Return TRUE on success, FALSE on failure. */ -static boolean +staticfn boolean readlibdir(library *lp) /* library pointer to fill in */ { int i; @@ -171,7 +171,7 @@ readlibdir(library *lp) /* library pointer to fill in */ * Look for the file in our directory structure. Return 1 if successful, * 0 if not found. Fill in the size and starting position. */ -static boolean +staticfn boolean find_file(const char *name, library **lib, long *startp, long *sizep) { int i, j; @@ -228,7 +228,7 @@ close_library(library *lp) * Open the library file once using stdio. Keep it open, but * keep track of the file position. */ -static boolean +staticfn boolean lib_dlb_init(void) { /* zero out array */ @@ -248,7 +248,7 @@ lib_dlb_init(void) return TRUE; } -static void +staticfn void lib_dlb_cleanup(void) { int i; @@ -269,7 +269,7 @@ build_dlb_filename(const char *lf) #endif /*ARGSUSED*/ -static boolean +staticfn boolean lib_dlb_fopen(dlb *dp, const char *name, const char *mode UNUSED) { long start, size; @@ -288,14 +288,14 @@ lib_dlb_fopen(dlb *dp, const char *name, const char *mode UNUSED) } /*ARGUSED*/ -static int +staticfn int lib_dlb_fclose(dlb *dp UNUSED) { /* nothing needs to be done */ return 0; } -static int +staticfn int lib_dlb_fread(char *buf, int size, int quan, dlb *dp) { long pos, nread, nbytes; @@ -320,7 +320,7 @@ lib_dlb_fread(char *buf, int size, int quan, dlb *dp) return (int) nread; } -static int +staticfn int lib_dlb_fseek(dlb *dp, long pos, int whence) { long curpos; @@ -345,7 +345,7 @@ lib_dlb_fseek(dlb *dp, long pos, int whence) return 0; } -static char * +staticfn char * lib_dlb_fgets(char *buf, int len, dlb *dp) { int i; @@ -377,7 +377,7 @@ lib_dlb_fgets(char *buf, int len, dlb *dp) return buf; } -static int +staticfn int lib_dlb_fgetc(dlb *dp) { char c; @@ -387,13 +387,13 @@ lib_dlb_fgetc(dlb *dp) return (int) c; } -static long +staticfn long lib_dlb_ftell(dlb *dp) { return dp->mark; } -const dlb_procs_t lib_dlb_procs = { lib_dlb_init, lib_dlb_cleanup, +static const dlb_procs_t lib_dlb_procs = { lib_dlb_init, lib_dlb_cleanup, lib_dlb_fopen, lib_dlb_fclose, lib_dlb_fread, lib_dlb_fseek, lib_dlb_fgets, lib_dlb_fgetc, @@ -402,7 +402,7 @@ const dlb_procs_t lib_dlb_procs = { lib_dlb_init, lib_dlb_cleanup, #endif /* DLBLIB */ #ifdef DLBRSRC -const dlb_procs_t rsrc_dlb_procs = { rsrc_dlb_init, rsrc_dlb_cleanup, +static const dlb_procs_t rsrc_dlb_procs = { rsrc_dlb_init, rsrc_dlb_cleanup, rsrc_dlb_fopen, rsrc_dlb_fclose, rsrc_dlb_fread, rsrc_dlb_fseek, rsrc_dlb_fgets, rsrc_dlb_fgetc, diff --git a/src/do.c b/src/do.c index 9719d7f68..cc0435558 100644 --- a/src/do.c +++ b/src/do.c @@ -7,19 +7,19 @@ #include "hack.h" -static boolean teleport_sink(void); -static void dosinkring(struct obj *); -static int drop(struct obj *); -static int menudrop_split(struct obj *, long); -static boolean engulfer_digests_food(struct obj *); -static boolean danger_uprops(void); -static int wipeoff(void); -static int menu_drop(int); -static boolean u_stuck_cannot_go(const char *); -static NHFILE *currentlevel_rewrite(void); -static void familiar_level_msg(void); -static void final_level(void); -static void temperature_change_msg(schar); +staticfn boolean teleport_sink(void); +staticfn void dosinkring(struct obj *); +staticfn int drop(struct obj *); +staticfn int menudrop_split(struct obj *, long); +staticfn boolean engulfer_digests_food(struct obj *); +staticfn boolean danger_uprops(void); +staticfn int wipeoff(void); +staticfn int menu_drop(int); +staticfn boolean u_stuck_cannot_go(const char *); +staticfn NHFILE *currentlevel_rewrite(void); +staticfn void familiar_level_msg(void); +staticfn void final_level(void); +staticfn void temperature_change_msg(schar); /* static boolean badspot(coordxy,coordxy); */ @@ -447,7 +447,7 @@ polymorph_sink(void) /* Teleports the sink at the player's position; return True if sink teleported. */ -static boolean +staticfn boolean teleport_sink(void) { coordxy cx, cy; @@ -485,7 +485,7 @@ teleport_sink(void) } /* obj is a ring being dropped over a kitchen sink */ -static void +staticfn void dosinkring(struct obj *obj) { struct obj *otmp, *otmp2; @@ -701,7 +701,7 @@ canletgo(struct obj *obj, const char *word) return TRUE; } -static int +staticfn int drop(struct obj *obj) { if (!obj) @@ -834,7 +834,7 @@ dropz(struct obj *obj, boolean with_impact) /* when swallowed, move dropped object from OBJ_FREE to u.ustuck's inventory; for purple worm, immediately eat any corpse, glob, or special meat item from object polymorph; return True if object is used up, False otherwise */ -static boolean +staticfn boolean engulfer_digests_food(struct obj *obj) { /* animal swallower (purple worn) eats any @@ -932,7 +932,7 @@ doddrop(void) return result; } -static int /* check callers */ +staticfn int /* check callers */ menudrop_split(struct obj *otmp, long cnt) { if (cnt && cnt < otmp->quan) { @@ -949,7 +949,7 @@ menudrop_split(struct obj *otmp, long cnt) } /* Drop things from the hero's inventory, using a menu. */ -static int +staticfn int menu_drop(int retry) { int n, i, n_dropped = 0; @@ -1078,7 +1078,7 @@ menu_drop(int retry) return (n_dropped ? ECMD_TIME : ECMD_OK); } -static boolean +staticfn boolean u_stuck_cannot_go(const char *updn) { if (u.ustuck) { @@ -1315,7 +1315,7 @@ doup(void) } /* check that we can write out the current level */ -static NHFILE * +staticfn NHFILE * currentlevel_rewrite(void) { NHFILE *nhfp; @@ -1415,7 +1415,7 @@ u_collide_m(struct monst *mtmp) } } -static void +staticfn void familiar_level_msg(void) { static const char *const fam_msgs[4] = { @@ -1969,7 +1969,7 @@ hellish_smoke_mesg(void) } /* give a message when the level temperature is different from previous */ -static void +staticfn void temperature_change_msg(schar prev_temperature) { if (prev_temperature != gl.level.flags.temperature) { @@ -1995,7 +1995,7 @@ maybe_lvltport_feedback(void) } } -static void +staticfn void final_level(void) { /* reset monster hostility relative to player */ @@ -2266,7 +2266,7 @@ zombify_mon(anything *arg, long timeout) } /* return TRUE if hero properties are dangerous to hero */ -static boolean +staticfn boolean danger_uprops(void) { return (Stoned || Slimed || Strangled || Sick); @@ -2308,7 +2308,7 @@ donull(void) return ECMD_TIME; /* Do nothing, but let other things happen */ } -static int +staticfn int wipeoff(void) { unsigned udelta = u.ucreamed; diff --git a/src/do_name.c b/src/do_name.c index 6a3eed42d..c58f5a73a 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -5,18 +5,18 @@ #include "hack.h" -static char *nextmbuf(void); -static char *name_from_player(char *, const char *, const char *); -static void do_mgivenname(void); -static boolean alreadynamed(struct monst *, char *, char *) NONNULLPTRS; -static void do_oname(struct obj *) NONNULLARG1; -static char *docall_xname(struct obj *) NONNULLARG1; -static void namefloorobj(void); +staticfn char *nextmbuf(void); +staticfn char *name_from_player(char *, const char *, const char *); +staticfn void do_mgivenname(void); +staticfn boolean alreadynamed(struct monst *, char *, char *) NONNULLPTRS; +staticfn void do_oname(struct obj *) NONNULLARG1; +staticfn char *docall_xname(struct obj *) NONNULLARG1; +staticfn void namefloorobj(void); #define NUMMBUF 5 /* manage a pool of BUFSZ buffers, so callers don't have to */ -static char * +staticfn char * nextmbuf(void) { static char NEARDATA bufs[NUMMBUF][BUFSZ]; @@ -101,7 +101,7 @@ safe_oname(struct obj *obj) /* get a name for a monster or an object from player; truncate if longer than PL_PSIZ, then return it */ -static char * +staticfn char * name_from_player( char *outbuf, /* output buffer, assumed to be at least BUFSZ long; * anything longer than PL_PSIZ will be truncated */ @@ -154,7 +154,7 @@ christen_monst(struct monst *mtmp, const char *name) /* check whether user-supplied name matches or nearly matches an unnameable monster's name, or is an attempt to delete the monster's name; if so, give alternate reject message for do_mgivenname() */ -static boolean +staticfn boolean alreadynamed(struct monst *mtmp, char *monnambuf, char *usrbuf) { char pronounbuf[10], *p; @@ -195,7 +195,7 @@ alreadynamed(struct monst *mtmp, char *monnambuf, char *usrbuf) } /* allow player to assign a name to some chosen monster */ -static void +staticfn void do_mgivenname(void) { char buf[BUFSZ], monnambuf[BUFSZ], qbuf[QBUFSZ]; @@ -286,7 +286,7 @@ do_mgivenname(void) * used with extreme care. Applying a name to an object no longer * allocates a replacement object, so that old risk is gone. */ -static void +staticfn void do_oname(struct obj *obj) { char *bufp, buf[BUFSZ], bufcpy[BUFSZ], qbuf[QBUFSZ]; @@ -600,7 +600,7 @@ docallcmd(void) } /* for use by safe_qbuf() */ -static char * +staticfn char * docall_xname(struct obj *obj) { struct obj otemp; @@ -672,7 +672,7 @@ docall(struct obj *obj) } } -static void +staticfn void namefloorobj(void) { coord cc; @@ -1318,7 +1318,8 @@ obj_pmname(struct obj *obj) /* used by bogusmon(next) and also by init_CapMons(rumors.c); bogon_is_pname(below) checks a hard-coded subset of these rather than - use this list */ + use this list. + Also used in rumors.c */ const char bogon_codes[] = "-_+|="; /* see dat/bonusmon.txt */ /* fake monsters used to be in a hard-coded array, now in a data file */ diff --git a/src/do_wear.c b/src/do_wear.c index e2fa3b813..724aaf043 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -20,37 +20,37 @@ static NEARDATA const long takeoff_order[] = { WORN_SHIRT, WORN_BOOTS, W_SWAPWEP, W_QUIVER, 0L }; -static void on_msg(struct obj *); -static void toggle_stealth(struct obj *, long, boolean); -static int Armor_on(void); +staticfn void on_msg(struct obj *); +staticfn void toggle_stealth(struct obj *, long, boolean); +staticfn int Armor_on(void); /* int Boots_on(void); -- moved to extern.h */ -static int Cloak_on(void); -static int Helmet_on(void); -static int Gloves_on(void); -static int Shield_on(void); -static int Shirt_on(void); -static void dragon_armor_handling(struct obj *, boolean, boolean); -static void Amulet_on(void); -static void learnring(struct obj *, boolean); -static void adjust_attrib(struct obj *, int, int); -static void Ring_off_or_gone(struct obj *, boolean); -static int select_off(struct obj *); -static struct obj *do_takeoff(void); -static int take_off(void); -static int menu_remarm(int); -static void wornarm_destroyed(struct obj *); -static void count_worn_stuff(struct obj **, boolean); -static int armor_or_accessory_off(struct obj *); -static int accessory_or_armor_on(struct obj *); -static void already_wearing(const char *); -static void already_wearing2(const char *, const char *); -static int equip_ok(struct obj *, boolean, boolean); -static int puton_ok(struct obj *); -static int remove_ok(struct obj *); -static int wear_ok(struct obj *); -static int takeoff_ok(struct obj *); +staticfn int Cloak_on(void); +staticfn int Helmet_on(void); +staticfn int Gloves_on(void); +staticfn int Shield_on(void); +staticfn int Shirt_on(void); +staticfn void dragon_armor_handling(struct obj *, boolean, boolean); +staticfn void Amulet_on(void); +staticfn void learnring(struct obj *, boolean); +staticfn void adjust_attrib(struct obj *, int, int); +staticfn void Ring_off_or_gone(struct obj *, boolean); +staticfn int select_off(struct obj *); +staticfn struct obj *do_takeoff(void); +staticfn int take_off(void); +staticfn int menu_remarm(int); +staticfn void wornarm_destroyed(struct obj *); +staticfn void count_worn_stuff(struct obj **, boolean); +staticfn int armor_or_accessory_off(struct obj *); +staticfn int accessory_or_armor_on(struct obj *); +staticfn void already_wearing(const char *); +staticfn void already_wearing2(const char *, const char *); +staticfn int equip_ok(struct obj *, boolean, boolean); +staticfn int puton_ok(struct obj *); +staticfn int remove_ok(struct obj *); +staticfn int wear_ok(struct obj *); +staticfn int takeoff_ok(struct obj *); /* maybe_destroy_armor() may return NULL */ -static struct obj *maybe_destroy_armor(struct obj *, struct obj *, +staticfn struct obj *maybe_destroy_armor(struct obj *, struct obj *, boolean *) NONNULLARG3; /* plural "fingers" or optionally "gloves" */ @@ -70,7 +70,7 @@ off_msg(struct obj *otmp) } /* for items that involve no delay */ -static void +staticfn void on_msg(struct obj *otmp) { if (flags.verbose) { @@ -91,7 +91,7 @@ on_msg(struct obj *otmp) give feedback and discover it iff stealth state is changing; stealth is blocked by riding unless hero+steed fly (handled with BStealth by mount and dismount routines) */ -static +staticfn void toggle_stealth( struct obj *obj, @@ -297,7 +297,7 @@ Boots_off(void) return 0; } -static int +staticfn int Cloak_on(void) { long oldprop = @@ -405,7 +405,7 @@ Cloak_off(void) return 0; } -static int +staticfn int Helmet_on(void) { switch (uarmh->otyp) { @@ -540,7 +540,7 @@ hard_helmet(struct obj *obj) return (is_metallic(obj) || is_crackable(obj)) ? TRUE : FALSE; } -static int +staticfn int Gloves_on(void) { long oldprop = @@ -669,7 +669,7 @@ Gloves_off(void) return 0; } -static int +staticfn int Shield_on(void) { /* no shield currently requires special handling when put on, but we @@ -719,7 +719,7 @@ Shield_off(void) return 0; } -static int +staticfn int Shirt_on(void) { /* no shirt currently requires special handling when put on, but we @@ -758,7 +758,7 @@ Shirt_off(void) } /* handle extra abilities for hero wearing dragon scale armor */ -static void +staticfn void dragon_armor_handling( struct obj *otmp, /* armor being put on or taken off */ boolean puton, /* True: on, False: off */ @@ -847,7 +847,7 @@ dragon_armor_handling( } } -static int +staticfn int Armor_on(void) { if (!uarm) /* no known instances of !uarm here but play it safe */ @@ -923,7 +923,7 @@ Armor_gone(void) return 0; } -static void +staticfn void Amulet_on(void) { /* make sure amulet isn't wielded; can't use remove_worn_item() @@ -1094,7 +1094,7 @@ Amulet_off(void) } /* handle ring discovery; comparable to learnwand() */ -static void +staticfn void learnring(struct obj *ring, boolean observed) { int ringtype = ring->otyp; @@ -1124,7 +1124,7 @@ learnring(struct obj *ring, boolean observed) } } -static void +staticfn void adjust_attrib(struct obj *obj, int which, int val) { int old_attrib; @@ -1246,7 +1246,7 @@ Ring_on(struct obj *obj) } } -static void +staticfn void Ring_off_or_gone(struct obj *obj, boolean gone) { long mask = (obj->owornmask & W_RING); @@ -1632,7 +1632,7 @@ stop_donning(struct obj *stolenobj) /* no message if stolenobj is already static NEARDATA int Narmorpieces, Naccessories; /* assign values to Narmorpieces and Naccessories */ -static void +staticfn void count_worn_stuff(struct obj **which, /* caller wants this when count is 1 */ boolean accessorizing) { @@ -1669,7 +1669,7 @@ count_worn_stuff(struct obj **which, /* caller wants this when count is 1 */ /* take off one piece or armor or one accessory; shared by dotakeoff('T') and doremring('R') */ -static int +staticfn int armor_or_accessory_off(struct obj *obj) { if (!(obj->owornmask & (W_ARMOR | W_ACCESSORY))) { @@ -1893,13 +1893,13 @@ armoroff(struct obj *otmp) return 1; } -static void +staticfn void already_wearing(const char *cc) { You("are already wearing %s%c", cc, (cc == c_that_) ? '!' : '.'); } -static void +staticfn void already_wearing2(const char *cc1, const char *cc2) { You_cant("wear %s because you're wearing %s there already.", cc1, cc2); @@ -2091,7 +2091,7 @@ canwearobj(struct obj *otmp, long *mask, boolean noisy) return !err; } -static int +staticfn int accessory_or_armor_on(struct obj *obj) { long mask = 0L; @@ -2575,7 +2575,7 @@ unchanger(void) return 0; } -static +staticfn int select_off(struct obj *otmp) { @@ -2702,7 +2702,7 @@ select_off(struct obj *otmp) return 0; } -static struct obj * +staticfn struct obj * do_takeoff(void) { struct obj *otmp = (struct obj *) 0; @@ -2778,7 +2778,7 @@ do_takeoff(void) } /* occupation callback for 'A' */ -static int +staticfn int take_off(void) { int i; @@ -2945,7 +2945,7 @@ remarm_swapwep(void) return (!uswapwep || uswapwep->bknown != oldbknown) ? ECMD_TIME : ECMD_OK; } -static int +staticfn int menu_remarm(int retry) { int n, i = 0; @@ -2999,7 +2999,7 @@ menu_remarm(int retry) /* take off the specific worn object and if it still exists after that, destroy it (taking off the item might already destroy it by dunking hero into lava) */ -static void +staticfn void wornarm_destroyed(struct obj *wornarm) { struct obj *invobj; @@ -3042,7 +3042,7 @@ wornarm_destroyed(struct obj *wornarm) * returns impacted armor with its in_use bit set, * or Null. *resisted is updated to reflect whether * it resisted or not */ -static struct obj * +staticfn struct obj * maybe_destroy_armor(struct obj *armor, struct obj *atmp, boolean *resisted) { if ((armor != 0) && (!atmp || atmp == armor) @@ -3195,7 +3195,7 @@ inaccessible_equipment(struct obj *obj, } /* not a getobj callback - unifies code among the other 4 getobj callbacks */ -static int +staticfn int equip_ok(struct obj *obj, boolean removing, boolean accessory) { boolean is_worn; @@ -3240,28 +3240,28 @@ equip_ok(struct obj *obj, boolean removing, boolean accessory) } /* getobj callback for P command */ -static int +staticfn int puton_ok(struct obj *obj) { return equip_ok(obj, FALSE, TRUE); } /* getobj callback for R command */ -static int +staticfn int remove_ok(struct obj *obj) { return equip_ok(obj, TRUE, TRUE); } /* getobj callback for W command */ -static int +staticfn int wear_ok(struct obj *obj) { return equip_ok(obj, FALSE, FALSE); } /* getobj callback for T command */ -static int +staticfn int takeoff_ok(struct obj *obj) { return equip_ok(obj, TRUE, FALSE); diff --git a/src/dog.c b/src/dog.c index 7e776e36c..fd22e3dda 100644 --- a/src/dog.c +++ b/src/dog.c @@ -5,11 +5,11 @@ #include "hack.h" -static int pet_type(void); -static struct permonst * pick_familiar_pm(struct obj *, boolean); -static void set_mon_lastmove(struct monst *); -static int mon_leave(struct monst *) NONNULLARG1; -static boolean keep_mon_accessible(struct monst *); +staticfn int pet_type(void); +staticfn struct permonst * pick_familiar_pm(struct obj *, boolean); +staticfn void set_mon_lastmove(struct monst *); +staticfn int mon_leave(struct monst *) NONNULLARG1; +staticfn boolean keep_mon_accessible(struct monst *); enum arrival { Before_you = 0, /* monsters kept on migrating_mons for accessibility; @@ -63,7 +63,7 @@ initedog(struct monst *mtmp) u.uconduct.pets++; } -static int +staticfn int pet_type(void) { if (gu.urole.petnum != NON_PM) @@ -76,7 +76,7 @@ pet_type(void) return rn2(2) ? PM_KITTEN : PM_LITTLE_DOG; } -static struct permonst * +staticfn struct permonst * pick_familiar_pm(struct obj *otmp, boolean quietly) { struct permonst *pm = (struct permonst *) 0; @@ -235,7 +235,7 @@ makedog(void) return mtmp; } -static void +staticfn void set_mon_lastmove(struct monst *mtmp) { mtmp->mlstmv = gm.moves; @@ -667,7 +667,7 @@ mon_catchup_elapsed_time( /* bookkeeping when mtmp is about to leave the current level; common to keepdogs() and migrate_to_level() */ -static int +staticfn int mon_leave(struct monst *mtmp) { struct obj *obj; @@ -706,7 +706,7 @@ mon_leave(struct monst *mtmp) /* when hero leaves a level, some monsters should be placed on the migrating_mons list instead of being stashed inside the level's file */ -static boolean +staticfn boolean keep_mon_accessible(struct monst *mon) { /* the Wizard is kept accessible so that his harassment can fetch diff --git a/src/dogmove.c b/src/dogmove.c index 22ba0976c..3a575830c 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -11,15 +11,15 @@ #define DOG_WEAK 500 #define DOG_STARVE 750 -static void dog_starve(struct monst *); -static boolean dog_hunger(struct monst *, struct edog *); -static int dog_invent(struct monst *, struct edog *, int); -static int dog_goal(struct monst *, struct edog *, int, int, int); -static struct monst *find_targ(struct monst *, int, int, int); -static int find_friends(struct monst *, struct monst *, int); -static struct monst *best_target(struct monst *); -static long score_targ(struct monst *, struct monst *); -static boolean can_reach_location(struct monst *, coordxy, coordxy, coordxy, +staticfn void dog_starve(struct monst *); +staticfn boolean dog_hunger(struct monst *, struct edog *); +staticfn int dog_invent(struct monst *, struct edog *, int); +staticfn int dog_goal(struct monst *, struct edog *, int, int, int); +staticfn struct monst *find_targ(struct monst *, int, int, int); +staticfn int find_friends(struct monst *, struct monst *, int); +staticfn struct monst *best_target(struct monst *); +staticfn long score_targ(struct monst *, struct monst *); +staticfn boolean can_reach_location(struct monst *, coordxy, coordxy, coordxy, coordxy) NONNULLARG1; /* pick a carried item for pet to drop */ @@ -135,7 +135,7 @@ static NEARDATA const char nofetch[] = { BALL_CLASS, CHAIN_CLASS, ROCK_CLASS, 0 }; -static void wantdoor(coordxy, coordxy, genericptr_t); +staticfn void wantdoor(coordxy, coordxy, genericptr_t); boolean cursed_object_at(coordxy x, coordxy y) @@ -325,7 +325,7 @@ dog_eat(struct monst *mtmp, return (DEADMONSTER(mtmp)) ? 2 : 1; } -static void +staticfn void dog_starve(struct monst *mtmp) { if (mtmp->mleashed && mtmp != u.usteed) @@ -339,7 +339,7 @@ dog_starve(struct monst *mtmp) } /* hunger effects -- returns TRUE on starvation */ -static boolean +staticfn boolean dog_hunger(struct monst *mtmp, struct edog *edog) { if (gm.moves > edog->hungrytime + DOG_WEAK) { @@ -377,7 +377,7 @@ dog_hunger(struct monst *mtmp, struct edog *edog) /* do something with object (drop, pick up, eat) at current position * returns 1 if object eaten (since that counts as dog's move), 2 if died */ -static int +staticfn int dog_invent(struct monst *mtmp, struct edog *edog, int udist) { coordxy omx, omy; @@ -459,7 +459,7 @@ dog_invent(struct monst *mtmp, struct edog *edog, int udist) /* set dog's goal -- gtyp, gx, gy; returns -1/0/1 (dog's desire to approach player) or -2 (abort move) */ -static int +staticfn int dog_goal( struct monst *mtmp, struct edog *edog, @@ -626,7 +626,7 @@ dog_goal( #undef FARAWAY } -static struct monst * +staticfn struct monst * find_targ( struct monst *mtmp, int dx, int dy, @@ -670,7 +670,7 @@ find_targ( return targ; } -static int +staticfn int find_friends(struct monst *mtmp, struct monst *mtarg, int maxdist) { struct monst *pal; @@ -714,7 +714,7 @@ find_friends(struct monst *mtmp, struct monst *mtarg, int maxdist) return 0; } -static long +staticfn long score_targ(struct monst *mtmp, struct monst *mtarg) { long score = 0L; @@ -814,7 +814,7 @@ score_targ(struct monst *mtmp, struct monst *mtarg) return score; } -static struct monst * +staticfn struct monst * best_target(struct monst *mtmp) /* Pet */ { int dx, dy; @@ -1331,7 +1331,7 @@ could_reach_item(struct monst *mon, coordxy nx, coordxy ny) * Since the maximum food distance is 5, this should never be more than 5 * calls deep. */ -static boolean +staticfn boolean can_reach_location(struct monst *mon, coordxy mx, coordxy my, coordxy fx, coordxy fy) { int i, j; @@ -1367,7 +1367,7 @@ can_reach_location(struct monst *mon, coordxy mx, coordxy my, coordxy fx, coordx } /* do_clear_area client */ -static void +staticfn void wantdoor(coordxy x, coordxy y, genericptr_t distance) { int ndist, *dist_ptr = (int *) distance; diff --git a/src/dokick.c b/src/dokick.c index e7f012eba..9c8ba1249 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -11,26 +11,26 @@ /* gk.kickedobj (decl.c) tracks a kicked object until placed or destroyed */ -static void kickdmg(struct monst *, boolean); -static boolean maybe_kick_monster(struct monst *, coordxy, coordxy); -static void kick_monster(struct monst *, coordxy, coordxy); -static int kick_object(coordxy, coordxy, char *) NONNULLARG3; -static int really_kick_object(coordxy, coordxy); -static char *kickstr(char *, const char *) NONNULLPTRS; -static boolean watchman_thief_arrest(struct monst *) NONNULLPTRS; -static boolean watchman_door_damage(struct monst *, +staticfn void kickdmg(struct monst *, boolean); +staticfn boolean maybe_kick_monster(struct monst *, coordxy, coordxy); +staticfn void kick_monster(struct monst *, coordxy, coordxy); +staticfn int kick_object(coordxy, coordxy, char *) NONNULLARG3; +staticfn int really_kick_object(coordxy, coordxy); +staticfn char *kickstr(char *, const char *) NONNULLPTRS; +staticfn boolean watchman_thief_arrest(struct monst *) NONNULLPTRS; +staticfn boolean watchman_door_damage(struct monst *, coordxy, coordxy) NONNULLARG1; -static void kick_dumb(coordxy, coordxy); -static void kick_ouch(coordxy, coordxy, const char *) NONNULLARG3; -static void kick_door(coordxy, coordxy, int); -static int kick_nondoor(coordxy, coordxy, int); -static void otransit_msg(struct obj *, boolean, boolean, long); -static void drop_to(coord *, schar, coordxy, coordxy) NONNULLARG1; +staticfn void kick_dumb(coordxy, coordxy); +staticfn void kick_ouch(coordxy, coordxy, const char *) NONNULLARG3; +staticfn void kick_door(coordxy, coordxy, int); +staticfn int kick_nondoor(coordxy, coordxy, int); +staticfn void otransit_msg(struct obj *, boolean, boolean, long); +staticfn void drop_to(coord *, schar, coordxy, coordxy) NONNULLARG1; static const char kick_passes_thru[] = "kick passes harmlessly through"; /* kicking damage when not poly'd into a form with a kick attack */ -static void +staticfn void kickdmg(struct monst *mon, boolean clumsy) { int mdx, mdy; @@ -122,7 +122,7 @@ kickdmg(struct monst *mon, boolean clumsy) use_skill(kick_skill, 1); } -static boolean +staticfn boolean maybe_kick_monster(struct monst *mon, coordxy x, coordxy y) { if (mon) { @@ -142,7 +142,7 @@ maybe_kick_monster(struct monst *mon, coordxy x, coordxy y) return (boolean) (mon != 0); } -static void +staticfn void kick_monster(struct monst *mon, coordxy x, coordxy y) { boolean clumsy = FALSE; @@ -480,7 +480,7 @@ container_impact_dmg( } /* jacket around really_kick_object */ -static int +staticfn int kick_object(coordxy x, coordxy y, char *kickobjnam) { int res = 0; @@ -498,7 +498,7 @@ kick_object(coordxy x, coordxy y, char *kickobjnam) } /* guts of kick_object */ -static int +staticfn int really_kick_object(coordxy x, coordxy y) { int range; @@ -783,7 +783,7 @@ really_kick_object(coordxy x, coordxy y) } /* cause of death if kicking kills kicker */ -static char * +staticfn char * kickstr(char *buf, const char *kickobjnam) { const char *what; @@ -823,7 +823,7 @@ kickstr(char *buf, const char *kickobjnam) return strcat(strcpy(buf, "kicking "), what); } -static boolean +staticfn boolean watchman_thief_arrest(struct monst *mtmp) { if (is_watch(mtmp->data) && couldsee(mtmp->mx, mtmp->my) @@ -835,7 +835,7 @@ watchman_thief_arrest(struct monst *mtmp) return FALSE; } -static boolean +staticfn boolean watchman_door_damage(struct monst *mtmp, coordxy x, coordxy y) { if (is_watch(mtmp->data) && mtmp->mpeaceful @@ -853,7 +853,7 @@ watchman_door_damage(struct monst *mtmp, coordxy x, coordxy y) return FALSE; } -static void +staticfn void kick_dumb(coordxy x, coordxy y) { exercise(A_DEX, FALSE); @@ -870,7 +870,7 @@ kick_dumb(coordxy x, coordxy y) hurtle(-u.dx, -u.dy, 1, TRUE); } -static void +staticfn void kick_ouch(coordxy x, coordxy y, const char *kickobjnam) { int dmg; @@ -899,7 +899,7 @@ kick_ouch(coordxy x, coordxy y, const char *kickobjnam) } /* kick a door */ -static void +staticfn void kick_door(coordxy x, coordxy y, int avrg_attrib) { if (gm.maploc->doormask == D_ISOPEN || gm.maploc->doormask == D_BROKEN @@ -958,7 +958,7 @@ kick_door(coordxy x, coordxy y, int avrg_attrib) } /* kick non-door terrain */ -static int +staticfn int kick_nondoor(coordxy x, coordxy y, int avrg_attrib) { if (gm.maploc->typ == SDOOR) { @@ -1455,7 +1455,7 @@ dokick(void) return ECMD_TIME; } -static void +staticfn void drop_to(coord *cc, schar loc, coordxy x, coordxy y) { stairway *stway = stairway_at(x, y); @@ -1889,7 +1889,7 @@ deliver_obj_to_mon(struct monst *mtmp, int cnt, unsigned long deliverflags) } } -static void +staticfn void otransit_msg(struct obj *otmp, boolean nodrop, boolean chainthere, long num) { char *optr = 0, obuf[BUFSZ], xbuf[BUFSZ]; diff --git a/src/dothrow.c b/src/dothrow.c index 4fe668e96..0b7b52b70 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -7,21 +7,21 @@ #include "hack.h" -static int throw_obj(struct obj *, int); -static boolean ok_to_throw(int *); -static int throw_ok(struct obj *); -static void autoquiver(void); -static struct obj *find_launcher(struct obj *); -static int gem_accept(struct monst *, struct obj *); -static boolean toss_up(struct obj *, boolean) NONNULLARG1; -static void sho_obj_return_to_u(struct obj * obj); -static struct obj *return_throw_to_inv(struct obj *, long, boolean, +staticfn int throw_obj(struct obj *, int); +staticfn boolean ok_to_throw(int *); +staticfn int throw_ok(struct obj *); +staticfn void autoquiver(void); +staticfn struct obj *find_launcher(struct obj *); +staticfn int gem_accept(struct monst *, struct obj *); +staticfn boolean toss_up(struct obj *, boolean) NONNULLARG1; +staticfn void sho_obj_return_to_u(struct obj * obj); +staticfn struct obj *return_throw_to_inv(struct obj *, long, boolean, struct obj *); -static void tmiss(struct obj *, struct monst *, boolean); -static int throw_gold(struct obj *); -static void check_shop_obj(struct obj *, coordxy, coordxy, boolean); -static void breakmsg(struct obj *, boolean); -static boolean mhurtle_step(genericptr_t, coordxy, coordxy); +staticfn void tmiss(struct obj *, struct monst *, boolean); +staticfn int throw_gold(struct obj *); +staticfn void check_shop_obj(struct obj *, coordxy, coordxy, boolean); +staticfn void breakmsg(struct obj *, boolean); +staticfn boolean mhurtle_step(genericptr_t, coordxy, coordxy); /* uwep might already be removed from inventory so test for W_WEP instead; for Valk+Mjollnir, caller needs to validate the strength requirement */ @@ -80,7 +80,7 @@ multishot_class_bonus( } /* Throw the selected object, asking for direction */ -static int +staticfn int throw_obj(struct obj *obj, int shotlimit) { struct obj *otmp, *oldslot; @@ -287,7 +287,7 @@ throw_obj(struct obj *obj, int shotlimit) } /* common to dothrow() and dofire() */ -static boolean +staticfn boolean ok_to_throw(int *shotlimit_p) /* (see dothrow()) */ { *shotlimit_p = LIMIT_TO_RANGE_INT(0, LARGEST_INT, gc.command_count); @@ -307,7 +307,7 @@ ok_to_throw(int *shotlimit_p) /* (see dothrow()) */ } /* getobj callback for object to be thrown */ -static int +staticfn int throw_ok(struct obj *obj) { if (!obj) @@ -371,7 +371,7 @@ dothrow(void) /* KMH -- Automatically fill quiver */ /* Suggested by Jeffrey Bay */ -static void +staticfn void autoquiver(void) { struct obj *otmp, *oammo = 0, *omissile = 0, *omisc = 0, *altammo = 0; @@ -437,7 +437,7 @@ autoquiver(void) /* look through hero inventory for launcher matching ammo, avoiding known cursed items. Returns NULL if no match. */ -static struct obj * +staticfn struct obj * find_launcher(struct obj *ammo) { struct obj *otmp, *oX; @@ -992,7 +992,7 @@ will_hurtle(struct monst *mon, coordxy x, coordxy y) return goodpos(x, y, mon, MM_IGNOREWATER | MM_IGNORELAVA); } -static boolean +staticfn boolean mhurtle_step(genericptr_t arg, coordxy x, coordxy y) { struct monst *mon = (struct monst *) arg; @@ -1180,7 +1180,7 @@ mhurtle(struct monst *mon, int dx, int dy, int range) return; } -static void +staticfn void check_shop_obj(struct obj *obj, coordxy x, coordxy y, boolean broken) { boolean costly_xy; @@ -1255,7 +1255,7 @@ harmless_missile(struct obj *obj) * * Returns FALSE if the object is gone. */ -static boolean +staticfn boolean toss_up(struct obj *obj, boolean hitsroof) { const char *action; @@ -1432,7 +1432,7 @@ throwing_weapon(struct obj *obj) } /* the currently thrown object is returning to you (not for boomerangs) */ -static void +staticfn void sho_obj_return_to_u(struct obj *obj) { /* might already be our location (bounced off a wall) */ @@ -1807,7 +1807,7 @@ throwit(struct obj *obj, /* handle a throw-and-return missile coming back into inventory; makes sure that if it was wielded, it will be re-wielded; if it was split off of a stack (boomerang), don't let it merge with a different compatible stack */ -static struct obj * +staticfn struct obj * return_throw_to_inv( struct obj *obj, /* object to add to invent */ long wep_mask, /* its owornmask before it was removed from invent */ @@ -1903,7 +1903,7 @@ omon_adj(struct monst *mon, struct obj *obj, boolean mon_notices) } /* thrown object misses target monster */ -static void +staticfn void tmiss(struct obj *obj, struct monst *mon, boolean maybe_wakeup) { const char *missile = mshot_xname(obj); @@ -2259,7 +2259,7 @@ thitmonst( #undef special_obj_hits_leader -static int +staticfn int gem_accept(struct monst *mon, struct obj *obj) { static NEARDATA const char @@ -2557,7 +2557,7 @@ breaktest(struct obj *obj) } } -static void +staticfn void breakmsg(struct obj *obj, boolean in_view) { const char *to_pieces; @@ -2599,7 +2599,7 @@ breakmsg(struct obj *obj, boolean in_view) } } -static int +staticfn int throw_gold(struct obj *obj) { int range, odx, ody; diff --git a/src/drawing.c b/src/drawing.c index 83dff55c5..7881e1f8e 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -9,6 +9,11 @@ #include "wintype.h" #include "sym.h" +extern const struct symparse loadsyms[]; +extern const struct class_sym def_oc_syms[MAXOCLASSES]; +extern const struct class_sym def_monsyms[MAXMCLASSES]; +extern const uchar def_r_oc_syms[MAXOCLASSES]; + /* Relevant header information in rm.h, objclass.h, sym.h, defsym.h. */ /* Default object class symbols. See objclass.h. diff --git a/src/dungeon.c b/src/dungeon.c index abf6fa149..86b8fb4a2 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -33,55 +33,56 @@ struct lchoice { }; #if 0 -static void Fread(genericptr_t, int, int, dlb *); +staticfn void Fread(genericptr_t, int, int, dlb *); #endif -static xint16 dname_to_dnum(const char *); -static int find_branch(const char *, struct proto_dungeon *); -static xint16 parent_dnum(const char *, struct proto_dungeon *); -static int level_range(xint16, int, int, int, struct proto_dungeon *, int *); -static xint16 parent_dlevel(const char *, struct proto_dungeon *); -static int correct_branch_type(struct tmpbranch *); -static branch *add_branch(int, int, struct proto_dungeon *); -static void add_level(s_level *); -static void init_level(int, int, struct proto_dungeon *); -static int possible_places(int, boolean *, struct proto_dungeon *); -static xint16 pick_level(boolean *, int); -static boolean place_level(int, struct proto_dungeon *); -static int get_dgn_flags(lua_State *); -static int get_dgn_align(lua_State *); -static void init_dungeon_levels(lua_State *, struct proto_dungeon *, int); -static void init_dungeon_branches(lua_State *, struct proto_dungeon *, int); -static void init_dungeon_set_entry(struct proto_dungeon *, int); -static void init_dungeon_set_depth(struct proto_dungeon *, int); -static void init_castle_tune(void); -static void fixup_level_locations(void); -static void free_proto_dungeon(struct proto_dungeon *); -static boolean init_dungeon_dungeons(lua_State *, struct proto_dungeon *, int); -static boolean unplaced_floater(struct dungeon *); -static boolean unreachable_level(d_level *, boolean); -static void tport_menu(winid, char *, struct lchoice *, d_level *, boolean); -static const char *br_string(int); -static char chr_u_on_lvl(d_level *); -static void print_branch(winid, int, int, int, boolean, struct lchoice *); -static char *get_annotation(d_level *); -static void query_annotation(d_level *); -static mapseen *load_mapseen(NHFILE *); -static void save_mapseen(NHFILE *, mapseen *); -static mapseen *find_mapseen(d_level *); -static mapseen *find_mapseen_by_str(const char *); -static void print_mapseen(winid, mapseen *, int, int, boolean); -static boolean interest_mapseen(mapseen *); -static void count_feat_lastseentyp(mapseen *, coordxy, coordxy); -static void traverse_mapseenchn(int, winid, int, int, int *); -static const char *seen_string(xint16, const char *); -static const char *br_string2(branch *); -static const char *shop_string(int); -static char *tunesuffix(mapseen *, char *, size_t); +staticfn xint16 dname_to_dnum(const char *); +staticfn int find_branch(const char *, struct proto_dungeon *); +staticfn xint16 parent_dnum(const char *, struct proto_dungeon *); +staticfn int level_range(xint16, int, int, int, struct proto_dungeon *, int *); +staticfn xint16 parent_dlevel(const char *, struct proto_dungeon *); +staticfn int correct_branch_type(struct tmpbranch *); +staticfn branch *add_branch(int, int, struct proto_dungeon *); +staticfn void add_level(s_level *); +staticfn void init_level(int, int, struct proto_dungeon *); +staticfn int possible_places(int, boolean *, struct proto_dungeon *); +staticfn xint16 pick_level(boolean *, int); +staticfn boolean place_level(int, struct proto_dungeon *); +staticfn int get_dgn_flags(lua_State *); +staticfn int get_dgn_align(lua_State *); +staticfn void init_dungeon_levels(lua_State *, struct proto_dungeon *, int); +staticfn void init_dungeon_branches(lua_State *, struct proto_dungeon *, int); +staticfn void init_dungeon_set_entry(struct proto_dungeon *, int); +staticfn void init_dungeon_set_depth(struct proto_dungeon *, int); +staticfn void init_castle_tune(void); +staticfn void fixup_level_locations(void); +staticfn void free_proto_dungeon(struct proto_dungeon *); +staticfn boolean init_dungeon_dungeons(lua_State *, struct proto_dungeon *, + int); +staticfn boolean unplaced_floater(struct dungeon *); +staticfn boolean unreachable_level(d_level *, boolean); +staticfn void tport_menu(winid, char *, struct lchoice *, d_level *, boolean); +staticfn const char *br_string(int); +staticfn char chr_u_on_lvl(d_level *); +staticfn void print_branch(winid, int, int, int, boolean, struct lchoice *); +staticfn char *get_annotation(d_level *); +staticfn void query_annotation(d_level *); +staticfn mapseen *load_mapseen(NHFILE *); +staticfn void save_mapseen(NHFILE *, mapseen *); +staticfn mapseen *find_mapseen(d_level *); +staticfn mapseen *find_mapseen_by_str(const char *); +staticfn void print_mapseen(winid, mapseen *, int, int, boolean); +staticfn boolean interest_mapseen(mapseen *); +staticfn void count_feat_lastseentyp(mapseen *, coordxy, coordxy); +staticfn void traverse_mapseenchn(int, winid, int, int, int *); +staticfn const char *seen_string(xint16, const char *); +staticfn const char *br_string2(branch *); +staticfn const char *shop_string(int); +staticfn char *tunesuffix(mapseen *, char *, size_t); #ifdef DEBUG -static void dumpit(void); +staticfn void dumpit(void); -static void +staticfn void dumpit(void) { #define DD gd.dungeons[i] @@ -265,7 +266,7 @@ restore_dungeon(NHFILE *nhfp) } #if 0 -static void +staticfn void Fread(genericptr_t ptr, int size, int nitems, dlb *stream) { int cnt; @@ -281,7 +282,7 @@ Fread(genericptr_t ptr, int size, int nitems, dlb *stream) DISABLE_WARNING_UNREACHABLE_CODE -static xint16 +staticfn xint16 dname_to_dnum(const char *s) { xint16 i; @@ -308,7 +309,7 @@ find_level(const char *s) } /* Find the branch that links the named dungeon. */ -static int +staticfn int find_branch( const char *s, /* dungeon name */ struct proto_dungeon *pd) @@ -343,7 +344,7 @@ DISABLE_WARNING_UNREACHABLE_CODE * Find the "parent" by searching the prototype branch list for the branch * listing, then figuring out to which dungeon it belongs. */ -static xint16 +staticfn xint16 parent_dnum( const char *s, /* dungeon name */ struct proto_dungeon *pd) @@ -377,7 +378,7 @@ RESTORE_WARNING_UNREACHABLE_CODE * a negative random component means from the (adjusted) base to the * end of the dungeon. */ -static int +staticfn int level_range( xint16 dgn, int base, int randc, int chain, @@ -412,7 +413,7 @@ level_range( return 1; } -static xint16 +staticfn xint16 parent_dlevel(const char *s, struct proto_dungeon *pd) { int i, j, num, base, dnum = parent_dnum(s, pd); @@ -437,7 +438,7 @@ parent_dlevel(const char *s, struct proto_dungeon *pd) } /* Convert from the temporary branch type to the dungeon branch type. */ -static int +staticfn int correct_branch_type(struct tmpbranch *tbr) { switch (tbr->type) { @@ -511,7 +512,7 @@ insert_branch(branch *new_branch, boolean extract_first) #undef branch_val /* Add a dungeon branch to the branch list. */ -static branch * +staticfn branch * add_branch( int dgn, int child_entry_level, struct proto_dungeon *pd) @@ -542,7 +543,7 @@ add_branch( * level that has a dungeon number less than the dungeon number of the * last entry. */ -static void +staticfn void add_level(s_level *new_lev) { s_level *prev, *curr; @@ -563,7 +564,7 @@ add_level(s_level *new_lev) } } -static void +staticfn void init_level(int dgn, int proto_index, struct proto_dungeon *pd) { s_level *new_level; @@ -595,7 +596,7 @@ init_level(int dgn, int proto_index, struct proto_dungeon *pd) new_level->next = (s_level *) 0; } -static int +staticfn int possible_places( int idx, /* prototype index */ boolean *map, /* array MAXLEVEL+1 in length */ @@ -629,7 +630,7 @@ possible_places( DISABLE_WARNING_UNREACHABLE_CODE /* Pick the nth TRUE entry in the given boolean array. */ -static xint16 +staticfn xint16 pick_level( boolean *map, /* an array MAXLEVEL+1 in size */ int nth) @@ -646,9 +647,9 @@ pick_level( RESTORE_WARNING_UNREACHABLE_CODE #ifdef DDEBUG -static void indent(int); +staticfn void indent(int); -static void +staticfn void indent(int d) { while (d-- > 0) @@ -663,7 +664,7 @@ indent(int d) * all possible places have been tried. If all possible places have * been exhausted, return false. */ -static boolean +staticfn boolean place_level(int proto_index, struct proto_dungeon *pd) { boolean map[MAXLEVEL + 1]; /* valid levels are 1..MAXLEVEL inclusive */ @@ -741,7 +742,7 @@ static struct level_map { #undef X_LOCATE #undef X_GOAL -static int +staticfn int get_dgn_flags(lua_State *L) { int dgn_flags = 0; @@ -778,7 +779,7 @@ get_dgn_flags(lua_State *L) return dgn_flags; } -static int +staticfn int get_dgn_align(lua_State *L) { static const char *const dgnaligns[] = { @@ -794,7 +795,7 @@ get_dgn_align(lua_State *L) return a; } -static void +staticfn void init_dungeon_levels( lua_State *L, struct proto_dungeon *pd, @@ -864,7 +865,7 @@ init_dungeon_levels( panic("init_dungeon: too many special levels"); } -static void +staticfn void init_dungeon_branches( lua_State *L, struct proto_dungeon *pd, @@ -930,7 +931,7 @@ init_dungeon_branches( panic("init_dungeon: too many branches"); } -static void +staticfn void init_dungeon_set_entry(struct proto_dungeon *pd, int dngidx) { int dgn_entry = pd->tmpdungeon[dngidx].entry_lev; @@ -957,7 +958,7 @@ init_dungeon_set_entry(struct proto_dungeon *pd, int dngidx) } } -static void +staticfn void init_dungeon_set_depth(struct proto_dungeon *pd, int dngidx) { branch *br; @@ -994,7 +995,7 @@ init_dungeon_set_depth(struct proto_dungeon *pd, int dngidx) - (gd.dungeons[dngidx].entry_lev - 1); } -static boolean +staticfn boolean init_dungeon_dungeons( lua_State *L, struct proto_dungeon *pd, @@ -1104,7 +1105,7 @@ init_dungeon_dungeons( } /* initialize the Castle drawbridge tune */ -static void +staticfn void init_castle_tune(void) { int i; @@ -1115,7 +1116,7 @@ init_castle_tune(void) } /* fix up the special level names and locations for quick access */ -static void +staticfn void fixup_level_locations(void) { int i; @@ -1177,7 +1178,7 @@ fixup_level_locations(void) } } -static void +staticfn void free_proto_dungeon(struct proto_dungeon *pd) { int i; @@ -2130,7 +2131,7 @@ lev_by_name(const char *nam) #undef dlev_in_current_branch -static boolean +staticfn boolean unplaced_floater(struct dungeon *dptr) { branch *br; @@ -2145,7 +2146,7 @@ unplaced_floater(struct dungeon *dptr) return FALSE; } -static boolean +staticfn boolean unreachable_level(d_level *lvl_p, boolean unplaced) { s_level *dummy; @@ -2159,7 +2160,7 @@ unreachable_level(d_level *lvl_p, boolean unplaced) return FALSE; } -static void +staticfn void tport_menu( winid win, char *entry, @@ -2195,7 +2196,7 @@ tport_menu( } /* Convert a branch type to a string usable by print_dungeon(). */ -static const char * +staticfn const char * br_string(int type) { switch (type) { @@ -2211,14 +2212,14 @@ br_string(int type) return " (unknown)"; } -static char +staticfn char chr_u_on_lvl(d_level *dlev) { return u.uz.dnum == dlev->dnum && u.uz.dlevel == dlev->dlevel ? '*' : ' '; } /* Print all child branches between the lower and upper bounds. */ -static void +staticfn void print_branch( winid win, int dnum, int lower_bound, int upper_bound, @@ -2433,7 +2434,7 @@ recbranch_mapseen(d_level *source, d_level *dest) } } -static char * +staticfn char * get_annotation(d_level *lev) { mapseen *mptr; @@ -2455,7 +2456,7 @@ print_level_annotation(void) /* ask user to annotate level lev. if lev is NULL, uses current level. */ -static void +staticfn void query_annotation(d_level *lev) { mapseen *mptr; @@ -2592,7 +2593,7 @@ load_exclusions(NHFILE *nhfp) } /* find the particular mapseen object in the chain; may return null */ -static mapseen * +staticfn mapseen * find_mapseen(d_level *lev) { mapseen *mptr; @@ -2604,7 +2605,7 @@ find_mapseen(d_level *lev) return mptr; } -static mapseen * +staticfn mapseen * find_mapseen_by_str(const char *s) { mapseen *mptr; @@ -2650,7 +2651,7 @@ rm_mapseen(int ledger_num) } } -static void +staticfn void save_mapseen(NHFILE *nhfp, mapseen *mptr) { branch *curr; @@ -2681,7 +2682,7 @@ save_mapseen(NHFILE *nhfp, mapseen *mptr) savecemetery(nhfp, &mptr->final_resting_place); } -static mapseen * +staticfn mapseen * load_mapseen(NHFILE *nhfp) { int branchnum = 0, brindx; @@ -2842,7 +2843,7 @@ init_mapseen(d_level *lev) /* || (feat).water || (feat).ice || (feat).lava */ /* returns true if this level has something interesting to print out */ -static boolean +staticfn boolean interest_mapseen(mapseen *mptr) { if (on_level(&u.uz, &mptr->lev)) @@ -2913,7 +2914,7 @@ update_mapseen_for(coordxy x, coordxy y) } /* count mapseen feature from lastseentyp at x,y */ -static void +staticfn void count_feat_lastseentyp( mapseen *mptr, /* remembered data for a level; update feat.X counts */ coordxy x, coordxy y) @@ -3304,7 +3305,7 @@ show_overview( } /* display endgame levels or non-endgame levels, not both */ -static void +staticfn void traverse_mapseenchn( int viewendgame, /* 0: show endgame branch; 1: show other branches */ winid win, /* output window */ @@ -3328,7 +3329,7 @@ traverse_mapseenchn( } } -static const char * +staticfn const char * seen_string(xint16 x, const char *obj) { /* players are computer scientists: 0, 1, 2, n */ @@ -3348,7 +3349,7 @@ seen_string(xint16 x, const char *obj) } /* better br_string */ -static const char * +staticfn const char * br_string2(branch *br) { /* Special case: quest portal says closed if kicked from quest */ @@ -3400,7 +3401,7 @@ endgamelevelname(char *outbuf, int indx) return outbuf; } -static const char * +staticfn const char * shop_string(int rtype) { const char *str = "shop"; /* catchall */ @@ -3451,7 +3452,7 @@ shop_string(int rtype) /* if player knows about the mastermind tune, append it to Castle annotation; if drawbridge has been destroyed, flags.castletune will be zero */ -static char * +staticfn char * tunesuffix( mapseen *mptr, char *outbuf, @@ -3507,7 +3508,7 @@ tunesuffix( } \ } while (0) -static void +staticfn void print_mapseen( winid win, mapseen *mptr, int final, /* -1: as menu; 0: not final; diff --git a/src/eat.c b/src/eat.c index 73a887a11..9f4faafd3 100644 --- a/src/eat.c +++ b/src/eat.c @@ -5,46 +5,46 @@ #include "hack.h" -static int eatmdone(void); -static int eatfood(void); -static struct obj *costly_tin(int); -static int opentin(void); -static int unfaint(void); +staticfn int eatmdone(void); +staticfn int eatfood(void); +staticfn struct obj *costly_tin(int); +staticfn int opentin(void); +staticfn int unfaint(void); -static const char *food_xname(struct obj *, boolean); -static void choke(struct obj *); -static void recalc_wt(void); -static int adj_victual_nutrition(void); -static struct obj *touchfood(struct obj *) NONNULL; -static void do_reset_eat(void); -static void done_eating(boolean); -static void cprefx(int); -static boolean temp_givit(int, struct permonst *); -static void givit(int, struct permonst *); -static void eye_of_newt_buzz(void); -static void cpostfx(int); -static void consume_tin(const char *); -static void start_tin(struct obj *); -static int eatcorpse(struct obj *); -static void start_eating(struct obj *, boolean); -static void garlic_breath(struct monst *); -static void fprefx(struct obj *); -static void fpostfx(struct obj *); -static int bite(void); -static int edibility_prompts(struct obj *); -static int doeat_nonfood(struct obj *); -static int tinopen_ok(struct obj *); -static int rottenfood(struct obj *); -static void eatspecial(void); -static int bounded_increase(int, int, int); -static void accessory_has_effect(struct obj *); -static void eataccessory(struct obj *); -static const char *foodword(struct obj *); -static int tin_variety(struct obj *, boolean); -static boolean maybe_cannibal(int, boolean); -static int eat_ok(struct obj *); -static int offer_ok(struct obj *); -static int tin_ok(struct obj *); +staticfn const char *food_xname(struct obj *, boolean); +staticfn void choke(struct obj *); +staticfn void recalc_wt(void); +staticfn int adj_victual_nutrition(void); +staticfn struct obj *touchfood(struct obj *) NONNULL; +staticfn void do_reset_eat(void); +staticfn void done_eating(boolean); +staticfn void cprefx(int); +staticfn boolean temp_givit(int, struct permonst *); +staticfn void givit(int, struct permonst *); +staticfn void eye_of_newt_buzz(void); +staticfn void cpostfx(int); +staticfn void consume_tin(const char *); +staticfn void start_tin(struct obj *); +staticfn int eatcorpse(struct obj *); +staticfn void start_eating(struct obj *, boolean); +staticfn void garlic_breath(struct monst *); +staticfn void fprefx(struct obj *); +staticfn void fpostfx(struct obj *); +staticfn int bite(void); +staticfn int edibility_prompts(struct obj *); +staticfn int doeat_nonfood(struct obj *); +staticfn int tinopen_ok(struct obj *); +staticfn int rottenfood(struct obj *); +staticfn void eatspecial(void); +staticfn int bounded_increase(int, int, int); +staticfn void accessory_has_effect(struct obj *); +staticfn void eataccessory(struct obj *); +staticfn const char *foodword(struct obj *); +staticfn int tin_variety(struct obj *, boolean); +staticfn boolean maybe_cannibal(int, boolean); +staticfn int eat_ok(struct obj *); +staticfn int offer_ok(struct obj *); +staticfn int tin_ok(struct obj *); /* also used to see if you're allowed to eat cats and dogs */ #define CANNIBAL_ALLOWED() (Role_if(PM_CAVE_DWELLER) || Race_if(PM_ORC)) @@ -64,7 +64,8 @@ static int tin_ok(struct obj *); #define nonrotting_food(otyp) \ ((otyp) == LEMBAS_WAFER || (otyp) == CRAM_RATION) -/* see hunger states in hack.h - texts used on bottom line */ +/* see hunger states in hack.h - texts used on bottom line + Also used in botl.c and insight.c */ const char *const hu_stat[] = { "Satiated", " ", "Hungry ", "Weak ", "Fainting", "Fainted ", "Starved " @@ -157,7 +158,7 @@ static const struct { #define TTSZ SIZE(tintxts) /* called after mimicking is over */ -static int +staticfn int eatmdone(void) { /* release `eatmbuf' */ @@ -211,7 +212,7 @@ eatmupdate(void) } /* ``[the(] singular(food, xname) [)]'' */ -static const char * +staticfn const char * food_xname(struct obj *food, boolean the_pfx) { const char *result; @@ -239,7 +240,7 @@ food_xname(struct obj *food, boolean the_pfx) * * To a full belly all food is bad. (It.) */ -static void +staticfn void choke(struct obj *food) { /* only happens if you were satiated */ @@ -286,7 +287,7 @@ choke(struct obj *food) } /* modify victual.piece->owt depending on time spent consuming it */ -static void +staticfn void recalc_wt(void) { struct obj *piece = gc.context.victual.piece; @@ -332,7 +333,7 @@ obj_nutrition(struct obj *otmp) /* nutrition increment for next byte; this used to be factored into victual.piece->oeaten but that produced weight change if hero polymorphed to or from one of the races which has nutrition adjusted */ -static int +staticfn int adj_victual_nutrition(void) { int otyp = gc.context.victual.piece->otyp; @@ -353,7 +354,7 @@ adj_victual_nutrition(void) return nut; } -static struct obj * +staticfn struct obj * touchfood(struct obj *otmp) { if (otmp->quan > 1L) { @@ -413,7 +414,7 @@ food_substitution(struct obj *old_obj, struct obj *new_obj) } } -static void +staticfn void do_reset_eat(void) { debugpline0("do_reset_eat..."); @@ -483,10 +484,10 @@ eating_dangerous_corpse(int res) } #if 0 /* no longer used */ -static void maybe_extend_timed_resist(int); +staticfn void maybe_extend_timed_resist(int); /* if temp resist against 'prop' is about to timeout, extend it slightly */ -static void +staticfn void maybe_extend_timed_resist(int prop) { long timeout = temp_resist(prop); @@ -505,7 +506,7 @@ maybe_extend_timed_resist(int prop) #endif /* called each move during eating process */ -static int +staticfn int eatfood(void) { struct obj *food = gc.context.victual.piece; @@ -530,7 +531,7 @@ eatfood(void) } } -static void +staticfn void done_eating(boolean message) { struct obj *piece = gc.context.victual.piece; @@ -738,7 +739,7 @@ eat_brains( } /* eating a corpse or egg of one's own species is usually naughty */ -static boolean +staticfn boolean maybe_cannibal(int pm, boolean allowmsg) { static NEARDATA long ate_brains = 0L; @@ -771,7 +772,7 @@ maybe_cannibal(int pm, boolean allowmsg) return FALSE; } -static void +staticfn void cprefx(int pm) { (void) maybe_cannibal(pm, TRUE); @@ -967,7 +968,7 @@ should_givit(int type, struct permonst *ptr) return (ptr->mlevel > rn2(chance)); } -static boolean +staticfn boolean temp_givit(int type, struct permonst *ptr) { int chance = (type == STONE_RES) ? 6 : (type == ACID_RES) ? 3 : 0; @@ -978,7 +979,7 @@ temp_givit(int type, struct permonst *ptr) /* givit() tries to give you an intrinsic based on the monster's level * and what type of intrinsic it is trying to give you. */ -static void +staticfn void givit(int type, struct permonst *ptr) { debugpline1("Attempting to give intrinsic %d", type); @@ -1078,7 +1079,7 @@ givit(int type, struct permonst *ptr) } } -static void +staticfn void eye_of_newt_buzz(void) { /* MRKR: "eye of newt" may give small magical energy boost */ @@ -1104,7 +1105,7 @@ eye_of_newt_buzz(void) DISABLE_WARNING_FORMAT_NONLITERAL /* called after completely consuming a corpse */ -static void +staticfn void cpostfx(int pm) { int tmp = 0; @@ -1350,7 +1351,7 @@ violated_vegetarian(void) /* common code to check and possibly charge for 1 gc.context.tin.tin, * will split() gc.context.tin.tin if necessary */ -static struct obj * +staticfn struct obj * costly_tin(int alter_type) /* COST_xxx */ { struct obj *tin = gc.context.tin.tin; @@ -1450,7 +1451,7 @@ set_tin_variety(struct obj *obj, int forcetype) obj->spe = -(r + 1); /* offset by 1 to allow index 0 */ } -static int +staticfn int tin_variety( struct obj *obj, boolean displ) /* we're just displaying so leave things alone */ @@ -1476,7 +1477,7 @@ tin_variety( return r; } -static void +staticfn void consume_tin(const char *mesg) { const char *what; @@ -1618,7 +1619,7 @@ consume_tin(const char *mesg) } /* called during each move whilst opening a tin */ -static int +staticfn int opentin(void) { /* perhaps it was stolen (although that should cause interruption) */ @@ -1638,7 +1639,7 @@ opentin(void) } /* called when starting to open a tin */ -static void +staticfn void start_tin(struct obj *otmp) { const char *mesg = 0; @@ -1727,7 +1728,7 @@ Hear_again(void) } /* called on the "first bite" of rotten food */ -static int +staticfn int rottenfood(struct obj *obj) { pline("Blecch! %s %s!", @@ -1769,7 +1770,7 @@ rottenfood(struct obj *obj) } /* called when a corpse is selected as food */ -static int +staticfn int eatcorpse(struct obj *otmp) { int retcode = 0, tp = 0, mnum = otmp->corpsenm; @@ -1934,7 +1935,7 @@ eatcorpse(struct obj *otmp) } /* called as you start to eat */ -static void +staticfn void start_eating(struct obj *otmp, boolean already_partly_eaten) { const char *old_nomovemsg, *save_nomovemsg; @@ -1997,7 +1998,7 @@ eating_glob(struct obj *glob) } /* scare nearby monster when hero eats garlic */ -static void +staticfn void garlic_breath(struct monst *mtmp) { if (olfaction(mtmp->data) && distu(mtmp->mx, mtmp->my) < 7) @@ -2010,7 +2011,7 @@ garlic_breath(struct monst *mtmp) * Messages should use present tense since multi-turn food won't be * finishing at the time they're issued. */ -static void +staticfn void fprefx(struct obj *otmp) { switch (otmp->otyp) { @@ -2119,7 +2120,7 @@ fprefx(struct obj *otmp) } /* increment a combat intrinsic with limits on its growth */ -static int +staticfn int bounded_increase(int old, int inc, int typ) { int absold, absinc, sgnold, sgninc; @@ -2156,14 +2157,14 @@ bounded_increase(int old, int inc, int typ) return old + inc; } -static void +staticfn void accessory_has_effect(struct obj *otmp) { pline("Magic spreads through your body as you digest the %s.", (otmp->oclass == RING_CLASS) ? "ring" : "amulet"); } -static void +staticfn void eataccessory(struct obj *otmp) { int typ = otmp->otyp; @@ -2311,7 +2312,7 @@ eataccessory(struct obj *otmp) } /* called after eating non-food */ -static void +staticfn void eatspecial(void) { struct obj *otmp = gc.context.victual.piece; @@ -2395,7 +2396,7 @@ static const char *const foodwords[] = { "plastic", "glass", "rich food", "stone" }; -static const char * +staticfn const char * foodword(struct obj *otmp) { if (otmp->oclass == FOOD_CLASS) @@ -2407,7 +2408,7 @@ foodword(struct obj *otmp) } /* called after consuming (non-corpse) food */ -static void +staticfn void fpostfx(struct obj *otmp) { switch (otmp->otyp) { @@ -2503,9 +2504,9 @@ fpostfx(struct obj *otmp) /* intended for eating a spellbook while polymorphed, but not used; "leather" applied to appearance, not composition, and has been changed to "leathery" to reflect that */ -static boolean leather_cover(struct obj *); +staticfn boolean leather_cover(struct obj *); -static boolean +staticfn boolean leather_cover(struct obj *otmp) { const char *odesc = OBJ_DESCR(objects[otmp->otyp]); @@ -2523,7 +2524,7 @@ leather_cover(struct obj *otmp) * return 1 if the food was dangerous and you chose to stop. * return 2 if the food was dangerous and you chose to eat it anyway. */ -static int +staticfn int edibility_prompts(struct obj *otmp) { /* Blessed food detection grants hero a one-use @@ -2630,7 +2631,7 @@ edibility_prompts(struct obj *otmp) return 0; } -static int +staticfn int doeat_nonfood(struct obj *otmp) { int basenutrit; /* nutrition of full item */ @@ -2969,7 +2970,7 @@ doeat(void) } /* getobj callback for object to be opened with a tin opener */ -static int +staticfn int tinopen_ok(struct obj *obj) { if (obj && obj->otyp == TIN) @@ -3014,7 +3015,7 @@ use_tin_opener(struct obj *obj) /* Take a single bite from a piece of food, checking for choking and * modifying usedtime. Returns 1 if they choked and survived, 0 otherwise. */ -static int +staticfn int bite(void) { /* hack to pacify static analyzer incorporated into gcc 12.2 */ @@ -3217,7 +3218,7 @@ lesshungry(int num) newuhs(FALSE); } -static int +staticfn int unfaint(void) { (void) Hear_again(); @@ -3398,7 +3399,7 @@ newuhs(boolean incr) } /* getobj callback for object to eat - effectively just wraps is_edible() */ -static int +staticfn int eat_ok(struct obj *obj) { /* 'getobj_else' will be non-zero if floor food is present and @@ -3420,7 +3421,7 @@ eat_ok(struct obj *obj) /* getobj callback for object to be offered (corpses and things that look like * the Amulet only */ -static int +staticfn int offer_ok(struct obj *obj) { if (!obj) @@ -3442,7 +3443,7 @@ offer_ok(struct obj *obj) } /* getobj callback for object to be tinned */ -static int +staticfn int tin_ok(struct obj *obj) { if (!obj) diff --git a/src/end.c b/src/end.c index 9dd33a5c4..f42e53401 100644 --- a/src/end.c +++ b/src/end.c @@ -20,26 +20,26 @@ #define nowrap_add(a, b) (a = ((a + b) < 0 ? LONG_MAX : (a + b))) #ifndef NO_SIGNAL -static void done_intr(int); +staticfn void done_intr(int); # if defined(UNIX) || defined(VMS) || defined(__EMX__) -static void done_hangup(int); +staticfn void done_hangup(int); # endif #endif -static void disclose(int, boolean); -static void get_valuables(struct obj *) NO_NNARGS; -static void sort_valuables(struct valuable_data *, int); -static void artifact_score(struct obj *, boolean, winid); -static boolean fuzzer_savelife(int); +staticfn void disclose(int, boolean); +staticfn void get_valuables(struct obj *) NO_NNARGS; +staticfn void sort_valuables(struct valuable_data *, int); +staticfn void artifact_score(struct obj *, boolean, winid); +staticfn boolean fuzzer_savelife(int); ATTRNORETURN static void really_done(int) NORETURN; -static void savelife(int); -static boolean should_query_disclose_option(int, char *); +staticfn void savelife(int); +staticfn boolean should_query_disclose_option(int, char *); #ifdef DUMPLOG -static void dump_plines(void); +staticfn void dump_plines(void); #endif -static void dump_everything(int, time_t); -static void fixup_death(int); -static int wordcount(char *); -static void bel_copy1(char **, char *); +staticfn void dump_everything(int, time_t); +staticfn void fixup_death(int); +staticfn int wordcount(char *); +staticfn void bel_copy1(char **, char *); #if defined(__BEOS__) || defined(MICRO) || defined(OS2) || defined(WIN32) ATTRNORETURN extern void nethack_exit(int) NORETURN; @@ -160,7 +160,7 @@ done2(void) #ifndef NO_SIGNAL /* called as signal() handler, so sent at least 1 arg */ /*ARGSUSED*/ -static void +staticfn void done_intr(int sig_unused UNUSED) { done_stopprint++; @@ -175,7 +175,7 @@ done_intr(int sig_unused UNUSED) #if defined(UNIX) || defined(VMS) || defined(__EMX__) /* signal() handler */ -static void +staticfn void done_hangup(int sig) { #ifdef HANGUPHANDLING @@ -360,7 +360,7 @@ static const struct { /* clear away while-helpless when the cause of death caused that helplessness (ie, "petrified by while getting stoned") */ -static void +staticfn void fixup_death(int how) { int i; @@ -470,7 +470,7 @@ panic VA_DECL(const char *, str) RESTORE_WARNING_FORMAT_NONLITERAL -static boolean +staticfn boolean should_query_disclose_option(int category, char *defquery) { int idx; @@ -512,7 +512,7 @@ should_query_disclose_option(int category, char *defquery) } #ifdef DUMPLOG -static void +staticfn void dump_plines(void) { int i, j; @@ -535,7 +535,7 @@ dump_plines(void) #endif /* DUMPLOG */ /*ARGSUSED*/ -static void +staticfn void dump_everything( int how, /* ASCENDED, ESCAPED, QUIT, etc */ time_t when) /* date+time at end of game */ @@ -610,7 +610,7 @@ dump_everything( #endif } -static void +staticfn void disclose(int how, boolean taken) { char c = '\0', defquery; @@ -694,7 +694,7 @@ disclose(int how, boolean taken) } /* try to get the player back in a viable state after being killed */ -static void +staticfn void savelife(int how) { int uhpmin; @@ -753,7 +753,7 @@ savelife(int how) * Get valuables from the given list. Revised code: the list always remains * intact. */ -static void +staticfn void get_valuables(struct obj *list) /* inventory or container contents */ { struct obj *obj; @@ -788,7 +788,7 @@ get_valuables(struct obj *list) /* inventory or container contents */ * Sort collected valuables, most frequent to least. We could just * as easily use qsort, but we don't care about efficiency here. */ -static void +staticfn void sort_valuables( struct valuable_data list[], int size) /* max value is less than 20 */ @@ -897,7 +897,7 @@ done_object_cleanup(void) } /* called twice; first to calculate total, then to list relevant items */ -static void +staticfn void artifact_score( struct obj *list, boolean counting, /* true => add up points; false => display them */ @@ -934,7 +934,7 @@ artifact_score( /* when dying while running the debug fuzzer, [almost] always keep going; True: forced survival; False: doomed unless wearing life-save amulet */ -static boolean +staticfn boolean fuzzer_savelife(int how) { /* @@ -1113,7 +1113,7 @@ done(int how) } /* separated from done() in order to specify the __noreturn__ attribute */ -static void +staticfn void really_done(int how) { boolean taken; @@ -1774,7 +1774,7 @@ restore_killers(NHFILE *nhfp) } } -static int +staticfn int wordcount(char *p) { int words = 0; @@ -1790,7 +1790,7 @@ wordcount(char *p) return words; } -static void +staticfn void bel_copy1(char **inp, char *out) { char *in = *inp; diff --git a/src/engrave.c b/src/engrave.c index 3d81b9ec0..2d7fc7cb7 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -38,14 +38,14 @@ struct _doengrave_ctx { size_t len; /* # of nonspace chars of new engraving text */ }; -static int stylus_ok(struct obj *); -static boolean u_can_engrave(void); -static void doengrave_ctx_init(struct _doengrave_ctx *); -static void doengrave_sfx_item_WAN(struct _doengrave_ctx *); -static boolean doengrave_sfx_item(struct _doengrave_ctx *); -static void doengrave_ctx_verb(struct _doengrave_ctx *); -static int engrave(void); -static const char *blengr(void); +staticfn int stylus_ok(struct obj *); +staticfn boolean u_can_engrave(void); +staticfn void doengrave_ctx_init(struct _doengrave_ctx *); +staticfn void doengrave_sfx_item_WAN(struct _doengrave_ctx *); +staticfn boolean doengrave_sfx_item(struct _doengrave_ctx *); +staticfn void doengrave_ctx_verb(struct _doengrave_ctx *); +staticfn int engrave(void); +staticfn const char *blengr(void); char * random_engraving(char *outbuf) @@ -423,7 +423,7 @@ freehand(void) } /* getobj callback for an object to engrave with */ -static int +staticfn int stylus_ok(struct obj *obj) { if (!obj) @@ -445,7 +445,7 @@ stylus_ok(struct obj *obj) } /* can hero engrave at all (at their location)? */ -static boolean +staticfn boolean u_can_engrave(void) { int levtyp = SURFACE_AT(u.ux, u.uy); @@ -487,7 +487,7 @@ u_can_engrave(void) } /* initialize the doengrave data */ -static void +staticfn void doengrave_ctx_init(struct _doengrave_ctx *de) { de->dengr = FALSE; @@ -525,7 +525,7 @@ doengrave_ctx_init(struct _doengrave_ctx *de) } /* special engraving effects for WAND objects */ -static void +staticfn void doengrave_sfx_item_WAN(struct _doengrave_ctx *de) { switch (de->otmp->otyp) { @@ -682,7 +682,7 @@ doengrave_sfx_item_WAN(struct _doengrave_ctx *de) } /* special engraving effects for all objects */ -static boolean +staticfn boolean doengrave_sfx_item(struct _doengrave_ctx *de) { switch (de->otmp->oclass) { @@ -828,7 +828,7 @@ doengrave_sfx_item(struct _doengrave_ctx *de) } /* which verb phrasing to use for engraving */ -static void +staticfn void doengrave_ctx_verb(struct _doengrave_ctx *de) { switch (de->type) { @@ -1178,7 +1178,7 @@ doengr_exit: } /* occupation callback for engraving some text */ -static int +staticfn int engrave(void) { struct engr *oep; @@ -1620,7 +1620,7 @@ static const char blind_writing[][21] = { 0x69, 0x76, 0x6b, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, }; -static const char * +staticfn const char * blengr(void) { return ROLL_FROM(blind_writing); diff --git a/src/exper.c b/src/exper.c index 193c46617..55cbef056 100644 --- a/src/exper.c +++ b/src/exper.c @@ -8,7 +8,7 @@ #include #endif -static int enermod(int); +staticfn int enermod(int); long newuexp(int lev) @@ -22,7 +22,7 @@ newuexp(int lev) return (10000000L * ((long) (lev - 19))); } -static int +staticfn int enermod(int en) { switch (Role_switch) { diff --git a/src/explode.c b/src/explode.c index 75b8a12f3..768aa72c9 100644 --- a/src/explode.c +++ b/src/explode.c @@ -4,8 +4,8 @@ #include "hack.h" -static int explosionmask(struct monst *, uchar, char) NONNULLARG1; -static void engulfer_explosion_msg(uchar, char); +staticfn int explosionmask(struct monst *, uchar, char) NONNULLARG1; +staticfn void engulfer_explosion_msg(uchar, char); /* Note: Arrays are column first, while the screen is row first */ static const int explosion[3][3] = { @@ -22,7 +22,7 @@ enum explode_action { }; /* check if shield effects are needed for location affected by explosion */ -static int +staticfn int explosionmask( struct monst *m, /* target monster (might be youmonst) */ uchar adtyp, /* damage type */ @@ -114,7 +114,7 @@ explosionmask( return res; } -static void +staticfn void engulfer_explosion_msg(uchar adtyp, char olet) { const char *adj = (char *) 0; diff --git a/src/extralev.c b/src/extralev.c index 08943c437..a6c733ff6 100644 --- a/src/extralev.c +++ b/src/extralev.c @@ -13,12 +13,11 @@ #define XL_LEFT 4 #define XL_RIGHT 8 -static void roguejoin(coordxy, coordxy, coordxy, coordxy, int); -static void roguecorr(coordxy, coordxy, int); -static void miniwalk(coordxy, coordxy); +staticfn void roguejoin(coordxy, coordxy, coordxy, coordxy, int); +staticfn void roguecorr(coordxy, coordxy, int); +staticfn void miniwalk(coordxy, coordxy); -static -void +staticfn void roguejoin(coordxy x1, coordxy y1, coordxy x2, coordxy y2, int horiz) { coordxy x, y, middle; @@ -42,8 +41,7 @@ roguejoin(coordxy x1, coordxy y1, coordxy x2, coordxy y2, int horiz) } } -static -void +staticfn void roguecorr(coordxy x, coordxy y, int dir) { coordxy fromx, fromy, tox, toy; @@ -137,8 +135,7 @@ roguecorr(coordxy x, coordxy y, int dir) } /* Modified walkfrom() from mkmaze.c */ -static -void +staticfn void miniwalk(coordxy x, coordxy y) { int q, dir; diff --git a/src/files.c b/src/files.c index 9a8c35f2f..1fddb59d5 100644 --- a/src/files.c +++ b/src/files.c @@ -120,119 +120,119 @@ extern char *translate_path_variables(const char *, char *); extern char *sounddir; /* defined in sounds.c */ #endif -static NHFILE *new_nhfile(void); -static void free_nhfile(NHFILE *); +staticfn NHFILE *new_nhfile(void); +staticfn void free_nhfile(NHFILE *); #ifdef SELECTSAVED -static int QSORTCALLBACK strcmp_wrap(const void *, const void *); +staticfn int QSORTCALLBACK strcmp_wrap(const void *, const void *); #endif -static char *set_bonesfile_name(char *, d_level *); -static char *set_bonestemp_name(void); +staticfn char *set_bonesfile_name(char *, d_level *); +staticfn char *set_bonestemp_name(void); #ifdef COMPRESS -static void redirect(const char *, const char *, FILE *, boolean); +staticfn void redirect(const char *, const char *, FILE *, boolean); #endif #if defined(COMPRESS) || defined(ZLIB_COMP) -static void docompress_file(const char *, boolean); +staticfn void docompress_file(const char *, boolean); #endif #if defined(ZLIB_COMP) -static boolean make_compressed_name(const char *, char *); +staticfn boolean make_compressed_name(const char *, char *); #endif #ifndef USE_FCNTL -static char *make_lockname(const char *, char *); +staticfn char *make_lockname(const char *, char *); #endif -static void set_configfile_name(const char *); -static FILE *fopen_config_file(const char *, int); -static int get_uchars(char *, uchar *, boolean, int, const char *); +staticfn void set_configfile_name(const char *); +staticfn FILE *fopen_config_file(const char *, int); +staticfn int get_uchars(char *, uchar *, boolean, int, const char *); #ifdef NOCWD_ASSUMPTIONS -static void adjust_prefix(char *, int); +staticfn void adjust_prefix(char *, int); #endif -static char *choose_random_part(char *, char); -static boolean config_error_nextline(const char *); -static void free_config_sections(void); -static char *is_config_section(char *); -static boolean handle_config_section(char *); +staticfn char *choose_random_part(char *, char); +staticfn boolean config_error_nextline(const char *); +staticfn void free_config_sections(void); +staticfn char *is_config_section(char *); +staticfn boolean handle_config_section(char *); boolean parse_config_line(char *); -static char *find_optparam(const char *); -static boolean cnf_line_OPTIONS(char *); -static boolean cnf_line_AUTOPICKUP_EXCEPTION(char *); -static boolean cnf_line_BINDINGS(char *); -static boolean cnf_line_AUTOCOMPLETE(char *); -static boolean cnf_line_MSGTYPE(char *); -static boolean cnf_line_HACKDIR(char *); -static boolean cnf_line_LEVELDIR(char *); -static boolean cnf_line_SAVEDIR(char *); -static boolean cnf_line_BONESDIR(char *); -static boolean cnf_line_DATADIR(char *); -static boolean cnf_line_SCOREDIR(char *); -static boolean cnf_line_LOCKDIR(char *); -static boolean cnf_line_CONFIGDIR(char *); -static boolean cnf_line_TROUBLEDIR(char *); -static boolean cnf_line_NAME(char *); -static boolean cnf_line_ROLE(char *); -static boolean cnf_line_dogname(char *); -static boolean cnf_line_catname(char *); -static boolean cnf_line_WIZARDS(char *); -static boolean cnf_line_SHELLERS(char *); -static boolean cnf_line_EXPLORERS(char *); -static boolean cnf_line_DEBUGFILES(char *); -static boolean cnf_line_DUMPLOGFILE(char *); -static boolean cnf_line_GENERICUSERS(char *); -static boolean cnf_line_BONES_POOLS(char *); -static boolean cnf_line_SUPPORT(char *); -static boolean cnf_line_RECOVER(char *); -static boolean cnf_line_CHECK_SAVE_UID(char *); -static boolean cnf_line_CHECK_PLNAME(char *); -static boolean cnf_line_SEDUCE(char *); -static boolean cnf_line_HIDEUSAGE(char *); -static boolean cnf_line_MAXPLAYERS(char *); -static boolean cnf_line_PERSMAX(char *); -static boolean cnf_line_PERS_IS_UID(char *); -static boolean cnf_line_ENTRYMAX(char *); -static boolean cnf_line_POINTSMIN(char *); -static boolean cnf_line_MAX_STATUENAME_RANK(char *); -static boolean cnf_line_LIVELOG(char *); -static boolean cnf_line_PANICTRACE_LIBC(char *); -static boolean cnf_line_PANICTRACE_GDB(char *); -static boolean cnf_line_GDBPATH(char *); -static boolean cnf_line_GREPPATH(char *); -static boolean cnf_line_CRASHREPORTURL(char *); -static boolean cnf_line_SAVEFORMAT(char *); -static boolean cnf_line_BONESFORMAT(char *); -static boolean cnf_line_ACCESSIBILITY(char *); -static boolean cnf_line_PORTABLE_DEVICE_PATHS(char *); -static boolean cnf_line_BOULDER(char *); -static boolean cnf_line_MENUCOLOR(char *); -static boolean cnf_line_HILITE_STATUS(char *); -static boolean cnf_line_WARNINGS(char *); -static boolean cnf_line_ROGUESYMBOLS(char *); -static boolean cnf_line_SYMBOLS(char *); -static boolean cnf_line_WIZKIT(char *); +staticfn char *find_optparam(const char *); +staticfn boolean cnf_line_OPTIONS(char *); +staticfn boolean cnf_line_AUTOPICKUP_EXCEPTION(char *); +staticfn boolean cnf_line_BINDINGS(char *); +staticfn boolean cnf_line_AUTOCOMPLETE(char *); +staticfn boolean cnf_line_MSGTYPE(char *); +staticfn boolean cnf_line_HACKDIR(char *); +staticfn boolean cnf_line_LEVELDIR(char *); +staticfn boolean cnf_line_SAVEDIR(char *); +staticfn boolean cnf_line_BONESDIR(char *); +staticfn boolean cnf_line_DATADIR(char *); +staticfn boolean cnf_line_SCOREDIR(char *); +staticfn boolean cnf_line_LOCKDIR(char *); +staticfn boolean cnf_line_CONFIGDIR(char *); +staticfn boolean cnf_line_TROUBLEDIR(char *); +staticfn boolean cnf_line_NAME(char *); +staticfn boolean cnf_line_ROLE(char *); +staticfn boolean cnf_line_dogname(char *); +staticfn boolean cnf_line_catname(char *); +staticfn boolean cnf_line_WIZARDS(char *); +staticfn boolean cnf_line_SHELLERS(char *); +staticfn boolean cnf_line_EXPLORERS(char *); +staticfn boolean cnf_line_DEBUGFILES(char *); +staticfn boolean cnf_line_DUMPLOGFILE(char *); +staticfn boolean cnf_line_GENERICUSERS(char *); +staticfn boolean cnf_line_BONES_POOLS(char *); +staticfn boolean cnf_line_SUPPORT(char *); +staticfn boolean cnf_line_RECOVER(char *); +staticfn boolean cnf_line_CHECK_SAVE_UID(char *); +staticfn boolean cnf_line_CHECK_PLNAME(char *); +staticfn boolean cnf_line_SEDUCE(char *); +staticfn boolean cnf_line_HIDEUSAGE(char *); +staticfn boolean cnf_line_MAXPLAYERS(char *); +staticfn boolean cnf_line_PERSMAX(char *); +staticfn boolean cnf_line_PERS_IS_UID(char *); +staticfn boolean cnf_line_ENTRYMAX(char *); +staticfn boolean cnf_line_POINTSMIN(char *); +staticfn boolean cnf_line_MAX_STATUENAME_RANK(char *); +staticfn boolean cnf_line_LIVELOG(char *); +staticfn boolean cnf_line_PANICTRACE_LIBC(char *); +staticfn boolean cnf_line_PANICTRACE_GDB(char *); +staticfn boolean cnf_line_GDBPATH(char *); +staticfn boolean cnf_line_GREPPATH(char *); +staticfn boolean cnf_line_CRASHREPORTURL(char *); +staticfn boolean cnf_line_SAVEFORMAT(char *); +staticfn boolean cnf_line_BONESFORMAT(char *); +staticfn boolean cnf_line_ACCESSIBILITY(char *); +staticfn boolean cnf_line_PORTABLE_DEVICE_PATHS(char *); +staticfn boolean cnf_line_BOULDER(char *); +staticfn boolean cnf_line_MENUCOLOR(char *); +staticfn boolean cnf_line_HILITE_STATUS(char *); +staticfn boolean cnf_line_WARNINGS(char *); +staticfn boolean cnf_line_ROGUESYMBOLS(char *); +staticfn boolean cnf_line_SYMBOLS(char *); +staticfn boolean cnf_line_WIZKIT(char *); #ifdef USER_SOUNDS -static boolean cnf_line_SOUNDDIR(char *); -static boolean cnf_line_SOUND(char *); +staticfn boolean cnf_line_SOUNDDIR(char *); +staticfn boolean cnf_line_SOUND(char *); #endif -static boolean cnf_line_QT_TILEWIDTH(char *); -static boolean cnf_line_QT_TILEHEIGHT(char *); -static boolean cnf_line_QT_FONTSIZE(char *); -static boolean cnf_line_QT_COMPACT(char *); +staticfn boolean cnf_line_QT_TILEWIDTH(char *); +staticfn boolean cnf_line_QT_TILEHEIGHT(char *); +staticfn boolean cnf_line_QT_FONTSIZE(char *); +staticfn boolean cnf_line_QT_COMPACT(char *); struct _cnf_parser_state; /* defined below (far below...) */ -static void cnf_parser_init(struct _cnf_parser_state *parser); -static void cnf_parser_done(struct _cnf_parser_state *parser); -static void parse_conf_buf(struct _cnf_parser_state *parser, +staticfn void cnf_parser_init(struct _cnf_parser_state *parser); +staticfn void cnf_parser_done(struct _cnf_parser_state *parser); +staticfn void parse_conf_buf(struct _cnf_parser_state *parser, boolean (*proc)(char *arg)); /* next one is in extern.h; why here too? */ boolean parse_conf_str(const char *str, boolean (*proc)(char *arg)); -static boolean parse_conf_file(FILE *fp, boolean (*proc)(char *arg)); -static void parseformat(int *, char *); -static FILE *fopen_wizkit_file(void); -static void wizkit_addinv(struct obj *); +staticfn boolean parse_conf_file(FILE *fp, boolean (*proc)(char *arg)); +staticfn void parseformat(int *, char *); +staticfn FILE *fopen_wizkit_file(void); +staticfn void wizkit_addinv(struct obj *); boolean proc_wizkit_line(char *buf); void read_wizkit(void); /* in extern.h; why here too? */ -static FILE *fopen_sym_file(void); +staticfn FILE *fopen_sym_file(void); #ifdef SELF_RECOVER -static boolean copy_bytes(int, int); +staticfn boolean copy_bytes(int, int); #endif -static NHFILE *viable_nhfile(NHFILE *); +staticfn NHFILE *viable_nhfile(NHFILE *); /* return a file's name without its path and optionally trailing 'type' */ const char * @@ -492,7 +492,7 @@ fopen_datafile(const char *filename, const char *mode, int prefix) /* ---------- EXTERNAL FILE SUPPORT ----------- */ /* determine byte order */ -const int bei = 1; +static const int bei = 1; #define IS_BIGENDIAN() ( (*(char*)&bei) == 0 ) void @@ -512,7 +512,7 @@ zero_nhfile(NHFILE *nhfp) nhfp->fnidx = 0; } -static NHFILE * +staticfn NHFILE * new_nhfile(void) { NHFILE *nhfp = (NHFILE *) alloc(sizeof(NHFILE)); @@ -521,7 +521,7 @@ new_nhfile(void) return nhfp; } -static void +staticfn void free_nhfile(NHFILE *nhfp) { if (nhfp) { @@ -551,8 +551,7 @@ rewind_nhfile(NHFILE *nhfp) } } -static -NHFILE * +staticfn NHFILE * viable_nhfile(NHFILE *nhfp) { /* perform some sanity checks before returning @@ -718,7 +717,7 @@ clearlocks(void) #if defined(SELECTSAVED) /* qsort comparison routine */ -static int QSORTCALLBACK +staticfn int QSORTCALLBACK strcmp_wrap(const void *p, const void *q) { #if defined(UNIX) && defined(QT_GRAPHICS) @@ -750,7 +749,7 @@ nhclose(int fd) /* set up "file" to be file name for retrieving bones, and return a * bonesid to be read/written in the bones file. */ -static char * +staticfn char * set_bonesfile_name(char *file, d_level *lev) { s_level *sptr; @@ -799,7 +798,7 @@ set_bonesfile_name(char *file, d_level *lev) * (we are not reading or writing level files while writing bones files, so * the same array may be used instead of copying.) */ -static char * +staticfn char * set_bonestemp_name(void) { char *tf; @@ -1426,7 +1425,7 @@ free_saved_games(char **saved) #ifdef COMPRESS /* external compression */ -static void +staticfn void redirect( const char *filename, const char *mode, @@ -1454,7 +1453,7 @@ redirect( * * cf. child() in unixunix.c. */ -static void +staticfn void docompress_file(const char *filename, boolean uncomp) { char *cfn = 0; @@ -1659,7 +1658,7 @@ nh_uncompress(const char *filename UNUSED_if_not_COMPRESS) } #ifdef ZLIB_COMP /* RLC 09 Mar 1999: Support internal ZLIB */ -static boolean +staticfn boolean make_compressed_name(const char *filename, char *cfn) { #ifndef SHORT_FILENAMES @@ -1690,7 +1689,7 @@ make_compressed_name(const char *filename, char *cfn) #endif /* SHORT_FILENAMES */ } -static void +staticfn void docompress_file(const char *filename, boolean uncomp) { gzFile compressedfile; @@ -1824,7 +1823,7 @@ docompress_file(const char *filename, boolean uncomp) static int lockfd = -1; /* for lock_file() to pass to unlock_file() */ #endif #ifdef USE_FCNTL -struct flock sflock; /* for unlocking, same as above */ +static struct flock sflock; /* for unlocking, same as above */ #endif #if defined(HANGUPHANDLING) @@ -1843,7 +1842,7 @@ struct flock sflock; /* for unlocking, same as above */ #ifndef USE_FCNTL -static char * +staticfn char * make_lockname(const char *filename UNUSED_conditional, char *lockname) { #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(WIN32) \ @@ -2082,7 +2081,7 @@ unlock_file(const char *filename) /* ---------- BEGIN CONFIG FILE HANDLING ----------- */ -const char *default_configfile = +static const char *default_configfile = #ifdef UNIX ".nethackrc"; #else @@ -2097,7 +2096,7 @@ const char *default_configfile = #endif #endif -/* used for messaging */ +/* used for messaging. Also used in options.c */ char configfile[BUFSZ]; #ifdef MSDOS @@ -2158,14 +2157,14 @@ do_write_config_file(void) /* remember the name of the file we're accessing; if may be used in option reject messages */ -static void +staticfn void set_configfile_name(const char *fname) { (void) strncpy(configfile, fname, sizeof configfile - 1); configfile[sizeof configfile - 1] = '\0'; } -static FILE * +staticfn FILE * fopen_config_file(const char *filename, int src) { FILE *fp; @@ -2306,7 +2305,7 @@ fopen_config_file(const char *filename, int src) * NOTE: zeros are inserted unless modlist is TRUE, in which case the list * location is unchanged. Callers must handle zeros if modlist is FALSE. */ -static int +staticfn int get_uchars(char *bufp, /* current pointer */ uchar *list, /* return list */ boolean modlist, /* TRUE: list is being modified in place */ @@ -2366,7 +2365,7 @@ get_uchars(char *bufp, /* current pointer */ } #ifdef NOCWD_ASSUMPTIONS -static void +staticfn void adjust_prefix(char *bufp, int prefixid) { char *ptr; @@ -2389,7 +2388,7 @@ adjust_prefix(char *bufp, int prefixid) #endif /* Choose at random one of the sep separated parts from str. Mangles str. */ -static char * +staticfn char * choose_random_part(char *str, char sep) { int nsep = 1; @@ -2427,7 +2426,7 @@ choose_random_part(char *str, char sep) return (char *) 0; } -static void +staticfn void free_config_sections(void) { if (gc.config_section_chosen) { @@ -2443,7 +2442,7 @@ free_config_sections(void) /* check for " [ anything-except-bracket-or-empty ] # arbitrary-comment" with spaces optional; returns pointer to "anything-except..." (with trailing " ] #..." stripped) if ok, otherwise Null */ -static char * +staticfn char * is_config_section( char *str) /* trailing spaces are stripped, ']' too iff result is good */ { @@ -2472,7 +2471,7 @@ is_config_section( return trimspaces(a); } -static boolean +staticfn boolean handle_config_section(char *buf) { char *sect = is_config_section(buf); @@ -2507,7 +2506,7 @@ handle_config_section(char *buf) #define match_varname(INP, NAM, LEN) match_optname(INP, NAM, LEN, TRUE) /* find the '=' or ':' */ -static char * +staticfn char * find_optparam(const char *buf) { char *bufp, *altp; @@ -2520,7 +2519,7 @@ find_optparam(const char *buf) return bufp; } -static boolean +staticfn boolean cnf_line_OPTIONS(char *origbuf) { char *bufp = find_optparam(origbuf); @@ -2529,33 +2528,33 @@ cnf_line_OPTIONS(char *origbuf) return parseoptions(bufp, TRUE, TRUE); } -static boolean +staticfn boolean cnf_line_AUTOPICKUP_EXCEPTION(char *bufp) { add_autopickup_exception(bufp); return TRUE; } -static boolean +staticfn boolean cnf_line_BINDINGS(char *bufp) { return parsebindings(bufp); } -static boolean +staticfn boolean cnf_line_AUTOCOMPLETE(char *bufp) { parseautocomplete(bufp, TRUE); return TRUE; } -static boolean +staticfn boolean cnf_line_MSGTYPE(char *bufp) { return msgtype_parse_add(bufp); } -static boolean +staticfn boolean cnf_line_HACKDIR(char *bufp) { #ifdef NOCWD_ASSUMPTIONS @@ -2570,7 +2569,7 @@ cnf_line_HACKDIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_LEVELDIR(char *bufp) { #ifdef NOCWD_ASSUMPTIONS @@ -2590,7 +2589,7 @@ cnf_line_LEVELDIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_SAVEDIR(char *bufp) { #ifdef NOCWD_ASSUMPTIONS @@ -2612,7 +2611,7 @@ cnf_line_SAVEDIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_BONESDIR(char *bufp) { #ifdef NOCWD_ASSUMPTIONS @@ -2623,7 +2622,7 @@ cnf_line_BONESDIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_DATADIR(char *bufp) { #ifdef NOCWD_ASSUMPTIONS @@ -2634,7 +2633,7 @@ cnf_line_DATADIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_SCOREDIR(char *bufp) { #ifdef NOCWD_ASSUMPTIONS @@ -2645,7 +2644,7 @@ cnf_line_SCOREDIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_LOCKDIR(char *bufp) { #ifdef NOCWD_ASSUMPTIONS @@ -2656,7 +2655,7 @@ cnf_line_LOCKDIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_CONFIGDIR(char *bufp) { #ifdef NOCWD_ASSUMPTIONS @@ -2667,7 +2666,7 @@ cnf_line_CONFIGDIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_TROUBLEDIR(char *bufp) { #ifdef NOCWD_ASSUMPTIONS @@ -2678,14 +2677,14 @@ cnf_line_TROUBLEDIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_NAME(char *bufp) { (void) strncpy(gp.plname, bufp, PL_NSIZ - 1); return TRUE; } -static boolean +staticfn boolean cnf_line_ROLE(char *bufp) { int len; @@ -2695,21 +2694,21 @@ cnf_line_ROLE(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_dogname(char *bufp) { (void) strncpy(gd.dogname, bufp, PL_PSIZ - 1); return TRUE; } -static boolean +staticfn boolean cnf_line_catname(char *bufp) { (void) strncpy(gc.catname, bufp, PL_PSIZ - 1); return TRUE; } -static boolean +staticfn boolean cnf_line_WIZARDS(char *bufp) { if (sysopt.wizards) @@ -2726,7 +2725,7 @@ cnf_line_WIZARDS(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_SHELLERS(char *bufp) { if (sysopt.shellers) @@ -2735,7 +2734,7 @@ cnf_line_SHELLERS(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_EXPLORERS(char *bufp) { if (sysopt.explorers) @@ -2744,7 +2743,7 @@ cnf_line_EXPLORERS(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_DEBUGFILES(char *bufp) { /* if showdebug() has already been called (perhaps we've added @@ -2758,7 +2757,7 @@ cnf_line_DEBUGFILES(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_DUMPLOGFILE(char *bufp) { #ifdef DUMPLOG @@ -2771,7 +2770,7 @@ cnf_line_DUMPLOGFILE(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_GENERICUSERS(char *bufp) { if (sysopt.genericusers) @@ -2780,7 +2779,7 @@ cnf_line_GENERICUSERS(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_BONES_POOLS(char *bufp) { /* max value of 10 guarantees (N % bones.pools) will be one digit @@ -2794,7 +2793,7 @@ cnf_line_BONES_POOLS(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_SUPPORT(char *bufp) { if (sysopt.support) @@ -2803,7 +2802,7 @@ cnf_line_SUPPORT(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_RECOVER(char *bufp) { if (sysopt.recover) @@ -2812,7 +2811,7 @@ cnf_line_RECOVER(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_CHECK_SAVE_UID(char *bufp) { int n = atoi(bufp); @@ -2821,7 +2820,7 @@ cnf_line_CHECK_SAVE_UID(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_CHECK_PLNAME(char *bufp) { int n = atoi(bufp); @@ -2830,7 +2829,7 @@ cnf_line_CHECK_PLNAME(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_SEDUCE(char *bufp) { int n = !!atoi(bufp); /* XXX this could be tighter */ @@ -2852,7 +2851,7 @@ cnf_line_SEDUCE(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_HIDEUSAGE(char *bufp) { int n = !!atoi(bufp); @@ -2861,7 +2860,7 @@ cnf_line_HIDEUSAGE(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_MAXPLAYERS(char *bufp) { int n = atoi(bufp); @@ -2875,7 +2874,7 @@ cnf_line_MAXPLAYERS(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_PERSMAX(char *bufp) { int n = atoi(bufp); @@ -2888,7 +2887,7 @@ cnf_line_PERSMAX(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_PERS_IS_UID(char *bufp) { int n = atoi(bufp); @@ -2901,7 +2900,7 @@ cnf_line_PERS_IS_UID(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_ENTRYMAX(char *bufp) { int n = atoi(bufp); @@ -2914,7 +2913,7 @@ cnf_line_ENTRYMAX(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_POINTSMIN(char *bufp) { int n = atoi(bufp); @@ -2927,7 +2926,7 @@ cnf_line_POINTSMIN(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_MAX_STATUENAME_RANK(char *bufp) { int n = atoi(bufp); @@ -2941,7 +2940,7 @@ cnf_line_MAX_STATUENAME_RANK(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_LIVELOG(char *bufp) { /* using 0 for base accepts "dddd" as decimal provided that first 'd' @@ -2958,7 +2957,7 @@ cnf_line_LIVELOG(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_PANICTRACE_LIBC(char *bufp) { int n = atoi(bufp); @@ -2973,7 +2972,7 @@ cnf_line_PANICTRACE_LIBC(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_PANICTRACE_GDB(char *bufp) { int n = atoi(bufp); @@ -2988,7 +2987,7 @@ cnf_line_PANICTRACE_GDB(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_GDBPATH(char *bufp) { #if defined(PANICTRACE) && !defined(VMS) @@ -3003,7 +3002,7 @@ cnf_line_GDBPATH(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_GREPPATH(char *bufp) { #if defined(PANICTRACE) && !defined(VMS) @@ -3018,7 +3017,7 @@ cnf_line_GREPPATH(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_CRASHREPORTURL(char *bufp) { if (sysopt.crashreporturl) @@ -3027,21 +3026,21 @@ cnf_line_CRASHREPORTURL(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_SAVEFORMAT(char *bufp) { parseformat(sysopt.saveformat, bufp); return TRUE; } -static boolean +staticfn boolean cnf_line_BONESFORMAT(char *bufp) { parseformat(sysopt.bonesformat, bufp); return TRUE; } -static boolean +staticfn boolean cnf_line_ACCESSIBILITY(char *bufp) { int n = atoi(bufp); @@ -3054,7 +3053,7 @@ cnf_line_ACCESSIBILITY(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_PORTABLE_DEVICE_PATHS(char *bufp) { #ifdef WIN32 @@ -3073,7 +3072,7 @@ cnf_line_PORTABLE_DEVICE_PATHS(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_BOULDER(char *bufp) { (void) get_uchars(bufp, &go.ov_primary_syms[SYM_BOULDER + SYM_OFF_X], @@ -3081,13 +3080,13 @@ cnf_line_BOULDER(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_MENUCOLOR(char *bufp) { return add_menu_coloring(bufp); } -static boolean +staticfn boolean cnf_line_HILITE_STATUS(char *bufp) { #ifdef STATUS_HILITES @@ -3098,7 +3097,7 @@ cnf_line_HILITE_STATUS(char *bufp) #endif } -static boolean +staticfn boolean cnf_line_WARNINGS(char *bufp) { uchar translate[MAXPCHARS]; @@ -3108,7 +3107,7 @@ cnf_line_WARNINGS(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_ROGUESYMBOLS(char *bufp) { if (parsesymbols(bufp, ROGUESET)) { @@ -3119,7 +3118,7 @@ cnf_line_ROGUESYMBOLS(char *bufp) return FALSE; } -static boolean +staticfn boolean cnf_line_SYMBOLS(char *bufp) { if (parsesymbols(bufp, PRIMARYSET)) { @@ -3130,7 +3129,7 @@ cnf_line_SYMBOLS(char *bufp) return FALSE; } -static boolean +staticfn boolean cnf_line_WIZKIT(char *bufp) { (void) strncpy(gw.wizkit, bufp, WIZKIT_MAX - 1); @@ -3138,7 +3137,7 @@ cnf_line_WIZKIT(char *bufp) } #ifdef USER_SOUNDS -static boolean +staticfn boolean cnf_line_SOUNDDIR(char *bufp) { if (sounddir) @@ -3147,7 +3146,7 @@ cnf_line_SOUNDDIR(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_SOUND(char *bufp) { add_sound_mapping(bufp); @@ -3155,7 +3154,7 @@ cnf_line_SOUND(char *bufp) } #endif /*USER_SOUNDS*/ -static boolean +staticfn boolean cnf_line_QT_TILEWIDTH(char *bufp) { #ifdef QT_GRAPHICS @@ -3169,7 +3168,7 @@ cnf_line_QT_TILEWIDTH(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_QT_TILEHEIGHT(char *bufp) { #ifdef QT_GRAPHICS @@ -3183,7 +3182,7 @@ cnf_line_QT_TILEHEIGHT(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_QT_FONTSIZE(char *bufp) { #ifdef QT_GRAPHICS @@ -3197,7 +3196,7 @@ cnf_line_QT_FONTSIZE(char *bufp) return TRUE; } -static boolean +staticfn boolean cnf_line_QT_COMPACT(char *bufp) { #ifdef QT_GRAPHICS @@ -3400,7 +3399,7 @@ config_error_init(boolean from_file, const char *sourcename, boolean secure) gp.program_state.config_error_ready = TRUE; } -static boolean +staticfn boolean config_error_nextline(const char *line) { struct _config_error_frame *ced = config_error_data; @@ -3564,7 +3563,7 @@ struct _cnf_parser_state { }; /* Initialize config parser data */ -static void +staticfn void cnf_parser_init(struct _cnf_parser_state *parser) { parser->rv = TRUE; /* assume successful parse */ @@ -3579,7 +3578,7 @@ cnf_parser_init(struct _cnf_parser_state *parser) } /* caller has finished with 'parser' (except for 'rv' so leave that intact) */ -static void +staticfn void cnf_parser_done(struct _cnf_parser_state *parser) { parser->ep = 0; /* points into parser->inbuf, so becoming stale */ @@ -3595,7 +3594,7 @@ cnf_parser_done(struct _cnf_parser_state *parser) * * Continued lines are merged together with one space in between. */ -static void +staticfn void parse_conf_buf(struct _cnf_parser_state *p, boolean (*proc)(char *arg)) { p->cont = FALSE; @@ -3745,7 +3744,7 @@ parse_conf_str(const char *str, boolean (*proc)(char *arg)) * * Read from file fp, calling parse_conf_buf for each line. */ -static boolean +staticfn boolean parse_conf_file(FILE *fp, boolean (*proc)(char *arg)) { struct _cnf_parser_state parser; @@ -3764,7 +3763,7 @@ parse_conf_file(FILE *fp, boolean (*proc)(char *arg)) return parser.rv; } -static void +staticfn void parseformat(int *arr, char *str) { const char *legal[] = { "historical", "lendian", "ascii" }; @@ -3801,7 +3800,7 @@ parseformat(int *arr, char *str) /* ---------- BEGIN WIZKIT FILE HANDLING ----------- */ -static FILE * +staticfn FILE * fopen_wizkit_file(void) { FILE *fp; @@ -3873,7 +3872,7 @@ fopen_wizkit_file(void) } /* add to hero's inventory if there's room, otherwise put item on floor */ -static void +staticfn void wizkit_addinv(struct obj *obj) { if (!obj || obj == &hands_obj) @@ -3945,8 +3944,7 @@ read_wizkit(void) extern const char *const known_handling[]; /* symbols.c */ extern const char *const known_restrictions[]; /* symbols.c */ -static -FILE * +staticfn FILE * fopen_sym_file(void) { FILE *fp; @@ -4749,11 +4747,11 @@ reveal_paths(void) #define MAXPASSAGES SIZE(gc.context.novel.pasg) /* 20 */ -static int choose_passage(int, unsigned); +staticfn int choose_passage(int, unsigned); /* choose a random passage that hasn't been chosen yet; once all have been chosen, reset the tracking to make all passages available again */ -static int +staticfn int choose_passage(int passagecnt, /* total of available passages */ unsigned oid) /* book.o_id, used to determine whether re-reading same book */ diff --git a/src/fountain.c b/src/fountain.c index 4c53979fd..492ebf6e8 100644 --- a/src/fountain.c +++ b/src/fountain.c @@ -6,12 +6,12 @@ #include "hack.h" -static void dowatersnakes(void); -static void dowaterdemon(void); -static void dowaternymph(void); -static void gush(coordxy, coordxy, genericptr_t) NONNULLARG3; -static void dofindgem(void); -static boolean watchman_warn_fountain(struct monst *) NONNULLARG1; +staticfn void dowatersnakes(void); +staticfn void dowaterdemon(void); +staticfn void dowaternymph(void); +staticfn void gush(coordxy, coordxy, genericptr_t) NONNULLARG3; +staticfn void dofindgem(void); +staticfn boolean watchman_warn_fountain(struct monst *) NONNULLARG1; DISABLE_WARNING_FORMAT_NONLITERAL @@ -34,7 +34,7 @@ floating_above(const char *what) RESTORE_WARNING_FORMAT_NONLITERAL /* Fountain of snakes! */ -static void +staticfn void dowatersnakes(void) { int num = rn1(5, 2); @@ -60,7 +60,7 @@ dowatersnakes(void) } /* Water demon */ -static void +staticfn void dowaterdemon(void) { struct monst *mtmp; @@ -90,7 +90,7 @@ dowaterdemon(void) } /* Water Nymph */ -static void +staticfn void dowaternymph(void) { struct monst *mtmp; @@ -130,7 +130,7 @@ dogushforth(int drinking) } } -static void +staticfn void gush(coordxy x, coordxy y, genericptr_t poolcnt) { struct monst *mtmp; @@ -161,7 +161,7 @@ gush(coordxy x, coordxy y, genericptr_t poolcnt) } /* Find a gem in the sparkling waters. */ -static void +staticfn void dofindgem(void) { if (!Blind) @@ -175,7 +175,7 @@ dofindgem(void) exercise(A_WIS, TRUE); /* a discovery! */ } -static boolean +staticfn boolean watchman_warn_fountain(struct monst *mtmp) { if (is_watch(mtmp->data) && couldsee(mtmp->mx, mtmp->my) diff --git a/src/getpos.c b/src/getpos.c index 527e7afea..417073a45 100644 --- a/src/getpos.c +++ b/src/getpos.c @@ -6,25 +6,25 @@ extern const char what_is_an_unknown_object[]; /* from pager.c */ -static void getpos_toggle_hilite_state(void); -static void getpos_getvalids_selection(struct selectionvar *, +staticfn void getpos_toggle_hilite_state(void); +staticfn void getpos_getvalids_selection(struct selectionvar *, boolean (*)(coordxy, coordxy)); -static void getpos_help_keyxhelp(winid, const char *, const char *, int); -static void getpos_help(boolean, const char *); -static int QSORTCALLBACK cmp_coord_distu(const void *, const void *); -static int gloc_filter_classify_glyph(int); -static int gloc_filter_floodfill_matcharea(coordxy, coordxy); -static void gloc_filter_floodfill(coordxy, coordxy); -static void gloc_filter_init(void); -static void gloc_filter_done(void); -static void gather_locs(coord **, int *, int); -static void truncate_to_map(coordxy *, coordxy *, schar, schar); -static void getpos_refresh(void); +staticfn void getpos_help_keyxhelp(winid, const char *, const char *, int); +staticfn void getpos_help(boolean, const char *); +staticfn int QSORTCALLBACK cmp_coord_distu(const void *, const void *); +staticfn int gloc_filter_classify_glyph(int); +staticfn int gloc_filter_floodfill_matcharea(coordxy, coordxy); +staticfn void gloc_filter_floodfill(coordxy, coordxy); +staticfn void gloc_filter_init(void); +staticfn void gloc_filter_done(void); +staticfn void gather_locs(coord **, int *, int); +staticfn void truncate_to_map(coordxy *, coordxy *, schar, schar); +staticfn void getpos_refresh(void); /* Callback function for getpos() to highlight desired map locations. * Parameter TRUE: initialize and highlight, FALSE: done (remove highlights). */ -static void (*getpos_hilitefunc)(boolean) = (void (*)(boolean)) 0; -static boolean (*getpos_getvalid)(coordxy, coordxy) +staticfn void (*getpos_hilitefunc)(boolean) = (void (*)(boolean)) 0; +staticfn boolean (*getpos_getvalid)(coordxy, coordxy) = (boolean (*)(coordxy, coordxy)) 0; enum getposHiliteState { HiliteNormalMap = 0, @@ -67,7 +67,7 @@ getpos_sethilite( positions and showing them via temporary S_goodpos symbol; when 'bgcolors' is On, there are three states and showing them via setting background color becomes the default */ -static void +staticfn void getpos_toggle_hilite_state(void) { /* getpos_hilitefunc isn't Null */ @@ -97,7 +97,7 @@ mapxy_valid(coordxy x, coordxy y) return FALSE; } -static void +staticfn void getpos_getvalids_selection( struct selectionvar *sel, boolean (*validf)(coordxy, coordxy)) @@ -132,7 +132,7 @@ static const char *const gloc_filtertxt[NUM_GFILTER] = { " in this area" }; -static void +staticfn void getpos_help_keyxhelp( winid tmpwin, const char *k1, const char *k2, @@ -162,7 +162,7 @@ getpos_help_keyxhelp( DISABLE_WARNING_FORMAT_NONLITERAL /* the response for '?' help request in getpos() */ -static void +staticfn void getpos_help(boolean force, const char *goal) { static const char *const fastmovemode[2] = { "8 units at a time", @@ -307,7 +307,7 @@ getpos_help(boolean force, const char *goal) RESTORE_WARNING_FORMAT_NONLITERAL -static int QSORTCALLBACK +staticfn int QSORTCALLBACK cmp_coord_distu(const void *a, const void *b) { const coord *c1 = a; @@ -336,7 +336,7 @@ cmp_coord_distu(const void *a, const void *b) (isok((x), (y)) \ && (selection_getpoint((x),(y), gg.gloc_filter_map))) -static int +staticfn int gloc_filter_classify_glyph(int glyph) { int c; @@ -359,7 +359,7 @@ gloc_filter_classify_glyph(int glyph) return 0; } -static int +staticfn int gloc_filter_floodfill_matcharea(coordxy x, coordxy y) { int glyph = back_to_glyph(x, y); @@ -377,7 +377,7 @@ gloc_filter_floodfill_matcharea(coordxy x, coordxy y) return FALSE; } -static void +staticfn void gloc_filter_floodfill(coordxy x, coordxy y) { gg.gloc_filter_floodfill_match_glyph = back_to_glyph(x, y); @@ -386,7 +386,7 @@ gloc_filter_floodfill(coordxy x, coordxy y) selection_floodfill(gg.gloc_filter_map, x, y, FALSE); } -static void +staticfn void gloc_filter_init(void) { if (iflags.getloc_filter == GFILTER_AREA) { @@ -407,7 +407,7 @@ gloc_filter_init(void) } } -static void +staticfn void gloc_filter_done(void) { if (gg.gloc_filter_map) { @@ -490,7 +490,7 @@ gather_locs_interesting(coordxy x, coordxy y, int gloc) RESTORE_WARNINGS /* gather locations for monsters or objects shown on the map */ -static void +staticfn void gather_locs(coord **arr_p, int *cnt_p, int gloc) { int pass, idx; @@ -706,7 +706,7 @@ getpos_menu(coord *ccp, int gloc) } /* add dx,dy to cx,cy, truncating at map edges */ -static void +staticfn void truncate_to_map(coordxy *cx, coordxy *cy, schar dx, schar dy) { /* diagonal moves complicate this... */ @@ -730,7 +730,7 @@ truncate_to_map(coordxy *cx, coordxy *cy, schar dx, schar dy) /* called when ^R typed; if '$' is being shown for valid spots, remove that; if alternate background color is being shown for that, redraw it */ -static void +staticfn void getpos_refresh(void) { if (getpos_hilitefunc && getpos_hilite_state == HiliteGoodposSymbol) { diff --git a/src/hack.c b/src/hack.c index 88fab01be..76bc26790 100644 --- a/src/hack.c +++ b/src/hack.c @@ -8,40 +8,40 @@ /* #define DEBUG */ /* uncomment for debugging */ -static boolean could_move_onto_boulder(coordxy, coordxy); -static int moverock(void); -static void dosinkfall(void); -static boolean findtravelpath(int); -static boolean trapmove(coordxy, coordxy, struct trap *); -static int QSORTCALLBACK notice_mons_cmp(const genericptr, const genericptr); -static schar u_simple_floortyp(coordxy, coordxy); -static boolean swim_move_danger(coordxy, coordxy); -static boolean domove_bump_mon(struct monst *, int) NONNULLARG1; -static boolean domove_attackmon_at(struct monst *, coordxy, coordxy, +staticfn boolean could_move_onto_boulder(coordxy, coordxy); +staticfn int moverock(void); +staticfn void dosinkfall(void); +staticfn boolean findtravelpath(int); +staticfn boolean trapmove(coordxy, coordxy, struct trap *); +staticfn int QSORTCALLBACK notice_mons_cmp(const genericptr, const genericptr); +staticfn schar u_simple_floortyp(coordxy, coordxy); +staticfn boolean swim_move_danger(coordxy, coordxy); +staticfn boolean domove_bump_mon(struct monst *, int) NONNULLARG1; +staticfn boolean domove_attackmon_at(struct monst *, coordxy, coordxy, boolean *) NONNULLPTRS; -static boolean domove_fight_ironbars(coordxy, coordxy); -static boolean domove_fight_web(coordxy, coordxy); -static boolean domove_swap_with_pet(struct monst *, +staticfn boolean domove_fight_ironbars(coordxy, coordxy); +staticfn boolean domove_fight_web(coordxy, coordxy); +staticfn boolean domove_swap_with_pet(struct monst *, coordxy, coordxy) NONNULLARG1; -static boolean domove_fight_empty(coordxy, coordxy); -static boolean air_turbulence(void); -static void slippery_ice_fumbling(void); -static boolean impaired_movement(coordxy *, coordxy *) NONNULLPTRS; -static boolean avoid_moving_on_trap(coordxy, coordxy, boolean); -static boolean avoid_moving_on_liquid(coordxy, coordxy, boolean); -static boolean avoid_running_into_trap_or_liquid(coordxy, coordxy); -static boolean move_out_of_bounds(coordxy, coordxy); -static boolean carrying_too_much(void); -static boolean escape_from_sticky_mon(coordxy, coordxy); -static void domove_core(void); -static void maybe_smudge_engr(coordxy, coordxy, coordxy, coordxy); -static struct monst *monstinroom(struct permonst *, int) NONNULLARG1; -static boolean furniture_present(int, int); -static void move_update(boolean); -static int pickup_checks(void); -static boolean doorless_door(coordxy, coordxy); -static void maybe_wail(void); -static boolean water_turbulence(coordxy *, coordxy *); +staticfn boolean domove_fight_empty(coordxy, coordxy); +staticfn boolean air_turbulence(void); +staticfn void slippery_ice_fumbling(void); +staticfn boolean impaired_movement(coordxy *, coordxy *) NONNULLPTRS; +staticfn boolean avoid_moving_on_trap(coordxy, coordxy, boolean); +staticfn boolean avoid_moving_on_liquid(coordxy, coordxy, boolean); +staticfn boolean avoid_running_into_trap_or_liquid(coordxy, coordxy); +staticfn boolean move_out_of_bounds(coordxy, coordxy); +staticfn boolean carrying_too_much(void); +staticfn boolean escape_from_sticky_mon(coordxy, coordxy); +staticfn void domove_core(void); +staticfn void maybe_smudge_engr(coordxy, coordxy, coordxy, coordxy); +staticfn struct monst *monstinroom(struct permonst *, int) NONNULLARG1; +staticfn boolean furniture_present(int, int); +staticfn void move_update(boolean); +staticfn int pickup_checks(void); +staticfn boolean doorless_door(coordxy, coordxy); +staticfn void maybe_wail(void); +staticfn boolean water_turbulence(coordxy *, coordxy *); #define IS_SHOP(x) (gr.rooms[x].rtype >= SHOPBASE) @@ -131,7 +131,7 @@ revive_nasty(coordxy x, coordxy y, const char *msg) /* can hero move onto a spot containing one or more boulders? used for m and travel and during boulder push failure */ -static boolean +staticfn boolean could_move_onto_boulder(coordxy sx, coordxy sy) { /* can if able to phaze through rock (must be poly'd, so not riding) */ @@ -152,7 +152,7 @@ could_move_onto_boulder(coordxy sx, coordxy sy) return squeezeablylightinvent(); } -static int +staticfn int moverock(void) { coordxy rx, ry, sx, sy; @@ -752,7 +752,7 @@ movobj(struct obj *obj, coordxy ox, coordxy oy) newsym(ox, oy); } -static void +staticfn void dosinkfall(void) { static const char fell_on_sink[] = "fell onto a sink"; @@ -1164,7 +1164,7 @@ test_move( * gt.travelmap keeps track of map locations we've moved through * this travel session. It will be cleared once the travel stops. */ -static boolean +staticfn boolean findtravelpath(int mode) { if (!gt.travelmap) @@ -1446,7 +1446,7 @@ is_valid_travelpt(coordxy x, coordxy y) /* try to escape being stuck in a trapped state by walking out of it; return true iff moving should continue to intended destination (all failures and most successful escapes leave hero at original spot) */ -static boolean +staticfn boolean trapmove( coordxy x, coordxy y, /* targeted destination, */ struct trap *desttrap) /* nonnull if another trap at */ @@ -1631,7 +1631,7 @@ notice_mon(struct monst *mtmp) } } -static int QSORTCALLBACK +staticfn int QSORTCALLBACK notice_mons_cmp(const genericptr ptr1, const genericptr ptr2) { const struct monst *m1 = *(const struct monst **) ptr1, @@ -1720,7 +1720,7 @@ u_locomotion(const char *def) } /* Return a simplified floor solid/liquid state based on hero's state */ -static schar +staticfn schar u_simple_floortyp(coordxy x, coordxy y) { boolean u_in_air = (Levitation || Flying || !grounded(gy.youmonst.data)); @@ -1768,7 +1768,7 @@ handle_tip(int tip) } /* Is it dangerous for hero to move to x,y due to water or lava? */ -static boolean +staticfn boolean swim_move_danger(coordxy x, coordxy y) { schar newtyp = u_simple_floortyp(x, y); @@ -1809,7 +1809,7 @@ swim_move_danger(coordxy x, coordxy y) } /* moving with 'm' prefix, bump into a monster? */ -static boolean +staticfn boolean domove_bump_mon(struct monst *mtmp, int glyph) { /* If they used a 'm' command, trying to move onto a monster @@ -1839,7 +1839,7 @@ domove_bump_mon(struct monst *mtmp, int glyph) returns TRUE if hero movement is used up. sets displaceu, if hero and monster could swap places instead. */ -static boolean +staticfn boolean domove_attackmon_at( struct monst *mtmp, coordxy x, coordxy y, @@ -1878,7 +1878,7 @@ domove_attackmon_at( } /* force-fight iron bars with your weapon? */ -static boolean +staticfn boolean domove_fight_ironbars(coordxy x, coordxy y) { if (gc.context.forcefight && levl[x][y].typ == IRONBARS && uwep) { @@ -1903,7 +1903,7 @@ domove_fight_ironbars(coordxy x, coordxy y) } /* force-fight a spider web with your weapon */ -static boolean +staticfn boolean domove_fight_web(coordxy x, coordxy y) { struct trap *trap = t_at(x, y); @@ -1980,7 +1980,7 @@ domove_fight_web(coordxy x, coordxy y) } /* maybe swap places with a pet? returns TRUE if swapped places */ -static boolean +staticfn boolean domove_swap_with_pet(struct monst *mtmp, coordxy x, coordxy y) { struct trap *trap; @@ -2100,7 +2100,7 @@ domove_swap_with_pet(struct monst *mtmp, coordxy x, coordxy y) } /* force-fight (x,y) which doesn't have anything to fight */ -static boolean +staticfn boolean domove_fight_empty(coordxy x, coordxy y) { static const char unknown_obstacle[] = "an unknown obstacle"; @@ -2211,7 +2211,7 @@ domove_fight_empty(coordxy x, coordxy y) } /* does the plane of air disturb movement? */ -static boolean +staticfn boolean air_turbulence(void) { if (Is_airlevel(&u.uz) && rn2(4) && !Levitation && !Flying) { @@ -2234,7 +2234,7 @@ air_turbulence(void) } /* does water disturb the movement? */ -static boolean +staticfn boolean water_turbulence(coordxy *x, coordxy *y) { if (u.uinwater) { @@ -2265,7 +2265,7 @@ water_turbulence(coordxy *x, coordxy *y) return FALSE; } -static void +staticfn void slippery_ice_fumbling(void) { boolean on_ice = !Levitation && is_ice(u.ux, u.uy); @@ -2294,7 +2294,7 @@ u_maybe_impaired(void) } /* change movement dir if impaired. return TRUE if can't move */ -static boolean +staticfn boolean impaired_movement(coordxy *x, coordxy *y) { if (u_maybe_impaired()) { @@ -2313,7 +2313,7 @@ impaired_movement(coordxy *x, coordxy *y) return FALSE; } -static boolean +staticfn boolean avoid_moving_on_trap(coordxy x, coordxy y, boolean msg) { struct trap *trap; @@ -2329,7 +2329,7 @@ avoid_moving_on_trap(coordxy x, coordxy y, boolean msg) return FALSE; } -static boolean +staticfn boolean avoid_moving_on_liquid( coordxy x, coordxy y, boolean msg) @@ -2361,7 +2361,7 @@ avoid_moving_on_liquid( /* when running/rushing, avoid stepping on a known trap or pool of liquid. returns TRUE if avoided. */ -static boolean +staticfn boolean avoid_running_into_trap_or_liquid(coordxy x, coordxy y) { boolean would_stop = (gc.context.run >= 2); @@ -2379,7 +2379,7 @@ avoid_running_into_trap_or_liquid(coordxy x, coordxy y) } /* trying to move out-of-bounds? */ -static boolean +staticfn boolean move_out_of_bounds(coordxy x, coordxy y) { if (!isok(x, y)) { @@ -2409,7 +2409,7 @@ move_out_of_bounds(coordxy x, coordxy y) } /* carrying too much to be able to move? */ -static boolean +staticfn boolean carrying_too_much(void) { int wtcap; @@ -2432,7 +2432,7 @@ carrying_too_much(void) /* try to pull free from sticking monster, or you release a monster you're sticking to. returns TRUE if you lose your movement. */ -static boolean +staticfn boolean escape_from_sticky_mon(coordxy x, coordxy y) { if (u.ustuck && (x != u.ustuck->mx || y != u.ustuck->my)) { @@ -2499,7 +2499,7 @@ domove(void) gd.domove_attempting = 0L; } -static void +staticfn void domove_core(void) { struct monst *mtmp; @@ -2831,7 +2831,7 @@ runmode_delay_output(void) } } -static void +staticfn void maybe_smudge_engr(coordxy x1, coordxy y1, coordxy x2, coordxy y2) { struct engr *ep; @@ -3181,7 +3181,7 @@ spoteffects(boolean pick) } /* returns first matching monster */ -static struct monst * +staticfn struct monst * monstinroom(struct permonst *mdat, int roomno) { struct monst *mtmp; @@ -3197,7 +3197,7 @@ monstinroom(struct permonst *mdat, int roomno) } /* check whether room contains a particular type of furniture */ -static boolean +staticfn boolean furniture_present(int furniture, int roomno) { int x, y, lx, ly, hx, hy; @@ -3303,7 +3303,7 @@ in_town(coordxy x, coordxy y) return !has_subrooms; } -static void +staticfn void move_update(boolean newlev) { char c, *ptr1, *ptr2, *ptr3, *ptr4; @@ -3502,7 +3502,7 @@ check_special_room(boolean newlev) 0 = cannot pickup, no time taken -1 = do normal pickup -2 = loot the monster */ -static int +staticfn int pickup_checks(void) { struct trap *traphere; @@ -3776,7 +3776,7 @@ lookaround(void) } /* check for a doorway which lacks its door (NODOOR or BROKEN) */ -static boolean +staticfn boolean doorless_door(coordxy x, coordxy y) { struct rm *lev_p = &levl[x][y]; @@ -3914,7 +3914,7 @@ unmul(const char *msg_override) } } -static void +staticfn void maybe_wail(void) { static short powers[] = { TELEPORT, SEE_INVIS, POISON_RES, COLD_RES, diff --git a/src/insight.c b/src/insight.c index b81ece08e..70f701046 100644 --- a/src/insight.c +++ b/src/insight.c @@ -14,28 +14,28 @@ #include "hack.h" -static void enlght_out(const char *); -static void enlght_line(const char *, const char *, const char *, +staticfn void enlght_out(const char *); +staticfn void enlght_line(const char *, const char *, const char *, const char *); -static char *enlght_combatinc(const char *, int, int, char *); -static void enlght_halfdmg(int, int); -static boolean walking_on_water(void); -static boolean cause_known(int); -static char *attrval(int, int, char *); -static char *fmt_elapsed_time(char *, int); -static void background_enlightenment(int, int); -static void basics_enlightenment(int, int); -static void characteristics_enlightenment(int, int); -static void one_characteristic(int, int, int); -static void status_enlightenment(int, int); -static void weapon_insight(int); -static void attributes_enlightenment(int, int); -static void show_achievements(int); -static int QSORTCALLBACK vanqsort_cmp(const genericptr, const genericptr); -static int num_extinct(void); -static int num_gone(int, int *); -static char *size_str(int); -static void item_resistance_message(int, const char *, int); +staticfn char *enlght_combatinc(const char *, int, int, char *); +staticfn void enlght_halfdmg(int, int); +staticfn boolean walking_on_water(void); +staticfn boolean cause_known(int); +staticfn char *attrval(int, int, char *); +staticfn char *fmt_elapsed_time(char *, int); +staticfn void background_enlightenment(int, int); +staticfn void basics_enlightenment(int, int); +staticfn void characteristics_enlightenment(int, int); +staticfn void one_characteristic(int, int, int); +staticfn void status_enlightenment(int, int); +staticfn void weapon_insight(int); +staticfn void attributes_enlightenment(int, int); +staticfn void show_achievements(int); +staticfn int QSORTCALLBACK vanqsort_cmp(const genericptr, const genericptr); +staticfn int num_extinct(void); +staticfn int num_gone(int, int *); +staticfn char *size_str(int); +staticfn void item_resistance_message(int, const char *, int); extern const char *const hu_stat[]; /* hunger status from eat.c */ extern const char *const enc_stat[]; /* encumbrance status from botl.c */ @@ -112,7 +112,7 @@ static struct ll_achieve_msg achieve_msg [] = { #define you_have_X(something) \ enl_msg(You_, have, (const char *) "", (something), "") -static void +staticfn void enlght_out(const char *buf) { if (ge.en_via_menu) { @@ -121,7 +121,7 @@ enlght_out(const char *buf) putstr(ge.en_win, 0, buf); } -static void +staticfn void enlght_line( const char *start, const char *middle, @@ -154,7 +154,7 @@ enlght_line( } /* format increased chance to hit or damage or defense (Protection) */ -static char * +staticfn char * enlght_combatinc(const char *inctyp, int incamt, int final, char *outbuf) { const char *modif, *bonus; @@ -191,7 +191,7 @@ enlght_combatinc(const char *inctyp, int incamt, int final, char *outbuf) } /* report half physical or half spell damage */ -static void +staticfn void enlght_halfdmg(int category, int final) { const char *category_name; @@ -214,7 +214,7 @@ enlght_halfdmg(int category, int final) } /* is hero actively using water walking capability on water (or lava)? */ -static boolean +staticfn boolean walking_on_water(void) { if (u.uinwater || Levitation || Flying) @@ -257,7 +257,7 @@ trap_predicament(char *outbuf, int final, boolean wizxtra) /* check whether hero is wearing something that player definitely knows confers the target property; item must have been seen and its type discovered but it doesn't necessarily have to be fully identified */ -static boolean +staticfn boolean cause_known( int propindx) /* index of a property which can be conveyed by worn item */ { @@ -277,7 +277,7 @@ cause_known( } /* format a characteristic value, accommodating Strength's strangeness */ -static char * +staticfn char * attrval( int attrindx, int attrvalue, @@ -304,7 +304,7 @@ attrval( (note: for a list of more than two entries, nethack usually includes the [style-wise] optional comma before "and" but in this instance it does not) */ -static char * +staticfn char * fmt_elapsed_time(char *outbuf, int final) { int fieldcnt; @@ -432,7 +432,7 @@ enlightenment( /*ARGSUSED*/ /* display role, race, alignment and such to en_win */ -static void +staticfn void background_enlightenment(int unused_mode UNUSED, int final) { const char *role_titl, *rank_titl; @@ -691,7 +691,7 @@ background_enlightenment(int unused_mode UNUSED, int final) /* hit points, energy points, armor class -- essential information which doesn't fit very well in other categories */ /*ARGSUSED*/ -static void +staticfn void basics_enlightenment(int mode UNUSED, int final) { static char Power[] = "energy points (spell power)"; @@ -790,7 +790,7 @@ basics_enlightenment(int mode UNUSED, int final) } /* characteristics: expanded version of bottom line strength, dexterity, &c */ -static void +staticfn void characteristics_enlightenment(int mode, int final) { char buf[BUFSZ]; @@ -809,7 +809,7 @@ characteristics_enlightenment(int mode, int final) } /* display one attribute value for characteristics_enlightenment() */ -static void +staticfn void one_characteristic(int mode, int final, int attrindx) { extern const char *const attrname[]; /* attrib.c */ @@ -903,7 +903,7 @@ one_characteristic(int mode, int final, int attrindx) } /* status: selected obvious capabilities, assorted troubles */ -static void +staticfn void status_enlightenment(int mode, int final) { boolean magic = (mode & MAGICENLIGHTENMENT) ? TRUE : FALSE; @@ -1232,7 +1232,7 @@ status_enlightenment(int mode, int final) } /* extracted from status_enlightenment() to reduce clutter there */ -static void +staticfn void weapon_insight(int final) { char buf[BUFSZ]; @@ -1430,7 +1430,7 @@ weapon_insight(int final) } /* skill applies */ } -static void +staticfn void item_resistance_message( int adtyp, const char *prot_message, @@ -1449,7 +1449,7 @@ item_resistance_message( } /* attributes: intrinsics and the like, other non-obvious capabilities */ -static void +staticfn void attributes_enlightenment( int unused_mode UNUSED, int final) @@ -2190,7 +2190,7 @@ show_conduct(int final) * Achievements (see 'enum achievements' in you.h). */ -static void +staticfn void show_achievements( int final) /* 'final' is used "behind the curtain" by enl_foo() macros */ { @@ -2547,7 +2547,8 @@ show_gamelog(int final) * Vanquished monsters. */ -/* the two uppercase choices are implemented but suppressed from menu */ +/* the two uppercase choices are implemented but suppressed from menu. + also used in options.c */ const char *const vanqorders[NUM_VANQ_ORDER_MODES][3] = { { "t", "traditional: by monster level", "traditional: by monster level, by internal monster index" }, @@ -2567,7 +2568,7 @@ const char *const vanqorders[NUM_VANQ_ORDER_MODES][3] = { "by count, low to high, by internal index within tied count" }, }; -static int QSORTCALLBACK +staticfn int QSORTCALLBACK vanqsort_cmp( const genericptr vptr1, const genericptr vptr2) @@ -2879,7 +2880,7 @@ num_genocides(void) } /* return a count of the number of extinct species */ -static int +staticfn int num_extinct(void) { int i, n = 0; @@ -2894,7 +2895,7 @@ num_extinct(void) } /* collect both genocides and extinctions, skipping uniques */ -static int +staticfn int num_gone(int mvflags, int *mindx) { uchar mflg = (uchar) mvflags; @@ -3110,7 +3111,7 @@ align_str(aligntyp alignment) return "unknown"; } -static char * +staticfn char * size_str(int msize) { static char outbuf[40]; diff --git a/src/invent.c b/src/invent.c index dfd9c243c..9cd06a2e4 100644 --- a/src/invent.c +++ b/src/invent.c @@ -10,45 +10,45 @@ #define CONTAINED_SYM '>' /* designator for inside a container */ #define HANDS_SYM '-' /* hands|fingers|self depending on context */ -static void inuse_classify(Loot *, struct obj *); -static char *loot_xname(struct obj *); -static int invletter_value(char); -static int QSORTCALLBACK sortloot_cmp(const genericptr, const genericptr); -static void reorder_invent(void); -static struct obj *addinv_core0(struct obj *, struct obj *, +staticfn void inuse_classify(Loot *, struct obj *); +staticfn char *loot_xname(struct obj *); +staticfn int invletter_value(char); +staticfn int QSORTCALLBACK sortloot_cmp(const genericptr, const genericptr); +staticfn void reorder_invent(void); +staticfn struct obj *addinv_core0(struct obj *, struct obj *, boolean) NONNULLARG1; -static void noarmor(boolean); -static void invdisp_nothing(const char *, const char *); -static boolean worn_wield_only(struct obj *); -static char *cinv_doname(struct obj *); -static char *cinv_ansimpleoname(struct obj *); -static boolean only_here(struct obj *); -static void compactify(char *); -static boolean taking_off(const char *); -static void mime_action(const char *); -static char *getobj_hands_txt(const char *, char *); -static int ckvalidcat(struct obj *); -static int ckunpaid(struct obj *); -static char *safeq_xprname(struct obj *); -static char *safeq_shortxprname(struct obj *); -static char display_pickinv(const char *, const char *, const char *, +staticfn void noarmor(boolean); +staticfn void invdisp_nothing(const char *, const char *); +staticfn boolean worn_wield_only(struct obj *); +staticfn char *cinv_doname(struct obj *); +staticfn char *cinv_ansimpleoname(struct obj *); +staticfn boolean only_here(struct obj *); +staticfn void compactify(char *); +staticfn boolean taking_off(const char *); +staticfn void mime_action(const char *); +staticfn char *getobj_hands_txt(const char *, char *); +staticfn int ckvalidcat(struct obj *); +staticfn int ckunpaid(struct obj *); +staticfn char *safeq_xprname(struct obj *); +staticfn char *safeq_shortxprname(struct obj *); +staticfn char display_pickinv(const char *, const char *, const char *, boolean, boolean, long *); -static char display_used_invlets(char); -static boolean this_type_only(struct obj *); -static void dounpaid(int, int, int); -static struct obj *find_unpaid(struct obj *, struct obj **); -static void menu_identify(int); -static boolean tool_being_used(struct obj *); -static int adjust_ok(struct obj *); -static int adjust_gold_ok(struct obj *); -static int doorganize_core(struct obj *); -static char obj_to_let(struct obj *); -static boolean item_naming_classification(struct obj *, char *, char *); -static int item_reading_classification(struct obj *, char *); -static void ia_addmenu(winid, int, char, const char *); -static void itemactions_pushkeys(struct obj *, int); -static int itemactions(struct obj *); -static int dispinv_with_action(char *, boolean, const char *); +staticfn char display_used_invlets(char); +staticfn boolean this_type_only(struct obj *); +staticfn void dounpaid(int, int, int); +staticfn struct obj *find_unpaid(struct obj *, struct obj **); +staticfn void menu_identify(int); +staticfn boolean tool_being_used(struct obj *); +staticfn int adjust_ok(struct obj *); +staticfn int adjust_gold_ok(struct obj *); +staticfn int doorganize_core(struct obj *); +staticfn char obj_to_let(struct obj *); +staticfn boolean item_naming_classification(struct obj *, char *, char *); +staticfn int item_reading_classification(struct obj *, char *); +staticfn void ia_addmenu(winid, int, char, const char *); +staticfn void itemactions_pushkeys(struct obj *, int); +staticfn int itemactions(struct obj *); +staticfn int dispinv_with_action(char *, boolean, const char *); /* enum and structs are defined in wintype.h */ static win_request_info wri_info; @@ -76,7 +76,7 @@ static const char *inuse_headers[] = { /* [4] shown first, [1] last */ /* sortloot() classification for in-use sort; called at most once [per sort] for each object */ -static void +staticfn void inuse_classify(Loot *sort_item, struct obj *obj) { long w_mask = (obj->owornmask & (W_ACCESSORY | W_WEAPONS | W_ARMOR)); @@ -315,7 +315,7 @@ loot_classify(Loot *sort_item, struct obj *obj) } /* sortloot() formatting routine; for alphabetizing, not shown to user */ -static char * +staticfn char * loot_xname(struct obj *obj) { struct obj saveo; @@ -397,7 +397,7 @@ loot_xname(struct obj *obj) } /* '$'==1, 'a'-'z'==2..27, 'A'-'Z'==28..53, '#'==54, catchall 55 */ -static int +staticfn int invletter_value(char c) { return ('a' <= c && c <= 'z') ? (c - 'a' + 2) @@ -408,7 +408,7 @@ invletter_value(char c) } /* qsort comparison routine for sortloot() */ -static int QSORTCALLBACK +staticfn int QSORTCALLBACK sortloot_cmp(const genericptr vptr1, const genericptr vptr2) { struct sortloot_item *sli1 = (struct sortloot_item *) vptr1, @@ -744,7 +744,7 @@ assigninvlet(struct obj *otmp) #define inv_rank(o) ((o)->invlet ^ 040) /* sort the inventory; used by addinv() and doorganize() */ -static void +staticfn void reorder_invent(void) { struct obj *otmp, *prev, *next; @@ -1038,7 +1038,7 @@ addinv_core2(struct obj *obj) * Add obj to the hero's inventory. Make sure the object is "free". * Adjust hero attributes as necessary. */ -static struct obj * +staticfn struct obj * addinv_core0(struct obj *obj, struct obj *other_obj, boolean update_perm_invent) { @@ -1581,7 +1581,7 @@ g_at(coordxy x, coordxy y) } /* compact a string of inventory letters by dashing runs of letters */ -static void +staticfn void compactify(char *buf) { int i1 = 1, i2 = 1; @@ -1626,13 +1626,13 @@ splittable(struct obj *obj) } /* match the prompt for either 'T' or 'R' command */ -static boolean +staticfn boolean taking_off(const char *action) { return !strcmp(action, "take off") || !strcmp(action, "remove"); } -static void +staticfn void mime_action(const char *word) { char buf[BUFSZ]; @@ -1673,7 +1673,7 @@ any_obj_ok(struct obj *obj) } /* return string describing your hands based on action. */ -static char * +staticfn char * getobj_hands_txt(const char *action, char *qbuf) { if (!strcmp(action, "grease")) { @@ -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 */ @@ -2092,14 +2088,14 @@ silly_thing(const char *word, RESTORE_WARNING_FORMAT_NONLITERAL -static int +staticfn int ckvalidcat(struct obj *otmp) { /* use allow_category() from pickup.c */ return (int) allow_category(otmp); } -static int +staticfn int ckunpaid(struct obj *otmp) { return (otmp->unpaid || (Has_contents(otmp) && count_unpaid(otmp->cobj))); @@ -2136,7 +2132,7 @@ static struct xprnctx { } safeq_xprn_ctx; /* safe_qbuf() -> short_oname() callback */ -static char * +staticfn char * safeq_xprname(struct obj *obj) { return xprname(obj, (char *) 0, safeq_xprn_ctx.let, safeq_xprn_ctx.dot, @@ -2144,7 +2140,7 @@ safeq_xprname(struct obj *obj) } /* alternate safe_qbuf() -> short_oname() callback */ -static char * +staticfn char * safeq_shortxprname(struct obj *obj) { return xprname(obj, ansimpleoname(obj), safeq_xprn_ctx.let, @@ -2530,7 +2526,7 @@ identify(struct obj *otmp) } /* menu of unidentified objects; select and identify up to id_limit of them */ -static void +staticfn void menu_identify(int id_limit) { menu_item *pick_list; @@ -2728,7 +2724,7 @@ doperminv(void) } /* should of course only be called for things in invent */ -static char +staticfn char obj_to_let(struct obj *obj) { if (!flags.invlet_constant) { @@ -2855,7 +2851,7 @@ enum item_action_actions { }; /* construct text for the menu entries for IA_NAME_OBJ and IA_NAME_OTYP */ -static boolean +staticfn boolean item_naming_classification( struct obj *obj, char *onamebuf, @@ -2895,7 +2891,7 @@ item_naming_classification( } /* construct text for the menu entries for IA_READ_OBJ */ -static int +staticfn int item_reading_classification(struct obj *obj, char *outbuf) { int otyp = obj->otyp, res = IA_READ_OBJ; @@ -2936,7 +2932,7 @@ item_reading_classification(struct obj *obj, char *outbuf) return res; } -static void +staticfn void ia_addmenu(winid win, int act, char let, const char *txt) { anything any; @@ -2948,7 +2944,7 @@ ia_addmenu(winid win, int act, char let, const char *txt) ATR_NONE, clr, txt, MENU_ITEMFLAGS_NONE); } -static void +staticfn void itemactions_pushkeys(struct obj *otmp, int act) { switch (act) { @@ -3083,7 +3079,7 @@ itemactions_pushkeys(struct obj *otmp, int act) } /* Show menu of possible actions hero could do with item otmp */ -static int +staticfn int itemactions(struct obj *otmp) { int n, act = IA_NONE; @@ -3420,7 +3416,7 @@ itemactions(struct obj *otmp) order to preform context-sensitive item action on it; always returns 'ok'; invent subsets specified by the ')', '[', '(', '=', '"', or '*' commands when they're invoked with the 'm' prefix (or without it for '*') */ -static int +staticfn int dispinv_with_action( char *lets, /* list of invlet values to include */ boolean use_inuse_ordering, /* affects sortloot() and header labels */ @@ -3475,7 +3471,7 @@ ddoinv(void) * next unpaid object is returned. This routine recursively follows * containers. */ -static struct obj * +staticfn struct obj * find_unpaid(struct obj *list, struct obj **last_found) { struct obj *obj; @@ -3511,7 +3507,7 @@ free_pickinv_cache(void) * Internal function used by display_inventory and getobj that can display * inventory and return a count as well as a letter. */ -static char +staticfn char display_pickinv( const char *lets, /* non-compacted list of invlet values */ const char *xtra_choice, /* non-object "bare hands" or "fingers" */ @@ -3906,7 +3902,7 @@ display_inventory(const char *lets, boolean want_reply) * Show what is current using inventory letters. * */ -static char +staticfn char display_used_invlets(char avoidlet) { struct obj *otmp; @@ -4092,7 +4088,7 @@ count_contents( return count; } -static void +staticfn void dounpaid( int count, /* unpaid items in inventory */ int floorcount, /* unpaid items on floor (rare) */ @@ -4231,7 +4227,7 @@ dounpaid( } -static boolean +staticfn boolean this_type_only(struct obj *obj) { boolean res = (obj->oclass == gt.this_type); @@ -4995,7 +4991,7 @@ doprwep(void) } /* caller is responsible for checking !wearing_armor() */ -static void +staticfn void noarmor(boolean report_uskin) { if (!uskin || !report_uskin) { @@ -5115,7 +5111,7 @@ dopramulet(void) } /* is 'obj' a tool that's in use? can't simply check obj->owornmask */ -static boolean +staticfn boolean tool_being_used(struct obj *obj) { /* @@ -5334,7 +5330,7 @@ check_invent_gold(const char *why) /* 'why' == caller in case of warning */ } /* normal getobj callback for item to #adjust; excludes gold */ -static int +staticfn int adjust_ok(struct obj *obj) { if (!obj || obj->oclass == COIN_CLASS) @@ -5344,7 +5340,7 @@ adjust_ok(struct obj *obj) } /* getobj callback for item to #adjust if gold is wonky; allows gold */ -static int +staticfn int adjust_gold_ok(struct obj *obj) { if (!obj) @@ -5485,7 +5481,7 @@ adjust_split(void) return doorganize_core(obj); } -static int +staticfn int doorganize_core(struct obj *obj) { struct obj *otmp, *splitting, *bumped; @@ -5696,7 +5692,7 @@ doorganize_core(struct obj *obj) } /* common to display_minventory and display_cinventory */ -static void +staticfn void invdisp_nothing(const char *hdr, const char *txt) { winid win; @@ -5715,7 +5711,7 @@ invdisp_nothing(const char *hdr, const char *txt) } /* query_objlist callback: return things that are worn or wielded */ -static boolean +staticfn boolean worn_wield_only(struct obj *obj) { #if 1 @@ -5797,7 +5793,7 @@ display_minventory( /* format a container name for cinventory_display(), inserting "trapped" if that's appropriate */ -static char * +staticfn char * cinv_doname(struct obj *obj) { char *result = doname(obj); @@ -5829,7 +5825,7 @@ cinv_doname(struct obj *obj) } /* used by safe_qbuf() if the full doname() result is too long */ -static char * +staticfn char * cinv_ansimpleoname(struct obj *obj) { char *result = ansimpleoname(obj); @@ -5883,7 +5879,7 @@ display_cinventory(struct obj *obj) } -static boolean +staticfn boolean only_here(struct obj *obj) { return (obj->ox == go.only.x && obj->oy == go.only.y); diff --git a/src/isaac64.c b/src/isaac64.c index 7b5d016dd..0fa0e7a8d 100644 --- a/src/isaac64.c +++ b/src/isaac64.c @@ -32,8 +32,8 @@ static inline uint32_t lower_bits(uint64_t); static inline uint32_t upper_bits(uint64_t); -static void isaac64_update(isaac64_ctx *); -static void isaac64_mix(uint64_t[8]); +staticfn void isaac64_update(isaac64_ctx *); +staticfn void isaac64_mix(uint64_t[8]); /* Extract ISAAC64_SZ_LOG bits (starting at bit 3). */ static inline uint32_t lower_bits(uint64_t x) @@ -47,7 +47,7 @@ static inline uint32_t upper_bits(uint64_t y) return (y >> (ISAAC64_SZ_LOG+3)) & (ISAAC64_SZ-1); } -static void isaac64_update(isaac64_ctx *_ctx){ +staticfn void isaac64_update(isaac64_ctx *_ctx){ uint64_t *m; uint64_t *r; uint64_t a; @@ -100,7 +100,7 @@ static void isaac64_update(isaac64_ctx *_ctx){ _ctx->n=ISAAC64_SZ; } -static void isaac64_mix(uint64_t _x[8]){ +staticfn void isaac64_mix(uint64_t _x[8]){ static const unsigned char SHIFT[8]={9,9,23,15,14,20,17,14}; int i; for(i=0;i<8;i++){ diff --git a/src/light.c b/src/light.c index 13708f8c7..aea499de1 100644 --- a/src/light.c +++ b/src/light.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 light.c $NHDT-Date: 1702680171 2023/12/15 22:42:51 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.66 $ */ +/* NetHack 3.7 light.c $NHDT-Date: 1710549969 2024/03/16 00:46:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ */ /* Copyright (c) Dean Luick, 1994 */ /* NetHack may be freely redistributed. See license for details. */ @@ -41,11 +41,12 @@ #define LSF_SHOW 0x1 /* display the light source */ #define LSF_NEEDS_FIXUP 0x2 /* need oid fixup */ -static light_source *new_light_core(coordxy, coordxy, +staticfn light_source *new_light_core(coordxy, coordxy, int, int, anything *) NONNULLPTRS; -static void discard_flashes(void); -static void write_ls(NHFILE *, light_source *); -static int maybe_write_ls(NHFILE *, int, boolean); +staticfn void delete_ls(light_source *); +staticfn void discard_flashes(void); +staticfn void write_ls(NHFILE *, light_source *); +staticfn int maybe_write_ls(NHFILE *, int, boolean); /* imported from vision.c, for small circles */ extern const coordxy circle_data[]; @@ -61,7 +62,7 @@ new_light_source(coordxy x, coordxy y, int range, int type, anything *id) } /* Create a new light source and return it. Only used within this file. */ -static light_source * +staticfn light_source * new_light_core(coordxy x, coordxy y, int range, int type, anything *id) { light_source *ls; @@ -89,14 +90,12 @@ new_light_core(coordxy x, coordxy y, int range, int type, anything *id) return ls; } -/* - * Delete a light source. This assumes only one light source is attached - * to an object at a time. - */ +/* Find and delete a light source. + Assumes at most one light source is attached to an object at a time. */ void del_light_source(int type, anything *id) { - light_source *curr, *prev; + light_source *curr; anything tmp_id; tmp_id = cg.zeroany; @@ -115,23 +114,46 @@ del_light_source(int type, anything *id) break; } - for (prev = 0, curr = gl.light_base; curr; prev = curr, curr = curr->next) { + /* find the light source from its id */ + for (curr = gl.light_base; curr; curr = curr->next) { if (curr->type != type) continue; if (curr->id.a_obj - == ((curr->flags & LSF_NEEDS_FIXUP) ? tmp_id.a_obj : id->a_obj)) { + == ((curr->flags & LSF_NEEDS_FIXUP) ? tmp_id.a_obj : id->a_obj)) + break; + } + if (curr) { + delete_ls(curr); + } else { + impossible("del_light_source: not found type=%d, id=%s", type, + fmt_ptr((genericptr_t) id->a_obj)); + } +} + +/* remove a light source from the light_base list and free it */ +staticfn void +delete_ls(light_source *ls) +{ + light_source *curr, *prev; + + for (prev = 0, curr = gl.light_base; curr; + prev = curr, curr = curr->next) { + if (curr == ls) { if (prev) prev->next = curr->next; else gl.light_base = curr->next; - - free((genericptr_t) curr); - gv.vision_full_recalc = 1; - return; + break; } } - impossible("del_light_source: not found type=%d, id=%s", type, - fmt_ptr((genericptr_t) id->a_obj)); + if (curr) { + assert(curr == ls); + free((genericptr_t) ls); + gv.vision_full_recalc = 1; + } else { + impossible("delete_ls not found, ls=%s", fmt_ptr((genericptr_t) ls)); + } + return; } /* Mark locations that are temporarily lit via mobile light sources. */ @@ -327,17 +349,15 @@ transient_light_cleanup(void) } /* camera flashes have Null object; caller wants to get rid of them now */ -static void +staticfn void discard_flashes(void) { light_source *ls, *nxt_ls; for (ls = gl.light_base; ls; ls = nxt_ls) { nxt_ls = ls->next; - if (ls->type != LS_OBJECT) - continue; - if (!ls->id.a_obj) - del_light_source(LS_OBJECT, &ls->id); + if (ls->type == LS_OBJECT && !ls->id.a_obj) + delete_ls(ls); } } @@ -509,7 +529,7 @@ relink_light_sources(boolean ghostly) * sources that would be written. If write_it is true, actually write * the light source out. */ -static int +staticfn int maybe_write_ls(NHFILE *nhfp, int range, boolean write_it) { int count = 0, is_global; @@ -572,7 +592,7 @@ light_sources_sanity_check(void) } /* Write a light source structure to disk. */ -static void +staticfn void write_ls(NHFILE *nhfp, light_source *ls) { anything arg_save; diff --git a/src/lock.c b/src/lock.c index 818c10c19..1f6e40c8d 100644 --- a/src/lock.c +++ b/src/lock.c @@ -6,12 +6,12 @@ #include "hack.h" /* occupation callbacks */ -static int picklock(void); -static int forcelock(void); +staticfn int picklock(void); +staticfn int forcelock(void); -static const char *lock_action(void); -static boolean obstructed(coordxy, coordxy, boolean); -static void chest_shatter_msg(struct obj *); +staticfn const char *lock_action(void); +staticfn boolean obstructed(coordxy, coordxy, boolean); +staticfn void chest_shatter_msg(struct obj *); boolean picking_lock(coordxy *x, coordxy *y) @@ -33,7 +33,7 @@ picking_at(coordxy x, coordxy y) } /* produce an occupation string appropriate for the current activity */ -static const char * +staticfn const char * lock_action(void) { /* "unlocking"+2 == "locking" */ @@ -63,7 +63,7 @@ lock_action(void) } /* try to open/close a lock */ -static int +staticfn int picklock(void) { if (gx.xlock.box) { @@ -207,7 +207,7 @@ breakchestlock(struct obj *box, boolean destroyit) } /* try to force a locked chest */ -static int +staticfn int forcelock(void) { if ((gx.xlock.box->ox != u.ux) || (gx.xlock.box->oy != u.uy)) @@ -908,7 +908,7 @@ doopen_indir(coordxy x, coordxy y) return ECMD_TIME; } -static boolean +staticfn boolean obstructed(coordxy x, coordxy y, boolean quietly) { struct monst *mtmp = m_at(x, y); @@ -1257,7 +1257,7 @@ doorlock(struct obj *otmp, coordxy x, coordxy y) return res; } -static void +staticfn void chest_shatter_msg(struct obj *otmp) { const char *disposition; diff --git a/src/mail.c b/src/mail.c index 1a026f88b..3c7d64c11 100644 --- a/src/mail.c +++ b/src/mail.c @@ -40,12 +40,12 @@ * random intervals. */ -static boolean md_start(coord *); -static boolean md_stop(coord *, coord *); -static boolean md_rush(struct monst *, int, int); -static void newmail(struct mail_info *); +staticfn boolean md_start(coord *); +staticfn boolean md_stop(coord *, coord *); +staticfn boolean md_rush(struct monst *, int, int); +staticfn void newmail(struct mail_info *); #if defined(SIMPLE_MAIL) || defined(SERVER_ADMIN_MSG) -static void read_simplemail(const char *mbox, boolean adminmsg); +staticfn void read_simplemail(const char *mbox, boolean adminmsg); #endif #if !defined(UNIX) && !defined(VMS) @@ -145,7 +145,7 @@ getmailstatus(void) * Pick coordinates for a starting position for the mail daemon. Called * from newmail() and newphone(). */ -static boolean +staticfn boolean md_start(coord *startp) { coord testcc; /* scratch coordinates */ @@ -243,7 +243,7 @@ md_start(coord *startp) * enexto(). Use enexto() as a last resort because enexto() chooses * its point randomly, which is not what we want. */ -static boolean +staticfn boolean md_stop(coord *stopp, /* stopping position (we fill it in) */ coord *startp) /* starting position (read only) */ { @@ -273,7 +273,7 @@ md_stop(coord *stopp, /* stopping position (we fill it in) */ } /* Let the mail daemon have a larger vocabulary. */ -static NEARDATA const char *mail_text[] = { "Gangway!", "Look out!", +staticfn NEARDATA const char *mail_text[] = { "Gangway!", "Look out!", "Pardon me!" }; #define md_exclamations() (mail_text[rn2(3)]) @@ -283,7 +283,7 @@ static NEARDATA const char *mail_text[] = { "Gangway!", "Look out!", * FALSE if the md gets stuck in a position where there is a monster. Return * TRUE otherwise. */ -static boolean +staticfn boolean md_rush(struct monst *md, int tx, int ty) /* destination of mail daemon */ { @@ -387,7 +387,7 @@ md_rush(struct monst *md, /* Deliver a scroll of mail. */ /*ARGSUSED*/ -static void +staticfn void newmail(struct mail_info *info) { struct monst *md; diff --git a/src/makemon.c b/src/makemon.c index bd61ef13e..48fc326a7 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -14,17 +14,17 @@ (mptr->mlet == S_HUMAN && Role_if(role_pm) \ && (mptr->msound == MS_LEADER || mptr->msound == MS_NEMESIS)) -static boolean uncommon(int); -static int align_shift(struct permonst *); -static int temperature_shift(struct permonst *); -static boolean mk_gen_ok(int, unsigned, unsigned); -static boolean wrong_elem_type(struct permonst *); -static void m_initgrp(struct monst *, coordxy, coordxy, int, mmflags_nht); -static void m_initthrow(struct monst *, int, int); -static void m_initweap(struct monst *); -static void m_initinv(struct monst *); -static boolean makemon_rnd_goodpos(struct monst *, mmflags_nht, coord *); -static void init_mextra(struct mextra *); +staticfn boolean uncommon(int); +staticfn int align_shift(struct permonst *); +staticfn int temperature_shift(struct permonst *); +staticfn boolean mk_gen_ok(int, unsigned, unsigned); +staticfn boolean wrong_elem_type(struct permonst *); +staticfn void m_initgrp(struct monst *, coordxy, coordxy, int, mmflags_nht); +staticfn void m_initthrow(struct monst *, int, int); +staticfn void m_initweap(struct monst *); +staticfn void m_initinv(struct monst *); +staticfn boolean makemon_rnd_goodpos(struct monst *, mmflags_nht, coord *); +staticfn void init_mextra(struct mextra *); #define m_initsgrp(mtmp, x, y, mmf) m_initgrp(mtmp, x, y, 3, mmf) #define m_initlgrp(mtmp, x, y, mmf) m_initgrp(mtmp, x, y, 10, mmf) @@ -51,7 +51,7 @@ is_home_elemental(struct permonst *ptr) /* * Return true if the given monster cannot exist on this elemental level. */ -static boolean +staticfn boolean wrong_elem_type(struct permonst *ptr) { if (ptr->mlet == S_ELEMENTAL) { @@ -74,7 +74,7 @@ wrong_elem_type(struct permonst *ptr) } /* make a group just like mtmp */ -static void +staticfn void m_initgrp(struct monst *mtmp, coordxy x, coordxy y, int n, mmflags_nht mmflags) { coord mm; @@ -140,8 +140,7 @@ m_initgrp(struct monst *mtmp, coordxy x, coordxy y, int n, mmflags_nht mmflags) } } -static -void +staticfn void m_initthrow(struct monst *mtmp, int otyp, int oquan) { struct obj *otmp; @@ -154,7 +153,7 @@ m_initthrow(struct monst *mtmp, int otyp, int oquan) (void) mpickobj(mtmp, otmp); } -static void +staticfn void m_initweap(struct monst *mtmp) { struct permonst *ptr = mtmp->data; @@ -576,7 +575,7 @@ mkmonmoney(struct monst *mtmp, long amount) } } -static void +staticfn void m_initinv(struct monst *mtmp) { int cnt; @@ -1041,7 +1040,7 @@ newmonhp(struct monst *mon, int mndx) static const struct mextra zeromextra = DUMMY; -static void +staticfn void init_mextra(struct mextra *mex) { *mex = zeromextra; @@ -1058,7 +1057,7 @@ newmextra(void) return mextra; } -static boolean +staticfn boolean makemon_rnd_goodpos( struct monst *mon, mmflags_nht gpflags, @@ -1567,7 +1566,7 @@ create_critters( return known; } -static boolean +staticfn boolean uncommon(int mndx) { if (mons[mndx].geno & (G_NOGEN | G_UNIQ)) @@ -1585,7 +1584,7 @@ uncommon(int mndx) * comparing the dungeon alignment and monster alignment. * return an integer in the range of 0-5. */ -static int +staticfn int align_shift(struct permonst *ptr) { static NEARDATA long oldmoves = 0L; /* != 1, starting value of moves */ @@ -1615,7 +1614,7 @@ align_shift(struct permonst *ptr) } /* return larger value if monster prefers the level temperature */ -static int +staticfn int temperature_shift(struct permonst *ptr) { if (gl.level.flags.temperature @@ -1710,7 +1709,7 @@ rndmonst_adj(int minadj, int maxadj) } /* decide whether it's ok to generate a candidate monster by mkclass() */ -static boolean +staticfn boolean mk_gen_ok(int mndx, unsigned mvflagsmask, unsigned genomask) { struct permonst *ptr = &mons[mndx]; diff --git a/src/mcastu.c b/src/mcastu.c index 88271b034..cd54ff7e2 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -35,17 +35,17 @@ enum mcast_cleric_spells { CLC_GEYSER }; -static void cursetxt(struct monst *, boolean); -static int choose_magic_spell(int); -static int choose_clerical_spell(int); -static int m_cure_self(struct monst *, int); -static void cast_wizard_spell(struct monst *, int, int); -static void cast_cleric_spell(struct monst *, int, int); -static boolean is_undirected_spell(unsigned int, int); -static boolean spell_would_be_useless(struct monst *, unsigned int, int); +staticfn void cursetxt(struct monst *, boolean); +staticfn int choose_magic_spell(int); +staticfn int choose_clerical_spell(int); +staticfn int m_cure_self(struct monst *, int); +staticfn void cast_wizard_spell(struct monst *, int, int); +staticfn void cast_cleric_spell(struct monst *, int, int); +staticfn boolean is_undirected_spell(unsigned int, int); +staticfn boolean spell_would_be_useless(struct monst *, unsigned int, int); /* feedback when frustrated monster couldn't cast a spell */ -static void +staticfn void cursetxt(struct monst *mtmp, boolean undirected) { if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my)) { @@ -73,7 +73,7 @@ cursetxt(struct monst *mtmp, boolean undirected) /* convert a level-based random selection into a specific mage spell; inappropriate choices will be screened out by spell_would_be_useless() */ -static int +staticfn int choose_magic_spell(int spellval) { /* for 3.4.3 and earlier, val greater than 22 selected default spell */ @@ -126,7 +126,7 @@ choose_magic_spell(int spellval) } /* convert a level-based random selection into a specific cleric spell */ -static int +staticfn int choose_clerical_spell(int spellnum) { /* for 3.4.3 and earlier, num greater than 13 selected the default spell @@ -357,7 +357,7 @@ castmu( return ret; } -static int +staticfn int m_cure_self(struct monst *mtmp, int dmg) { if (mtmp->mhp < mtmp->mhpmax) { @@ -439,8 +439,7 @@ death_inflicted_by( If you modify either of these, be sure to change is_undirected_spell() and spell_would_be_useless(). */ -static -void +staticfn void cast_wizard_spell(struct monst *mtmp, int dmg, int spellnum) { if (dmg == 0 && !is_undirected_spell(AD_SPEL, spellnum)) { @@ -618,7 +617,7 @@ cast_wizard_spell(struct monst *mtmp, int dmg, int spellnum) DISABLE_WARNING_FORMAT_NONLITERAL -static void +staticfn void cast_cleric_spell(struct monst *mtmp, int dmg, int spellnum) { int orig_dmg = 0; @@ -865,7 +864,7 @@ cast_cleric_spell(struct monst *mtmp, int dmg, int spellnum) RESTORE_WARNING_FORMAT_NONLITERAL -static boolean +staticfn boolean is_undirected_spell(unsigned int adtyp, int spellnum) { if (adtyp == AD_SPEL) { @@ -893,7 +892,7 @@ is_undirected_spell(unsigned int adtyp, int spellnum) } /* Some spells are useless under some circumstances. */ -static boolean +staticfn boolean spell_would_be_useless(struct monst *mtmp, unsigned int adtyp, int spellnum) { /* Some spells don't require the player to really be there and can be cast diff --git a/src/mdlib.c b/src/mdlib.c index f2aae69a7..530574547 100644 --- a/src/mdlib.c +++ b/src/mdlib.c @@ -60,7 +60,7 @@ char *version_id_string(char *, size_t, const char *) NONNULL NONNULLPTRS; char *bannerc_string(char *, size_t, const char *) NONNULL NONNULLPTRS; int case_insensitive_comp(const char *, const char *) NONNULLPTRS; -static void make_version(void); +staticfn void make_version(void); #ifndef HAS_NO_MKSTEMP #ifdef _MSC_VER @@ -83,10 +83,10 @@ const char *do_runtime_info(int *) NO_NNARGS; void release_runtime_info(void); char *mdlib_version_string(char *, const char *) NONNULL NONNULLPTRS; -static void build_options(void); -static int count_and_validate_winopts(void); -static void opt_out_words(char *, int *) NONNULLPTRS; -static void build_savebones_compat_string(void); +staticfn void build_options(void); +staticfn int count_and_validate_winopts(void); +staticfn void opt_out_words(char *, int *) NONNULLPTRS; +staticfn void build_savebones_compat_string(void); static int idxopttext, done_runtime_opt_init_once = 0; #define MAXOPT 60 /* 3.7: currently 40 lines get inserted into opttext[] */ @@ -95,7 +95,7 @@ static char *opttext[MAXOPT] = { 0 }; ((void) ((idxopttext < MAXOPT) \ ? (opttext[idxopttext++] = dupstr(line)) \ : 0)) -char optbuf[COLBUFSZ]; +static char optbuf[COLBUFSZ]; static struct version_info version; static const char opt_indent[] = " "; @@ -160,7 +160,7 @@ static struct win_information window_opts[] = { }; #if !defined(MAKEDEFS_C) -static int count_and_validate_soundlibopts(void); +staticfn int count_and_validate_soundlibopts(void); struct soundlib_information { enum soundlib_ids id; @@ -252,7 +252,7 @@ md_ignored_features(void) ); } -static void +staticfn void make_version(void) { int i; @@ -415,7 +415,7 @@ mkstemp(char *template) static char save_bones_compat_buf[BUFSZ]; -static void +staticfn void build_savebones_compat_string(void) { #ifdef VERSION_COMPATIBILITY @@ -633,7 +633,7 @@ static const char *const build_opts[] = { "and basic NetHack features" }; -static int +staticfn int count_and_validate_winopts(void) { int i, cnt = 0; @@ -658,7 +658,7 @@ count_and_validate_winopts(void) } #if !defined(MAKEDEFS_C) -static int +staticfn int count_and_validate_soundlibopts(void) { int i, cnt = 0; @@ -672,7 +672,7 @@ count_and_validate_soundlibopts(void) } #endif -static void +staticfn void opt_out_words( char *str, /* input, but modified during processing */ int *length_p) /* in/out */ @@ -700,7 +700,7 @@ opt_out_words( } } -static void +staticfn void build_options(void) { char buf[COLBUFSZ]; diff --git a/src/mhitm.c b/src/mhitm.c index 3e401f395..d74866296 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -9,21 +9,21 @@ static const char brief_feeling[] = "have a %s feeling for a moment, then it passes."; -static void noises(struct monst *, struct attack *); -static void pre_mm_attack(struct monst *, struct monst *); -static void missmm(struct monst *, struct monst *, struct attack *); -static int hitmm(struct monst *, struct monst *, struct attack *, +staticfn void noises(struct monst *, struct attack *); +staticfn void pre_mm_attack(struct monst *, struct monst *); +staticfn void missmm(struct monst *, struct monst *, struct attack *); +staticfn int hitmm(struct monst *, struct monst *, struct attack *, struct obj *, int); -static int gazemm(struct monst *, struct monst *, struct attack *); -static int gulpmm(struct monst *, struct monst *, struct attack *); -static int explmm(struct monst *, struct monst *, struct attack *); -static int mdamagem(struct monst *, struct monst *, struct attack *, +staticfn int gazemm(struct monst *, struct monst *, struct attack *); +staticfn int gulpmm(struct monst *, struct monst *, struct attack *); +staticfn int explmm(struct monst *, struct monst *, struct attack *); +staticfn int mdamagem(struct monst *, struct monst *, struct attack *, struct obj *, int); -static void mswingsm(struct monst *, struct monst *, struct obj *); -static int passivemm(struct monst *, struct monst *, boolean, int, +staticfn void mswingsm(struct monst *, struct monst *, struct obj *); +staticfn int passivemm(struct monst *, struct monst *, boolean, int, struct obj *); -static void +staticfn void noises(struct monst *magr, struct attack *mattk) { boolean farq = (mdistu(magr) > 15); @@ -37,7 +37,7 @@ noises(struct monst *magr, struct attack *mattk) } } -static void +staticfn void pre_mm_attack(struct monst *magr, struct monst *mdef) { boolean showit = FALSE; @@ -72,8 +72,7 @@ pre_mm_attack(struct monst *magr, struct monst *mdef) } /* feedback for when a monster-vs-monster attack misses */ -static -void +staticfn void missmm( struct monst *magr, /* attacker */ struct monst *mdef, /* defender */ @@ -631,7 +630,7 @@ failed_grab( } /* Returns the result of mdamagem(). */ -static int +staticfn int hitmm( struct monst *magr, struct monst *mdef, @@ -722,7 +721,7 @@ hitmm( } /* Returns the same values as mdamagem(). */ -static int +staticfn int gazemm(struct monst *magr, struct monst *mdef, struct attack *mattk) { char buf[BUFSZ]; @@ -835,7 +834,7 @@ engulf_target(struct monst *magr, struct monst *mdef) } /* Returns the same values as mattackm(). */ -static int +staticfn int gulpmm( struct monst *magr, struct monst *mdef, @@ -954,7 +953,7 @@ gulpmm( return status; } -static int +staticfn int explmm(struct monst *magr, struct monst *mdef, struct attack *mattk) { int result; @@ -1000,7 +999,7 @@ explmm(struct monst *magr, struct monst *mdef, struct attack *mattk) /* * See comment at top of mattackm(), for return values. */ -static int +staticfn int mdamagem( struct monst *magr, struct monst *mdef, @@ -1259,7 +1258,7 @@ rustm(struct monst *mdef, struct obj *obj) (void) erode_obj(obj, (char *) 0, dmgtyp, EF_GREASE | EF_VERBOSE); } -static void +staticfn void mswingsm( struct monst *magr, /* attacker */ struct monst *mdef, /* defender */ @@ -1279,7 +1278,7 @@ mswingsm( * Passive responses by defenders. Does not replicate responses already * handled above. Returns same values as mattackm. */ -static int +staticfn int passivemm( struct monst *magr, struct monst *mdef, diff --git a/src/mhitu.c b/src/mhitu.c index 055700e57..412ccc717 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -8,18 +8,18 @@ static NEARDATA struct obj *mon_currwep = (struct obj *) 0; -static void missmu(struct monst *, boolean, struct attack *); -static void mswings(struct monst *, struct obj *, boolean); -static void wildmiss(struct monst *, struct attack *); -static void calc_mattacku_vars(struct monst *, boolean *, boolean *, +staticfn void missmu(struct monst *, boolean, struct attack *); +staticfn void mswings(struct monst *, struct obj *, boolean); +staticfn void wildmiss(struct monst *, struct attack *); +staticfn void calc_mattacku_vars(struct monst *, boolean *, boolean *, boolean *, boolean *); -static void summonmu(struct monst *, boolean); -static int hitmu(struct monst *, struct attack *); -static int gulpmu(struct monst *, struct attack *); -static int explmu(struct monst *, struct attack *, boolean); -static void mayberem(struct monst *, const char *, struct obj *, +staticfn void summonmu(struct monst *, boolean); +staticfn int hitmu(struct monst *, struct attack *); +staticfn int gulpmu(struct monst *, struct attack *); +staticfn int explmu(struct monst *, struct attack *, boolean); +staticfn void mayberem(struct monst *, const char *, struct obj *, const char *); -static int passiveum(struct permonst *, struct monst *, struct attack *); +staticfn int passiveum(struct permonst *, struct monst *, struct attack *); #define ld() ((yyyymmdd((time_t) 0) - (getyear() * 10000L)) == 0xe5) @@ -80,7 +80,7 @@ hitmsg(struct monst *mtmp, struct attack *mattk) } /* monster missed you */ -static void +staticfn void missmu(struct monst *mtmp, boolean nearmiss, struct attack *mattk) { gh.hitmsg_mid = 0; @@ -125,7 +125,7 @@ mswings_verb( } /* monster swings obj */ -static void +staticfn void mswings( struct monst *mtmp, /* attacker */ struct obj *otemp, /* attacker's weapon */ @@ -167,7 +167,7 @@ u_slow_down(void) /* monster attacked wrong location due to monster blindness, hero invisibility, hero displacement, or hero being underwater */ -static void +staticfn void wildmiss(struct monst *mtmp, struct attack *mattk) { int compat; @@ -405,7 +405,7 @@ getmattk(struct monst *magr, struct monst *mdef, } /* calc some variables needed for mattacku() */ -static void +staticfn void calc_mattacku_vars( struct monst *mtmp, boolean *ranged, boolean *range2, @@ -877,7 +877,7 @@ mattacku(struct monst *mtmp) } /* monster summons help for its fight against hero */ -static void +staticfn void summonmu(struct monst *mtmp, boolean youseeit) { struct permonst *mdat = mtmp->data; @@ -1062,7 +1062,7 @@ magic_negation(struct monst *mon) * hitmu: monster hits you * returns MM_ flags */ -static int +staticfn int hitmu(struct monst *mtmp, struct attack *mattk) { struct permonst *mdat = mtmp->data; @@ -1206,7 +1206,7 @@ gulp_blnd_check(void) } /* monster swallows you, or damage if u.uswallow */ -static int +staticfn int gulpmu(struct monst *mtmp, struct attack *mattk) { struct trap *t = t_at(u.ux, u.uy); @@ -1498,7 +1498,7 @@ gulpmu(struct monst *mtmp, struct attack *mattk) } /* monster explodes in your face */ -static int +staticfn int explmu(struct monst *mtmp, struct attack *mattk, boolean ufound) { boolean kill_agr = TRUE; @@ -2195,7 +2195,7 @@ doseduce(struct monst *mon) } /* 'mon' tries to remove a piece of hero's armor */ -static void +staticfn void mayberem(struct monst *mon, const char *seducer, /* only used for alternate message */ struct obj *obj, const char *str) @@ -2248,7 +2248,7 @@ mayberem(struct monst *mon, * to know whether hero reverted in order to decide whether passive * damage applies. */ -static int +staticfn int passiveum( struct permonst *olduasmon, struct monst *mtmp, diff --git a/src/mklev.c b/src/mklev.c index 85ebd1fc4..888bdb6ac 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -9,40 +9,40 @@ /* croom->lx etc are schar (width <= int), so % arith ensures that */ /* conversion of result to int is reasonable */ -static boolean generate_stairs_room_good(struct mkroom *, int); -static struct mkroom *generate_stairs_find_room(void); -static void generate_stairs(void); -static void mkfount(struct mkroom *); -static boolean find_okay_roompos(struct mkroom *, coord *) NONNULLARG12; -static void mksink(struct mkroom *); -static void mkaltar(struct mkroom *); -static void mkgrave(struct mkroom *); -static void mkinvpos(coordxy, coordxy, int); -static int mkinvk_check_wall(coordxy x, coordxy y); -static void mk_knox_portal(coordxy, coordxy); -static void makevtele(void); -static void fill_ordinary_room(struct mkroom *, boolean) NONNULLARG1; -static void makelevel(void); -static boolean bydoor(coordxy, coordxy); -static void mktrap_victim(struct trap *); -static int traptype_rnd(unsigned); -static int traptype_roguelvl(void); -static struct mkroom *find_branch_room(coord *) NONNULLARG1; -static struct mkroom *pos_to_room(coordxy, coordxy); -static boolean cardinal_nextto_room(struct mkroom *, coordxy, coordxy); -static boolean place_niche(struct mkroom *, int *, coordxy *, coordxy *); -static void makeniche(int); -static void make_niches(void); -static int QSORTCALLBACK mkroom_cmp(const genericptr, const genericptr); -static void dosdoor(coordxy, coordxy, struct mkroom *, int); -static void join(int, int, boolean); -static void alloc_doors(void); -static void do_room_or_subroom(struct mkroom *, +staticfn boolean generate_stairs_room_good(struct mkroom *, int); +staticfn struct mkroom *generate_stairs_find_room(void); +staticfn void generate_stairs(void); +staticfn void mkfount(struct mkroom *); +staticfn boolean find_okay_roompos(struct mkroom *, coord *) NONNULLARG12; +staticfn void mksink(struct mkroom *); +staticfn void mkaltar(struct mkroom *); +staticfn void mkgrave(struct mkroom *); +staticfn void mkinvpos(coordxy, coordxy, int); +staticfn int mkinvk_check_wall(coordxy x, coordxy y); +staticfn void mk_knox_portal(coordxy, coordxy); +staticfn void makevtele(void); +staticfn void fill_ordinary_room(struct mkroom *, boolean) NONNULLARG1; +staticfn void makelevel(void); +staticfn boolean bydoor(coordxy, coordxy); +staticfn void mktrap_victim(struct trap *); +staticfn int traptype_rnd(unsigned); +staticfn int traptype_roguelvl(void); +staticfn struct mkroom *find_branch_room(coord *) NONNULLARG1; +staticfn struct mkroom *pos_to_room(coordxy, coordxy); +staticfn boolean cardinal_nextto_room(struct mkroom *, coordxy, coordxy); +staticfn boolean place_niche(struct mkroom *, int *, coordxy *, coordxy *); +staticfn void makeniche(int); +staticfn void make_niches(void); +staticfn int QSORTCALLBACK mkroom_cmp(const genericptr, const genericptr); +staticfn void dosdoor(coordxy, coordxy, struct mkroom *, int); +staticfn void join(int, int, boolean); +staticfn void alloc_doors(void); +staticfn void do_room_or_subroom(struct mkroom *, coordxy, coordxy, coordxy, coordxy, boolean, schar, boolean, boolean); -static void makerooms(void); -static boolean door_into_nonjoined(coordxy, coordxy); -static boolean finddpos(coord *, coordxy, coordxy, coordxy, coordxy); +staticfn void makerooms(void); +staticfn boolean door_into_nonjoined(coordxy, coordxy); +staticfn boolean finddpos(coord *, coordxy, coordxy, coordxy, coordxy); #define create_vault() create_room(-1, -1, 2, 2, -1, -1, VAULT, TRUE) #define init_vault() gv.vault_x = -1 @@ -50,7 +50,7 @@ static boolean finddpos(coord *, coordxy, coordxy, coordxy, coordxy); /* Args must be (const genericptr) so that qsort will always be happy. */ -static int QSORTCALLBACK +staticfn int QSORTCALLBACK mkroom_cmp(const genericptr vx, const genericptr vy) { const struct mkroom *x, *y; @@ -68,7 +68,7 @@ mkroom_cmp(const genericptr vx, const genericptr vy) * (such as shops) that will never randomly generate unwanted doors in order * to connect them up to other areas. */ -static boolean +staticfn boolean door_into_nonjoined(coordxy x, coordxy y) { coordxy tx, ty, i; @@ -88,7 +88,7 @@ door_into_nonjoined(coordxy x, coordxy y) return FALSE; } -static boolean +staticfn boolean finddpos(coord *cc, coordxy xl, coordxy yl, coordxy xh, coordxy yh) { coordxy x, y; @@ -140,7 +140,7 @@ sort_rooms(void) } } -static void +staticfn void do_room_or_subroom(struct mkroom *croom, coordxy lowx, coordxy lowy, coordxy hix, coordxy hiy, boolean lit, schar rtype, boolean special, boolean is_room) @@ -264,7 +264,7 @@ free_luathemes(enum lua_theme_group theme_group) } } -static void +staticfn void makerooms(void) { boolean tried_vault = FALSE; @@ -341,7 +341,7 @@ makerooms(void) } } -static void +staticfn void join(int a, int b, boolean nxcor) { coord cc, tt, org, dest; @@ -460,7 +460,7 @@ makecorridors(void) } /* (re)allocate space for gd.doors array */ -static void +staticfn void alloc_doors(void) { if (!gd.doors || gd.doorindex >= gd.doors_alloc) { @@ -518,7 +518,7 @@ add_door(coordxy x, coordxy y, struct mkroom *aroom) gd.doors[aroom->fdoor].y = y; } -static void +staticfn void dosdoor(coordxy x, coordxy y, struct mkroom *aroom, int type) { boolean shdoor = *in_rooms(x, y, SHOPBASE) ? TRUE : FALSE; @@ -584,7 +584,7 @@ dosdoor(coordxy x, coordxy y, struct mkroom *aroom, int type) /* is x,y location such that NEWS direction from it is inside aroom, excluding subrooms */ -static boolean +staticfn boolean cardinal_nextto_room(struct mkroom *aroom, coordxy x, coordxy y) { int rmno = (int) ((aroom - gr.rooms) + ROOMOFFSET); @@ -604,7 +604,7 @@ cardinal_nextto_room(struct mkroom *aroom, coordxy x, coordxy y) return FALSE; } -static boolean +staticfn boolean place_niche( struct mkroom *aroom, int *dy, @@ -643,7 +643,7 @@ static NEARDATA const char *trap_engravings[TRAPNUM] = { (char *) 0, (char *) 0, }; -static void +staticfn void makeniche(int trap_type) { struct mkroom *aroom; @@ -705,7 +705,7 @@ makeniche(int trap_type) } } -static void +staticfn void make_niches(void) { int ct = rnd((gn.nroom >> 1) + 1), dep = depth(&u.uz); @@ -724,7 +724,7 @@ make_niches(void) } } -static void +staticfn void makevtele(void) { makeniche(TELEP_TRAP); @@ -841,7 +841,7 @@ clear_level_structures(void) If bonus_items is TRUE, there may be an additional special item generated, depending on depth. */ -static void +staticfn void fill_ordinary_room( struct mkroom *croom, boolean bonus_items) @@ -1076,7 +1076,7 @@ fill_ordinary_room( } } -static void +staticfn void makelevel(void) { struct mkroom *croom; @@ -1467,7 +1467,7 @@ topologize(struct mkroom *croom) } /* Find an unused room for a branch location. */ -static struct mkroom * +staticfn struct mkroom * find_branch_room(coord *mp) { struct mkroom *croom = 0; @@ -1484,7 +1484,7 @@ find_branch_room(coord *mp) } /* Find the room for (x,y). Return null if not in a room. */ -static struct mkroom * +staticfn struct mkroom * pos_to_room(coordxy x, coordxy y) { int i; @@ -1559,7 +1559,7 @@ place_branch( gm.made_branch = TRUE; } -static boolean +staticfn boolean bydoor(coordxy x, coordxy y) { int typ; @@ -1624,7 +1624,7 @@ occupied(coordxy x, coordxy y) } /* generate a corpse and some items on top of a trap */ -static void +staticfn void mktrap_victim(struct trap *ttmp) { /* Object generated by the trap; initially NULL, stays NULL if @@ -1744,7 +1744,7 @@ mktrap_victim(struct trap *ttmp) } /* pick a random trap type, return NO_TRAP if "too hard" */ -static int +staticfn int traptype_rnd(unsigned mktrapflags) { unsigned lvl = level_difficulty(); @@ -1808,7 +1808,7 @@ traptype_rnd(unsigned mktrapflags) } /* random trap type for the Rogue level */ -static int +staticfn int traptype_roguelvl(void) { int kind; @@ -1999,7 +1999,7 @@ mkstairs( } /* is room a good one to generate up or down stairs in? */ -static boolean +staticfn boolean generate_stairs_room_good(struct mkroom *croom, int phase) { /* @@ -2017,7 +2017,7 @@ generate_stairs_room_good(struct mkroom *croom, int phase) } /* find a good room to generate an up or down stairs in */ -static struct mkroom * +staticfn struct mkroom * generate_stairs_find_room(void) { struct mkroom *croom; @@ -2048,7 +2048,7 @@ generate_stairs_find_room(void) /* construct stairs up and down within the same branch, up and down in different rooms if possible */ -static void +staticfn void generate_stairs(void) { /* generate_stairs_find_room() returns Null if nroom == 0, but that @@ -2083,7 +2083,7 @@ generate_stairs(void) } } -static void +staticfn void mkfount(struct mkroom *croom) { coord m; @@ -2101,7 +2101,7 @@ mkfount(struct mkroom *croom) gl.level.flags.nfountains++; } -static boolean +staticfn boolean find_okay_roompos(struct mkroom *croom, coord *crd) { int tryct = 0; @@ -2115,7 +2115,7 @@ find_okay_roompos(struct mkroom *croom, coord *crd) return TRUE; } -static void +staticfn void mksink(struct mkroom *croom) { coord m; @@ -2130,7 +2130,7 @@ mksink(struct mkroom *croom) gl.level.flags.nsinks++; } -static void +staticfn void mkaltar(struct mkroom *croom) { coord m; @@ -2151,7 +2151,7 @@ mkaltar(struct mkroom *croom) levl[m.x][m.y].altarmask = Align2amask(al); } -static void +staticfn void mkgrave(struct mkroom *croom) { coord m; @@ -2301,7 +2301,7 @@ mkinvokearea(void) /* Change level topology. Boulders in the vicinity are eliminated. * Temporarily overrides vision in the name of a nice effect. */ -static void +staticfn void mkinvpos(coordxy x, coordxy y, int dist) { struct trap *ttmp; @@ -2401,7 +2401,7 @@ mkinvpos(coordxy x, coordxy y, int dist) /* reduces clutter in mkinvokearea() while avoiding potential static analyzer confusion about using isok(x,y) to control access to levl[x][y] */ -static int +staticfn int mkinvk_check_wall(coordxy x, coordxy y) { unsigned ltyp; @@ -2422,7 +2422,7 @@ mkinvk_check_wall(coordxy x, coordxy y) * * Ludios will remain isolated until the branch is corrected by this function. */ -static void +staticfn void mk_knox_portal(coordxy x, coordxy y) { d_level *source; diff --git a/src/mkmap.c b/src/mkmap.c index 89a87ad22..4e7c057c1 100644 --- a/src/mkmap.c +++ b/src/mkmap.c @@ -8,19 +8,19 @@ #define HEIGHT (ROWNO - 1) #define WIDTH (COLNO - 2) -static void init_map(schar); -static void init_fill(schar, schar); -static schar get_map(int, int, schar); -static void pass_one(schar, schar); -static void pass_two(schar, schar); -static void pass_three(schar, schar); -static void join_map_cleanup(void); -static void join_map(schar, schar); -static void finish_map(schar, schar, boolean, boolean, boolean); -static void remove_room(unsigned); +staticfn void init_map(schar); +staticfn void init_fill(schar, schar); +staticfn schar get_map(int, int, schar); +staticfn void pass_one(schar, schar); +staticfn void pass_two(schar, schar); +staticfn void pass_three(schar, schar); +staticfn void join_map_cleanup(void); +staticfn void join_map(schar, schar); +staticfn void finish_map(schar, schar, boolean, boolean, boolean); +staticfn void remove_room(unsigned); void mkmap(lev_init *); -static void +staticfn void init_map(schar bg_typ) { int i, j; @@ -33,7 +33,7 @@ init_map(schar bg_typ) } } -static void +staticfn void init_fill(schar bg_typ, schar fg_typ) { int i, j; @@ -51,7 +51,7 @@ init_fill(schar bg_typ, schar fg_typ) } } -static schar +staticfn schar get_map(int col, int row, schar bg_typ) { if (col <= 0 || row < 0 || col > WIDTH || row >= HEIGHT) @@ -59,12 +59,12 @@ get_map(int col, int row, schar bg_typ) return levl[col][row].typ; } -static const int dirs[16] = { +staticfn const int dirs[16] = { -1, -1 /**/, -1, 0 /**/, -1, 1 /**/, 0, -1 /**/, 0, 1 /**/, 1, -1 /**/, 1, 0 /**/, 1, 1 }; -static void +staticfn void pass_one(schar bg_typ, schar fg_typ) { int i, j; @@ -97,7 +97,7 @@ pass_one(schar bg_typ, schar fg_typ) #define new_loc(i, j) *(gn.new_locations + ((j) * (WIDTH + 1)) + (i)) -static void +staticfn void pass_two(schar bg_typ, schar fg_typ) { int i, j; @@ -120,7 +120,7 @@ pass_two(schar bg_typ, schar fg_typ) levl[i][j].typ = new_loc(i, j); } -static void +staticfn void pass_three(schar bg_typ, schar fg_typ) { int i, j; @@ -243,7 +243,7 @@ flood_fill_rm( } /* join_map uses temporary rooms; clean up after it */ -static void +staticfn void join_map_cleanup(void) { coordxy x, y; @@ -255,7 +255,7 @@ join_map_cleanup(void) gr.rooms[gn.nroom].hx = gs.subrooms[gn.nsubroom].hx = -1; } -static void +staticfn void join_map(schar bg_typ, schar fg_typ) { struct mkroom *croom, *croom2; @@ -329,7 +329,7 @@ join_map(schar bg_typ, schar fg_typ) join_map_cleanup(); } -static void +staticfn void finish_map( schar fg_typ, schar bg_typ, @@ -408,7 +408,7 @@ remove_rooms(int lx, int ly, int hx, int hy) * level structure contents corresponding to roomno have already been reset. * Currently handles only the removal of rooms that have no subrooms. */ -static void +staticfn void remove_room(unsigned int roomno) { struct mkroom *croom = &gr.rooms[roomno]; diff --git a/src/mkmaze.c b/src/mkmaze.c index 92cb485d2..e151b56f8 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -6,27 +6,27 @@ #include "hack.h" #include "sp_lev.h" -static int iswall(coordxy, coordxy); -static int iswall_or_stone(coordxy, coordxy); -static boolean is_solid(coordxy, coordxy); -static int extend_spine(int[3][3], int, int, int); -static void wall_cleanup(coordxy, coordxy, coordxy, coordxy); -static boolean okay(coordxy, coordxy, coordxy); -static void maze0xy(coord *); -static boolean put_lregion_here(coordxy, coordxy, coordxy, coordxy, coordxy, +staticfn int iswall(coordxy, coordxy); +staticfn int iswall_or_stone(coordxy, coordxy); +staticfn boolean is_solid(coordxy, coordxy); +staticfn int extend_spine(int[3][3], int, int, int); +staticfn void wall_cleanup(coordxy, coordxy, coordxy, coordxy); +staticfn boolean okay(coordxy, coordxy, coordxy); +staticfn void maze0xy(coord *); +staticfn boolean put_lregion_here(coordxy, coordxy, coordxy, coordxy, coordxy, coordxy, xint16, boolean, d_level *); -static void baalz_fixup(void); -static void setup_waterlevel(void); -static void unsetup_waterlevel(void); -static void check_ransacked(const char *); -static void migr_booty_item(int, const char *); -static void migrate_orc(struct monst *, unsigned long); -static void shiny_orc_stuff(struct monst *); -static void stolen_booty(void); -static boolean maze_inbounds(coordxy, coordxy); -static void maze_remove_deadends(xint16); -static void populate_maze(void); -static boolean is_exclusion_zone(xint16, coordxy, coordxy); +staticfn void baalz_fixup(void); +staticfn void setup_waterlevel(void); +staticfn void unsetup_waterlevel(void); +staticfn void check_ransacked(const char *); +staticfn void migr_booty_item(int, const char *); +staticfn void migrate_orc(struct monst *, unsigned long); +staticfn void shiny_orc_stuff(struct monst *); +staticfn void stolen_booty(void); +staticfn boolean maze_inbounds(coordxy, coordxy); +staticfn void maze_remove_deadends(xint16); +staticfn void populate_maze(void); +staticfn boolean is_exclusion_zone(xint16, coordxy, coordxy); /* adjust a coordinate one step in the specified direction */ #define mz_move(X, Y, dir) \ @@ -40,7 +40,7 @@ static boolean is_exclusion_zone(xint16, coordxy, coordxy); } \ } while (0) -static int +staticfn int iswall(coordxy x, coordxy y) { int type; @@ -52,7 +52,7 @@ iswall(coordxy x, coordxy y) || type == SDOOR || type == IRONBARS); } -static int +staticfn int iswall_or_stone(coordxy x, coordxy y) { /* out of bounds = stone */ @@ -63,7 +63,7 @@ iswall_or_stone(coordxy x, coordxy y) } /* return TRUE if out of bounds, wall or rock */ -static boolean +staticfn boolean is_solid(coordxy x, coordxy y) { return (boolean) (!isok(x, y) || IS_STWALL(levl[x][y].typ)); @@ -148,7 +148,7 @@ set_levltyp_lit(coordxy x, coordxy y, schar typ, schar lit) * W x W This would extend a spine from x down. * . W W */ -static int +staticfn int extend_spine(int locale[3][3], int wall_there, int dx, int dy) { int spine, nx, ny; @@ -180,7 +180,7 @@ extend_spine(int locale[3][3], int wall_there, int dx, int dy) } /* Remove walls totally surrounded by stone */ -static void +staticfn void wall_cleanup(coordxy x1, coordxy y1, coordxy x2, coordxy y2) { uchar type; @@ -279,7 +279,7 @@ wallification(coordxy x1, coordxy y1, coordxy x2, coordxy y2) fix_wall_spines(x1, y1, x2, y2); } -static boolean +staticfn boolean okay(coordxy x, coordxy y, coordxy dir) { mz_move(x, y, dir); @@ -291,7 +291,7 @@ okay(coordxy x, coordxy y, coordxy dir) } /* find random starting point for maze generation */ -static void +staticfn void maze0xy(coord *cc) { cc->x = 3 + 2 * rn2((gx.x_maze_max >> 1) - 1); @@ -299,7 +299,7 @@ maze0xy(coord *cc) return; } -static boolean +staticfn boolean is_exclusion_zone(xint16 type, coordxy x, coordxy y) { struct exclusion_zone *ez = ge.exclusion_zones; @@ -383,7 +383,7 @@ place_lregion( impossible("Couldn't place lregion type %d!", rtype); } -static boolean +staticfn boolean put_lregion_here( coordxy x, coordxy y, coordxy nlx, coordxy nly, coordxy nhx, coordxy nhy, @@ -443,7 +443,7 @@ put_lregion_here( /* fix up Baalzebub's lair, which depicts a level-sized beetle; its legs are walls within solid rock--regular wallification classifies them as superfluous and gets rid of them */ -static void +staticfn void baalz_fixup(void) { struct monst *mtmp; @@ -674,7 +674,7 @@ fixup_special(void) gn.num_lregions = 0; } -static void +staticfn void check_ransacked(const char *s) { /* this kludge only works as long as orctown is minetn-1 */ @@ -684,7 +684,7 @@ check_ransacked(const char *s) #define ORC_LEADER 1 static const char *const orcfruit[] = { "paddle cactus", "dwarven root" }; -static void +staticfn void migrate_orc(struct monst *mtmp, unsigned long mflags) { int nlev, max_depth, cur_depth; @@ -715,7 +715,7 @@ migrate_orc(struct monst *mtmp, unsigned long mflags) migrate_to_level(mtmp, ledger_no(&dest), MIGR_RANDOM, (coord *) 0); } -static void +staticfn void shiny_orc_stuff(struct monst *mtmp) { int gemprob, goldprob, otyp; @@ -747,7 +747,7 @@ shiny_orc_stuff(struct monst *mtmp) } } -static void +staticfn void migr_booty_item(int otyp, const char *gang) { struct obj *otmp; @@ -766,7 +766,7 @@ migr_booty_item(int otyp, const char *gang) } } -static void +staticfn void stolen_booty(void) { char *gang, gang_name[BUFSZ]; @@ -860,7 +860,7 @@ stolen_booty(void) #undef ORC_LEADER -static boolean +staticfn boolean maze_inbounds(coordxy x, coordxy y) { return (x >= 2 && y >= 2 @@ -870,7 +870,7 @@ maze_inbounds(coordxy x, coordxy y) && isok(x, y)); } -static void +staticfn void maze_remove_deadends(xint16 typ) { char dirok[4]; @@ -1064,7 +1064,7 @@ pick_vibrasquare_location(void) } /* add objects and monsters to random maze */ -static void +staticfn void populate_maze(void) { int i; @@ -1488,9 +1488,9 @@ fumaroles(void) #define gbxmax (gx.xmax - 1) #define gbymax (gy.ymax - 1) -static void set_wportal(void); -static void mk_bubble(coordxy, coordxy, int); -static void mv_bubble(struct bubble *, coordxy, coordxy, boolean); +staticfn void set_wportal(void); +staticfn void mk_bubble(coordxy, coordxy, int); +staticfn void mv_bubble(struct bubble *, coordxy, coordxy, boolean); void movebubbles(void) @@ -1748,7 +1748,7 @@ restore_waterlevel(NHFILE *nhfp) } } -static void +staticfn void set_wportal(void) { /* there better be only one magic portal on water level... */ @@ -1758,7 +1758,7 @@ set_wportal(void) impossible("set_wportal(): no portal!"); } -static void +staticfn void setup_waterlevel(void) { int typ, glyph; @@ -1806,7 +1806,7 @@ setup_waterlevel(void) mk_bubble(x, y, rn2(7)); } -static void +staticfn void unsetup_waterlevel(void) { struct bubble *b, *bb; @@ -1819,7 +1819,7 @@ unsetup_waterlevel(void) gb.bbubbles = ge.ebubbles = (struct bubble *) 0; } -static void +staticfn void mk_bubble(coordxy x, coordxy y, int n) { /* @@ -1882,7 +1882,7 @@ mk_bubble(coordxy x, coordxy y, int n) * in the immediate neighborhood of one, he/she may get sucked inside. * This property also makes leaving a bubble slightly difficult. */ -static void +staticfn void mv_bubble(struct bubble *b, coordxy dx, coordxy dy, boolean ini) { int i, j, colli = 0; diff --git a/src/mkobj.c b/src/mkobj.c index 422ef9d06..337b08126 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -5,27 +5,27 @@ #include "hack.h" -static boolean may_generate_eroded(struct obj *); -static void mkobj_erosions(struct obj *); -static void mkbox_cnts(struct obj *); -static unsigned nextoid(struct obj *, struct obj *); -static void mksobj_init(struct obj *, boolean); -static int item_on_ice(struct obj *); -static void shrinking_glob_gone(struct obj *); -static void obj_timer_checks(struct obj *, coordxy, coordxy, int); -static struct obj *save_mtraits(struct obj *, struct monst *); -static void objlist_sanity(struct obj *, int, const char *); -static void shop_obj_sanity(struct obj *, const char *); -static void mon_obj_sanity(struct monst *, const char *); -static void insane_obj_bits(struct obj *, struct monst *); -static boolean nomerge_exception(struct obj *); -static const char *where_name(struct obj *); -static void insane_object(struct obj *, const char *, const char *, +staticfn boolean may_generate_eroded(struct obj *); +staticfn void mkobj_erosions(struct obj *); +staticfn void mkbox_cnts(struct obj *); +staticfn unsigned nextoid(struct obj *, struct obj *); +staticfn void mksobj_init(struct obj *, boolean); +staticfn int item_on_ice(struct obj *); +staticfn void shrinking_glob_gone(struct obj *); +staticfn void obj_timer_checks(struct obj *, coordxy, coordxy, int); +staticfn struct obj *save_mtraits(struct obj *, struct monst *); +staticfn void objlist_sanity(struct obj *, int, const char *); +staticfn void shop_obj_sanity(struct obj *, const char *); +staticfn void mon_obj_sanity(struct monst *, const char *); +staticfn void insane_obj_bits(struct obj *, struct monst *); +staticfn boolean nomerge_exception(struct obj *); +staticfn const char *where_name(struct obj *); +staticfn void insane_object(struct obj *, const char *, const char *, struct monst *); -static void check_contained(struct obj *, const char *); -static void check_glob(struct obj *, const char *); -static void sanity_check_worn(struct obj *); -static void init_oextra(struct oextra *); +staticfn void check_contained(struct obj *, const char *); +staticfn void check_glob(struct obj *, const char *); +staticfn void sanity_check_worn(struct obj *); +staticfn void init_oextra(struct oextra *); struct icp { int iprob; /* probability of an item type */ @@ -75,7 +75,7 @@ static const struct icp hellprobs[] = { { 20, WEAPON_CLASS }, static const struct oextra zerooextra = DUMMY; -static void +staticfn void init_oextra(struct oextra *oex) { *oex = zerooextra; @@ -172,7 +172,7 @@ free_omailcmd(struct obj *otmp) } /* can object be generated eroded? */ -static boolean +staticfn boolean may_generate_eroded(struct obj *otmp) { /* initial hero inventory */ @@ -191,7 +191,7 @@ may_generate_eroded(struct obj *otmp) } /* random chance of applying erosions/grease to object */ -static void +staticfn void mkobj_erosions(struct obj *otmp) { if (may_generate_eroded(otmp)) { @@ -299,7 +299,7 @@ mkobj(int oclass, boolean artif) return mksobj(i, TRUE, artif); } -static void +staticfn void mkbox_cnts(struct obj *box) { int n; @@ -527,7 +527,7 @@ next_ident(void) /* when splitting a stack that has o_id-based shop prices, pick an o_id value for the new stack that will maintain the same price */ -static unsigned +staticfn unsigned nextoid(struct obj *oldobj, struct obj *newobj) { int olddif, newdif, trylimit = 256; /* limit of 4 suffices at present */ @@ -857,7 +857,7 @@ unknow_object(struct obj *obj) } /* do some initialization to newly created object; otyp must already be set */ -static void +staticfn void mksobj_init(struct obj *otmp, boolean artif) { int mndx, tryct; @@ -1374,7 +1374,7 @@ enum obj_on_ice { }; /* used by shrink_glob(); is 'item' or enclosing container on or under ice? */ -static int +staticfn int item_on_ice(struct obj *item) { struct obj *otmp; @@ -1604,7 +1604,7 @@ shrink_glob( } /* a glob has shrunk away to nothing; handle owornmask, then delete glob */ -static void +staticfn void shrinking_glob_gone(struct obj *obj) { xint16 owhere = obj->where; @@ -2075,7 +2075,7 @@ obj_attach_mid(struct obj *obj, unsigned int mid) return obj; } -static struct obj * +staticfn struct obj * save_mtraits(struct obj *obj, struct monst *mtmp) { if (mtmp->ispriest) @@ -2356,7 +2356,7 @@ peek_at_iced_corpse_age(struct obj *otmp) return retval; } -static void +staticfn void obj_timer_checks( struct obj *otmp, coordxy x, coordxy y, @@ -2897,7 +2897,7 @@ obj_sanity_check(void) } /* sanity check for objects on specified list (fobj, &c) */ -static void +staticfn void objlist_sanity(struct obj *objlist, int wheretype, const char *mesg) { struct obj *obj; @@ -2960,7 +2960,7 @@ objlist_sanity(struct obj *objlist, int wheretype, const char *mesg) /* check obj->unpaid and obj->no_charge for shop sanity; caller has verified that at least one of them is set */ -static void +staticfn void shop_obj_sanity(struct obj *obj, const char *mesg) { struct obj *otop; @@ -3030,7 +3030,7 @@ shop_obj_sanity(struct obj *obj, const char *mesg) } /* sanity check for objects carried by all monsters in specified list */ -static void +staticfn void mon_obj_sanity(struct monst *monlist, const char *mesg) { struct monst *mon; @@ -3063,7 +3063,7 @@ mon_obj_sanity(struct monst *monlist, const char *mesg) } } -static void +staticfn void insane_obj_bits(struct obj *obj, struct monst *mon) { unsigned o_in_use = obj->in_use, o_bypass = obj->bypass, @@ -3086,7 +3086,7 @@ insane_obj_bits(struct obj *obj, struct monst *mon) } /* does 'obj' use the 'nomerge' flag persistently? */ -static boolean +staticfn boolean nomerge_exception(struct obj *obj) { /* special prize objects for achievement tracking are set 'nomerge' @@ -3104,7 +3104,7 @@ static const char *const obj_state_names[NOBJ_STATES] = { "luafree" }; -static const char * +staticfn const char * where_name(struct obj *obj) { static char unknown[32]; /* big enough to handle rogue 64-bit int */ @@ -3122,7 +3122,7 @@ where_name(struct obj *obj) DISABLE_WARNING_FORMAT_NONLITERAL -static void +staticfn void insane_object( struct obj *obj, const char *fmt, @@ -3180,7 +3180,7 @@ init_dummyobj(struct obj *obj, short otyp, long oquan) } /* obj sanity check: check objects inside container */ -static void +staticfn void check_contained(struct obj *container, const char *mesg) { struct obj *obj; @@ -3226,7 +3226,7 @@ check_contained(struct obj *container, const char *mesg) } /* called when 'obj->globby' is set so we don't recheck it here */ -static void +staticfn void check_glob(struct obj *obj, const char *mesg) { #define LOWEST_GLOB GLOB_OF_GRAY_OOZE @@ -3253,7 +3253,7 @@ check_glob(struct obj *obj, const char *mesg) } /* check an object in hero's or monster's inventory which has worn mask set */ -static void +staticfn void sanity_check_worn(struct obj *obj) { #if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) || defined(DEBUG) diff --git a/src/mkroom.c b/src/mkroom.c index 5607ca953..0d256ab79 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -17,23 +17,23 @@ #include "hack.h" -static boolean isbig(struct mkroom *); -static struct mkroom *pick_room(boolean); -static void mkshop(void), mkzoo(int), mkswamp(void); -static void mk_zoo_thronemon(coordxy, coordxy); -static void mktemple(void); -static coord *shrine_pos(int); -static struct permonst *morguemon(void); -static struct permonst *squadmon(void); -static void save_room(NHFILE *, struct mkroom *); -static void rest_room(NHFILE *, struct mkroom *); -static boolean invalid_shop_shape(struct mkroom *sroom); +staticfn boolean isbig(struct mkroom *); +staticfn struct mkroom *pick_room(boolean); +staticfn void mkshop(void), mkzoo(int), mkswamp(void); +staticfn void mk_zoo_thronemon(coordxy, coordxy); +staticfn void mktemple(void); +staticfn coord *shrine_pos(int); +staticfn struct permonst *morguemon(void); +staticfn struct permonst *squadmon(void); +staticfn void save_room(NHFILE *, struct mkroom *); +staticfn void rest_room(NHFILE *, struct mkroom *); +staticfn boolean invalid_shop_shape(struct mkroom *sroom); #define sq(x) ((x) * (x)) extern const struct shclass shtypes[]; /* defined in shknam.c */ -static boolean +staticfn boolean isbig(struct mkroom *sroom) { int area = (sroom->hx - sroom->lx + 1) @@ -86,7 +86,7 @@ do_mkroom(int roomtype) } } -static void +staticfn void mkshop(void) { struct mkroom *sroom; @@ -211,7 +211,7 @@ mkshop(void) } /* pick an unused room, preferably with only one door */ -static struct mkroom * +staticfn struct mkroom * pick_room(boolean strict) { struct mkroom *sroom; @@ -235,7 +235,7 @@ pick_room(boolean strict) return (struct mkroom *) 0; } -static void +staticfn void mkzoo(int type) { struct mkroom *sroom; @@ -248,7 +248,7 @@ mkzoo(int type) } } -static void +staticfn void mk_zoo_thronemon(coordxy x, coordxy y) { int i = rnd(level_difficulty()); @@ -465,7 +465,7 @@ mkundead( gl.level.flags.graveyard = TRUE; /* reduced chance for undead corpse */ } -static struct permonst * +staticfn struct permonst * morguemon(void) { int i = rn2(100), hd = rn2(level_difficulty()); @@ -517,7 +517,7 @@ antholemon(void) : &mons[mtyp]); } -static void +staticfn void mkswamp(void) /* Michiel Huisjes & Fred de Wilde */ { struct mkroom *sroom; @@ -564,7 +564,7 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */ } } -static coord * +staticfn coord * shrine_pos(int roomno) { static coord buf; @@ -585,7 +585,7 @@ shrine_pos(int roomno) return &buf; } -static void +staticfn void mktemple(void) { struct mkroom *sroom; @@ -804,7 +804,7 @@ static const struct { { PM_CAPTAIN, 1 } }; /* return soldier types. */ -static struct permonst * +staticfn struct permonst * squadmon(void) { int sel_prob, i, cpro, mndx; @@ -831,7 +831,7 @@ squadmon(void) * save_room : A recursive function that saves a room and its subrooms * (if any). */ -static void +staticfn void save_room(NHFILE *nhfp, struct mkroom *r) { short i; @@ -863,7 +863,7 @@ save_rooms(NHFILE *nhfp) save_room(nhfp, &gr.rooms[i]); } -static void +staticfn void rest_room(NHFILE *nhfp, struct mkroom *r) { short i; @@ -1039,7 +1039,7 @@ cmap_to_type(int sym) * Note that the invalidity of the shape derives from the position of its door * already being chosen. It's quite possible that if the door were somewhere * else on the perimeter of this room, it would work fine as a shop.*/ -static boolean +staticfn boolean invalid_shop_shape(struct mkroom *sroom) { coordxy x, y; diff --git a/src/mon.c b/src/mon.c index f3bf3907a..037adf617 100644 --- a/src/mon.c +++ b/src/mon.c @@ -7,33 +7,33 @@ #include "mfndpos.h" #include -static void sanity_check_single_mon(struct monst *, boolean, const char *); -static struct obj *make_corpse(struct monst *, unsigned); -static int minliquid_core(struct monst *); -static void m_calcdistress(struct monst *); -static boolean monlineu(struct monst *, int, int); -static long mm_2way_aggression(struct monst *, struct monst *); -static long mm_aggression(struct monst *, struct monst *); -static long mm_displacement(struct monst *, struct monst *); -static void mon_leaving_level(struct monst *); -static void m_detach(struct monst *, struct permonst *, boolean); -static void set_mon_min_mhpmax(struct monst *, int); -static void lifesaved_monster(struct monst *); -static boolean vamprises(struct monst *); -static void logdeadmon(struct monst *, int); -static boolean ok_to_obliterate(struct monst *); -static void qst_guardians_respond(void); -static void peacefuls_respond(struct monst *); -static void m_restartcham(struct monst *); -static boolean restrap(struct monst *); -static int pick_animal(void); -static int pickvampshape(struct monst *); -static boolean isspecmon(struct monst *); -static boolean validspecmon(struct monst *, int); -static int wiz_force_cham_form(struct monst *); -static struct permonst *accept_newcham_form(struct monst *, int); -static void kill_eggs(struct obj *) NO_NNARGS; -static void pacify_guard(struct monst *); +staticfn void sanity_check_single_mon(struct monst *, boolean, const char *); +staticfn struct obj *make_corpse(struct monst *, unsigned); +staticfn int minliquid_core(struct monst *); +staticfn void m_calcdistress(struct monst *); +staticfn boolean monlineu(struct monst *, int, int); +staticfn long mm_2way_aggression(struct monst *, struct monst *); +staticfn long mm_aggression(struct monst *, struct monst *); +staticfn long mm_displacement(struct monst *, struct monst *); +staticfn void mon_leaving_level(struct monst *); +staticfn void m_detach(struct monst *, struct permonst *, boolean); +staticfn void set_mon_min_mhpmax(struct monst *, int); +staticfn void lifesaved_monster(struct monst *); +staticfn boolean vamprises(struct monst *); +staticfn void logdeadmon(struct monst *, int); +staticfn boolean ok_to_obliterate(struct monst *); +staticfn void qst_guardians_respond(void); +staticfn void peacefuls_respond(struct monst *); +staticfn void m_restartcham(struct monst *); +staticfn boolean restrap(struct monst *); +staticfn int pick_animal(void); +staticfn int pickvampshape(struct monst *); +staticfn boolean isspecmon(struct monst *); +staticfn boolean validspecmon(struct monst *, int); +staticfn int wiz_force_cham_form(struct monst *); +staticfn struct permonst *accept_newcham_form(struct monst *, int); +staticfn void kill_eggs(struct obj *) NO_NNARGS; +staticfn void pacify_guard(struct monst *); extern const struct shclass shtypes[]; /* defined in shknam.c */ @@ -51,7 +51,7 @@ const char *warnings[] = { #endif /* 0 */ -static void +staticfn void sanity_check_single_mon( struct monst *mtmp, boolean chk_geno, @@ -515,7 +515,7 @@ pm_to_cham(int mndx) * G_NOCORPSE set in order to prevent wishing for one, finding tins of one, * etc.... */ -static struct obj * +staticfn struct obj * make_corpse(struct monst *mtmp, unsigned int corpseflags) { struct permonst *mdat = mtmp->data; @@ -746,7 +746,7 @@ minliquid(struct monst *mtmp) } /* guts of minliquid() */ -static int +staticfn int minliquid_core(struct monst *mtmp) { boolean inpool, inlava, infountain; @@ -944,7 +944,7 @@ mcalcdistress(void) iter_mons(m_calcdistress); } -static void +staticfn void m_calcdistress(struct monst *mtmp) { /* must check non-moving monsters once/turn in case they managed @@ -1824,7 +1824,7 @@ can_carry(struct monst *mtmp, struct obj *otmp) } /* is in direct line with where 'mon' thinks hero is? */ -static boolean +staticfn boolean monlineu(struct monst *mon, int nx, int ny) { return online2(nx, ny, mon->mux, mon->muy); @@ -2151,7 +2151,7 @@ mfndpos( /* Part of mm_aggression that represents two-way aggression. To avoid having to code each case twice, this function contains those cases that ought to happen twice, and mm_aggression will call it twice. */ -static long +staticfn long mm_2way_aggression(struct monst *magr, struct monst *mdef) { /* zombies vs things that can be zombified */ @@ -2166,7 +2166,7 @@ mm_2way_aggression(struct monst *magr, struct monst *mdef) in the absence of Conflict. There is no provision for targeting other monsters; just hand to hand fighting when they happen to be next to each other. */ -static long +staticfn long mm_aggression( struct monst *magr, /* monster that is currently deciding where to move */ struct monst *mdef) /* another monster which is next to it */ @@ -2189,7 +2189,7 @@ mm_aggression( } /* Monster displacing another monster out of the way */ -static long +staticfn long mm_displacement( struct monst *magr, /* monster that is currently deciding where to move */ struct monst *mdef) /* another monster which is next to it */ @@ -2426,7 +2426,7 @@ dealloc_monst(struct monst *mon) /* 'mon' is being removed from level due to migration [relmon from keepdogs or migrate_to_level] or due to death [m_detach from mondead or mongone] */ -static void +staticfn void mon_leaving_level(struct monst *mon) { coordxy mx = mon->mx, my = mon->my; @@ -2464,7 +2464,7 @@ mon_leaving_level(struct monst *mon) } /* 'mtmp' is going away; remove effects of mtmp from other data structures */ -static void +staticfn void m_detach( struct monst *mtmp, struct permonst *mptr, /* reflects mtmp->data _prior_ to mtmp's death */ @@ -2536,7 +2536,7 @@ m_detach( /* give a life-saved monster a reasonable mhpmax value in case it has been the victim of excessive life draining */ -static void +staticfn void set_mon_min_mhpmax( struct monst *mon, int minimum_mhpmax) /* monster life-saving has traditionally used 10 */ @@ -2567,7 +2567,7 @@ mlifesaver(struct monst *mon) return (struct obj *) 0; } -static void +staticfn void lifesaved_monster(struct monst *mtmp) { boolean surviver; @@ -2619,7 +2619,7 @@ DISABLE_WARNING_FORMAT_NONLITERAL /* when a shape-shifted vampire is killed, it reverts to base form instead of dying; moved into separate routine to unclutter mondead() */ -static boolean +staticfn boolean vamprises(struct monst *mtmp) { int mndx = mtmp->cham; @@ -2694,7 +2694,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL /* when a mon has died, maybe record an achievement or issue livelog message; moved into separate routine to unclutter mondead() */ -static void +staticfn void logdeadmon(struct monst *mtmp, int mndx) { int howmany = gm.mvitals[mndx].died; @@ -3528,7 +3528,7 @@ migrate_mon( migrate_to_level(mtmp, target_lev, xyloc, (coord *) 0); } -static boolean +staticfn boolean ok_to_obliterate(struct monst *mtmp) { /* @@ -3786,7 +3786,7 @@ m_respond(struct monst *mtmp) } /* how quest guardians respond when you attack the quest leader */ -static void +staticfn void qst_guardians_respond(void) { struct monst *mon; @@ -3814,7 +3814,7 @@ qst_guardians_respond(void) } /* how other peacefuls react when you attack monster */ -static void +staticfn void peacefuls_respond(struct monst *mtmp) { struct monst *mon; @@ -4226,7 +4226,7 @@ rescham(void) iter_mons(normal_shape); } -static void +staticfn void m_restartcham(struct monst *mtmp) { if (!mtmp->mcan) @@ -4261,7 +4261,7 @@ restore_cham(struct monst *mon) } /* unwatched hiders may hide again; if so, returns True */ -static boolean +staticfn boolean restrap(struct monst *mtmp) { struct trap *t; @@ -4443,7 +4443,7 @@ mon_animal_list(boolean construct) } } -static int +staticfn int pick_animal(void) { int res; @@ -4528,7 +4528,7 @@ decide_to_shapeshift(struct monst *mon, int shiftflags) } } -static int +staticfn int pickvampshape(struct monst *mon) { int mndx = mon->cham, wolfchance = 10; @@ -4565,7 +4565,7 @@ pickvampshape(struct monst *mon) } /* nonshapechangers who warrant special polymorph handling */ -static boolean +staticfn boolean isspecmon(struct monst *mon) { return (mon->isshk || mon->ispriest || mon->isgd @@ -4575,7 +4575,7 @@ isspecmon(struct monst *mon) /* restrict certain special monsters (shopkeepers, aligned priests, vault guards) to forms that allow them to behave sensibly (catching gold, speaking?) so that they don't need too much extra code */ -static boolean +staticfn boolean validspecmon(struct monst *mon, int mndx) { if (mndx == NON_PM) @@ -4659,7 +4659,7 @@ validvamp(struct monst *mon, int *mndx_p, int monclass) return (boolean) (*mndx_p != NON_PM); } -static int +staticfn int wiz_force_cham_form(struct monst *mon) { char pprompt[BUFSZ], parttwo[QBUFSZ], buf[BUFSZ], prevbuf[BUFSZ]; @@ -4810,7 +4810,7 @@ select_newcham_form(struct monst *mon) } /* this used to be inline within newcham() but monpolycontrol needs it too */ -static struct permonst * +staticfn struct permonst * accept_newcham_form(struct monst *mon, int mndx) { struct permonst *mdat; @@ -5168,7 +5168,7 @@ dead_species(int m_idx, boolean egg) } /* kill off any eggs of genocided monsters */ -static void +staticfn void kill_eggs(struct obj *obj_list) { struct obj *otmp; @@ -5325,7 +5325,7 @@ angry_guards(boolean silent) return FALSE; } -static void +staticfn void pacify_guard(struct monst *mtmp) { if (is_watch(mtmp->data)) diff --git a/src/mondata.c b/src/mondata.c index 52a2032cc..dd324b302 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -401,7 +401,7 @@ mstrength(struct permonst *ptr) } /* returns True if monster can attack at range */ -static boolean +staticfn boolean mstrength_ranged_attk(struct permonst *ptr) { int i, j; diff --git a/src/monmove.c b/src/monmove.c index 2c0d62f14..b0a25e3ae 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -7,29 +7,29 @@ #include "mfndpos.h" #include "artifact.h" -static void msg_mon_movement(struct monst *, coordxy, coordxy) NONNULLARG1; -static void watch_on_duty(struct monst *); -static int disturb(struct monst *); -static void release_hero(struct monst *); -static void distfleeck(struct monst *, int *, int *, int *); -static int m_arrival(struct monst *); -static void mind_blast(struct monst *); -static boolean holds_up_web(coordxy, coordxy); -static int count_webbing_walls(coordxy, coordxy); -static boolean soko_allow_web(struct monst *); -static boolean m_search_items(struct monst *, coordxy *, coordxy *, int *, +staticfn void msg_mon_movement(struct monst *, coordxy, coordxy) NONNULLARG1; +staticfn void watch_on_duty(struct monst *); +staticfn int disturb(struct monst *); +staticfn void release_hero(struct monst *); +staticfn void distfleeck(struct monst *, int *, int *, int *); +staticfn int m_arrival(struct monst *); +staticfn void mind_blast(struct monst *); +staticfn boolean holds_up_web(coordxy, coordxy); +staticfn int count_webbing_walls(coordxy, coordxy); +staticfn boolean soko_allow_web(struct monst *); +staticfn boolean m_search_items(struct monst *, coordxy *, coordxy *, int *, int *); -static int postmov(struct monst *, struct permonst *, coordxy, coordxy, int, - boolean, boolean, boolean, boolean); -static boolean leppie_avoidance(struct monst *); -static void leppie_stash(struct monst *); -static boolean m_balks_at_approaching(struct monst *); -static boolean stuff_prevents_passage(struct monst *); -static int vamp_shift(struct monst *, struct permonst *, boolean); -static void maybe_spin_web(struct monst *); +staticfn int postmov(struct monst *, struct permonst *, coordxy, coordxy, int, + boolean, boolean, boolean, boolean); +staticfn boolean leppie_avoidance(struct monst *); +staticfn void leppie_stash(struct monst *); +staticfn boolean m_balks_at_approaching(struct monst *); +staticfn boolean stuff_prevents_passage(struct monst *); +staticfn int vamp_shift(struct monst *, struct permonst *, boolean); +staticfn void maybe_spin_web(struct monst *); /* a11y: give a message when monster moved */ -static void +staticfn void msg_mon_movement(struct monst *mtmp, coordxy omx, coordxy omy) { if (a11y.mon_movement && canspotmon(mtmp) && mtmp->mspotted) { @@ -158,7 +158,7 @@ m_break_boulder(struct monst *mtmp, coordxy x, coordxy y) } } -static void +staticfn void watch_on_duty(struct monst *mtmp) { coordxy x, y; @@ -299,7 +299,7 @@ mon_regen(struct monst *mon, boolean digest_meal) * Possibly awaken the given monster. Return a 1 if the monster has been * jolted awake. */ -static int +staticfn int disturb(struct monst *mtmp) { /* @@ -334,7 +334,7 @@ disturb(struct monst *mtmp) } /* ungrab/expel held/swallowed hero */ -static void +staticfn void release_hero(struct monst *mon) { if (mon == u.ustuck) { @@ -478,7 +478,7 @@ monflee( mon_track_clear(mtmp); } -static void +staticfn void distfleeck( struct monst *mtmp, int *inrange, int *nearby, int *scared) /* output */ @@ -519,7 +519,7 @@ distfleeck( /* perform a special one-time action for a monster; returns -1 if nothing special happened, 0 if monster uses up its turn, 1 if monster is killed */ -static int +staticfn int m_arrival(struct monst *mon) { mon->mstrategy &= ~STRAT_ARRIVE; /* always reset */ @@ -528,7 +528,7 @@ m_arrival(struct monst *mon) } /* a mind flayer unleashes a mind blast */ -static void +staticfn void mind_blast(struct monst *mtmp) { struct monst *m2, *nmon = (struct monst *) 0; @@ -1052,7 +1052,7 @@ m_digweapon_check( } /* does leprechaun want to avoid the hero? */ -static boolean +staticfn boolean leppie_avoidance(struct monst *mtmp) { struct obj *lepgold, *ygold; @@ -1067,7 +1067,7 @@ leppie_avoidance(struct monst *mtmp) } /* unseen leprechaun with gold might stash it */ -static void +staticfn void leppie_stash(struct monst *mtmp) { struct obj *gold; @@ -1088,7 +1088,7 @@ leppie_stash(struct monst *mtmp) } /* does monster want to avoid you? */ -static boolean +staticfn boolean m_balks_at_approaching(struct monst *mtmp) { /* peaceful, far away, or can't see you */ @@ -1115,7 +1115,7 @@ m_balks_at_approaching(struct monst *mtmp) return FALSE; } -static boolean +staticfn boolean holds_up_web(coordxy x, coordxy y) { stairway *sway; @@ -1132,7 +1132,7 @@ holds_up_web(coordxy x, coordxy y) /* returns the number of walls in the four cardinal directions that could hold up a web */ -static int +staticfn int count_webbing_walls(coordxy x, coordxy y) { return (holds_up_web(x, y - 1) + holds_up_web(x + 1, y) @@ -1140,7 +1140,7 @@ count_webbing_walls(coordxy x, coordxy y) } /* reject webs which interfere with solving Sokoban */ -static boolean +staticfn boolean soko_allow_web(struct monst *mon) { stairway *stway; @@ -1157,7 +1157,7 @@ soko_allow_web(struct monst *mon) } /* monster might spin a web */ -static void +staticfn void maybe_spin_web(struct monst *mtmp) { if (webmaker(mtmp->data) @@ -1188,7 +1188,7 @@ maybe_spin_web(struct monst *mtmp) #define SQSRCHRADIUS 5 /* monster looks for items it wants nearby */ -static boolean +staticfn boolean m_search_items( struct monst *mtmp, coordxy *ggx, coordxy *ggy, @@ -1313,7 +1313,7 @@ finish_search: #undef SQSRCHRADIUS -static int +staticfn int postmov( struct monst *mtmp, struct permonst *ptr, @@ -2156,7 +2156,7 @@ undesirable_disp( * Inventory prevents passage under door. * Used by can_ooze() and can_fog(). */ -static boolean +staticfn boolean stuff_prevents_passage(struct monst *mtmp) { struct obj *chain, *obj; @@ -2211,7 +2211,7 @@ can_fog(struct monst *mtmp) return FALSE; } -static int +staticfn int vamp_shift( struct monst *mon, struct permonst *ptr, diff --git a/src/monst.c b/src/monst.c index 5518e8e44..4b7f57fb1 100644 --- a/src/monst.c +++ b/src/monst.c @@ -10,6 +10,9 @@ #include "color.h" +extern const struct attack c_sa_yes[NATTK]; +extern const struct attack c_sa_no[NATTK]; + #define NO_ATTK { 0, 0, 0, 0 } /* monster type with single name */ @@ -32,7 +35,7 @@ #define ATTK(at, ad, n, d) { at, ad, n, d } #define A(a1, a2, a3, a4, a5, a6) { a1, a2, a3, a4, a5, a6 } -struct permonst mons_init[NUMMONS + 1] = { +static struct permonst mons_init[NUMMONS + 1] = { #include "monsters.h" /* * Array terminator, added to the end of the entries in monsters.h. diff --git a/src/mplayer.c b/src/mplayer.c index 6e76e8b08..a422de3ca 100644 --- a/src/mplayer.c +++ b/src/mplayer.c @@ -4,9 +4,9 @@ #include "hack.h" -static const char *dev_name(void); -static void get_mplname(struct monst *, char *); -static void mk_mplayer_armor(struct monst *, short); +staticfn const char *dev_name(void); +staticfn void get_mplname(struct monst *, char *); +staticfn void mk_mplayer_armor(struct monst *, short); /* These are the names of those who * contributed to the development of NetHack 3.2/3.3/3.4/3.6. @@ -40,7 +40,7 @@ static const char *const developers[] = { }; /* return a randomly chosen developer name */ -static const char * +staticfn const char * dev_name(void) { int i, m = 0, n = SIZE(developers); @@ -68,7 +68,7 @@ dev_name(void) return (developers[i]); } -static void +staticfn void get_mplname(struct monst* mtmp, char *nam) { boolean fmlkind = is_female(mtmp->data); @@ -91,7 +91,7 @@ get_mplname(struct monst* mtmp, char *nam) (boolean) mtmp->female)); } -static void +staticfn void mk_mplayer_armor(struct monst *mon, short typ) { struct obj *obj; diff --git a/src/mthrowu.c b/src/mthrowu.c index 09b67def5..5079f7dc0 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -5,13 +5,13 @@ #include "hack.h" -static int monmulti(struct monst *, struct obj *, struct obj *); -static void monshoot(struct monst *, struct obj *, struct obj *); -static boolean ucatchgem(struct obj *, struct monst *); -static const char *breathwep_name(int); -static boolean drop_throw(struct obj *, boolean, coordxy, coordxy); -static boolean blocking_terrain(coordxy, coordxy); -static int m_lined_up(struct monst *, struct monst *) NONNULLARG12; +staticfn int monmulti(struct monst *, struct obj *, struct obj *); +staticfn void monshoot(struct monst *, struct obj *, struct obj *); +staticfn boolean ucatchgem(struct obj *, struct monst *); +staticfn const char *breathwep_name(int); +staticfn boolean drop_throw(struct obj *, boolean, coordxy, coordxy); +staticfn boolean blocking_terrain(coordxy, coordxy); +staticfn int m_lined_up(struct monst *, struct monst *) NONNULLARG12; #define URETREATING(x, y) \ (distmin(u.ux, u.uy, x, y) > distmin(u.ux0, u.uy0, x, y)) @@ -26,7 +26,7 @@ static NEARDATA const char *breathwep[] = { }; /* hallucinatory ray types */ -const char *const hallublasts[] = { +static const char *const hallublasts[] = { "asteroids", "beads", "bubbles", "butterflies", "champagne", "chaos", "coins", "cotton candy", "crumbs", "dark matter", "darkness", "dust specks", "emoticons", "emotions", "entropy", "flowers", "foam", "fog", "gamma rays", @@ -156,7 +156,7 @@ thitu( * dothrow.c (for consistency). --KAA * Returns FALSE if object still exists (not destroyed). */ -static boolean +staticfn boolean drop_throw( struct obj *obj, boolean ohit, @@ -195,7 +195,7 @@ drop_throw( /* calculate multishot volley count for mtmp throwing otmp (if not ammo) or shooting otmp with mwep (if otmp is ammo and mwep appropriate launcher) */ -static int +staticfn int monmulti(struct monst *mtmp, struct obj *otmp, struct obj *mwep) { int multishot = 1; @@ -254,7 +254,7 @@ monmulti(struct monst *mtmp, struct obj *otmp, struct obj *mwep) } /* mtmp throws otmp, or shoots otmp with mwep, at hero or at monster mtarg */ -static void +staticfn void monshoot(struct monst *mtmp, struct obj *otmp, struct obj *mwep) { struct monst *mtarg = gm.mtarget; @@ -498,7 +498,7 @@ ohitmon( } /* hero catches gem thrown by mon iff poly'd into unicorn; might drop it */ -static boolean +staticfn boolean ucatchgem( struct obj *gem, /* caller has verified gem->oclass */ struct monst *mon) @@ -888,7 +888,7 @@ spitmm(struct monst *mtmp, struct attack *mattk, struct monst *mtarg) /* Return the name of a breath weapon. If the player is hallucinating, return * a silly name instead. * typ is AD_MAGM, AD_FIRE, etc */ -static const char * +staticfn const char * breathwep_name(int typ) { if (Hallucination) @@ -1078,7 +1078,7 @@ breamu(struct monst *mtmp, struct attack *mattk) } /* return TRUE if terrain at x,y blocks linedup checks */ -static boolean +staticfn boolean blocking_terrain(coordxy x, coordxy y) { if (!isok(x, y) || IS_ROCK(levl[x][y].typ) || closed_door(x, y) @@ -1172,7 +1172,7 @@ linedup( return FALSE; } -static int +staticfn int m_lined_up(struct monst *mtarg, struct monst *mtmp) { boolean utarget = (mtarg == &gy.youmonst); diff --git a/src/muse.c b/src/muse.c index 9885b955c..b1d5e97c5 100644 --- a/src/muse.c +++ b/src/muse.c @@ -14,43 +14,43 @@ * are confused don't know not to read scrolls, etc.... */ -static int precheck(struct monst *, struct obj *); -static void mzapwand(struct monst *, struct obj *, boolean); -static void mplayhorn(struct monst *, struct obj *, boolean); -static void mreadmsg(struct monst *, struct obj *); -static void mquaffmsg(struct monst *, struct obj *); -static boolean m_use_healing(struct monst *); -static boolean m_sees_sleepy_soldier(struct monst *); -static void m_tele(struct monst *, boolean, boolean, int); -static boolean m_next2m(struct monst *); -static void reveal_trap(struct trap *, boolean); -static boolean linedup_chk_corpse(coordxy, coordxy); -static void m_use_undead_turning(struct monst *, struct obj *); -static boolean hero_behind_chokepoint(struct monst *); -static boolean mon_has_friends(struct monst *); -static int mbhitm(struct monst *, struct obj *); -static void mbhit(struct monst *, int, int (*)(MONST_P, OBJ_P), +staticfn int precheck(struct monst *, struct obj *); +staticfn void mzapwand(struct monst *, struct obj *, boolean); +staticfn void mplayhorn(struct monst *, struct obj *, boolean); +staticfn void mreadmsg(struct monst *, struct obj *); +staticfn void mquaffmsg(struct monst *, struct obj *); +staticfn boolean m_use_healing(struct monst *); +staticfn boolean m_sees_sleepy_soldier(struct monst *); +staticfn void m_tele(struct monst *, boolean, boolean, int); +staticfn boolean m_next2m(struct monst *); +staticfn void reveal_trap(struct trap *, boolean); +staticfn boolean linedup_chk_corpse(coordxy, coordxy); +staticfn void m_use_undead_turning(struct monst *, struct obj *); +staticfn boolean hero_behind_chokepoint(struct monst *); +staticfn boolean mon_has_friends(struct monst *); +staticfn int mbhitm(struct monst *, struct obj *); +staticfn void mbhit(struct monst *, int, int (*)(MONST_P, OBJ_P), int (*)(OBJ_P, OBJ_P), struct obj *); -static struct permonst *muse_newcham_mon(struct monst *); -static int mloot_container(struct monst *mon, struct obj *, boolean); -static void you_aggravate(struct monst *); +staticfn struct permonst *muse_newcham_mon(struct monst *); +staticfn int mloot_container(struct monst *mon, struct obj *, boolean); +staticfn void you_aggravate(struct monst *); #if 0 static boolean necrophiliac(struct obj *, boolean); #endif -static void mon_consume_unstone(struct monst *, struct obj *, boolean, +staticfn void mon_consume_unstone(struct monst *, struct obj *, boolean, boolean); -static boolean cures_stoning(struct monst *, struct obj *, boolean); -static boolean mcould_eat_tin(struct monst *); -static boolean muse_unslime(struct monst *, struct obj *, struct trap *, +staticfn boolean cures_stoning(struct monst *, struct obj *, boolean); +staticfn boolean mcould_eat_tin(struct monst *); +staticfn boolean muse_unslime(struct monst *, struct obj *, struct trap *, boolean); -static int cures_sliming(struct monst *, struct obj *); -static boolean green_mon(struct monst *); +staticfn int cures_sliming(struct monst *, struct obj *); +staticfn boolean green_mon(struct monst *); /* Any preliminary checks which may result in the monster being unable to use * the item. Returns 0 if nothing happened, 2 if the monster can't do * anything (i.e. it teleported) and 1 if it's dead. */ -static int +staticfn int precheck(struct monst *mon, struct obj *obj) { boolean vis; @@ -155,7 +155,7 @@ precheck(struct monst *mon, struct obj *obj) /* when a monster zaps a wand give a message, deduct a charge, and if it isn't directly seen, remove hero's memory of the number of charges */ -static void +staticfn void mzapwand( struct monst *mtmp, struct obj *otmp, @@ -185,7 +185,7 @@ mzapwand( } /* similar to mzapwand() but for magical horns (only instrument mons play) */ -static void +staticfn void mplayhorn( struct monst *mtmp, struct obj *otmp, @@ -228,7 +228,7 @@ mplayhorn( /* see or hear a monster reading a scroll; when scroll hasn't been seen, its label is revealed unless hero is deaf */ -static void +staticfn void mreadmsg(struct monst *mtmp, struct obj *otmp) { char onambuf[BUFSZ]; @@ -276,7 +276,7 @@ mreadmsg(struct monst *mtmp, struct obj *otmp) vismon ? mon_nam(mtmp) : mhe(mtmp)); } -static void +staticfn void mquaffmsg(struct monst *mtmp, struct obj *otmp) { if (canseemon(mtmp)) { @@ -320,7 +320,7 @@ mquaffmsg(struct monst *mtmp, struct obj *otmp) * that if you polymorph into one you teleport at will. */ -static boolean +staticfn boolean m_use_healing(struct monst *mtmp) { struct obj *obj; @@ -344,7 +344,7 @@ m_use_healing(struct monst *mtmp) } /* return TRUE if monster mtmp can see at least one sleeping soldier */ -static boolean +staticfn boolean m_sees_sleepy_soldier(struct monst *mtmp) { coordxy x = mtmp->mx, y = mtmp->my; @@ -367,7 +367,7 @@ m_sees_sleepy_soldier(struct monst *mtmp) return FALSE; } -static void +staticfn void m_tele( struct monst *mtmp, /* monst that might be teleported */ boolean vismon, /* can see it */ @@ -403,7 +403,7 @@ m_tele( * Called from find_defensive() where it is limited to Is_knox() * only, otherwise you could trap two monsters next to each other * in a boulder fort, and they would be happy to stay in there. */ -static boolean +staticfn boolean m_next2m(struct monst *mtmp) { coordxy x, y; @@ -740,7 +740,7 @@ find_defensive(struct monst *mtmp, boolean tryescape) accessible (trap doors and teleporters inside niches are located at secret corridor locations; convert such into normal corridor even if hero doesn't see it happen) */ -static void +staticfn void reveal_trap(struct trap *t, boolean seeit) { struct rm *lev = &levl[t->tx][t->ty]; @@ -1241,13 +1241,13 @@ rnd_defensive_item(struct monst *mtmp) /*#define MUSE_WAN_UNDEAD_TURNING 20*/ /* also a defensive item so don't * redefine; nonconsecutive value is ok */ -static boolean +staticfn boolean linedup_chk_corpse(coordxy x, coordxy y) { return (sobj_at(CORPSE, x, y) != 0); } -static void +staticfn void m_use_undead_turning(struct monst *mtmp, struct obj *obj) { coordxy ax = u.ux + sgn(mtmp->mux - mtmp->mx) * 3, @@ -1293,7 +1293,7 @@ m_use_undead_turning(struct monst *mtmp, struct obj *obj) } /* from monster's point of view, is hero behind a chokepoint? */ -static boolean +staticfn boolean hero_behind_chokepoint(struct monst *mtmp) { coordxy dx = sgn(mtmp->mx - mtmp->mux); @@ -1320,7 +1320,7 @@ hero_behind_chokepoint(struct monst *mtmp) } /* hostile monster has another hostile next to it */ -static boolean +staticfn boolean mon_has_friends(struct monst *mtmp) { coordxy dx, dy; @@ -1514,7 +1514,7 @@ find_offensive(struct monst *mtmp) #undef nomore } -static int +staticfn int mbhitm(struct monst *mtmp, struct obj *otmp) { int tmp; @@ -1627,7 +1627,7 @@ mbhitm(struct monst *mtmp, struct obj *otmp) * zapping you, so we need a special function for it. (Unless someone wants * to merge the two functions...) */ -static void +staticfn void mbhit( struct monst *mon, /* monster shooting the wand */ int range, /* direction and range */ @@ -2151,7 +2151,7 @@ find_misc(struct monst *mtmp) /* type of monster to polymorph into; defaults to one suitable for the current level rather than the totally arbitrary choice of newcham() */ -static struct permonst * +staticfn struct permonst * muse_newcham_mon(struct monst *mon) { struct obj *m_armr; @@ -2165,7 +2165,7 @@ muse_newcham_mon(struct monst *mon) return rndmonst(); } -static int +staticfn int mloot_container( struct monst *mon, struct obj *container, @@ -2501,7 +2501,7 @@ use_misc(struct monst *mtmp) RESTORE_WARNINGS -static void +staticfn void you_aggravate(struct monst *mtmp) { pline("For some reason, %s presence is known to you.", @@ -2776,7 +2776,7 @@ munstone(struct monst *mon, boolean by_you) return FALSE; } -static void +staticfn void mon_consume_unstone( struct monst *mon, struct obj *obj, @@ -2855,7 +2855,7 @@ mon_consume_unstone( } /* decide whether obj can cure petrification; also used when picking up */ -static boolean +staticfn boolean cures_stoning(struct monst *mon, struct obj *obj, boolean tinok) { if (obj->otyp == POT_ACID) @@ -2871,7 +2871,7 @@ cures_stoning(struct monst *mon, struct obj *obj, boolean tinok) || acidic(&mons[obj->corpsenm])); } -static boolean +staticfn boolean mcould_eat_tin(struct monst *mon) { struct obj *obj, *mwep; @@ -2974,7 +2974,7 @@ munslime(struct monst *mon, boolean by_you) } /* mon uses an item--selected by caller--to burn away incipient slime */ -static boolean +staticfn boolean muse_unslime( struct monst *mon, struct obj *obj, @@ -3115,7 +3115,7 @@ muse_unslime( } /* decide whether obj can be used to cure green slime */ -static int +staticfn int cures_sliming(struct monst *mon, struct obj *obj) { /* scroll of fire */ @@ -3138,7 +3138,7 @@ cures_sliming(struct monst *mon, struct obj *obj) seem plausibly green (which didn't necessarily match the categorization by the color of the text). iflags.use_color is not meant for game behavior decisions */ -static boolean +staticfn boolean green_mon(struct monst *mon) { struct permonst *ptr = mon->data; diff --git a/src/music.c b/src/music.c index 06ebe724a..ce4510321 100644 --- a/src/music.c +++ b/src/music.c @@ -28,19 +28,19 @@ #include "hack.h" -static void awaken_scare(struct monst *, boolean); -static void awaken_monsters(int); -static void put_monsters_to_sleep(int); -static void charm_snakes(int); -static void calm_nymphs(int); -static void charm_monsters(int); -static void do_earthquake(int); -static const char *generic_lvl_desc(void); -static int do_improvisation(struct obj *); -static char *improvised_notes(boolean *); +staticfn void awaken_scare(struct monst *, boolean); +staticfn void awaken_monsters(int); +staticfn void put_monsters_to_sleep(int); +staticfn void charm_snakes(int); +staticfn void calm_nymphs(int); +staticfn void charm_monsters(int); +staticfn void do_earthquake(int); +staticfn const char *generic_lvl_desc(void); +staticfn int do_improvisation(struct obj *); +staticfn char *improvised_notes(boolean *); /* wake up monster, possibly scare it */ -static void +staticfn void awaken_scare(struct monst *mtmp, boolean scary) { mtmp->msleeping = 0; @@ -62,7 +62,7 @@ awaken_scare(struct monst *mtmp, boolean scary) * Wake every monster in range... */ -static void +staticfn void awaken_monsters(int distance) { struct monst *mtmp; @@ -80,7 +80,7 @@ awaken_monsters(int distance) * Make monsters fall asleep. Note that they may resist the spell. */ -static void +staticfn void put_monsters_to_sleep(int distance) { struct monst *mtmp; @@ -100,7 +100,7 @@ put_monsters_to_sleep(int distance) * Charm snakes in range. Note that the snakes are NOT tamed. */ -static void +staticfn void charm_snakes(int distance) { struct monst *mtmp; @@ -134,7 +134,7 @@ charm_snakes(int distance) * Calm nymphs in range. */ -static void +staticfn void calm_nymphs(int distance) { struct monst *mtmp; @@ -191,7 +191,7 @@ awaken_soldiers(struct monst* bugler /* monster that played instrument */) } /* Charm monsters in range. Note that they may resist the spell. */ -static void +staticfn void charm_monsters(int distance) { struct monst *mtmp, *mtmp2; @@ -218,7 +218,7 @@ charm_monsters(int distance) /* Generate earthquake :-) of desired force. * That is: create random chasms (pits). */ -static void +staticfn void do_earthquake(int force) { static const char into_a_chasm[] = " into a chasm"; @@ -455,7 +455,7 @@ do_earthquake(int force) } } -static const char * +staticfn const char * generic_lvl_desc(void) { if (Is_astralevel(&u.uz)) @@ -472,7 +472,7 @@ generic_lvl_desc(void) return "dungeon"; } -const char *beats[] = { +static const char *beats[] = { "stepper", "one drop", "slow two", "triple stroke roll", "double shuffle", "half-time shuffle", "second line", "train" }; @@ -480,14 +480,14 @@ const char *beats[] = { /* * The player is trying to extract something from his/her instrument. */ -static int +staticfn int do_improvisation(struct obj *instr) { int damage, mode, do_spec = !(Stunned || Confusion); 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,10 +706,11 @@ do_improvisation(struct obj *instr) impossible("What a weird instrument (%d)!", instr->otyp); return 0; } + nhUse(improvisation); return 2; /* That takes time */ } -static char * +staticfn char * improvised_notes(boolean *same_as_last_time) { static const char notes[7] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G' }; diff --git a/src/nhlobj.c b/src/nhlobj.c index 2eefac8b9..411219f0a 100644 --- a/src/nhlobj.c +++ b/src/nhlobj.c @@ -10,28 +10,28 @@ struct _lua_obj { struct obj *obj; }; -static struct _lua_obj *l_obj_check(lua_State *, int); -static int l_obj_add_to_container(lua_State *); -static int l_obj_gc(lua_State *); -static int l_obj_getcontents(lua_State *); -static int l_obj_isnull(lua_State *); -static int l_obj_new_readobjnam(lua_State *); -static int l_obj_nextobj(lua_State *); -static int l_obj_objects_to_table(lua_State *); -static int l_obj_placeobj(lua_State *); -static int l_obj_to_table(lua_State *); -static int l_obj_at(lua_State *); -static int l_obj_container(lua_State *); -static int l_obj_timer_has(lua_State *); -static int l_obj_timer_peek(lua_State *); -static int l_obj_timer_stop(lua_State *); -static int l_obj_timer_start(lua_State *); -static int l_obj_bury(lua_State *); -static struct _lua_obj *l_obj_push(lua_State *, struct obj *); +staticfn struct _lua_obj *l_obj_check(lua_State *, int); +staticfn int l_obj_add_to_container(lua_State *); +staticfn int l_obj_gc(lua_State *); +staticfn int l_obj_getcontents(lua_State *); +staticfn int l_obj_isnull(lua_State *); +staticfn int l_obj_new_readobjnam(lua_State *); +staticfn int l_obj_nextobj(lua_State *); +staticfn int l_obj_objects_to_table(lua_State *); +staticfn int l_obj_placeobj(lua_State *); +staticfn int l_obj_to_table(lua_State *); +staticfn int l_obj_at(lua_State *); +staticfn int l_obj_container(lua_State *); +staticfn int l_obj_timer_has(lua_State *); +staticfn int l_obj_timer_peek(lua_State *); +staticfn int l_obj_timer_stop(lua_State *); +staticfn int l_obj_timer_start(lua_State *); +staticfn int l_obj_bury(lua_State *); +staticfn struct _lua_obj *l_obj_push(lua_State *, struct obj *); #define lobj_is_ok(lo) ((lo) && (lo)->obj && (lo)->obj->where != OBJ_LUAFREE) -static struct _lua_obj * +staticfn struct _lua_obj * l_obj_check(lua_State *L, int indx) { struct _lua_obj *lo; @@ -43,7 +43,7 @@ l_obj_check(lua_State *L, int indx) return lo; } -static int +staticfn int l_obj_gc(lua_State *L) { struct obj *obj, *otmp; @@ -69,7 +69,7 @@ l_obj_gc(lua_State *L) return 0; } -static struct _lua_obj * +staticfn struct _lua_obj * l_obj_push(lua_State *L, struct obj *otmp) { struct _lua_obj *lo = (struct _lua_obj *) lua_newuserdata(L, sizeof(struct _lua_obj)); @@ -92,7 +92,7 @@ nhl_push_obj(lua_State *L, struct obj *otmp) /* local o = obj.new("large chest"); local cobj = o:contents(); */ -static int +staticfn int l_obj_getcontents(lua_State *L) { struct _lua_obj *lo = l_obj_check(L, 1); @@ -109,7 +109,7 @@ l_obj_getcontents(lua_State *L) /* local box = obj.new("large chest"); box:addcontent(obj.new("rock")); */ -static int +staticfn int l_obj_add_to_container(lua_State *L) { struct _lua_obj *lobox = l_obj_check(L, 1); @@ -166,7 +166,7 @@ DISABLE_WARNING_UNREACHABLE_CODE /* local odata = obj.class(otbl.otyp); */ /* local odata = obj.class(obj.new("rock")); */ /* local odata = o:class(); */ -static int +staticfn int l_obj_objects_to_table(lua_State *L) { int argc = lua_gettop(L); @@ -242,7 +242,7 @@ RESTORE_WARNING_UNREACHABLE_CODE object fields. local o = obj.new("rock"); local otbl = o:totable(); */ -static int +staticfn int l_obj_to_table(lua_State *L) { struct _lua_obj *lo = l_obj_check(L, 1); @@ -343,7 +343,7 @@ DISABLE_WARNING_UNREACHABLE_CODE /* create a new object via wishing routine */ /* local o = obj.new("rock"); */ -static int +staticfn int l_obj_new_readobjnam(lua_State *L) { int argc = lua_gettop(L); @@ -366,7 +366,7 @@ l_obj_new_readobjnam(lua_State *L) /* Get the topmost object on the map at x,y */ /* local o = obj.at(x, y); */ -static int +staticfn int l_obj_at(lua_State *L) { int argc = lua_gettop(L); @@ -390,7 +390,7 @@ l_obj_at(lua_State *L) /* Place an object on the map at (x,y). local o = obj.new("rock"); o:placeobj(u.ux, u.uy); */ -static int +staticfn int l_obj_placeobj(lua_State *L) { int argc = lua_gettop(L); @@ -422,7 +422,7 @@ RESTORE_WARNING_UNREACHABLE_CODE local o2 = o:next(true); local firstobj = obj.next(); */ -static int +staticfn int l_obj_nextobj(lua_State *L) { int argc = lua_gettop(L); @@ -446,7 +446,7 @@ l_obj_nextobj(lua_State *L) /* Get the container object is in */ /* local box = o:container(); */ -static int +staticfn int l_obj_container(lua_State *L) { struct _lua_obj *lo = l_obj_check(L, 1); @@ -460,7 +460,7 @@ l_obj_container(lua_State *L) /* Is the object a null? */ /* local badobj = o:isnull(); */ -static int +staticfn int l_obj_isnull(lua_State *L) { struct _lua_obj *lo = l_obj_check(L, 1); @@ -473,7 +473,7 @@ DISABLE_WARNING_UNREACHABLE_CODE /* does object have a timer of certain type? */ /* local hastimer = o:has_timer("rot-organic"); */ -static int +staticfn int l_obj_timer_has(lua_State *L) { int argc = lua_gettop(L); @@ -497,7 +497,7 @@ l_obj_timer_has(lua_State *L) /* peek at an object timer. return the turn when timer triggers. returns 0 if no such timer attached to the object. */ /* local timeout = o:peek_timer("hatch-egg"); */ -static int +staticfn int l_obj_timer_peek(lua_State *L) { int argc = lua_gettop(L); @@ -524,7 +524,7 @@ l_obj_timer_peek(lua_State *L) without a timer type parameter, stops all timers for the object. */ /* local timeout = o:stop_timer("rot-organic"); */ /* o:stop_timer(); */ -static int +staticfn int l_obj_timer_stop(lua_State *L) { int argc = lua_gettop(L); @@ -556,7 +556,7 @@ RESTORE_WARNING_UNREACHABLE_CODE /* start an object timer. */ /* o:start_timer("hatch-egg", 10); */ -static int +staticfn int l_obj_timer_start(lua_State *L) { int argc = lua_gettop(L); @@ -580,7 +580,7 @@ l_obj_timer_start(lua_State *L) false otherwise. */ /* local ogone = o:bury(); */ /* local ogone = o:bury(5,5); */ -static int +staticfn int l_obj_bury(lua_State *L) { int argc = lua_gettop(L); diff --git a/src/nhlsel.c b/src/nhlsel.c index bb3a44451..544df9d4b 100644 --- a/src/nhlsel.c +++ b/src/nhlsel.c @@ -7,41 +7,41 @@ struct selectionvar *l_selection_check(lua_State *, int); -static struct selectionvar *l_selection_push_new(lua_State *); +staticfn struct selectionvar *l_selection_push_new(lua_State *); /* lua_CFunction prototypes */ -static int l_selection_new(lua_State *); -static int l_selection_clone(lua_State *); -static int l_selection_numpoints(lua_State *); -static int l_selection_getpoint(lua_State *); -static int l_selection_setpoint(lua_State *); -static int l_selection_filter_percent(lua_State *); -static int l_selection_rndcoord(lua_State *); -static int l_selection_room(lua_State *); -static int l_selection_getbounds(lua_State *); -static boolean params_sel_2coords(lua_State *, struct selectionvar **, +staticfn int l_selection_new(lua_State *); +staticfn int l_selection_clone(lua_State *); +staticfn int l_selection_numpoints(lua_State *); +staticfn int l_selection_getpoint(lua_State *); +staticfn int l_selection_setpoint(lua_State *); +staticfn int l_selection_filter_percent(lua_State *); +staticfn int l_selection_rndcoord(lua_State *); +staticfn int l_selection_room(lua_State *); +staticfn int l_selection_getbounds(lua_State *); +staticfn boolean params_sel_2coords(lua_State *, struct selectionvar **, coordxy *, coordxy *, coordxy *, coordxy *); -static int l_selection_line(lua_State *); -static int l_selection_randline(lua_State *); -static int l_selection_rect(lua_State *); -static int l_selection_fillrect(lua_State *); -static int l_selection_grow(lua_State *); -static int l_selection_filter_mapchar(lua_State *); -static int l_selection_match(lua_State *); -static int l_selection_flood(lua_State *); -static int l_selection_circle(lua_State *); -static int l_selection_ellipse(lua_State *); -static int l_selection_gradient(lua_State *); -static int l_selection_iterate(lua_State *); -static int l_selection_gc(lua_State *); -static int l_selection_not(lua_State *); -static int l_selection_and(lua_State *); -static int l_selection_or(lua_State *); -static int l_selection_xor(lua_State *); +staticfn int l_selection_line(lua_State *); +staticfn int l_selection_randline(lua_State *); +staticfn int l_selection_rect(lua_State *); +staticfn int l_selection_fillrect(lua_State *); +staticfn int l_selection_grow(lua_State *); +staticfn int l_selection_filter_mapchar(lua_State *); +staticfn int l_selection_match(lua_State *); +staticfn int l_selection_flood(lua_State *); +staticfn int l_selection_circle(lua_State *); +staticfn int l_selection_ellipse(lua_State *); +staticfn int l_selection_gradient(lua_State *); +staticfn int l_selection_iterate(lua_State *); +staticfn int l_selection_gc(lua_State *); +staticfn int l_selection_not(lua_State *); +staticfn int l_selection_and(lua_State *); +staticfn int l_selection_or(lua_State *); +staticfn int l_selection_xor(lua_State *); /* There doesn't seem to be a point in having a l_selection_add since it would * do the same thing as l_selection_or. The addition operator is mapped to * l_selection_or. */ -static int l_selection_sub(lua_State *); +staticfn int l_selection_sub(lua_State *); #if 0 /* the following do not appear to currently be used and because they are static, the OSX @@ -49,8 +49,8 @@ static int l_selection_sub(lua_State *); if ifdef'd out the prototype here and the function body below. */ -static int l_selection_ipairs(lua_State *); -static struct selectionvar *l_selection_to(lua_State *, int); +staticfn int l_selection_ipairs(lua_State *); +staticfn struct selectionvar *l_selection_to(lua_State *, int); #endif struct selectionvar * @@ -65,7 +65,7 @@ l_selection_check(lua_State *L, int index) return sel; } -static int +staticfn int l_selection_gc(lua_State *L) { struct selectionvar *sel = l_selection_check(L, 1); @@ -76,7 +76,7 @@ l_selection_gc(lua_State *L) } #if 0 -static struct selectionvar * +staticfn struct selectionvar * l_selection_to(lua_State *L, int index) { struct selectionvar *sel = (struct selectionvar *) lua_touserdata(L, index); @@ -88,7 +88,7 @@ l_selection_to(lua_State *L, int index) #endif /* push a new selection into lua stack, return the selectionvar */ -static struct selectionvar * +staticfn struct selectionvar * l_selection_push_new(lua_State *L) { struct selectionvar *tmp = selection_new(); @@ -121,7 +121,7 @@ l_selection_push_copy(lua_State *L, struct selectionvar *tmp) /* local sel = selection.new(); */ -static int +staticfn int l_selection_new(lua_State *L) { (void) l_selection_push_new(L); @@ -130,7 +130,7 @@ l_selection_new(lua_State *L) /* Replace the topmost selection in the stack with a clone of it. */ /* local sel = selection.clone(sel); */ -static int +staticfn int l_selection_clone(lua_State *L) { struct selectionvar *sel = l_selection_check(L, 1); @@ -153,7 +153,7 @@ DISABLE_WARNING_UNREACHABLE_CODE /* local sel = sel:set(); */ /* local sel = selection.set(sel); */ /* TODO: allow setting multiple coordinates at once: set({x,y}, {x,y}, ...); */ -static int +staticfn int l_selection_setpoint(lua_State *L) { struct selectionvar *sel = (struct selectionvar *) 0; @@ -197,7 +197,7 @@ l_selection_setpoint(lua_State *L) } /* local numpoints = selection.numpoints(sel); */ -static int +staticfn int l_selection_numpoints(lua_State *L) { struct selectionvar *sel = l_selection_check(L, 1); @@ -218,7 +218,7 @@ l_selection_numpoints(lua_State *L) } /* local value = selection.get(sel, x, y); */ -static int +staticfn int l_selection_getpoint(lua_State *L) { struct selectionvar *sel = l_selection_check(L, 1); @@ -253,7 +253,7 @@ RESTORE_WARNING_UNREACHABLE_CODE /* local s = selection.negate(sel); */ /* local s = selection.negate(); */ /* local s = sel:negate(); */ -static int +staticfn int l_selection_not(lua_State *L) { int argc = lua_gettop(L); @@ -274,7 +274,7 @@ l_selection_not(lua_State *L) } /* local sel = selection.area(4,5, 40,10) & selection.rect(7,8, 60,14); */ -static int +staticfn int l_selection_and(lua_State *L) { int x,y; @@ -297,7 +297,7 @@ l_selection_and(lua_State *L) } /* local sel = selection.area(4,5, 40,10) | selection.rect(7,8, 60,14); */ -static int +staticfn int l_selection_or(lua_State *L) { int x,y; @@ -321,7 +321,7 @@ l_selection_or(lua_State *L) } /* local sel = selection.area(4,5, 40,10) ~ selection.rect(7,8, 60,14); */ -static int +staticfn int l_selection_xor(lua_State *L) { int x,y; @@ -348,7 +348,7 @@ l_selection_xor(lua_State *L) /* local sel = selection.area(10,10, 20,20) - selection.area(14,14, 17,17) * - i.e. points that are in A but not in B */ -static int +staticfn int l_selection_sub(lua_State *L) { int x,y; @@ -376,7 +376,7 @@ l_selection_sub(lua_State *L) } /* local s = selection.percentage(sel, 50); */ -static int +staticfn int l_selection_filter_percent(lua_State *L) { int argc = lua_gettop(L); @@ -394,7 +394,7 @@ l_selection_filter_percent(lua_State *L) /* local pt = selection.rndcoord(sel); */ /* local pt = selection.rndcoord(sel, 1); */ -static int +staticfn int l_selection_rndcoord(lua_State *L) { struct selectionvar *sel = l_selection_check(L, 1); @@ -419,7 +419,7 @@ l_selection_rndcoord(lua_State *L) } /* local s = selection.room(); */ -static int +staticfn int l_selection_room(lua_State *L) { struct selectionvar *sel; @@ -441,7 +441,7 @@ l_selection_room(lua_State *L) } /* local rect = sel:bounds(); */ -static int +staticfn int l_selection_getbounds(lua_State *L) { struct selectionvar *sel = l_selection_check(L, 1); @@ -463,7 +463,7 @@ l_selection_getbounds(lua_State *L) */ /* function(selection, x1,y1, x2,y2) */ /* selection:function(x1,y1, x2,y2) */ -static boolean +staticfn boolean params_sel_2coords(lua_State *L, struct selectionvar **sel, coordxy *x1, coordxy *y1, coordxy *x2, coordxy *y2) { @@ -496,7 +496,7 @@ params_sel_2coords(lua_State *L, struct selectionvar **sel, /* local s = selection.line(sel, x1,y1, x2,y2); */ /* local s = selection.line(x1,y1, x2,y2); */ /* s:line(x1,y1, x2,y2); */ -static int +staticfn int l_selection_line(lua_State *L) { struct selectionvar *sel = NULL; @@ -516,7 +516,7 @@ l_selection_line(lua_State *L) } /* local s = selection.rect(sel, x1,y1, x2,y2); */ -static int +staticfn int l_selection_rect(lua_State *L) { struct selectionvar *sel = NULL; @@ -544,7 +544,7 @@ l_selection_rect(lua_State *L) /* local s = selection.fillrect(x1,y1, x2,y2); */ /* s:fillrect(x1,y1, x2,y2); */ /* selection.area(x1,y1, x2,y2); */ -static int +staticfn int l_selection_fillrect(lua_State *L) { struct selectionvar *sel = NULL; @@ -576,7 +576,7 @@ l_selection_fillrect(lua_State *L) /* local s = selection.randline(x1,y1, x2,y2, roughness); */ /* TODO: selection.randline(x1,y1, x2,y2, roughness); */ /* TODO: selection.randline({x1,y1}, {x2,y2}, roughness); */ -static int +staticfn int l_selection_randline(lua_State *L) { int argc = lua_gettop(L); @@ -616,7 +616,7 @@ l_selection_randline(lua_State *L) /* local s = selection.grow(sel); */ /* local s = selection.grow(sel, "north"); */ -static int +staticfn int l_selection_grow(lua_State *L) { int argc = lua_gettop(L); @@ -637,7 +637,7 @@ l_selection_grow(lua_State *L) /* local s = selection.filter_mapchar(sel, mapchar, lit); */ -static int +staticfn int l_selection_filter_mapchar(lua_State *L) { int argc = lua_gettop(L); @@ -662,7 +662,7 @@ l_selection_filter_mapchar(lua_State *L) } /* local s = selection.match([[...]]); */ -static int +staticfn int l_selection_match(lua_State *L) { int argc = lua_gettop(L); @@ -702,7 +702,7 @@ l_selection_match(lua_State *L) /* local s = selection.floodfill(x,y); */ /* local s = selection.floodfill(x,y, diagonals); */ -static int +staticfn int l_selection_flood(lua_State *L) { int argc = lua_gettop(L); @@ -738,7 +738,7 @@ l_selection_flood(lua_State *L) /* local s = selection.circle(x, y, radius, filled); */ /* local s = selection.circle(sel, x, y, radius); */ /* local s = selection.circle(sel, x, y, radius, filled); */ -static int +staticfn int l_selection_circle(lua_State *L) { int argc = lua_gettop(L); @@ -786,7 +786,7 @@ l_selection_circle(lua_State *L) /* local s = selection.ellipse(x, y, radius1, radius2, filled); */ /* local s = selection.ellipse(sel, x, y, radius1, radius2); */ /* local s = selection.ellipse(sel, x, y, radius1, radius2, filled); */ -static int +staticfn int l_selection_ellipse(lua_State *L) { int argc = lua_gettop(L); @@ -838,7 +838,7 @@ l_selection_ellipse(lua_State *L) * non-obvious argument order. */ /* selection.gradient({ type = "radial", x = 3, y = 5, x2 = 10, y2 = 12, * mindist = 4, maxdist = 10, limited = false }); */ -static int +staticfn int l_selection_gradient(lua_State *L) { int argc = lua_gettop(L); @@ -898,7 +898,7 @@ l_selection_gradient(lua_State *L) * The x, y coordinates passed to the function are map- or room-relative * rather than absolute, unless there has been no previous map or room defined. */ -static int +staticfn int l_selection_iterate(lua_State *L) { int argc = lua_gettop(L); diff --git a/src/nhlua.c b/src/nhlua.c index d6bed268f..79f240364 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -27,68 +27,68 @@ struct e; /* lua_CFunction prototypes */ #ifdef DUMPLOG -static int nhl_dump_fmtstr(lua_State *); +staticfn int nhl_dump_fmtstr(lua_State *); #endif /* DUMPLOG */ -static int nhl_dnum_name(lua_State *); -static int nhl_stairways(lua_State *); -static int nhl_pushkey(lua_State *); -static int nhl_doturn(lua_State *); -static int nhl_debug_flags(lua_State *); -static int nhl_timer_has_at(lua_State *); -static int nhl_timer_peek_at(lua_State *); -static int nhl_timer_stop_at(lua_State *); -static int nhl_timer_start_at(lua_State *); -static int nhl_get_cmd_key(lua_State *); -static int nhl_callback(lua_State *); -static int nhl_gamestate(lua_State *); -static int nhl_test(lua_State *); -static int nhl_getmap(lua_State *); -static char splev_typ2chr(schar); -static int nhl_gettrap(lua_State *); -static int nhl_deltrap(lua_State *); +staticfn int nhl_dnum_name(lua_State *); +staticfn int nhl_stairways(lua_State *); +staticfn int nhl_pushkey(lua_State *); +staticfn int nhl_doturn(lua_State *); +staticfn int nhl_debug_flags(lua_State *); +staticfn int nhl_timer_has_at(lua_State *); +staticfn int nhl_timer_peek_at(lua_State *); +staticfn int nhl_timer_stop_at(lua_State *); +staticfn int nhl_timer_start_at(lua_State *); +staticfn int nhl_get_cmd_key(lua_State *); +staticfn int nhl_callback(lua_State *); +staticfn int nhl_gamestate(lua_State *); +staticfn int nhl_test(lua_State *); +staticfn int nhl_getmap(lua_State *); +staticfn char splev_typ2chr(schar); +staticfn int nhl_gettrap(lua_State *); +staticfn int nhl_deltrap(lua_State *); #if 0 -static int nhl_setmap(lua_State *); +staticfn int nhl_setmap(lua_State *); #endif -static int nhl_impossible(lua_State *); -static int nhl_pline(lua_State *); -static int nhl_verbalize(lua_State *); -static int nhl_parse_config(lua_State *); -static int nhl_menu(lua_State *); -static int nhl_text(lua_State *); -static int nhl_getlin(lua_State *); -static int nhl_makeplural(lua_State *); -static int nhl_makesingular(lua_State *); -static int nhl_s_suffix(lua_State *); -static int nhl_ing_suffix(lua_State *); -static int nhl_an(lua_State *); -static int nhl_rn2(lua_State *); -static int nhl_random(lua_State *); -static int nhl_level_difficulty(lua_State *); -static void init_nhc_data(lua_State *); -static int nhl_push_anything(lua_State *, int, void *); -static int nhl_meta_u_index(lua_State *); -static int nhl_meta_u_newindex(lua_State *); -static int nhl_u_clear_inventory(lua_State *); -static int nhl_u_giveobj(lua_State *); -static void init_u_data(lua_State *); +staticfn int nhl_impossible(lua_State *); +staticfn int nhl_pline(lua_State *); +staticfn int nhl_verbalize(lua_State *); +staticfn int nhl_parse_config(lua_State *); +staticfn int nhl_menu(lua_State *); +staticfn int nhl_text(lua_State *); +staticfn int nhl_getlin(lua_State *); +staticfn int nhl_makeplural(lua_State *); +staticfn int nhl_makesingular(lua_State *); +staticfn int nhl_s_suffix(lua_State *); +staticfn int nhl_ing_suffix(lua_State *); +staticfn int nhl_an(lua_State *); +staticfn int nhl_rn2(lua_State *); +staticfn int nhl_random(lua_State *); +staticfn int nhl_level_difficulty(lua_State *); +staticfn void init_nhc_data(lua_State *); +staticfn int nhl_push_anything(lua_State *, int, void *); +staticfn int nhl_meta_u_index(lua_State *); +staticfn int nhl_meta_u_newindex(lua_State *); +staticfn int nhl_u_clear_inventory(lua_State *); +staticfn int nhl_u_giveobj(lua_State *); +staticfn void init_u_data(lua_State *); #ifdef notyet -static int nhl_set_package_path(lua_State *, const char *); +staticfn int nhl_set_package_path(lua_State *, const char *); #endif -static int traceback_handler(lua_State *); -static uint32_t nhl_getmeminuse(lua_State *); +staticfn int traceback_handler(lua_State *); +staticfn uint32_t nhl_getmeminuse(lua_State *); #ifdef NHL_SANDBOX -static void nhlL_openlibs(lua_State *, uint32_t); +staticfn void nhlL_openlibs(lua_State *, uint32_t); #endif -static void *nhl_alloc(void *, void *, size_t, size_t); -static lua_State *nhlL_newstate (nhl_sandbox_info *, const char *); -static void end_luapat(void); -static int nhl_get_config(lua_State *); -static int nhl_variable(lua_State *); -static void nhl_clearfromtable(lua_State *, int, int, struct e *); -static void nhl_warn(void *, const char *, int); -static void nhl_clearfromtable(lua_State *, int, int, struct e *); -static int nhl_panic(lua_State *); -static void nhl_hookfn(lua_State *, lua_Debug *); +staticfn void *nhl_alloc(void *, void *, size_t, size_t); +staticfn lua_State *nhlL_newstate (nhl_sandbox_info *, const char *); +staticfn void end_luapat(void); +staticfn int nhl_get_config(lua_State *); +staticfn int nhl_variable(lua_State *); +staticfn void nhl_clearfromtable(lua_State *, int, int, struct e *); +staticfn void nhl_warn(void *, const char *, int); +staticfn void nhl_clearfromtable(lua_State *, int, int, struct e *); +staticfn int nhl_panic(lua_State *); +staticfn void nhl_hookfn(lua_State *, lua_Debug *); static const char *const nhcore_call_names[NUM_NHCORE_CALLS] = { "start_new_game", @@ -329,7 +329,7 @@ nhl_add_table_entry_region(lua_State *L, const char *name, coordxy x1, /* converting from special level "map character" to levl location type and back. order here is important. */ -const struct { +static const struct { char ch; schar typ; } char2typ[] = { @@ -389,7 +389,7 @@ check_mapchr(const char *s) return INVALID_TYPE; } -static char +staticfn char splev_typ2chr(schar typ) { int i; @@ -404,7 +404,7 @@ DISABLE_WARNING_UNREACHABLE_CODE /* local t = nh.gettrap(x,y); */ /* local t = nh.gettrap({ x = 10, y = 10 }); */ -static int +staticfn int nhl_gettrap(lua_State *L) { lua_Integer lx, ly; @@ -458,7 +458,7 @@ nhl_gettrap(lua_State *L) } /* nh.deltrap(x,y); nh.deltrap({ x = 10, y = 15 }); */ -static int +staticfn int nhl_deltrap(lua_State *L) { lua_Integer lx, ly; @@ -517,7 +517,7 @@ DISABLE_WARNING_UNREACHABLE_CODE /* local loc = nh.getmap(x,y); */ /* local loc = nh.getmap({ x = 10, y = 35 }); */ -static int +staticfn int nhl_getmap(lua_State *L) { lua_Integer lx, ly; @@ -607,7 +607,7 @@ nhl_getmap(lua_State *L) } /* impossible("Error!") */ -static int +staticfn int nhl_impossible(lua_State *L) { int argc = lua_gettop(L); @@ -621,7 +621,7 @@ nhl_impossible(lua_State *L) /* pline("It hits!") */ /* pline("It hits!", true) */ -static int +staticfn int nhl_pline(lua_State *L) { int argc = lua_gettop(L); @@ -637,7 +637,7 @@ nhl_pline(lua_State *L) } /* verbalize("Fool!") */ -static int +staticfn int nhl_verbalize(lua_State *L) { int argc = lua_gettop(L); @@ -651,7 +651,7 @@ nhl_verbalize(lua_State *L) } /* parse_config("OPTIONS=!color") */ -static int +staticfn int nhl_parse_config(lua_State *L) { int argc = lua_gettop(L); @@ -665,7 +665,7 @@ nhl_parse_config(lua_State *L) } /* local windowtype = get_config("windowtype"); */ -static int +staticfn int nhl_get_config(lua_State *L) { int argc = lua_gettop(L); @@ -682,7 +682,7 @@ nhl_get_config(lua_State *L) /* str = getlin("What do you want to call this dungeon level?"); */ -static int +staticfn int nhl_getlin(lua_State *L) { int argc = lua_gettop(L); @@ -707,7 +707,7 @@ nhl_getlin(lua_State *L) selected = menu("prompt", default, pickX, { {key:"a", text:"option a"}, {key:"b", text:"option b"}, ... } ) */ -static int +staticfn int nhl_menu(lua_State *L) { static const char *const pickX[] = { "none", "one", "any" }; /* PICK_x */ @@ -796,7 +796,7 @@ nhl_menu(lua_State *L) } /* text("foo\nbar\nbaz") */ -static int +staticfn int nhl_text(lua_State *L) { int argc = lua_gettop(L); @@ -841,7 +841,7 @@ nhl_text(lua_State *L) } /* makeplural("zorkmid") */ -static int +staticfn int nhl_makeplural(lua_State *L) { int argc = lua_gettop(L); @@ -855,7 +855,7 @@ nhl_makeplural(lua_State *L) } /* makesingular("zorkmids") */ -static int +staticfn int nhl_makesingular(lua_State *L) { int argc = lua_gettop(L); @@ -869,7 +869,7 @@ nhl_makesingular(lua_State *L) } /* s_suffix("foo") */ -static int +staticfn int nhl_s_suffix(lua_State *L) { int argc = lua_gettop(L); @@ -883,7 +883,7 @@ nhl_s_suffix(lua_State *L) } /* ing_suffix("foo") */ -static int +staticfn int nhl_ing_suffix(lua_State *L) { int argc = lua_gettop(L); @@ -897,7 +897,7 @@ nhl_ing_suffix(lua_State *L) } /* an("foo") */ -static int +staticfn int nhl_an(lua_State *L) { int argc = lua_gettop(L); @@ -911,7 +911,7 @@ nhl_an(lua_State *L) } /* rn2(10) */ -static int +staticfn int nhl_rn2(lua_State *L) { int argc = lua_gettop(L); @@ -926,7 +926,7 @@ nhl_rn2(lua_State *L) /* random(10); -- is the same as rn2(10); */ /* random(5,8); -- same as 5 + rn2(8); */ -static int +staticfn int nhl_random(lua_State *L) { int argc = lua_gettop(L); @@ -943,7 +943,7 @@ nhl_random(lua_State *L) } /* level_difficulty() */ -static int +staticfn int nhl_level_difficulty(lua_State *L) { int argc = lua_gettop(L); @@ -1070,7 +1070,7 @@ get_table_option(lua_State *L, #ifdef DUMPLOG /* local fname = dump_fmtstr("/tmp/nethack.%n.%d.log"); */ -static int +staticfn int nhl_dump_fmtstr(lua_State *L) { int argc = lua_gettop(L); @@ -1085,7 +1085,7 @@ nhl_dump_fmtstr(lua_State *L) #endif /* DUMPLOG */ /* local dungeon_name = dnum_name(u.dnum); */ -static int +staticfn int nhl_dnum_name(lua_State *L) { int argc = lua_gettop(L); @@ -1108,7 +1108,7 @@ DISABLE_WARNING_UNREACHABLE_CODE /* set or get variables which are saved and restored along with the game. nh.variable("test", 10); local ten = nh.variable("test"); */ -static int +staticfn int nhl_variable(lua_State *L) { int argc = lua_gettop(L); @@ -1243,7 +1243,7 @@ restore_luadata(NHFILE *nhfp) } /* local stairs = stairways(); */ -static int +staticfn int nhl_stairways(lua_State *L) { stairway *tmp = gs.stairs; @@ -1274,7 +1274,7 @@ nhl_stairways(lua_State *L) /* test( { x = 123, y = 456 } ); */ -static int +staticfn int nhl_test(lua_State *L) { coordxy x, y; @@ -1298,7 +1298,7 @@ nhl_test(lua_State *L) /* push a key into command queue */ /* nh.pushkey("i"); */ -static int +staticfn int nhl_pushkey(lua_State *L) { int argc = lua_gettop(L); @@ -1314,7 +1314,7 @@ nhl_pushkey(lua_State *L) /* do a turn of moveloop, or until gm.multi is done if param is true. */ /* nh.doturn(); nh.doturn(true); */ -static int +staticfn int nhl_doturn(lua_State *L) { int argc = lua_gettop(L); @@ -1334,7 +1334,7 @@ nhl_doturn(lua_State *L) /* nh.debug_flags({ mongen = false, hunger = false, overwrite_stairs = true }); */ -static int +staticfn int nhl_debug_flags(lua_State *L) { int val; @@ -1377,7 +1377,7 @@ DISABLE_WARNING_UNREACHABLE_CODE /* does location at x,y have timer? */ /* local has_melttimer = nh.has_timer_at(x,y, "melt-ice"); */ /* local has_melttimer = nh.has_timer_at({x=4,y=7}, "melt-ice"); */ -static int +staticfn int nhl_timer_has_at(lua_State *L) { boolean ret = FALSE; @@ -1408,7 +1408,7 @@ nhl_timer_has_at(lua_State *L) /* when does location at x,y timer trigger? */ /* local melttime = nh.peek_timer_at(x,y, "melt-ice"); */ /* local melttime = nh.peek_timer_at({x=5,y=6}, "melt-ice"); */ -static int +staticfn int nhl_timer_peek_at(lua_State *L) { long when = 0L; @@ -1436,7 +1436,7 @@ nhl_timer_peek_at(lua_State *L) /* stop timer at location x,y */ /* nh.stop_timer_at(x,y, "melt-ice"); */ /* nh.stop_timer_at({x=6,y=8}, "melt-ice"); */ -static int +staticfn int nhl_timer_stop_at(lua_State *L) { short timertype = nhl_get_timertype(L, -1); @@ -1461,7 +1461,7 @@ nhl_timer_stop_at(lua_State *L) /* start timer at location x,y */ /* nh.start_timer_at(x,y, "melt-ice", 10); */ -static int +staticfn int nhl_timer_start_at(lua_State *L) { short timertype = nhl_get_timertype(L, -2); @@ -1493,7 +1493,7 @@ nhl_timer_start_at(lua_State *L) /* returns the visual interpretation of the key bound to an extended command, or the ext cmd name if not bound to any key */ /* local helpkey = eckey("help"); */ -static int +staticfn int nhl_get_cmd_key(lua_State *L) { int argc = lua_gettop(L); @@ -1513,7 +1513,7 @@ nhl_get_cmd_key(lua_State *L) /* callback("level_enter", "function_name"); */ /* callback("level_enter", "function_name", true); */ /* level_enter, level_leave, cmd_before */ -static int +staticfn int nhl_callback(lua_State *L) { int argc = lua_gettop(L); @@ -1563,7 +1563,7 @@ nhl_callback(lua_State *L) /* currently handles inventory and turns. */ /* gamestate(); -- save state */ /* gamestate(true); -- restore state */ -static int +staticfn int nhl_gamestate(lua_State *L) { static struct obj *gmst_invent = NULL; @@ -1702,7 +1702,7 @@ static const struct { }; /* register and init the constants table */ -static void +staticfn void init_nhc_data(lua_State *L) { int i; @@ -1718,7 +1718,7 @@ init_nhc_data(lua_State *L) lua_setglobal(L, "nhc"); } -static int +staticfn int nhl_push_anything(lua_State *L, int anytype, void *src) { anything any = cg.zeroany; @@ -1742,7 +1742,7 @@ nhl_push_anything(lua_State *L, int anytype, void *src) DISABLE_WARNING_UNREACHABLE_CODE -static int +staticfn int nhl_meta_u_index(lua_State *L) { static const struct { @@ -1809,7 +1809,7 @@ nhl_meta_u_index(lua_State *L) return 0; } -static int +staticfn int nhl_meta_u_newindex(lua_State *L) { nhl_error(L, "Cannot set u table values"); @@ -1819,7 +1819,7 @@ nhl_meta_u_newindex(lua_State *L) RESTORE_WARNING_UNREACHABLE_CODE -static int +staticfn int nhl_u_clear_inventory(lua_State *L UNUSED) { while (gi.invent) @@ -1829,7 +1829,7 @@ nhl_u_clear_inventory(lua_State *L UNUSED) /* Put object into player's inventory */ /* u.giveobj(obj.new("rock")); */ -static int +staticfn int nhl_u_giveobj(lua_State *L) { return nhl_obj_u_giveobj(L); @@ -1841,7 +1841,7 @@ static const struct luaL_Reg nhl_u_functions[] = { { NULL, NULL } }; -static void +staticfn void init_u_data(lua_State *L) { lua_newtable(L); @@ -1856,7 +1856,7 @@ init_u_data(lua_State *L) } #ifdef notyet -static int +staticfn int nhl_set_package_path(lua_State *L, const char *path) { if (LUA_TTABLE != lua_getglobal(L, "package")) { @@ -1870,7 +1870,7 @@ nhl_set_package_path(lua_State *L, const char *path) } #endif -static int +staticfn int traceback_handler(lua_State *L) { luaL_traceback(L, L, lua_tostring(L, 1), 0); @@ -1878,7 +1878,7 @@ traceback_handler(lua_State *L) return 1; } -static uint32_t +staticfn uint32_t nhl_getmeminuse(lua_State *L) { return lua_gc(L, LUA_GCCOUNT) * 1024 + lua_gc(L, LUA_GCCOUNTB); @@ -2377,7 +2377,7 @@ static struct e ct_os_files[] = { #define DROPIF(flag, lib, ct) \ nhl_clearfromtable(L, !!(lflags & flag), lib, ct) -static void +staticfn void nhl_clearfromtable(lua_State *L, int flag, int tndx, struct e *todo) { while (todo->when != EOT) { @@ -2428,7 +2428,7 @@ return values from "call it": * We're going to do #3. */ #ifdef notyet -static boolean +staticfn boolean start_luapat(void) { int rv; @@ -2449,7 +2449,7 @@ start_luapat(void) } #endif -static void +staticfn void end_luapat(void) { if (luapat) { @@ -2459,7 +2459,7 @@ end_luapat(void) } #ifdef notyet -static int +staticfn int opencheckpat(lua_State *L, const char *ename, int param) { /* careful - we're using 2 different and unrelated Lua states */ @@ -2513,7 +2513,7 @@ nhl_pushhooked_open_table(lua_State *L) } #ifdef notyet -static int +staticfn int hooked_open(lua_State *L) { const char *mode; @@ -2581,7 +2581,7 @@ hooked_open(lua_State *L) return (*io_open)(L); } -static boolean +staticfn boolean hook_open(lua_State *L) { boolean rv = FALSE; @@ -2613,7 +2613,7 @@ hook_open(lua_State *L) DISABLE_WARNING_CONDEXPR_IS_CONSTANT #ifdef NHL_SANDBOX -static void +staticfn void nhlL_openlibs(lua_State *L, uint32_t lflags) { /* translate lflags from user-friendly to internal */ @@ -2736,7 +2736,7 @@ UNSAFEIO: RESTORE_WARNING_CONDEXPR_IS_CONSTANT -static void * +staticfn void * nhl_alloc(void *ud, void *ptr, size_t osize UNUSED, size_t nsize) { nhl_user_data *nud = ud; @@ -2759,7 +2759,7 @@ nhl_alloc(void *ud, void *ptr, size_t osize UNUSED, size_t nsize) DISABLE_WARNING_UNREACHABLE_CODE -static int +staticfn int nhl_panic(lua_State *L) { const char *msg = lua_tostring(L, -1); @@ -2775,7 +2775,7 @@ RESTORE_WARNING_UNREACHABLE_CODE /* called when lua issues a warning message; the text of the message is passed to us in pieces across multiple function calls */ -static void +staticfn void nhl_warn( void *userdata UNUSED, const char *msg_fragment, @@ -2796,7 +2796,7 @@ nhl_warn( } #ifdef NHL_SANDBOX -static void +staticfn void nhl_hookfn(lua_State *L, lua_Debug *ar UNUSED) { nhl_user_data *nud; @@ -2811,7 +2811,7 @@ nhl_hookfn(lua_State *L, lua_Debug *ar UNUSED) } #endif -static lua_State * +staticfn lua_State * nhlL_newstate(nhl_sandbox_info *sbi, const char *name) { nhl_user_data *nud = 0; diff --git a/src/nhmd4.c b/src/nhmd4.c index 67966d769..02d9aa74e 100644 --- a/src/nhmd4.c +++ b/src/nhmd4.c @@ -29,7 +29,7 @@ #include "nhmd4.h" -static const unsigned char *nhmd4_body(struct nhmd4_context *, +staticfn const unsigned char *nhmd4_body(struct nhmd4_context *, const unsigned char *, size_t); /* Avoid a conflict from a Lua header */ @@ -79,7 +79,7 @@ static const unsigned char *nhmd4_body(struct nhmd4_context *, * This processes one or more 64-byte data blocks, but does NOT update * the bit counters. There're no alignment requirements. */ -static const unsigned char * +staticfn const unsigned char * nhmd4_body( struct nhmd4_context *ctx, const unsigned char *data, diff --git a/src/o_init.c b/src/o_init.c index d56e0689f..7ae3840e7 100644 --- a/src/o_init.c +++ b/src/o_init.c @@ -5,20 +5,20 @@ #include "hack.h" -static void setgemprobs(d_level *); -static void randomize_gem_colors(void); -static void shuffle(int, int, boolean); -static void shuffle_all(void); -static int QSORTCALLBACK discovered_cmp(const genericptr, const genericptr); -static char *sortloot_descr(int, char *); -static char *disco_typename(int); -static void disco_append_typename(char *, int); -static void disco_output_sorted(winid, char **, int, boolean); -static char *oclass_to_name(char, char *); +staticfn void setgemprobs(d_level *); +staticfn void randomize_gem_colors(void); +staticfn void shuffle(int, int, boolean); +staticfn void shuffle_all(void); +staticfn int QSORTCALLBACK discovered_cmp(const genericptr, const genericptr); +staticfn char *sortloot_descr(int, char *); +staticfn char *disco_typename(int); +staticfn void disco_append_typename(char *, int); +staticfn void disco_output_sorted(winid, char **, int, boolean); +staticfn char *oclass_to_name(char, char *); #ifdef TILES_IN_GLYPHMAP extern glyph_map glyphmap[MAX_GLYPH]; -static void shuffle_tiles(void); +staticfn void shuffle_tiles(void); /* Shuffle tile assignments to match descriptions, so a red potion isn't * displayed with a blue tile and so on. @@ -29,7 +29,7 @@ static void shuffle_tiles(void); * is restored. So might as well do that the first time instead of writing * another routine. */ -static void +staticfn void shuffle_tiles(void) { int i; @@ -48,7 +48,7 @@ shuffle_tiles(void) } #endif /* TILES_IN_GLYPHMAP */ -static void +staticfn void setgemprobs(d_level *dlev) { int j, first, lev, sum = 0; @@ -79,7 +79,7 @@ setgemprobs(d_level *dlev) } /* some gems can have different colors */ -static void +staticfn void randomize_gem_colors(void) { #define COPY_OBJ_DESCR(o_dst, o_src) \ @@ -107,7 +107,7 @@ randomize_gem_colors(void) } /* shuffle descriptions on objects o_low to o_high */ -static void +staticfn void shuffle(int o_low, int o_high, boolean domaterial) { int i, j, num_to_shuffle; @@ -312,7 +312,7 @@ obj_shuffle_range( } /* randomize object descriptions */ -static void +staticfn void shuffle_all(void) { /* entire classes; obj_shuffle_range() handles their exceptions */ @@ -516,7 +516,7 @@ static const short uniq_objs[] = { }; /* discoveries qsort comparison function */ -static int QSORTCALLBACK +staticfn int QSORTCALLBACK discovered_cmp(const genericptr v1, const genericptr v2) { const char *s1 = *(const char **) v1; @@ -530,7 +530,7 @@ discovered_cmp(const genericptr v1, const genericptr v2) return res; } -static char * +staticfn char * sortloot_descr(int otyp, char *outbuf) { Loot sl_cookie; @@ -562,8 +562,8 @@ sortloot_descr(int otyp, char *outbuf) #define DISCO_ALPHABYCLASS 2 /* alphabetized within each class */ #define DISCO_ALPHABETIZED 3 /* alphabetized across all classes */ /* also used in options.c (optfn_sortdiscoveries) */ -const char disco_order_let[] = "osca"; -const char *const disco_orders_descr[] = { +static const char disco_order_let[] = "osca"; +static const char *const disco_orders_descr[] = { "by order of discovery within each class", "sortloot order (by class with some sub-class groupings)", "alphabetical within each class", @@ -621,7 +621,7 @@ choose_disco_sort( } /* augment obj_typename() with explanation of Japanese item names */ -static char * +staticfn char * disco_typename(int otyp) { char *result = obj_typename(otyp); @@ -653,7 +653,7 @@ disco_typename(int otyp) } /* append typename(dis) to buf[], possibly truncating in the process */ -static void +staticfn void disco_append_typename(char *buf, int dis) { unsigned len = (unsigned) strlen(buf); @@ -677,7 +677,7 @@ disco_append_typename(char *buf, int dis) } /* sort and output sorted_lines to window and free the lines */ -static void +staticfn void disco_output_sorted(winid tmpwin, char **sorted_lines, int sorted_ct, boolean lootsort) @@ -799,7 +799,7 @@ dodiscovered(void) /* free after Robert Viduya */ } /* lower case let_to_name() output, which differs from def_oc_syms[].name */ -static char * +staticfn char * oclass_to_name(char oclass, char *buf) { char *s; diff --git a/src/objects.c b/src/objects.c index a7ef8d52c..45ceaeeab 100644 --- a/src/objects.c +++ b/src/objects.c @@ -10,13 +10,13 @@ #include "color.h" #include "objclass.h" -NEARDATA struct objdescr obj_descr_init[NUM_OBJECTS + 1] = { +static struct objdescr obj_descr_init[NUM_OBJECTS + 1] = { #define OBJECTS_DESCR_INIT #include "objects.h" #undef OBJECTS_DESCR_INIT }; -NEARDATA struct objclass obj_init[NUM_OBJECTS + 1] = { +static struct objclass obj_init[NUM_OBJECTS + 1] = { #define OBJECTS_INIT #include "objects.h" #undef OBJECTS_INIT diff --git a/src/objnam.c b/src/objnam.c index 4682624db..b2422de54 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -32,30 +32,30 @@ struct _readobjnam_data { char fruitbuf[BUFSZ]; }; -static char *strprepend(char *, const char *); -static char *nextobuf(void); -static void releaseobuf(char *); -static void xcalled(char *, int, const char *, const char *); -static char *xname_flags(struct obj *, unsigned); -static char *minimal_xname(struct obj *); -static void add_erosion_words(struct obj *, char *); -static char *doname_base(struct obj *obj, unsigned); -static boolean singplur_lookup(char *, char *, boolean, +staticfn char *strprepend(char *, const char *); +staticfn char *nextobuf(void); +staticfn void releaseobuf(char *); +staticfn void xcalled(char *, int, const char *, const char *); +staticfn char *xname_flags(struct obj *, unsigned); +staticfn char *minimal_xname(struct obj *); +staticfn void add_erosion_words(struct obj *, char *); +staticfn char *doname_base(struct obj *obj, unsigned); +staticfn boolean singplur_lookup(char *, char *, boolean, const char *const *); -static char *singplur_compound(char *); -static boolean ch_ksound(const char *basestr); -static boolean badman(const char *, boolean); -static boolean wishymatch(const char *, const char *, boolean); -static short rnd_otyp_by_wpnskill(schar); -static short rnd_otyp_by_namedesc(const char *, char, int); -static struct obj *wizterrainwish(struct _readobjnam_data *); -static void dbterrainmesg(const char *, coordxy, coordxy) NONNULLARG1; -static void readobjnam_init(char *, struct _readobjnam_data *); -static int readobjnam_preparse(struct _readobjnam_data *); -static void readobjnam_parse_charges(struct _readobjnam_data *); -static int readobjnam_postparse1(struct _readobjnam_data *); -static int readobjnam_postparse2(struct _readobjnam_data *); -static int readobjnam_postparse3(struct _readobjnam_data *); +staticfn char *singplur_compound(char *); +staticfn boolean ch_ksound(const char *basestr); +staticfn boolean badman(const char *, boolean); +staticfn boolean wishymatch(const char *, const char *, boolean); +staticfn short rnd_otyp_by_wpnskill(schar); +staticfn short rnd_otyp_by_namedesc(const char *, char, int); +staticfn struct obj *wizterrainwish(struct _readobjnam_data *); +staticfn void dbterrainmesg(const char *, coordxy, coordxy) NONNULLARG1; +staticfn void readobjnam_init(char *, struct _readobjnam_data *); +staticfn int readobjnam_preparse(struct _readobjnam_data *); +staticfn void readobjnam_parse_charges(struct _readobjnam_data *); +staticfn int readobjnam_postparse1(struct _readobjnam_data *); +staticfn int readobjnam_postparse2(struct _readobjnam_data *); +staticfn int readobjnam_postparse3(struct _readobjnam_data *); struct Jitem { int item; @@ -118,7 +118,7 @@ static const struct Jitem Japanese_items[] = { { 0, "" } }; -static char * +staticfn char * strprepend(char *s, const char *pref) { int i = (int) strlen(pref); @@ -136,7 +136,7 @@ strprepend(char *s, const char *pref) static char NEARDATA obufs[NUMOBUF][BUFSZ]; static int obufidx = 0; -static char * +staticfn char * nextobuf(void) { obufidx = (obufidx + 1) % NUMOBUF; @@ -144,7 +144,7 @@ nextobuf(void) } /* put the most recently allocated buffer back if possible */ -static void +staticfn void releaseobuf(char *bufp) { /* caller may not know whether bufp is the most recently allocated @@ -528,7 +528,7 @@ reorder_fruit(boolean forward) } /* add " called " to end of buf, truncating if necessary */ -static void +staticfn void xcalled( char *buf, /* eos(obuf) or eos(&obuf[PREFIX]) */ int siz, /* BUFSZ or BUFSZ-PREFIX */ @@ -551,7 +551,7 @@ xname(struct obj *obj) return xname_flags(obj, CXN_NORMAL); } -static char * +staticfn char * xname_flags( struct obj *obj, unsigned cxn_flags) /* bitmask of CXN_xxx values */ @@ -995,7 +995,7 @@ xname_flags( brown potion -- if oc_name_known not set potion of object detection -- if discovered */ -static char * +staticfn char * minimal_xname(struct obj *obj) { char *bufp; @@ -1098,7 +1098,7 @@ the_unique_pm(struct permonst *ptr) return uniq; } -static void +staticfn void add_erosion_words(struct obj *obj, char *prefix) { boolean iscrys = (obj->otyp == CRYSKNIFE); @@ -1177,7 +1177,7 @@ erosion_matters(struct obj *obj) #define DONAME_FOR_MENU 4 /* [not used anywhere yet] */ /* core of doname() */ -static char * +staticfn char * doname_base( struct obj *obj, /* object to format */ unsigned doname_flags) /* special case requests */ @@ -2596,7 +2596,7 @@ static const char *const as_is[] = { }; /* singularize/pluralize decisions common to both makesingular & makeplural */ -static boolean +staticfn boolean singplur_lookup( char *basestr, char *endstring, /* base string, pointer to eos(string) */ boolean to_plural, /* true => makeplural, false => makesingular */ @@ -2671,7 +2671,7 @@ singplur_lookup( } /* searches for common compounds, ex. lump of royal jelly */ -static char * +staticfn char * singplur_compound(char *str) { /* if new entries are added, be sure to keep compound_start[] in sync */ @@ -3056,7 +3056,7 @@ makesingular(const char *oldstr) } -static boolean +staticfn boolean ch_ksound(const char *basestr) { /* these are some *ch words/suffixes that make a k-sound. They pluralize by @@ -3082,7 +3082,7 @@ ch_ksound(const char *basestr) return FALSE; } -static boolean +staticfn boolean badman( const char *basestr, boolean to_plural) /* True: makeplural, False: makesingular */ @@ -3131,7 +3131,7 @@ badman( } /* compare user string against object name string using fuzzy matching */ -static boolean +staticfn boolean wishymatch( const char *u_str, /* from user, so might be variant spelling */ const char *o_str, /* from objects[], so is in canonical form */ @@ -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 @@ -3318,7 +3319,7 @@ static const struct alt_spellings { { (const char *) 0, 0 }, }; -static short +staticfn short rnd_otyp_by_wpnskill(schar skill) { int i, n = 0; @@ -3341,7 +3342,7 @@ rnd_otyp_by_wpnskill(schar skill) return otyp; } -static short +staticfn short rnd_otyp_by_namedesc( const char *name, char oclass, @@ -3425,7 +3426,7 @@ shiny_obj(char oclass) } /* in wizard mode, readobjnam() can accept wishes for traps and terrain */ -static struct obj * +staticfn struct obj * wizterrainwish(struct _readobjnam_data *d) { struct rm *lev; @@ -3796,7 +3797,7 @@ wizterrainwish(struct _readobjnam_data *d) } /* message common to several wizterrainwish() results */ -static void +staticfn void dbterrainmesg( const char *newtype, coordxy x, coordxy y) @@ -3809,7 +3810,7 @@ dbterrainmesg( #define TIN_EMPTY 1 #define TIN_SPINACH 2 -static void +staticfn void readobjnam_init(char *bp, struct _readobjnam_data *d) { d->otmp = (struct obj *) 0; @@ -3842,7 +3843,7 @@ readobjnam_init(char *bp, struct _readobjnam_data *d) /* return 1 if d->bp is empty or contains only various qualifiers like "blessed", "rustproof", and so on, or 0 if anything else is present */ -static int +staticfn int readobjnam_preparse(struct _readobjnam_data *d) { char *save_bp = 0; @@ -4054,7 +4055,7 @@ readobjnam_preparse(struct _readobjnam_data *d) return res; } -static void +staticfn void readobjnam_parse_charges(struct _readobjnam_data *d) { if (strlen(d->bp) > 1 && (d->p = strrchr(d->bp, '(')) != 0) { @@ -4116,7 +4117,7 @@ readobjnam_parse_charges(struct _readobjnam_data *d) d->rechrg = 7; /* recharge_limit */ } -static int +staticfn int readobjnam_postparse1(struct _readobjnam_data *d) { int i; @@ -4528,7 +4529,7 @@ readobjnam_postparse1(struct _readobjnam_data *d) return 0; } -static int +staticfn int readobjnam_postparse2(struct _readobjnam_data *d) { int i; @@ -4589,7 +4590,7 @@ readobjnam_postparse2(struct _readobjnam_data *d) return 0; } -static int +staticfn int readobjnam_postparse3(struct _readobjnam_data *d) { int i; @@ -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/src/options.c b/src/options.c index f5e562795..6b4691e1e 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 options.c $NHDT-Date: 1708737173 2024/02/24 01:12:53 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.709 $ */ +/* NetHack 3.7 options.c $NHDT-Date: 1710792444 2024/03/18 20:07:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.723 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2008. */ /* NetHack may be freely redistributed. See license for details. */ @@ -111,7 +111,7 @@ static struct allopt_t allopt[SIZE(allopt_init)]; /* use rest of file */ -extern char configfile[]; /* for messages */ +extern char configfile[]; /* for messages; files.c */ extern const struct symparse loadsyms[]; #if defined(TOS) extern boolean colors_changed; /* in tos.c */ @@ -315,83 +315,83 @@ static const menu_cmd_t default_menu_cmd_info[] = { { (char *) 0, '\0', (char *) 0 } }; -static void nmcpy(char *, const char *, int); -static void escapes(const char *, char *); -static void rejectoption(const char *); -static char *string_for_opt(char *, boolean); -static char *string_for_env_opt(const char *, char *, boolean); -static void bad_negation(const char *, boolean); -static int change_inv_order(char *); -static boolean warning_opts(char *, const char *); -static int feature_alert_opts(char *, const char *); -static boolean duplicate_opt_detection(int); -static void complain_about_duplicate(int); -static int length_without_val(const char *, int len); -static void determine_ambiguities(void); -static int check_misc_menu_command(char *, char *); -static int opt2roleopt(int); -static char *getoptstr(int, int); -static void saveoptstr(int, const char *); -static void unsaveoptstr(int, int); -static int petname_optfn(int, int, boolean, char *, char *); -static int shared_menu_optfn(int, int, boolean, char *, char *); -static int spcfn_misc_menu_cmd(int, int, boolean, char *, char *); +staticfn void nmcpy(char *, const char *, int); +staticfn void escapes(const char *, char *); +staticfn void rejectoption(const char *); +staticfn char *string_for_opt(char *, boolean); +staticfn char *string_for_env_opt(const char *, char *, boolean); +staticfn void bad_negation(const char *, boolean); +staticfn int change_inv_order(char *); +staticfn boolean warning_opts(char *, const char *); +staticfn int feature_alert_opts(char *, const char *); +staticfn boolean duplicate_opt_detection(int); +staticfn void complain_about_duplicate(int); +staticfn int length_without_val(const char *, int len); +staticfn void determine_ambiguities(void); +staticfn int check_misc_menu_command(char *, char *); +staticfn int opt2roleopt(int); +staticfn char *getoptstr(int, int); +staticfn void saveoptstr(int, const char *); +staticfn void unsaveoptstr(int, int); +staticfn int petname_optfn(int, int, boolean, char *, char *); +staticfn int shared_menu_optfn(int, int, boolean, char *, char *); +staticfn int spcfn_misc_menu_cmd(int, int, boolean, char *, char *); -static const char * msgtype2name(int); -static int query_msgtype(void); -static boolean msgtype_add(int, char *); -static void free_one_msgtype(int); -static int msgtype_count(void); -static boolean test_regex_pattern(const char *, const char *); -static boolean parse_role_opt(int, boolean, const char *, char *, char **); -static char *get_cnf_role_opt(int); -static unsigned int longest_option_name(int, int); -static int doset_simple_menu(void); -static void doset_add_menu(winid, const char *, const char *, int, int); -static int handle_add_list_remove(const char *, int); -static void all_options_conds(strbuf_t *); -static void all_options_menucolors(strbuf_t *); -static void all_options_msgtypes(strbuf_t *); -static void all_options_apes(strbuf_t *); -static void remove_autopickup_exception(struct autopickup_exception *); -static int count_apes(void); -static int count_cond(void); -static void enhance_menu_text(char *, size_t, int, boolean *, +staticfn const char * msgtype2name(int); +staticfn int query_msgtype(void); +staticfn boolean msgtype_add(int, char *); +staticfn void free_one_msgtype(int); +staticfn int msgtype_count(void); +staticfn boolean test_regex_pattern(const char *, const char *); +staticfn boolean parse_role_opt(int, boolean, const char *, char *, char **); +staticfn char *get_cnf_role_opt(int); +staticfn unsigned int longest_option_name(int, int); +staticfn int doset_simple_menu(void); +staticfn void doset_add_menu(winid, const char *, const char *, int, int); +staticfn int handle_add_list_remove(const char *, int); +staticfn void all_options_conds(strbuf_t *); +staticfn void all_options_menucolors(strbuf_t *); +staticfn void all_options_msgtypes(strbuf_t *); +staticfn void all_options_apes(strbuf_t *); +staticfn void remove_autopickup_exception(struct autopickup_exception *); +staticfn int count_apes(void); +staticfn int count_cond(void); +staticfn void enhance_menu_text(char *, size_t, int, boolean *, struct allopt_t *); -static boolean can_set_perm_invent(void); -static int handler_align_misc(int); -static int handler_autounlock(int); -static int handler_disclose(void); -static int handler_menu_headings(void); -static int handler_menustyle(void); -static int handler_msg_window(void); -static int handler_number_pad(void); -static int handler_paranoid_confirmation(void); -static int handler_perminv_mode(void); -static int handler_pickup_burden(void); -static int handler_pickup_types(void); -static int handler_runmode(void); -static int handler_petattr(void); -static int handler_sortloot(void); -static int handler_symset(int); -static int handler_versinfo(void); -static int handler_whatis_coord(void); -static int handler_whatis_filter(void); +staticfn boolean can_set_perm_invent(void); +staticfn int handler_align_misc(int); +staticfn int handler_autounlock(int); +staticfn int handler_disclose(void); +staticfn int handler_menu_headings(void); +staticfn int handler_menustyle(void); +staticfn int handler_msg_window(void); +staticfn int handler_number_pad(void); +staticfn int handler_paranoid_confirmation(void); +staticfn int handler_perminv_mode(void); +staticfn int handler_pickup_burden(void); +staticfn int handler_pickup_types(void); +staticfn int handler_runmode(void); +staticfn int handler_petattr(void); +staticfn int handler_sortloot(void); +staticfn int handler_symset(int); +staticfn int handler_versinfo(void); +staticfn int handler_whatis_coord(void); +staticfn int handler_whatis_filter(void); /* next few are not allopt[] entries, so will only be called directly from doset, not from individual optfn's */ -static int handler_autopickup_exception(void); -static int handler_menu_colors(void); -static int handler_msgtype(void); -static int handler_windowborders(void); +staticfn int handler_autopickup_exception(void); +staticfn int handler_menu_colors(void); +staticfn int handler_msgtype(void); +staticfn int handler_windowborders(void); -static boolean is_wc_option(const char *); -static boolean wc_supported(const char *); -static boolean is_wc2_option(const char *); -static boolean wc2_supported(const char *); -static void wc_set_font_name(int, char *); -static int wc_set_window_colors(char *); -static boolean illegal_menu_cmd_key(uchar); -static const char *term_for_boolean(int, boolean *); +staticfn boolean is_wc_option(const char *); +staticfn boolean wc_supported(const char *); +staticfn boolean is_wc2_option(const char *); +staticfn boolean wc2_supported(const char *); +staticfn void wc_set_font_name(int, char *); +staticfn int wc_set_window_colors(char *); +staticfn boolean illegal_menu_cmd_key(uchar); +staticfn const char *term_for_boolean(int, boolean *); /* ask user if they want a tutorial, except if tutorial boolean option has been set in config - either on or off - in which case just obey that @@ -646,7 +646,7 @@ parseoptions( return FALSE; } -static int +staticfn int check_misc_menu_command(char *opts, char *op UNUSED) { int i; @@ -667,7 +667,7 @@ static int roleopt2opt[4] = { }; /* role => 0, race => 1, gender => 2, alignment =>3 */ -static int +staticfn int opt2roleopt(int roleopt) { switch (roleopt) { @@ -686,7 +686,7 @@ opt2roleopt(int roleopt) } /* fetch saved option string for a particular option phase */ -static char * +staticfn char * getoptstr(int optidx, int ophase) { int roleoptindx = opt2roleopt(optidx); @@ -710,7 +710,7 @@ getoptstr(int optidx, int ophase) } /* to track some unparsed option settings in case #saveoptions needs them */ -static void +staticfn void saveoptstr(int optidx, const char *optstr) { int phase = go.opt_phase, roleoptindx = opt2roleopt(optidx); @@ -728,7 +728,7 @@ saveoptstr(int optidx, const char *optstr) } /* discard specific saved option string */ -static void +staticfn void unsaveoptstr(int optidx, int ophase) { int roleoptindx = opt2roleopt(optidx); @@ -802,7 +802,7 @@ restoptvals(NHFILE *nhfp) #endif /* 0 */ /* common to optfn_catname(), optfn_dogname(), optfn_horsename() */ -static int +staticfn int petname_optfn( int optidx, int req, boolean negated, @@ -839,7 +839,7 @@ petname_optfn( ********************************** */ -static int +staticfn int optfn_alignment( int optidx, int req, @@ -877,7 +877,7 @@ optfn_alignment( } -static int +staticfn int optfn_align_message( int optidx, int req, boolean negated, char *opts, char *op) @@ -927,7 +927,7 @@ optfn_align_message( return optn_ok; } -static int +staticfn int optfn_align_status(int optidx, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -974,7 +974,7 @@ optfn_align_status(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_altkeyhandling( int optidx UNUSED, int req, @@ -1018,7 +1018,7 @@ optfn_altkeyhandling( return optn_ok; } -static int +staticfn int optfn_autounlock( int optidx, int req, @@ -1123,7 +1123,7 @@ optfn_autounlock( return optn_ok; } -static int +staticfn int optfn_boulder(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -1200,7 +1200,7 @@ optfn_boulder(int optidx UNUSED, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_catname( int optidx, int req, boolean negated, @@ -1210,7 +1210,7 @@ optfn_catname( } #ifdef CRASHREPORT -static int +staticfn int optfn_crash_email(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op) { if (req == do_init) { @@ -1234,7 +1234,7 @@ optfn_crash_email(int optidx UNUSED, int req, boolean negated UNUSED, char *opts return optn_ok; } -static int +staticfn int optfn_crash_name(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op) { if (req == do_init) { @@ -1258,7 +1258,7 @@ optfn_crash_name(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, return optn_ok; } -static int +staticfn int optfn_crash_urlmax(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op) { if (req == do_init) { @@ -1288,7 +1288,7 @@ optfn_crash_urlmax(int optidx UNUSED, int req, boolean negated UNUSED, char *opt #endif /* CRASHREPORT */ #ifdef CURSES_GRAPHICS -static int +staticfn int optfn_cursesgraphics(int optidx, int req, boolean negated, char *opts, char *op UNUSED) { @@ -1336,7 +1336,7 @@ optfn_cursesgraphics(int optidx, int req, boolean negated, } #endif -static int +staticfn int optfn_DECgraphics(int optidx, int req, boolean negated, char *opts, char *op UNUSED) { @@ -1383,7 +1383,7 @@ optfn_DECgraphics(int optidx, int req, boolean negated, return optn_ok; } -static int +staticfn int optfn_disclose(int optidx, int req, boolean negated, char *opts, char *op) { int i, idx, prefix_val; @@ -1501,7 +1501,7 @@ optfn_disclose(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_dogname( int optidx, int req, boolean negated, @@ -1510,7 +1510,7 @@ optfn_dogname( return petname_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_dungeon(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -1531,7 +1531,7 @@ optfn_dungeon(int optidx UNUSED, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_effects(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -1552,28 +1552,28 @@ optfn_effects(int optidx UNUSED, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_font_map(int optidx, int req, boolean negated, char *opts, char *op) { /* send them over to the prefix handling for font_ */ return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_font_menu(int optidx, int req, boolean negated, char *opts, char *op) { /* send them over to the prefix handling for font_ */ return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_font_message(int optidx, int req, boolean negated, char *opts, char *op) { /* send them over to the prefix handling for font_ */ return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_font_size_map( int optidx, int req, boolean negated, char *opts, char *op) @@ -1582,7 +1582,7 @@ optfn_font_size_map( return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_font_size_menu( int optidx, int req, boolean negated, char *opts, char *op) @@ -1591,7 +1591,7 @@ optfn_font_size_menu( return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_font_size_message( int optidx, int req, boolean negated, char *opts, char *op) @@ -1600,7 +1600,7 @@ optfn_font_size_message( return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_font_size_status( int optidx, int req, boolean negated, char *opts, char *op) @@ -1609,7 +1609,7 @@ optfn_font_size_status( return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_font_size_text( int optidx, int req, boolean negated, char *opts, char *op) @@ -1618,21 +1618,21 @@ optfn_font_size_text( return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_font_status(int optidx, int req, boolean negated, char *opts, char *op) { /* send them over to the prefix handling for font_ */ return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_font_text(int optidx, int req, boolean negated, char *opts, char *op) { /* send them over to the prefix handling for font_ */ return pfxfn_font(optidx, req, negated, opts, op); } -static int +staticfn int optfn_fruit(int optidx UNUSED, int req, boolean negated, char *opts, char *op) { @@ -1702,7 +1702,7 @@ optfn_fruit(int optidx UNUSED, int req, boolean negated, return optn_ok; } -static int +staticfn int optfn_gender( int optidx, int req, @@ -1740,7 +1740,7 @@ optfn_gender( return optn_ok; } -static int +staticfn int optfn_glyph(int optidx UNUSED, int req, boolean negated, char *opts, char *op) { #ifdef ENHANCED_SYMBOLS @@ -1779,7 +1779,7 @@ optfn_glyph(int optidx UNUSED, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_hilite_status( int optidx UNUSED, int req, @@ -1824,7 +1824,7 @@ optfn_hilite_status( return optn_ok; } -static int +staticfn int optfn_horsename( int optidx, int req, boolean negated, @@ -1833,7 +1833,7 @@ optfn_horsename( return petname_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_IBMgraphics(int optidx, int req, boolean negated, char *opts, char *op UNUSED) { @@ -1889,7 +1889,7 @@ optfn_IBMgraphics(int optidx, int req, boolean negated, return optn_ok; } -static int +staticfn int optfn_map_mode(int optidx, int req, boolean negated, char *opts, char *op) { int i; @@ -1969,8 +1969,8 @@ 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 */ -static int -shared_menu_optfn(int optidx UNUSED, int req, boolean negated UNUSED, +staticfn int +shared_menu_optfn(int optidx UNUSED, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -1994,91 +1994,91 @@ shared_menu_optfn(int optidx UNUSED, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_menu_deselect_all(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_deselect_page(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_first_page(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_invert_all(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_invert_page(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_last_page(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_next_page(int optidx , int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_previous_page(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_search(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_select_all(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_select_page(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_shift_left(int optidx, int req, boolean negated, char *opts, char *op) { return shared_menu_optfn(optidx, req, negated, opts, op); } -static int +staticfn int optfn_menu_shift_right(int optidx, int req, boolean negated, char *opts, char *op) { @@ -2087,7 +2087,7 @@ optfn_menu_shift_right(int optidx, int req, boolean negated, /* end of shared key assignments for menu commands */ -static int +staticfn int optfn_menu_headings( int optidx, int req, boolean negated, @@ -2129,7 +2129,7 @@ optfn_menu_headings( return optn_ok; } -static int +staticfn int optfn_menuinvertmode( int optidx, int req, boolean negated UNUSED, @@ -2159,7 +2159,7 @@ optfn_menuinvertmode( return optn_ok; } -static int +staticfn int optfn_menustyle(int optidx, int req, boolean negated, char *opts, char *op) { int tmp; @@ -2215,7 +2215,7 @@ optfn_menustyle(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_monsters(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -2232,7 +2232,7 @@ optfn_monsters(int optidx UNUSED, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_mouse_support( int optidx, int req, boolean negated, char *opts, char *op) @@ -2292,7 +2292,7 @@ optfn_mouse_support( return optn_ok; } -static int +staticfn int optfn_msg_window(int optidx, int req, boolean negated, char *opts, char *op) { int retval = optn_ok; @@ -2357,7 +2357,7 @@ optfn_msg_window(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_msghistory(int optidx, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -2381,7 +2381,7 @@ optfn_msghistory(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_name( int optidx, int req, boolean negated UNUSED, char *opts, char *op) @@ -2406,7 +2406,7 @@ optfn_name( return optn_ok; } -static int +staticfn int optfn_number_pad( int optidx, int req, boolean negated, char *opts, char *op) @@ -2480,7 +2480,7 @@ optfn_number_pad( return optn_ok; } -static int +staticfn int optfn_objects(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -2501,7 +2501,7 @@ optfn_objects(int optidx UNUSED, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_packorder(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op) { @@ -2526,7 +2526,7 @@ optfn_packorder(int optidx UNUSED, int req, boolean negated UNUSED, } #ifdef CHANGE_COLOR -static int +staticfn int optfn_palette( int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op) @@ -2628,7 +2628,7 @@ optfn_palette( #endif /* CHANGE_COLOR */ /* for "paranoid_confirmation:foo" and alias "[!]prayconfirm" */ -static int +staticfn int optfn_paranoid_confirmation( int optidx, int req, boolean opt_negated, char *opts, char *op) @@ -2856,7 +2856,7 @@ optfn_paranoid_confirmation( return optn_ok; } -static int +staticfn int optfn_perminv_mode( int optidx, int req, boolean negated, char *opts, char *op) @@ -2948,7 +2948,7 @@ optfn_perminv_mode( return retval; } -static int +staticfn int optfn_petattr( int optidx, int req, boolean negated, char *opts, char *op) @@ -3007,7 +3007,7 @@ optfn_petattr( return optn_ok; } -static int +staticfn int optfn_pettype(int optidx, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -3064,7 +3064,7 @@ optfn_pettype(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_pickup_burden( int optidx, int req, boolean negated UNUSED, char *opts, char *op) @@ -3116,7 +3116,7 @@ optfn_pickup_burden( return optn_ok; } -static int +staticfn int optfn_pickup_types( int optidx, int req, boolean negated, @@ -3213,7 +3213,7 @@ optfn_pickup_types( return optn_ok; } -static int +staticfn int optfn_pile_limit( int optidx, int req, boolean negated, @@ -3248,7 +3248,7 @@ optfn_pile_limit( return optn_ok; } -static int +staticfn int optfn_player_selection( int optidx, int req, boolean negated, char *opts, char *op) @@ -3281,7 +3281,7 @@ optfn_player_selection( return optn_ok; } -static int +staticfn int optfn_playmode(int optidx, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -3315,7 +3315,7 @@ optfn_playmode(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_race( int optidx, int req, @@ -3353,7 +3353,7 @@ optfn_race( return optn_ok; } -static int +staticfn int optfn_roguesymset(int optidx, int req, boolean negated UNUSED, char *opts, char *op) { @@ -3392,7 +3392,7 @@ optfn_roguesymset(int optidx, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_role( int optidx, int req, @@ -3430,7 +3430,7 @@ optfn_role( return optn_ok; } -static int +staticfn int optfn_runmode(int optidx, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -3469,7 +3469,7 @@ optfn_runmode(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_scores(int optidx, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -3560,7 +3560,7 @@ optfn_scores(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_scroll_amount( int optidx, int req, boolean negated, char *opts, char *op) @@ -3591,7 +3591,7 @@ optfn_scroll_amount( return optn_ok; } -static int +staticfn int optfn_scroll_margin( int optidx, int req, boolean negated, char *opts, char *op) @@ -3621,7 +3621,7 @@ optfn_scroll_margin( return optn_ok; } -static int +staticfn int optfn_soundlib(int optidx, int req, boolean negated UNUSED, char *opts, char *op) { @@ -3656,7 +3656,7 @@ optfn_soundlib(int optidx, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_sortdiscoveries( int optidx, int req, boolean negated, char *opts, char *op) @@ -3707,7 +3707,7 @@ optfn_sortdiscoveries( return optn_ok; } -static int +staticfn int optfn_sortloot( int optidx, int req, boolean negated UNUSED, @@ -3752,7 +3752,7 @@ optfn_sortloot( return optn_ok; } -static int +staticfn int optfn_sortvanquished( int optidx, int req, boolean negated, @@ -3808,7 +3808,7 @@ optfn_sortvanquished( return optn_ok; } -static int +staticfn int optfn_statushilites( int optidx UNUSED, int req, @@ -3865,7 +3865,7 @@ optfn_statushilites( return optn_ok; } -static int +staticfn int optfn_statuslines( int optidx, int req, boolean negated, char *opts, char *op) @@ -3909,7 +3909,7 @@ optfn_statuslines( } #ifdef WIN32CON -static int +staticfn int optfn_subkeyvalue( int optidx UNUSED, int req, @@ -3936,7 +3936,7 @@ optfn_subkeyvalue( } #endif /* WIN32CON */ -static int +staticfn int optfn_suppress_alert(int optidx, int req, boolean negated, char *opts, char *op) { @@ -3967,9 +3967,9 @@ optfn_suppress_alert(int optidx, int req, boolean negated, extern const char *const known_handling[]; /* symbols.c */ extern const char *const known_restrictions[]; /* symbols.c */ -static int +staticfn int optfn_symset( - int optidx UNUSED, + int optidx, int req, boolean negated UNUSED, char *opts, @@ -4044,7 +4044,7 @@ optfn_symset( return optn_ok; } -static int +staticfn int optfn_term_cols(int optidx, int req, boolean negated, char *opts, char *op) { int retval = optn_ok; @@ -4083,7 +4083,7 @@ optfn_term_cols(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_term_rows(int optidx, int req, boolean negated, char *opts, char *op) { int retval = optn_ok; @@ -4122,7 +4122,7 @@ optfn_term_rows(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_tile_file(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op) { @@ -4154,7 +4154,7 @@ optfn_tile_file(int optidx UNUSED, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_tile_height(int optidx, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -4184,7 +4184,7 @@ optfn_tile_height(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_tile_width(int optidx, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -4214,7 +4214,7 @@ optfn_tile_width(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; } -static int +staticfn int optfn_traps(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -4235,7 +4235,7 @@ optfn_traps(int optidx UNUSED, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_vary_msgcount( int optidx, int req, boolean negated, char *opts, char *op) @@ -4267,7 +4267,7 @@ optfn_vary_msgcount( return optn_ok; } -static int +staticfn int optfn_versinfo( int optidx, int req, boolean negated, char *opts, char *op) @@ -4333,7 +4333,7 @@ optfn_versinfo( } #ifdef VIDEOSHADES -static int +staticfn int optfn_videocolors(int optidx, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -4367,7 +4367,7 @@ optfn_videocolors(int optidx, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_videoshades(int optidx, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -4397,7 +4397,7 @@ optfn_videoshades(int optidx, int req, boolean negated UNUSED, #endif /* VIDEOSHADES */ #ifdef MSDOS -static int +staticfn int optfn_video_width(int optidx UNUSED, int req, boolean negated, char *opts, char *op) { @@ -4417,7 +4417,7 @@ optfn_video_width(int optidx UNUSED, int req, boolean negated, return optn_ok; } -static int +staticfn int optfn_video_height(int optidx UNUSED, int req, boolean negated, char *opts, char *op) { @@ -4438,7 +4438,7 @@ optfn_video_height(int optidx UNUSED, int req, boolean negated, } #ifdef NO_TERMS -static int +staticfn int optfn_video(int optidx, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -4472,7 +4472,7 @@ optfn_video(int optidx, int req, boolean negated UNUSED, #endif /* NO_TERMS */ #endif /* MSDOS */ -static int +staticfn int optfn_warnings(int optidx, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -4492,7 +4492,7 @@ optfn_warnings(int optidx, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_whatis_coord( int optidx, int req, boolean negated, char *opts, char *op) @@ -4537,7 +4537,7 @@ optfn_whatis_coord( return optn_ok; } -static int +staticfn int optfn_whatis_filter( int optidx, int req, boolean negated, char *opts, char *op) @@ -4586,7 +4586,7 @@ optfn_whatis_filter( return optn_ok; } -static int +staticfn int optfn_windowborders( int optidx, int req, boolean negated, char *opts, char *op) @@ -4646,7 +4646,7 @@ optfn_windowborders( } #ifdef WINCHAIN -static int +staticfn int optfn_windowchain( int optidx, int req, boolean negated UNUSED, @@ -4674,18 +4674,26 @@ optfn_windowchain( } #endif -static int -optfn_windowcolors(int optidx, int req, boolean negated UNUSED, - char *opts, char *op) +int wcolors_opt[WC_COUNT]; + +staticfn int +optfn_windowcolors( + int optidx, int req, + boolean negated UNUSED, + char *opts, char *op) { if (req == do_init) { + int wccount; + + for (wccount = 0; wccount < WC_COUNT; ++wccount) { + wcolors_opt[wccount] = 0; + } return optn_ok; } if (req == do_set) { /* WINCAP * setting window colors - * syntax: windowcolors=menu foregrnd/backgrnd text - * foregrnd/backgrnd + * syntax: windowcolors=menu foregrnd/backgrnd text foregrnd/backgrnd */ if ((op = string_for_opt(opts, FALSE)) != empty_optstr) { if (!wc_set_window_colors(op)) { @@ -4697,24 +4705,38 @@ optfn_windowcolors(int optidx, int req, boolean negated UNUSED, return optn_ok; } if (req == get_val || req == get_cnf_val) { - Sprintf( - opts, "%s/%s %s/%s %s/%s %s/%s", - iflags.wc_foregrnd_menu ? iflags.wc_foregrnd_menu : defbrief, - iflags.wc_backgrnd_menu ? iflags.wc_backgrnd_menu : defbrief, - iflags.wc_foregrnd_message ? iflags.wc_foregrnd_message - : defbrief, - iflags.wc_backgrnd_message ? iflags.wc_backgrnd_message - : defbrief, - iflags.wc_foregrnd_status ? iflags.wc_foregrnd_status : defbrief, - iflags.wc_backgrnd_status ? iflags.wc_backgrnd_status : defbrief, - iflags.wc_foregrnd_text ? iflags.wc_foregrnd_text : defbrief, - iflags.wc_backgrnd_text ? iflags.wc_backgrnd_text : defbrief); + /* FIXME: this constructed value is not correct for 'get_cnf_val' */ + Sprintf(opts, "%s/%s %s/%s %s/%s %s/%s", + iflags.wcolors[wcolor_menu].fg + ? iflags.wcolors[wcolor_menu].fg + : defbrief, + iflags.wcolors[wcolor_menu].bg + ? iflags.wcolors[wcolor_menu].bg + : defbrief, + iflags.wcolors[wcolor_message].fg + ? iflags.wcolors[wcolor_message].fg + : defbrief, + iflags.wcolors[wcolor_message].bg + ? iflags.wcolors[wcolor_message].bg + : defbrief, + iflags.wcolors[wcolor_status].fg + ? iflags.wcolors[wcolor_status].fg + : defbrief, + iflags.wcolors[wcolor_status].bg + ? iflags.wcolors[wcolor_status].bg + : defbrief, + iflags.wcolors[wcolor_text].fg + ? iflags.wcolors[wcolor_text].fg + : defbrief, + iflags.wcolors[wcolor_text].bg + ? iflags.wcolors[wcolor_text].bg + : defbrief); return optn_ok; } return optn_ok; } -static int +staticfn int optfn_windowtype( int optidx, int req, boolean negated UNUSED, @@ -4762,7 +4784,7 @@ optfn_windowtype( * Prefix-handling functions */ -static int +staticfn int pfxfn_cond_( int optidx UNUSED, int req, @@ -4807,7 +4829,7 @@ pfxfn_cond_( return optn_ok; } -static int +staticfn int pfxfn_font(int optidx, int req, boolean negated, char *opts, char *op) { int opttype = -1; @@ -4960,7 +4982,7 @@ pfxfn_IBM_(int optidx UNUSED, int req, boolean negated UNUSED, * (Use optidx to reference the specific option) */ -static int +staticfn int optfn_boolean( int optidx, int req, boolean negated, char *opts, char *op) @@ -5186,7 +5208,7 @@ optfn_boolean( return optn_ok; } -static int +staticfn int spcfn_misc_menu_cmd(int midx, int req, boolean negated, char *opts, char *op) { if (req == do_init) { @@ -5222,7 +5244,7 @@ spcfn_misc_menu_cmd(int midx, int req, boolean negated, char *opts, char *op) */ /* test whether 'perm_invent' can be toggled On */ -static boolean +staticfn boolean can_set_perm_invent(void) { /* @@ -5263,7 +5285,7 @@ can_set_perm_invent(void) return TRUE; } -static int +staticfn int handler_menustyle(void) { winid tmpwin; @@ -5305,7 +5327,7 @@ handler_menustyle(void) return optn_ok; } -static int +staticfn int handler_align_misc(int optidx) { winid tmpwin; @@ -5343,7 +5365,7 @@ handler_align_misc(int optidx) return optn_ok; } -static int +staticfn int handler_autounlock(int optidx) { winid tmpwin; @@ -5394,7 +5416,7 @@ handler_autounlock(int optidx) return res; } -static int +staticfn int handler_disclose(void) { winid tmpwin; @@ -5499,7 +5521,7 @@ handler_disclose(void) return optn_ok; } -static int +staticfn int handler_menu_headings(void) { boolean gotca = query_color_attr(&iflags.menu_headings, @@ -5514,7 +5536,7 @@ handler_menu_headings(void) return optn_ok; } -static int +staticfn int handler_msg_window(void) { #if PREV_MSGS /* tty or curses */ @@ -5573,7 +5595,7 @@ handler_msg_window(void) return optn_ok; } -static int +staticfn int handler_number_pad(void) { winid tmpwin; @@ -5633,7 +5655,7 @@ handler_number_pad(void) return optn_ok; } -static int +staticfn int handler_paranoid_confirmation(void) { winid tmpwin; @@ -5691,7 +5713,7 @@ handler_paranoid_confirmation(void) return optn_ok; } -static int +staticfn int handler_perminv_mode(void) { winid tmpwin; @@ -5766,7 +5788,7 @@ handler_perminv_mode(void) return optn_ok; } -static int +staticfn int handler_pickup_burden(void) { winid tmpwin; @@ -5794,7 +5816,7 @@ handler_pickup_burden(void) return optn_ok; } -static int +staticfn int handler_pickup_types(void) { char buf[BUFSZ]; @@ -5804,7 +5826,7 @@ handler_pickup_types(void) return optn_ok; } -static int +staticfn int handler_runmode(void) { winid tmpwin; @@ -5832,7 +5854,7 @@ handler_runmode(void) return optn_ok; } -static int +staticfn int handler_petattr(void) { int tmp = query_attr("Select pet highlight attribute", iflags.wc2_petattr); @@ -5846,7 +5868,7 @@ handler_petattr(void) return optn_ok; } -static int +staticfn int handler_sortloot(void) { winid tmpwin; @@ -5885,7 +5907,7 @@ handler_sortloot(void) return optn_ok; } -static int +staticfn int handler_whatis_coord(void) { winid tmpwin; @@ -5958,7 +5980,7 @@ handler_whatis_coord(void) return optn_ok; } -static int +staticfn int handler_whatis_filter(void) { winid tmpwin; @@ -6000,7 +6022,7 @@ handler_whatis_filter(void) return optn_ok; } -static int +staticfn int handler_symset(int optidx) { int reslt; @@ -6010,7 +6032,7 @@ handler_symset(int optidx) return reslt; } -static int +staticfn int handler_autopickup_exception(void) { winid tmpwin; @@ -6086,7 +6108,7 @@ handler_autopickup_exception(void) return optn_ok; } -static int +staticfn int handler_menu_colors(void) { winid tmpwin; @@ -6181,7 +6203,7 @@ handler_menu_colors(void) return optn_ok; } -static int +staticfn int handler_msgtype(void) { winid tmpwin; @@ -6253,7 +6275,7 @@ handler_msgtype(void) } -static int +staticfn int handler_versinfo(void) { winid tmpwin; @@ -6300,7 +6322,7 @@ handler_versinfo(void) return optn_ok; } -static int +staticfn int handler_windowborders(void) { winid tmpwin; @@ -6345,7 +6367,7 @@ handler_windowborders(void) ********************************** */ -static char * +staticfn char * string_for_opt(char *opts, boolean val_optional) { char *colon, *equals; @@ -6363,7 +6385,7 @@ string_for_opt(char *opts, boolean val_optional) return colon; } -static char * +staticfn char * string_for_env_opt(const char *optname, char *opts, boolean val_optional) { if (!go.opt_initial) { @@ -6373,7 +6395,7 @@ string_for_env_opt(const char *optname, char *opts, boolean val_optional) return string_for_opt(opts, val_optional); } -static void +staticfn void bad_negation(const char *optname, boolean with_parameter) { config_error_add("The %s option may not %sbe negated.", optname, @@ -6383,7 +6405,7 @@ bad_negation(const char *optname, boolean with_parameter) /* go through all of the options and set the minmatch value based on what is needed for uniqueness of each individual option. Set a minimum of 3 characters. */ -static void +staticfn void determine_ambiguities(void) { int i, j, len, tmpneeded, needed[SIZE(allopt)]; @@ -6419,7 +6441,7 @@ determine_ambiguities(void) } } -static int +staticfn int length_without_val(const char *user_string, int len) { const char *p = strchr(user_string, ':'), @@ -6462,7 +6484,7 @@ reset_duplicate_opt_detection(void) allopt[k].dupdetected = 0; } -static boolean +staticfn boolean duplicate_opt_detection(int optidx) { if (go.opt_initial && go.opt_from_file) @@ -6470,7 +6492,7 @@ duplicate_opt_detection(int optidx) return FALSE; } -static void +staticfn void complain_about_duplicate(int optidx) { char buf[BUFSZ]; @@ -6492,7 +6514,7 @@ complain_about_duplicate(int optidx) return; } -static void +staticfn void rejectoption(const char *optname) { #ifdef MICRO @@ -6541,7 +6563,7 @@ nh_getenv(const char *ev) /* copy up to maxlen-1 characters; 'dest' must be able to hold maxlen; treat comma as alternate end of 'src' */ -static void +staticfn void nmcpy(char *dest, const char *src, int maxlen) { int count; @@ -6576,7 +6598,7 @@ nmcpy(char *dest, const char *src, int maxlen) * an appropriate digit will also fall through to \ and yield 'X' * or 'O', plus stop if the non-digit is end-of-string. */ -static void +staticfn void escapes(const char *cp, /* might be 'tp', updating in place */ char *tp) /* result is never longer than 'cp' */ { @@ -7160,7 +7182,7 @@ initoptions_finish(void) * Used by: optfn_packorder() * */ -static int +staticfn int change_inv_order(char *op) { int oc_sym, num; @@ -7215,7 +7237,7 @@ change_inv_order(char *op) * */ -static boolean +staticfn boolean warning_opts(char *opts, const char *optype) { uchar translate[WARNCOUNT]; @@ -7252,7 +7274,7 @@ assign_warnings(uchar *graph_chars) * */ -static int +staticfn int feature_alert_opts(char *op, const char *optn) { char buf[BUFSZ]; @@ -7384,7 +7406,7 @@ static const struct { { "norep", MSGTYP_NOREP, "Do not repeat the message" } }; -static const char * +staticfn const char * msgtype2name(int typ) { int i; @@ -7395,7 +7417,7 @@ msgtype2name(int typ) return (char *) 0; } -static int +staticfn int query_msgtype(void) { winid tmpwin; @@ -7425,7 +7447,7 @@ query_msgtype(void) return -1; } -static boolean +staticfn boolean msgtype_add(int typ, char *pattern) { static const char *const re_error = "MSGTYPE regex error"; @@ -7465,7 +7487,7 @@ msgtype_free(void) gp.plinemsg_types = (struct plinemsg_type *) 0; } -static void +staticfn void free_one_msgtype(int idx) /* 0 .. */ { struct plinemsg_type *tmp = gp.plinemsg_types; @@ -7524,7 +7546,7 @@ hide_unhide_msgtypes(boolean hide, int hide_mask) } } -static int +staticfn int msgtype_count(void) { int c = 0; @@ -7564,7 +7586,7 @@ msgtype_parse_add(char *str) /* parse 'str' as a regular expression to check whether it's valid; compiled regexp gets thrown away regardless of the outcome */ -static boolean +staticfn boolean test_regex_pattern(const char *str, const char *errmsg) { static const char def_errmsg[] = "NHregex error"; @@ -7598,7 +7620,7 @@ test_regex_pattern(const char *str, const char *errmsg) } /* parse 'role' or 'race' or 'gender' or 'alignment' */ -static boolean +staticfn boolean parse_role_opt( int optidx, boolean negated, @@ -7714,7 +7736,7 @@ parse_role_opt( /* fetch a saved role|race|gender|alignment value suitable for writing into a new run-time config file */ -static char * +staticfn char * get_cnf_role_opt(int optidx) { int phase; @@ -7730,7 +7752,7 @@ get_cnf_role_opt(int optidx) } /* Check if character c is illegal as a menu command key */ -static boolean +staticfn boolean illegal_menu_cmd_key(uchar c) { if (c == 0 || c == '\r' || c == '\n' || c == '\033' || c == ' ' @@ -7992,17 +8014,11 @@ 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() */ -static int +staticfn int optfn_o_autopickup_exceptions( int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op UNUSED) @@ -8024,7 +8040,7 @@ optfn_o_autopickup_exceptions( return optn_ok; } -static int +staticfn int optfn_o_bind_keys( int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op UNUSED) @@ -8046,7 +8062,7 @@ optfn_o_bind_keys( return optn_ok; } -static int +staticfn int optfn_o_menu_colors(int optidx UNUSED, int req, boolean negated UNUSED, char *opts, char *op UNUSED) { @@ -8067,7 +8083,7 @@ optfn_o_menu_colors(int optidx UNUSED, int req, boolean negated UNUSED, return optn_ok; } -static int +staticfn int optfn_o_message_types( int optidx UNUSED, int req, @@ -8092,7 +8108,7 @@ optfn_o_message_types( return optn_ok; } -static int +staticfn int optfn_o_status_cond( int optidx UNUSED, int req, @@ -8124,7 +8140,7 @@ optfn_o_status_cond( } #ifdef STATUS_HILITES -static int +staticfn int optfn_o_status_hilites( int optidx UNUSED, int req, @@ -8186,7 +8202,7 @@ get_option_value(const char *optname, boolean cnfvalid) return (char *) 0; } -static unsigned int +staticfn unsigned int longest_option_name(int startpass, int endpass) { /* spin through the options to find the longest name */ @@ -8214,7 +8230,7 @@ longest_option_name(int startpass, int endpass) } /* guts of doset_simple(); called repeatedly until no choice is made */ -static int +staticfn int doset_simple_menu(void) { /* unlike doset()'s fmtstr, there is no leading %s for indentation */ @@ -8427,7 +8443,7 @@ doset_simple(void) return ECMD_OK; } -static const char * +staticfn const char * term_for_boolean(int idx, boolean *b) { int i, f_t = (*b) ? 1: 0; @@ -8621,7 +8637,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, @@ -8682,7 +8698,7 @@ doset(void) /* changing options via menu by Per Liboriussen */ #undef HELP_IDX /* doset(#optionsfull command) menu entries for compound options */ -static void +staticfn void doset_add_menu( winid win, /* window to add to */ const char *option, /* option name */ @@ -8843,7 +8859,7 @@ show_menu_controls(winid win, boolean dolist) RESTORE_WARNING_FORMAT_NONLITERAL -static int +staticfn int count_cond(void) { int i, cnt = 0; @@ -8855,7 +8871,7 @@ count_cond(void) return cnt; } -static int +staticfn int count_apes(void) { int numapes = 0; @@ -8872,7 +8888,7 @@ count_apes(void) DISABLE_WARNING_FORMAT_NONLITERAL /* common to msg-types, menu-colors, autopickup-exceptions */ -static int +staticfn int handle_add_list_remove(const char *optname, int numtotal) { winid tmpwin; @@ -8991,7 +9007,7 @@ add_autopickup_exception(const char *mapping) return 1; } -static void +staticfn void remove_autopickup_exception(struct autopickup_exception *whichape) { struct autopickup_exception *ape, *freeape, *prev = 0; @@ -9197,7 +9213,7 @@ option_help(void) entry spread across multiple lines with backslash+newline if needed; conditions with their default settings (cond_blind, !cond_glowhands, &c) are excluded */ -static void +staticfn void all_options_conds(strbuf_t *sbuf) { char buf[BUFSZ], nextcond[BUFSZ]; @@ -9236,7 +9252,7 @@ all_options_conds(strbuf_t *sbuf) } /* append menucolor lines to strbuf */ -static void +staticfn void all_options_menucolors(strbuf_t *sbuf) { int i = 0, ncolors = count_menucolors(); @@ -9269,7 +9285,7 @@ all_options_menucolors(strbuf_t *sbuf) free(arr); } -static void +staticfn void all_options_msgtypes(strbuf_t *sbuf) { struct plinemsg_type *tmp = gp.plinemsg_types; @@ -9284,7 +9300,7 @@ all_options_msgtypes(strbuf_t *sbuf) } } -static void +staticfn void all_options_apes(strbuf_t *sbuf) { struct autopickup_exception *tmp = ga.apelist; @@ -9513,7 +9529,7 @@ set_wc_option_mod_status(unsigned long optmask, int status) } } -static boolean +staticfn boolean is_wc_option(const char *optnam) { int k = 0; @@ -9526,7 +9542,7 @@ is_wc_option(const char *optnam) return FALSE; } -static boolean +staticfn boolean wc_supported(const char *optnam) { int k; @@ -9567,7 +9583,7 @@ set_wc2_option_mod_status(unsigned long optmask, int status) } } -static boolean +staticfn boolean is_wc2_option(const char *optnam) { int k = 0; @@ -9580,7 +9596,7 @@ is_wc2_option(const char *optnam) return FALSE; } -static boolean +staticfn boolean wc2_supported(const char *optnam) { int k; @@ -9593,7 +9609,7 @@ wc2_supported(const char *optnam) return FALSE; } -static void +staticfn void wc_set_font_name(int opttype, char *fontname) { char **fn = (char **) 0; @@ -9627,28 +9643,31 @@ wc_set_font_name(int opttype, char *fontname) return; } -static int +staticfn int wc_set_window_colors(char *op) { /* syntax: * menu white/black message green/yellow status white/blue text * white/black */ - int j; - char buf[BUFSZ]; - char *wn, *tfg, *tbg, *newop; - static const char *const wnames[] = { + static const char *const wnames[WC_COUNT] = { "menu", "message", "status", "text" }; - static const char *const shortnames[] = { "mnu", "msg", "sts", "txt" }; - static char **fgp[] = { &iflags.wc_foregrnd_menu, - &iflags.wc_foregrnd_message, - &iflags.wc_foregrnd_status, - &iflags.wc_foregrnd_text }; - static char **bgp[] = { &iflags.wc_backgrnd_menu, - &iflags.wc_backgrnd_message, - &iflags.wc_backgrnd_status, - &iflags.wc_backgrnd_text }; + static const char *const shortnames[WC_COUNT] = { + "mnu", "msg", "sts", "txt" + }; + static char **fgp[] = { &iflags.wcolors[wcolor_menu].fg, + &iflags.wcolors[wcolor_message].fg, + &iflags.wcolors[wcolor_status].fg, + &iflags.wcolors[wcolor_text].fg }; + static char **bgp[] = { &iflags.wcolors[wcolor_menu].bg, + &iflags.wcolors[wcolor_message].bg, + &iflags.wcolors[wcolor_status].bg, + &iflags.wcolors[wcolor_text].bg }; + int j; + int32 clr; + char buf[BUFSZ]; + char *wn, *tfg, *tbg, *newop; Strcpy(buf, op); newop = mungspaces(buf); @@ -9698,21 +9717,33 @@ wc_set_window_colors(char *op) if (*newop) *newop++ = '\0'; - for (j = 0; j < 4; ++j) { + for (j = 0; j < WC_COUNT; ++j) { if (!strcmpi(wn, wnames[j]) || !strcmpi(wn, shortnames[j])) { if (!strstri(tfg, " ")) { if (*fgp[j]) free((genericptr_t) *fgp[j]); - *fgp[j] = dupstr(tfg); + clr = check_enhanced_colors(tfg); + *fgp[j] = dupstr((clr >= 0) ? wc_color_name(clr) : tfg); } if (!strstri(tbg, " ")) { if (*bgp[j]) free((genericptr_t) *bgp[j]); - *bgp[j] = dupstr(tbg); + clr = check_enhanced_colors(tbg); + *bgp[j] = dupstr((clr >= 0) ? wc_color_name(clr) : tbg); } + if (wcolors_opt[j] != 0) { + config_error_add( + "windowcolors for %s windows specified multiple times", + wnames[j]); + } + wcolors_opt[j]++; break; } } + if (j == WC_COUNT) { + config_error_add("windowcolors for unrecognized window type: %s", + wn); + } } return 1; } @@ -9742,7 +9773,7 @@ set_playmode(void) /* don't need to do anything special for normal play */ } -static void +staticfn void enhance_menu_text( char *buf, size_t sz, diff --git a/src/pager.c b/src/pager.c index 2b2c051be..3b25511c9 100644 --- a/src/pager.c +++ b/src/pager.c @@ -11,46 +11,46 @@ #include "hack.h" #include "dlb.h" -static boolean is_swallow_sym(int); -static int append_str(char *, const char *) NONNULLPTRS; -static void trap_description(char *, int, coordxy, coordxy) NONNULLARG1; -static void look_at_object(char *, coordxy, coordxy, int) NONNULLARG1; -static void look_at_monster(char *, char *, struct monst *, +staticfn boolean is_swallow_sym(int); +staticfn int append_str(char *, const char *) NONNULLPTRS; +staticfn void trap_description(char *, int, coordxy, coordxy) NONNULLARG1; +staticfn void look_at_object(char *, coordxy, coordxy, int) NONNULLARG1; +staticfn void look_at_monster(char *, char *, struct monst *, coordxy, coordxy) NONNULLARG13; /* lookat() can return Null */ -static struct permonst *lookat(coordxy, coordxy, char *, char *) NONNULLPTRS; -static boolean checkfile(char *, struct permonst *, unsigned, +staticfn struct permonst *lookat(coordxy, coordxy, char *, char *) NONNULLPTRS; +staticfn boolean checkfile(char *, struct permonst *, unsigned, char *) NO_NNARGS; -static int add_cmap_descr(int, int, int, int, coord, +staticfn int add_cmap_descr(int, int, int, int, coord, const char *, const char *, boolean *, const char **, char *) NONNULLPTRS; -static void look_region_nearby(coordxy *, coordxy *, coordxy *, coordxy *, +staticfn void look_region_nearby(coordxy *, coordxy *, coordxy *, coordxy *, boolean) NONNULLPTRS; -static void look_all(boolean, boolean); -static void look_traps(boolean); -static void look_engrs(boolean); -static void do_supplemental_info(char *, struct permonst *, +staticfn void look_all(boolean, boolean); +staticfn void look_traps(boolean); +staticfn void look_engrs(boolean); +staticfn void do_supplemental_info(char *, struct permonst *, boolean) NONNULLPTRS; -static void whatdoes_help(void); -static void docontact(void); -static void dispfile_help(void); -static void dispfile_shelp(void); -static void dispfile_optionfile(void); -static void dispfile_optmenu(void); -static void dispfile_license(void); -static void dispfile_debughelp(void); -static void dispfile_usagehelp(void); -static void hmenu_doextversion(void); -static void hmenu_dohistory(void); -static void hmenu_dowhatis(void); -static void hmenu_dowhatdoes(void); -static void hmenu_doextlist(void); -static void domenucontrols(void); +staticfn void whatdoes_help(void); +staticfn void docontact(void); +staticfn void dispfile_help(void); +staticfn void dispfile_shelp(void); +staticfn void dispfile_optionfile(void); +staticfn void dispfile_optmenu(void); +staticfn void dispfile_license(void); +staticfn void dispfile_debughelp(void); +staticfn void dispfile_usagehelp(void); +staticfn void hmenu_doextversion(void); +staticfn void hmenu_dohistory(void); +staticfn void hmenu_dowhatis(void); +staticfn void hmenu_dowhatdoes(void); +staticfn void hmenu_doextlist(void); +staticfn void domenucontrols(void); #ifdef PORT_HELP extern void port_help(void); #endif -static char *setopt_cmd(char *) NONNULL NONNULLARG1; -static boolean add_quoted_engraving(coordxy, coordxy, char *) NONNULLARG3; +staticfn char *setopt_cmd(char *) NONNULL NONNULLARG1; +staticfn boolean add_quoted_engraving(coordxy, coordxy, char *) NONNULLARG3; enum checkfileflags { chkfilNone = 0, @@ -63,7 +63,7 @@ static const char invisexplain[] = "remembered, unseen, creature", altinvisexplain[] = "unseen creature"; /* for clairvoyance */ /* Returns "true" for characters that could represent a monster's stomach. */ -static boolean +staticfn boolean is_swallow_sym(int c) { int i; @@ -77,7 +77,7 @@ is_swallow_sym(int c) /* Append " or "+new_str to the end of buf if new_str doesn't already exist as a substring of buf. Return 1 if the string was appended, 0 otherwise. It is expected that buf is of size BUFSZ. */ -static int +staticfn int append_str(char *buf, const char *new_str) { static const char sep[] = " or "; @@ -159,7 +159,7 @@ monhealthdescr(struct monst *mon, boolean addspace, char *outbuf) } /* copy a trap's description into outbuf[] */ -static void +staticfn void trap_description(char *outbuf, int tnum, coordxy x, coordxy y) { /* @@ -310,7 +310,7 @@ object_from_map(int glyph, coordxy x, coordxy y, struct obj **obj_p) return fakeobj; /* when True, caller needs to dealloc *obj_p */ } -static void +staticfn void look_at_object( char *buf, /* output buffer */ coordxy x, coordxy y, @@ -346,7 +346,7 @@ look_at_object( return; } -static void +staticfn void look_at_monster( char *buf, char *monbuf, /* buf: output, monbuf: optional output */ struct monst *mtmp, @@ -578,7 +578,7 @@ ice_descr(coordxy x, coordxy y, char *outbuf) * Return the name of the glyph found at (x,y). * If not hallucinating and the glyph is a monster, also monster data. */ -static struct permonst * +staticfn struct permonst * lookat(coordxy x, coordxy y, char *buf, char *monbuf) { struct monst *mtmp = (struct monst *) 0; @@ -751,7 +751,7 @@ ia_checkfile(struct obj *otmp) * * Returns True if an entry is found, False otherwise. */ -static boolean +staticfn boolean checkfile( char *inp, /* string to look up */ struct permonst *pm, /* monster type to look up (overrides 'inp') */ @@ -1054,7 +1054,7 @@ checkfile( } /* extracted from do_screen_description() */ -static int +staticfn int add_cmap_descr( int found, /* number of matching descriptions so far */ int idx, /* cmap index into defsyms[] */ @@ -1529,7 +1529,7 @@ do_screen_description( } /* when farlook is reporting on an engraving, include its text */ -static boolean +staticfn boolean add_quoted_engraving(coordxy x, coordxy y, char *buf) { char temp_buf[BUFSZ]; @@ -1562,7 +1562,7 @@ add_quoted_engraving(coordxy x, coordxy y, char *buf) return TRUE; } -/* also used by getpos hack in do_name.c */ +/* also used by getpos hack in getpos.c */ const char what_is_an_unknown_object[] = "an unknown object"; int @@ -1828,7 +1828,7 @@ do_look(int mode, coord *click_cc) return ECMD_OK; } -static void +staticfn void look_region_nearby( coordxy *lo_x, coordxy *lo_y, coordxy *hi_x, coordxy *hi_y, boolean nearby) @@ -1841,7 +1841,7 @@ look_region_nearby( DISABLE_WARNING_FORMAT_NONLITERAL /* RESTORE is after do_supplemental_info() */ -static void +staticfn void look_all( boolean nearby, /* True => within BOLTLIM, False => entire map */ boolean do_mons) /* True => monsters, False => objects */ @@ -1942,7 +1942,7 @@ look_all( } /* give a /M style display of discovered traps, even when they're covered */ -static void +staticfn void look_traps(boolean nearby) { winid win; @@ -2008,7 +2008,7 @@ look_traps(boolean nearby) /* display of discovered engravings including headstones, even when they're covered provided they've been read */ -static void +staticfn void look_engrs(boolean nearby) { winid win; @@ -2119,7 +2119,7 @@ static const char *suptext2[] = { (char *) 0, }; -static void +staticfn void do_supplemental_info( char *name, struct permonst *pm, @@ -2287,7 +2287,7 @@ doidtrap(void) rest_on_space, #if SHELL, #if SUSPEND) are booleans. */ -static void +staticfn void whatdoes_help(void) { dlb *fp; @@ -2322,9 +2322,9 @@ struct wd_stack_frame { Bitfield(else_seen, 1); }; -static boolean whatdoes_cond(char *, struct wd_stack_frame *, int *, int); +staticfn boolean whatdoes_cond(char *, struct wd_stack_frame *, int *, int); -static boolean +staticfn boolean whatdoes_cond(char *buf, struct wd_stack_frame *stack, int *depth, int lnum) { const char badstackfmt[] = "cmdhlp: too many &%c directives at line %d."; @@ -2584,7 +2584,7 @@ dowhatdoes(void) return ECMD_OK; } -static void +staticfn void docontact(void) { winid cwin = create_nhwindow(NHW_TEXT); @@ -2614,79 +2614,79 @@ docontact(void) destroy_nhwindow(cwin); } -static void +staticfn void dispfile_help(void) { display_file(HELP, TRUE); } -static void +staticfn void dispfile_shelp(void) { display_file(SHELP, TRUE); } -static void +staticfn void dispfile_optionfile(void) { display_file(OPTIONFILE, TRUE); } -static void +staticfn void dispfile_optmenu(void) { display_file(OPTMENUHELP, TRUE); } -static void +staticfn void dispfile_license(void) { display_file(LICENSE, TRUE); } -static void +staticfn void dispfile_debughelp(void) { display_file(DEBUGHELP, TRUE); } -static void +staticfn void dispfile_usagehelp(void) { display_file(USAGEHELP, TRUE); } -static void +staticfn void hmenu_doextversion(void) { (void) doextversion(); } -static void +staticfn void hmenu_dohistory(void) { (void) dohistory(); } -static void +staticfn void hmenu_dowhatis(void) { (void) dowhatis(); } -static void +staticfn void hmenu_dowhatdoes(void) { (void) dowhatdoes(); } -static void +staticfn void hmenu_doextlist(void) { (void) doextlist(); } -static void +staticfn void domenucontrols(void) { winid cwin = create_nhwindow(NHW_TEXT); @@ -2774,7 +2774,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL normally 'O' but could be bound to something else, or not bound at all; with the implementation of a simple options subset, now need 'mO' to get the full options command; format it as 'm O' */ -static char * +staticfn char * setopt_cmd(char *outbuf) { char cmdbuf[QBUFSZ]; diff --git a/src/pickup.c b/src/pickup.c index 3256ff734..a215d4ff8 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -11,47 +11,47 @@ #define CONTAINED_SYM '>' /* from invent.c */ -static void simple_look(struct obj *, boolean); -static boolean query_classes(char *, boolean *, boolean *, const char *, +staticfn void simple_look(struct obj *, boolean); +staticfn boolean query_classes(char *, boolean *, boolean *, const char *, struct obj *, boolean, int *); -static boolean fatal_corpse_mistake(struct obj *, boolean); -static boolean describe_decor(void); -static void check_here(boolean); -static boolean n_or_more(struct obj *); -static boolean all_but_uchain(struct obj *); +staticfn boolean fatal_corpse_mistake(struct obj *, boolean); +staticfn boolean describe_decor(void); +staticfn void check_here(boolean); +staticfn boolean n_or_more(struct obj *); +staticfn boolean all_but_uchain(struct obj *); #if 0 /* not used */ -static boolean allow_cat_no_uchain(struct obj *); +staticfn boolean allow_cat_no_uchain(struct obj *); #endif -static int autopick(struct obj *, int, menu_item **); -static int count_categories(struct obj *, int); -static int delta_cwt(struct obj *, struct obj *); -static long carry_count(struct obj *, struct obj *, long, boolean, int *, +staticfn int autopick(struct obj *, int, menu_item **); +staticfn int count_categories(struct obj *, int); +staticfn int delta_cwt(struct obj *, struct obj *); +staticfn long carry_count(struct obj *, struct obj *, long, boolean, int *, int *); -static int lift_object(struct obj *, struct obj *, long *, boolean); -static void pickup_prinv(struct obj *, long, const char *); -static boolean mbag_explodes(struct obj *, int); -static boolean is_boh_item_gone(void); -static void do_boh_explosion(struct obj *, boolean); -static long boh_loss(struct obj *, boolean); -static int in_container(struct obj *); -static int out_container(struct obj *); -static long mbag_item_gone(boolean, struct obj *, boolean); -static int stash_ok(struct obj *); -static void explain_container_prompt(boolean); -static int traditional_loot(boolean); -static int menu_loot(int, boolean); -static int tip_ok(struct obj *); -static int choose_tip_container_menu(void); -static struct obj *tipcontainer_gettarget(struct obj *, boolean *); -static int tipcontainer_checks(struct obj *, struct obj *, boolean); -static char in_or_out_menu(const char *, struct obj *, boolean, boolean, +staticfn int lift_object(struct obj *, struct obj *, long *, boolean); +staticfn void pickup_prinv(struct obj *, long, const char *); +staticfn boolean mbag_explodes(struct obj *, int); +staticfn boolean is_boh_item_gone(void); +staticfn void do_boh_explosion(struct obj *, boolean); +staticfn long boh_loss(struct obj *, boolean); +staticfn int in_container(struct obj *); +staticfn int out_container(struct obj *); +staticfn long mbag_item_gone(boolean, struct obj *, boolean); +staticfn int stash_ok(struct obj *); +staticfn void explain_container_prompt(boolean); +staticfn int traditional_loot(boolean); +staticfn int menu_loot(int, boolean); +staticfn int tip_ok(struct obj *); +staticfn int choose_tip_container_menu(void); +staticfn struct obj *tipcontainer_gettarget(struct obj *, boolean *); +staticfn int tipcontainer_checks(struct obj *, struct obj *, boolean); +staticfn char in_or_out_menu(const char *, struct obj *, boolean, boolean, boolean, boolean); -static boolean able_to_loot(coordxy, coordxy, boolean); -static boolean reverse_loot(void); -static boolean mon_beside(coordxy, coordxy); -static int do_loot_cont(struct obj **, int, int); -static int doloot_core(void); -static void tipcontainer(struct obj *); +staticfn boolean able_to_loot(coordxy, coordxy, boolean); +staticfn boolean reverse_loot(void); +staticfn boolean mon_beside(coordxy, coordxy); +staticfn int do_loot_cont(struct obj **, int, int); +staticfn int doloot_core(void); +staticfn void tipcontainer(struct obj *); /* define for query_objlist() and autopickup() */ #define FOLLOW(curr, flags) \ @@ -72,7 +72,7 @@ static const char /* BUG: this lets you look at cockatrice corpses while blind without touching them */ /* much simpler version of the look-here code; used by query_classes() */ -static void +staticfn void simple_look(struct obj *otmp, /* list of objects */ boolean here) /* flag for type of obj list linkage */ { @@ -137,7 +137,7 @@ collect_obj_classes(char ilets[], struct obj *otmp, boolean here, * it was changed to enhance menu entry ordering ('A' stands out, but * some players complain that it is too easy to choose accidentally). */ -static boolean +staticfn boolean query_classes( char oclasses[], /* selected classes */ boolean *one_at_a_time, /* to tell caller that user picked 'A' */ @@ -262,7 +262,7 @@ query_classes( } /* check whether hero is bare-handedly touching a cockatrice corpse */ -static boolean +staticfn boolean fatal_corpse_mistake(struct obj *obj, boolean remotely) { if (uarmg || remotely || obj->otyp != CORPSE @@ -331,7 +331,7 @@ deferred_decor( /* handle 'mention_decor' (when walking onto a dungeon feature such as stairs or altar, describe it even if it isn't covered up by an object) */ -static boolean +staticfn boolean describe_decor(void) { char outbuf[BUFSZ], fbuf[QBUFSZ]; @@ -408,7 +408,7 @@ describe_decor(void) } /* look at the objects at our location, unless there are too many of them */ -static void +staticfn void check_here(boolean picked_some) { struct obj *obj; @@ -438,7 +438,7 @@ check_here(boolean picked_some) } /* query_objlist callback: return TRUE if obj's count is >= reference value */ -static boolean +staticfn boolean n_or_more(struct obj *obj) { if (obj == uchain) @@ -487,7 +487,7 @@ add_valid_menu_class(int c) } /* query_objlist callback: return TRUE if not uchain */ -static boolean +staticfn boolean all_but_uchain(struct obj *obj) { return (boolean) (obj != uchain); @@ -575,7 +575,7 @@ allow_category(struct obj *obj) #if 0 /* not used */ /* query_objlist callback: return TRUE if valid category (class), no uchain */ -static boolean +staticfn boolean allow_cat_no_uchain(struct obj *obj) { if (obj != uchain @@ -949,7 +949,7 @@ autopick_testobj(struct obj *otmp, boolean calc_costly) * picked is zero, the pickup list is left alone. The caller of this * function must free the pickup list. */ -static int +staticfn int autopick( struct obj *olist, /* the object list */ int follow, /* how to follow the object list */ @@ -1484,7 +1484,7 @@ query_category( return n; } -static int +staticfn int count_categories(struct obj *olist, int qflags) { char *pack; @@ -1517,7 +1517,7 @@ count_categories(struct obj *olist, int qflags) * object is removed from it. Use before and after weight amounts rather * than trying to match the calculation used by weight() in mkobj.c. */ -static int +staticfn int delta_cwt(struct obj *container, struct obj *obj) { struct obj **prev; @@ -1543,7 +1543,7 @@ delta_cwt(struct obj *container, struct obj *obj) } /* could we carry `obj'? if not, could we carry some of it/them? */ -static long +staticfn long carry_count(struct obj *obj, /* object to pick up... */ struct obj *container, /* ...bag it is coming out of */ long count, @@ -1678,8 +1678,7 @@ carry_count(struct obj *obj, /* object to pick up... */ } /* determine whether character is able and player is willing to carry `obj' */ -static -int +staticfn int lift_object( struct obj *obj, /* object to pick up... */ struct obj *container, /* ...bag it's coming out of */ @@ -1922,7 +1921,7 @@ pick_obj(struct obj *otmp) /* pickup_object()/out_container() helper; print an added-to-invent message for current object, limiting feedback about encumbrance to the first item which causes that to change */ -static void +staticfn void pickup_prinv( struct obj *obj, long count, @@ -2017,7 +2016,7 @@ container_at(coordxy x, coordxy y, boolean countem) return container_count; } -static boolean +staticfn boolean able_to_loot( coordxy x, coordxy y, boolean looting) /* loot vs tip */ @@ -2048,7 +2047,7 @@ able_to_loot( return TRUE; } -static boolean +staticfn boolean mon_beside(coordxy x, coordxy y) { int i, j; @@ -2064,7 +2063,7 @@ mon_beside(coordxy x, coordxy y) return FALSE; } -static int +staticfn int do_loot_cont( struct obj **cobjp, int cindex, /* index of this container (1..N)... */ @@ -2153,7 +2152,7 @@ doloot(void) } /* loot a container on the floor or loot saddle from mon. */ -static int +staticfn int doloot_core(void) { struct obj *cobj, *nobj; @@ -2325,7 +2324,7 @@ doloot_core(void) } /* called when attempting to #loot while confused */ -static boolean +staticfn boolean reverse_loot(void) { struct obj *goldob = 0, *coffers, *otmp, boxdummy; @@ -2462,7 +2461,7 @@ loot_mon(struct monst *mtmp, int *passed_info, boolean *prev_loot) * Decide whether an object being placed into a magic bag will cause * it to explode. If the object is a bag itself, check recursively. */ -static boolean +staticfn boolean mbag_explodes(struct obj *obj, int depthin) { /* these won't cause an explosion when they're empty */ @@ -2484,7 +2483,7 @@ mbag_explodes(struct obj *obj, int depthin) return FALSE; } -static boolean +staticfn boolean is_boh_item_gone(void) { return (boolean) (!rn2(13)); @@ -2492,7 +2491,7 @@ is_boh_item_gone(void) /* Scatter most of Bag of holding contents around. Some items will be destroyed with the same chance as looting a cursed bag. */ -static void +staticfn void do_boh_explosion(struct obj *boh, boolean on_floor) { struct obj *otmp, *nobj; @@ -2511,7 +2510,7 @@ do_boh_explosion(struct obj *boh, boolean on_floor) /* boh is about to be deleted so no need to reset its in_use flag here */ } -static long +staticfn long boh_loss(struct obj *container, boolean held) { /* sometimes toss objects if a cursed magic bag */ @@ -2532,7 +2531,7 @@ boh_loss(struct obj *container, boolean held) } /* Returns: -1 to stop, 1 item was inserted, 0 item was not inserted. */ -static int +staticfn int in_container(struct obj *obj) { boolean floor_container = !carried(gc.current_container); @@ -2699,7 +2698,7 @@ ck_bag(struct obj *obj) } /* Returns: -1 to stop, 1 item was removed, 0 item was not removed. */ -static int +staticfn int out_container(struct obj *obj) { struct obj *otmp; @@ -2775,7 +2774,7 @@ removed_from_icebox(struct obj *obj) } /* an object inside a cursed bag of holding is being destroyed */ -static long +staticfn long mbag_item_gone(boolean held, struct obj *item, boolean silent) { struct monst *shkp; @@ -2869,7 +2868,7 @@ container_gone(int (*fn)(OBJ_P)) && !gc.current_container); } -static void +staticfn void explain_container_prompt(boolean more_containers) { static const char *const explaintext[] = { @@ -2915,7 +2914,7 @@ u_handsy(void) } /* getobj callback for object to be stashed into a container */ -static int +staticfn int stash_ok(struct obj *obj) { if (!obj) @@ -3186,7 +3185,7 @@ use_container( } /* loot current_container (take things out or put things in), by prompting */ -static int +staticfn int traditional_loot(boolean put_in) { int (*actionfunc)(OBJ_P), (*checkfunc)(OBJ_P); @@ -3221,7 +3220,7 @@ traditional_loot(boolean put_in) } /* loot current_container (take things out or put things in), using a menu */ -static int +staticfn int menu_loot(int retry, boolean put_in) { int n, i, n_looted = 0; @@ -3352,7 +3351,7 @@ menu_loot(int retry, boolean put_in) return n_looted ? ECMD_TIME : ECMD_OK; } -static char +staticfn char in_or_out_menu( const char *prompt, struct obj *obj, @@ -3435,7 +3434,7 @@ in_or_out_menu( } /* getobj callback for object to tip */ -static int +staticfn int tip_ok(struct obj *obj) { if (!obj || obj->oclass == COIN_CLASS) @@ -3459,7 +3458,7 @@ tip_ok(struct obj *obj) returns ECMD_CANCEL if menu was canceled, ECMD_TIME if a container was picked, otherwise returns ECMD_OK. */ -static int +staticfn int choose_tip_container_menu(void) { int n, i; @@ -3641,7 +3640,7 @@ enum tipping_check_values { TIPCHECK_EMPTY }; -static void +staticfn void tipcontainer(struct obj *box) /* or bag */ { coordxy ox = u.ux, oy = u.uy; /* #tip only works at hero's location */ @@ -3797,11 +3796,11 @@ tipcontainer(struct obj *box) /* or bag */ } #if 0 -static int count_target_containers(struct obj *, struct obj *); +staticfn int count_target_containers(struct obj *, struct obj *); /* returns number of containers in object chain; does not recurse into containers; skips bags of tricks when they're known */ -static int +staticfn int count_target_containers( struct obj *olist, /* list of objects (invent) */ struct obj *excludo) /* particular object to exclude if found in list */ @@ -3823,7 +3822,7 @@ count_target_containers( /* ask user for a carried container into which they want box to be emptied; cancelled is TRUE if user cancelled the menu pick; hands aren't required when tipping to the floor but are when tipping into another container */ -static struct obj * +staticfn struct obj * tipcontainer_gettarget( struct obj *box, boolean *cancelled) @@ -3906,7 +3905,7 @@ tipcontainer_gettarget( /* Perform check on box if we can tip it. Returns one of TIPCHECK_foo values. If allowempty if TRUE, return TIPCHECK_OK instead of TIPCHECK_EMPTY. */ -static int +staticfn int tipcontainer_checks( struct obj *box, /* container player wants to tip */ struct obj *targetbox, /* destination (used here for horn of plenty) */ diff --git a/src/pline.c b/src/pline.c index 7abba3bf0..09196d4f2 100644 --- a/src/pline.c +++ b/src/pline.c @@ -9,10 +9,10 @@ * config file parsing) with modest decoration; * result will then be truncated to BUFSZ-1 */ -static void putmesg(const char *); -static char *You_buf(int); +staticfn void putmesg(const char *); +staticfn char *You_buf(int); #if defined(MSGHANDLER) -static void execplinehandler(const char *); +staticfn void execplinehandler(const char *); #endif #ifdef USER_SOUNDS extern void maybe_play_sound(const char *); @@ -63,7 +63,7 @@ dumplogfreemessages(void) #endif /* keeps windowprocs usage out of pline() */ -static void +staticfn void putmesg(const char *line) { int attr = ATR_NONE; @@ -78,7 +78,7 @@ putmesg(const char *line) SoundSpeak(line); } -static void vpline(const char *, va_list); +staticfn void vpline(const char *, va_list); DISABLE_WARNING_FORMAT_NONLITERAL @@ -133,7 +133,7 @@ set_msg_xy(coordxy x, coordxy y) a11y.msg_loc.y = y; } -static void +staticfn void vpline(const char *line, va_list the_args) { static int in_pline = 0; @@ -312,7 +312,7 @@ Norep(const char *line, ...) va_end(the_args); } -static char * +staticfn char * You_buf(int siz) { if (siz > gy.you_buf_siz) { @@ -520,7 +520,7 @@ livelog_printf( #endif /* !CHRONICLE */ -static void vraw_printf(const char *, va_list); +staticfn void vraw_printf(const char *, va_list); void raw_printf(const char *line, ...) @@ -536,7 +536,7 @@ raw_printf(const char *line, ...) DISABLE_WARNING_FORMAT_NONLITERAL -static void +staticfn void vraw_printf(const char *line, va_list the_args) { char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */ @@ -609,7 +609,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL #if defined(MSGHANDLER) static boolean use_pline_handler = TRUE; -static void +staticfn void execplinehandler(const char *line) { #if defined(POSIX_TYPES) || defined(__GNUC__) @@ -664,7 +664,7 @@ execplinehandler(const char *line) /* * varargs handling for files.c */ -static void vconfig_error_add(const char *, va_list); +staticfn void vconfig_error_add(const char *, va_list); DISABLE_WARNING_FORMAT_NONLITERAL @@ -678,7 +678,7 @@ config_error_add(const char *str, ...) va_end(the_args); } -static void +staticfn void vconfig_error_add(const char *str, va_list the_args) { /* start of vconf...() or of nested block in USE_OLDARG's conf...() */ int vlen = 0; diff --git a/src/polyself.c b/src/polyself.c index d09d9af30..806192693 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -21,14 +21,14 @@ #include "hack.h" -static void check_strangling(boolean); -static void polyman(const char *, const char *); -static void dropp(struct obj *); -static void break_armor(void); -static void drop_weapon(int); -static int armor_to_dragon(int); -static void newman(void); -static void polysense(void); +staticfn void check_strangling(boolean); +staticfn void polyman(const char *, const char *); +staticfn void dropp(struct obj *); +staticfn void break_armor(void); +staticfn void drop_weapon(int); +staticfn int armor_to_dragon(int); +staticfn void newman(void); +staticfn void polysense(void); static const char no_longer_petrify_resistant[] = "No longer petrify-resistant, you"; @@ -157,7 +157,7 @@ steed_vs_stealth(void) } /* for changing into form that's immune to strangulation */ -static void +staticfn void check_strangling(boolean on) { /* on -- maybe resume strangling */ @@ -189,7 +189,7 @@ check_strangling(boolean on) DISABLE_WARNING_FORMAT_NONLITERAL /* make a (new) human out of the player */ -static void +staticfn void polyman(const char *fmt, const char *arg) { boolean sticking = (sticks(gy.youmonst.data) && u.ustuck && !u.uswallow), @@ -321,7 +321,7 @@ livelog_newform(boolean viapoly, int oldgend, int newgend) } } -static void +staticfn void newman(void) { const char *newform; @@ -1108,7 +1108,7 @@ uasmon_maxStr(void) } /* dropx() jacket for break_armor() */ -static void +staticfn void dropp(struct obj *obj) { struct obj *otmp; @@ -1133,7 +1133,7 @@ dropp(struct obj *obj) } } -static void +staticfn void break_armor(void) { struct obj *otmp; @@ -1276,7 +1276,7 @@ break_armor(void) /* rings stay worn even when no hands */ } -static void +staticfn void drop_weapon(int alone) { struct obj *otmp; @@ -2160,7 +2160,7 @@ ugolemeffects(int damtype, int dam) } } -static int +staticfn int armor_to_dragon(int atyp) { switch (atyp) { @@ -2205,7 +2205,7 @@ armor_to_dragon(int atyp) } /* some species have awareness of other species */ -static void +staticfn void polysense(void) { short warnidx = NON_PM; diff --git a/src/potion.c b/src/potion.c index f04da9595..be7e7f80d 100644 --- a/src/potion.c +++ b/src/potion.c @@ -5,43 +5,43 @@ #include "hack.h" -static long itimeout(long); -static long itimeout_incr(long, int); -static void ghost_from_bottle(void); -static int drink_ok(struct obj *); -static void peffect_restore_ability(struct obj *); -static void peffect_hallucination(struct obj *); -static void peffect_water(struct obj *); -static void peffect_booze(struct obj *); -static void peffect_enlightenment(struct obj *); -static void peffect_invisibility(struct obj *); -static void peffect_see_invisible(struct obj *); -static void peffect_paralysis(struct obj *); -static void peffect_sleeping(struct obj *); -static int peffect_monster_detection(struct obj *); -static int peffect_object_detection(struct obj *); -static void peffect_sickness(struct obj *); -static void peffect_confusion(struct obj *); -static void peffect_gain_ability(struct obj *); -static void peffect_speed(struct obj *); -static void peffect_blindness(struct obj *); -static void peffect_gain_level(struct obj *); -static void peffect_healing(struct obj *); -static void peffect_extra_healing(struct obj *); -static void peffect_full_healing(struct obj *); -static void peffect_levitation(struct obj *); -static void peffect_gain_energy(struct obj *); -static void peffect_oil(struct obj *); -static void peffect_acid(struct obj *); -static void peffect_polymorph(struct obj *); -static boolean H2Opotion_dip(struct obj *, struct obj *, boolean, +staticfn long itimeout(long); +staticfn long itimeout_incr(long, int); +staticfn void ghost_from_bottle(void); +staticfn int drink_ok(struct obj *); +staticfn void peffect_restore_ability(struct obj *); +staticfn void peffect_hallucination(struct obj *); +staticfn void peffect_water(struct obj *); +staticfn void peffect_booze(struct obj *); +staticfn void peffect_enlightenment(struct obj *); +staticfn void peffect_invisibility(struct obj *); +staticfn void peffect_see_invisible(struct obj *); +staticfn void peffect_paralysis(struct obj *); +staticfn void peffect_sleeping(struct obj *); +staticfn int peffect_monster_detection(struct obj *); +staticfn int peffect_object_detection(struct obj *); +staticfn void peffect_sickness(struct obj *); +staticfn void peffect_confusion(struct obj *); +staticfn void peffect_gain_ability(struct obj *); +staticfn void peffect_speed(struct obj *); +staticfn void peffect_blindness(struct obj *); +staticfn void peffect_gain_level(struct obj *); +staticfn void peffect_healing(struct obj *); +staticfn void peffect_extra_healing(struct obj *); +staticfn void peffect_full_healing(struct obj *); +staticfn void peffect_levitation(struct obj *); +staticfn void peffect_gain_energy(struct obj *); +staticfn void peffect_oil(struct obj *); +staticfn void peffect_acid(struct obj *); +staticfn void peffect_polymorph(struct obj *); +staticfn boolean H2Opotion_dip(struct obj *, struct obj *, boolean, const char *); -static short mixtype(struct obj *, struct obj *); -static int dip_ok(struct obj *); -static int dip_hands_ok(struct obj *); -static void hold_potion(struct obj *, const char *, const char *, +staticfn short mixtype(struct obj *, struct obj *); +staticfn int dip_ok(struct obj *); +staticfn int dip_hands_ok(struct obj *); +staticfn void hold_potion(struct obj *, const char *, const char *, const char *); -static int potion_dip(struct obj *obj, struct obj *potion); +staticfn int potion_dip(struct obj *obj, struct obj *potion); /* used to indicate whether quaff or dip has skipped an opportunity to use a fountain or such, in order to vary the feedback if hero lacks @@ -50,7 +50,7 @@ static int potion_dip(struct obj *obj, struct obj *potion); static int drink_ok_extra = 0; /* force `val' to be within valid range for intrinsic timeout value */ -static long +staticfn long itimeout(long val) { if (val >= TIMEOUT) @@ -62,7 +62,7 @@ itimeout(long val) } /* increment `old' by `incr' and force result to be valid intrinsic timeout */ -static long +staticfn long itimeout_incr(long old, int incr) { return itimeout((old & TIMEOUT) + (long) incr); @@ -475,7 +475,7 @@ self_invis_message(void) : "can't see yourself"); } -static void +staticfn void ghost_from_bottle(void) { struct monst *mtmp = makemon(&mons[PM_GHOST], u.ux, u.uy, MM_NOMSG); @@ -499,7 +499,7 @@ ghost_from_bottle(void) /* getobj callback for object to drink from, which also does double duty as the callback for dipping into (both just allow potions). */ -static int +staticfn int drink_ok(struct obj *obj) { /* getobj()'s callback to test whether hands/self is a valid "item" to @@ -630,7 +630,7 @@ dopotion(struct obj *otmp) /* potion or spell of restore ability; for spell, otmp is a temporary spellbook object that will be blessed if hero is skilled in healing */ -static void +staticfn void peffect_restore_ability(struct obj *otmp) { gp.potion_unkn++; @@ -677,7 +677,7 @@ peffect_restore_ability(struct obj *otmp) } } -static void +staticfn void peffect_hallucination(struct obj *otmp) { if (Halluc_resistance) { @@ -698,7 +698,7 @@ peffect_hallucination(struct obj *otmp) } } -static void +staticfn void peffect_water(struct obj *otmp) { if (!otmp->blessed && !otmp->cursed) { @@ -752,7 +752,7 @@ peffect_water(struct obj *otmp) } } -static void +staticfn void peffect_booze(struct obj *otmp) { gp.potion_unkn++; @@ -776,7 +776,7 @@ peffect_booze(struct obj *otmp) } } -static void +staticfn void peffect_enlightenment(struct obj *otmp) { if (otmp->cursed) { @@ -792,7 +792,7 @@ peffect_enlightenment(struct obj *otmp) } } -static void +staticfn void peffect_invisibility(struct obj *otmp) { boolean is_spell = (otmp->oclass == SPBOOK_CLASS); @@ -818,7 +818,7 @@ peffect_invisibility(struct obj *otmp) } } -static void +staticfn void peffect_see_invisible(struct obj *otmp) { int msg = Invisible && !Blind; @@ -857,7 +857,7 @@ peffect_see_invisible(struct obj *otmp) } } -static void +staticfn void peffect_paralysis(struct obj *otmp) { if (Free_action) { @@ -877,7 +877,7 @@ peffect_paralysis(struct obj *otmp) } } -static void +staticfn void peffect_sleeping(struct obj *otmp) { if (Sleep_resistance || Free_action) { @@ -890,7 +890,7 @@ peffect_sleeping(struct obj *otmp) } } -static int +staticfn int peffect_monster_detection(struct obj *otmp) { if (otmp->blessed) { @@ -931,7 +931,7 @@ peffect_monster_detection(struct obj *otmp) return 0; } -static int +staticfn int peffect_object_detection(struct obj *otmp) { if (object_detect(otmp, 0)) @@ -940,7 +940,7 @@ peffect_object_detection(struct obj *otmp) return 0; } -static void +staticfn void peffect_sickness(struct obj *otmp) { pline("Yecch! This stuff tastes like poison."); @@ -990,7 +990,7 @@ peffect_sickness(struct obj *otmp) } } -static void +staticfn void peffect_confusion(struct obj *otmp) { if (!Confusion) { @@ -1006,7 +1006,7 @@ peffect_confusion(struct obj *otmp) FALSE); } -static void +staticfn void peffect_gain_ability(struct obj *otmp) { if (otmp->cursed) { @@ -1028,7 +1028,7 @@ peffect_gain_ability(struct obj *otmp) } } -static void +staticfn void peffect_speed(struct obj *otmp) { boolean is_speed = (otmp->otyp == POT_SPEED); @@ -1049,7 +1049,7 @@ peffect_speed(struct obj *otmp) } } -static void +staticfn void peffect_blindness(struct obj *otmp) { if (Blind || ((HBlinded || EBlinded) && BBlinded)) @@ -1059,7 +1059,7 @@ peffect_blindness(struct obj *otmp) (boolean) !Blind); } -static void +staticfn void peffect_gain_level(struct obj *otmp) { if (otmp->cursed) { @@ -1095,7 +1095,7 @@ peffect_gain_level(struct obj *otmp) u.uexp = rndexp(TRUE); } -static void +staticfn void peffect_healing(struct obj *otmp) { You_feel("better."); @@ -1104,7 +1104,7 @@ peffect_healing(struct obj *otmp) exercise(A_CON, TRUE); } -static void +staticfn void peffect_extra_healing(struct obj *otmp) { You_feel("much better."); @@ -1120,7 +1120,7 @@ peffect_extra_healing(struct obj *otmp) heal_legs(0); } -static void +staticfn void peffect_full_healing(struct obj *otmp) { You_feel("completely healed."); @@ -1141,7 +1141,7 @@ peffect_full_healing(struct obj *otmp) heal_legs(0); } -static void +staticfn void peffect_levitation(struct obj *otmp) { /* @@ -1200,7 +1200,7 @@ peffect_levitation(struct obj *otmp) float_vs_flight(); } -static void +staticfn void peffect_gain_energy(struct obj *otmp) { int num; @@ -1236,7 +1236,7 @@ peffect_gain_energy(struct obj *otmp) exercise(A_WIS, TRUE); } -static void +staticfn void peffect_oil(struct obj *otmp) { boolean good_for_you = FALSE, vulnerable; @@ -1273,7 +1273,7 @@ peffect_oil(struct obj *otmp) exercise(A_WIS, good_for_you); } -static void +staticfn void peffect_acid(struct obj *otmp) { if (Acid_resistance) { @@ -1294,7 +1294,7 @@ peffect_acid(struct obj *otmp) gp.potion_unkn++; /* holy/unholy water can burn like acid too */ } -static void +staticfn void peffect_polymorph(struct obj *otmp) { You_feel("a little %s.", Hallucination ? "normal" : "strange"); @@ -1455,9 +1455,9 @@ strange_feeling(struct obj *obj, const char *txt) useup(obj); } -const char *bottlenames[] = { "bottle", "phial", "flagon", "carafe", +static const char *bottlenames[] = { "bottle", "phial", "flagon", "carafe", "flask", "jar", "vial" }; -const char *hbottlenames[] = { +static const char *hbottlenames[] = { "jug", "pitcher", "barrel", "tin", "bag", "box", "glass", "beaker", "tumbler", "vase", "flowerpot", "pan", "thingy", "mug", "teacup", "teapot", "keg", "bucket", "thermos", "amphora", "wineskin", "parcel", @@ -1474,7 +1474,7 @@ bottlename(void) } /* handle item dipped into water potion or steed saddle splashed by same */ -static boolean +staticfn boolean H2Opotion_dip( struct obj *potion, /* water */ struct obj *targobj, /* item being dipped into the water */ @@ -2085,7 +2085,7 @@ potionbreathe(struct obj *obj) } /* returns the potion type when o1 is dipped in o2 */ -static short +staticfn short mixtype(struct obj *o1, struct obj *o2) { int o1typ = o1->otyp, o2typ = o2->otyp; @@ -2175,7 +2175,7 @@ mixtype(struct obj *o1, struct obj *o2) /* getobj callback for object to be dipped (not the thing being dipped into, * that uses drink_ok) */ -static int +staticfn int dip_ok(struct obj *obj) { if (!obj) @@ -2192,7 +2192,7 @@ dip_ok(struct obj *obj) } /* getobj callback for object to be dipped when hero has slippery hands */ -static int +staticfn int dip_hands_ok(struct obj *obj) { if (!obj && (Glib && can_reach_floor(FALSE))) @@ -2204,7 +2204,7 @@ dip_hands_ok(struct obj *obj) /* call hold_another_object() to deal with a transformed potion; its weight won't have changed but it might require an extra slot that isn't available or it might merge into some other carried stack */ -static void +staticfn void hold_potion( struct obj *potobj, const char *drop_fmt, const char *drop_arg, @@ -2370,7 +2370,7 @@ dip_into(void) } /* called by dodip() or dip_into() after obj and potion have been chosen */ -static int +staticfn int potion_dip(struct obj *obj, struct obj *potion) { struct obj *singlepotion; diff --git a/src/pray.c b/src/pray.c index 99154656f..5d4b9a0ab 100644 --- a/src/pray.c +++ b/src/pray.c @@ -4,32 +4,32 @@ #include "hack.h" -static int prayer_done(void); -static void maybe_turn_mon_iter(struct monst *); -static struct obj *worst_cursed_item(void); -static int in_trouble(void); -static void fix_curse_trouble(struct obj *, const char *); -static void fix_worst_trouble(int); -static void angrygods(aligntyp); -static void at_your_feet(const char *); -static void gcrownu(void); -static void give_spell(void); -static void pleased(aligntyp); -static void godvoice(aligntyp, const char *); -static void god_zaps_you(aligntyp); -static void fry_by_god(aligntyp, boolean); -static void gods_angry(aligntyp); -static void gods_upset(aligntyp); -static void consume_offering(struct obj *); -static void offer_too_soon(aligntyp); -static void offer_real_amulet(struct obj *, aligntyp); /* NORETURN */ -static void offer_fake_amulet(struct obj *, boolean, aligntyp); -static void offer_different_alignment_altar(struct obj *, aligntyp); -static void sacrifice_your_race(struct obj *, boolean, aligntyp); -static int bestow_artifact(void); -static boolean pray_revive(void); -static boolean water_prayer(boolean); -static boolean blocked_boulder(int, int); +staticfn int prayer_done(void); +staticfn void maybe_turn_mon_iter(struct monst *); +staticfn struct obj *worst_cursed_item(void); +staticfn int in_trouble(void); +staticfn void fix_curse_trouble(struct obj *, const char *); +staticfn void fix_worst_trouble(int); +staticfn void angrygods(aligntyp); +staticfn void at_your_feet(const char *); +staticfn void gcrownu(void); +staticfn void give_spell(void); +staticfn void pleased(aligntyp); +staticfn void godvoice(aligntyp, const char *); +staticfn void god_zaps_you(aligntyp); +staticfn void fry_by_god(aligntyp, boolean); +staticfn void gods_angry(aligntyp); +staticfn void gods_upset(aligntyp); +staticfn void consume_offering(struct obj *); +staticfn void offer_too_soon(aligntyp); +staticfn void offer_real_amulet(struct obj *, aligntyp); /* NORETURN */ +staticfn void offer_fake_amulet(struct obj *, boolean, aligntyp); +staticfn void offer_different_alignment_altar(struct obj *, aligntyp); +staticfn void sacrifice_your_race(struct obj *, boolean, aligntyp); +staticfn int bestow_artifact(void); +staticfn boolean pray_revive(void); +staticfn boolean water_prayer(boolean); +staticfn boolean blocked_boulder(int, int); /* simplify a few tests */ #define Cursed_obj(obj, typ) ((obj) && (obj)->otyp == (typ) && (obj)->cursed) @@ -190,7 +190,7 @@ stuck_in_wall(void) * 3.4.2: make an exception if polymorphed into a form which lacks * hands; that's a case where the ramifications override this doubt. */ -static int +staticfn int in_trouble(void) { struct obj *otmp; @@ -280,7 +280,7 @@ in_trouble(void) } /* select an item for TROUBLE_CURSED_ITEMS */ -static struct obj * +staticfn struct obj * worst_cursed_item(void) { struct obj *otmp; @@ -341,7 +341,7 @@ worst_cursed_item(void) return otmp; } -static void +staticfn void fix_curse_trouble(struct obj *otmp, const char *what) { if (!otmp) { @@ -365,7 +365,7 @@ fix_curse_trouble(struct obj *otmp, const char *what) update_inventory(); } -static void +staticfn void fix_worst_trouble(int trouble) { int i; @@ -601,7 +601,7 @@ fix_worst_trouble(int trouble) * bathroom walls, but who is foiled by bathrobes." --Bertrand Russell, 1943 * Divine wrath, dungeon walls, and armor follow the same principle. */ -static void +staticfn void god_zaps_you(aligntyp resp_god) { if (u.uswallow) { @@ -685,7 +685,7 @@ god_zaps_you(aligntyp resp_god) } } -static void +staticfn void fry_by_god(aligntyp resp_god, boolean via_disintegration) { You("%s!", !via_disintegration ? "fry to a crisp" @@ -695,7 +695,7 @@ fry_by_god(aligntyp resp_god, boolean via_disintegration) done(DIED); } -static void +staticfn void angrygods(aligntyp resp_god) { int maxanger, new_ublesscnt; @@ -776,7 +776,7 @@ angrygods(aligntyp resp_god) } /* helper to print "str appears at your feet", or appropriate */ -static void +staticfn void at_your_feet(const char *str) { if (Blind) @@ -793,7 +793,7 @@ at_your_feet(const char *str) } } -static void +staticfn void gcrownu(void) { struct obj *obj; @@ -986,7 +986,7 @@ gcrownu(void) return; } -static void +staticfn void give_spell(void) { struct obj *otmp; @@ -1057,7 +1057,7 @@ give_spell(void) return; } -static void +staticfn void pleased(aligntyp g_align) { /* don't use p_trouble, worst trouble may get fixed while praying */ @@ -1365,7 +1365,7 @@ pleased(aligntyp g_align) /* either blesses or curses water on the altar, * returns true if it found any water here. */ -static boolean +staticfn boolean water_prayer(boolean bless_water) { struct obj *otmp; @@ -1393,7 +1393,7 @@ water_prayer(boolean bless_water) return (boolean) (changed > 0L); } -static void +staticfn void godvoice(aligntyp g_align, const char *words) { const char *quot = ""; @@ -1407,14 +1407,14 @@ godvoice(aligntyp g_align, const char *words) ROLL_FROM(godvoices), quot, words, quot); } -static void +staticfn void gods_angry(aligntyp g_align) { godvoice(g_align, "Thou hast angered me."); } /* The g_align god is upset with you. */ -static void +staticfn void gods_upset(aligntyp g_align) { if (g_align == u.ualign.type) @@ -1424,7 +1424,7 @@ gods_upset(aligntyp g_align) angrygods(g_align); } -static void +staticfn void consume_offering(struct obj *otmp) { if (Hallucination) @@ -1458,7 +1458,7 @@ consume_offering(struct obj *otmp) /* feedback when attempting to offer the Amulet on a "low altar" (not one of the high altars in the temples on the Astral Plane or Moloch's Sanctum) */ -static void +staticfn void offer_too_soon(aligntyp altaralign) { if (altaralign == A_NONE && Inhell) { @@ -1507,7 +1507,7 @@ desecrate_altar(boolean highaltar, aligntyp altaralign) /* offering the Amulet on a high altar (checked by caller) ends the game; we don't declare this 'NORETURN' because done() can return (if called with some reasons other than ASCENDED and ESCAPED) */ -static void +staticfn void offer_real_amulet(struct obj *otmp, aligntyp altaralign) { static NEARDATA const char @@ -1570,7 +1570,7 @@ offer_real_amulet(struct obj *otmp, aligntyp altaralign) /*NOTREACHED*/ } -static void +staticfn void offer_fake_amulet( struct obj *otmp, boolean highaltar, @@ -1604,7 +1604,7 @@ offer_fake_amulet( } /* possibly convert an altar's alignment or the hero's alignment */ -static void +staticfn void offer_different_alignment_altar( struct obj *otmp, aligntyp altaralign) @@ -1671,7 +1671,7 @@ offer_different_alignment_altar( } } -static void +staticfn void sacrifice_your_race( struct obj *otmp, boolean highaltar, @@ -1754,7 +1754,7 @@ sacrifice_your_race( useupf(otmp, 1L); } -static int +staticfn int bestow_artifact(void) { int nartifacts = nartifact_exist(); @@ -2090,7 +2090,7 @@ can_pray(boolean praying) /* false means no messages should be given */ } /* return TRUE if praying revived a pet corpse */ -static boolean +staticfn boolean pray_revive(void) { struct obj *otmp; @@ -2183,7 +2183,7 @@ dopray(void) return ECMD_TIME; } -static int +staticfn int prayer_done(void) /* M. Stephenson (1.0.3b) */ { aligntyp alignment = gp.p_aligntyp; @@ -2254,7 +2254,7 @@ prayer_done(void) /* M. Stephenson (1.0.3b) */ } /* iterable for undead turning by priest/knight */ -static void +staticfn void maybe_turn_mon_iter(struct monst *mtmp) { /* 3.6.3: used to use cansee() here but the purpose is to prevent @@ -2578,7 +2578,7 @@ altar_wrath(coordxy x, coordxy y) } /* assumes isok() at one space away, but not necessarily at two */ -static boolean +staticfn boolean blocked_boulder(int dx, int dy) { struct obj *otmp; diff --git a/src/priest.c b/src/priest.c index 57969b5f8..108bf11a4 100644 --- a/src/priest.c +++ b/src/priest.c @@ -9,8 +9,8 @@ #define ALGN_SINNED (-4) /* worse than strayed (-1..-3) */ #define ALGN_PIOUS 14 /* better than fervent (9..13) */ -static boolean histemple_at(struct monst *, coordxy, coordxy); -static boolean has_shrine(struct monst *); +staticfn boolean histemple_at(struct monst *, coordxy, coordxy); +staticfn boolean has_shrine(struct monst *); void newepri(struct monst *mtmp) @@ -148,7 +148,7 @@ temple_occupied(char *array) return '\0'; } -static boolean +staticfn boolean histemple_at(struct monst *priest, coordxy x, coordxy y) { return (boolean) (priest && priest->ispriest @@ -377,7 +377,7 @@ p_coaligned(struct monst *priest) return (boolean) (u.ualign.type == mon_aligntyp(priest)); } -static boolean +staticfn boolean has_shrine(struct monst *pri) { struct rm *lev; diff --git a/src/quest.c b/src/quest.c index 9e12604c0..e2c363903 100644 --- a/src/quest.c +++ b/src/quest.c @@ -11,18 +11,18 @@ #define Not_firsttime (on_level(&u.uz0, &u.uz)) #define Qstat(x) (gq.quest_status.x) -static void on_start(void); -static void on_locate(void); -static void on_goal(void); -static boolean not_capable(void); -static int is_pure(boolean); -static void expulsion(boolean); -static void chat_with_leader(struct monst *); -static void chat_with_nemesis(void); -static void chat_with_guardian(void); -static void prisoner_speaks(struct monst *); +staticfn void on_start(void); +staticfn void on_locate(void); +staticfn void on_goal(void); +staticfn boolean not_capable(void); +staticfn int is_pure(boolean); +staticfn void expulsion(boolean); +staticfn void chat_with_leader(struct monst *); +staticfn void chat_with_nemesis(void); +staticfn void chat_with_guardian(void); +staticfn void prisoner_speaks(struct monst *); -static void +staticfn void on_start(void) { if (!Qstat(first_start)) { @@ -36,7 +36,7 @@ on_start(void) } } -static void +staticfn void on_locate(void) { /* the locate messages are phrased in a manner such that they only @@ -58,7 +58,7 @@ on_locate(void) } } -static void +staticfn void on_goal(void) { if (Qstat(killed_nemesis)) { @@ -143,13 +143,13 @@ ok_to_quest(void) && is_pure(FALSE) > 0) || Qstat(killed_leader)); } -static boolean +staticfn boolean not_capable(void) { return (boolean) (u.ulevel < MIN_QUEST_LEVEL); } -static int +staticfn int is_pure(boolean talk) { int purity; @@ -182,7 +182,7 @@ is_pure(boolean talk) * This assumes that the hero is currently _in_ the quest dungeon and that * there is a single branch to and from it. */ -static void +staticfn void expulsion(boolean seal) { branch *br; @@ -278,7 +278,7 @@ finish_quest(struct obj *obj) /* quest artifact or thrown unique item or faux } } -static void +staticfn void chat_with_leader(struct monst *mtmp) { if (!mtmp->mpeaceful || Qstat(pissed_off)) @@ -376,7 +376,7 @@ leader_speaks(struct monst *mtmp) chat_with_leader(mtmp); } -static void +staticfn void chat_with_nemesis(void) { /* The nemesis will do most of the talking, but... */ @@ -423,7 +423,7 @@ nemesis_stinks(coordxy mx, coordxy my) gc.context.mon_moving = save_mon_moving; } -static void +staticfn void chat_with_guardian(void) { /* These guys/gals really don't have much to say... */ @@ -433,7 +433,7 @@ chat_with_guardian(void) qt_pager("guardtalk_before"); } -static void +staticfn void prisoner_speaks(struct monst *mtmp) { if (mtmp->data == &mons[PM_PRISONER] diff --git a/src/questpgr.c b/src/questpgr.c index 7831733d2..bacfbc01d 100644 --- a/src/questpgr.c +++ b/src/questpgr.c @@ -13,19 +13,19 @@ #include "wintty.h" #endif -static const char *intermed(void); +staticfn const char *intermed(void); /* sometimes find_qarti(gi.invent), and gi.invent can be null */ -static struct obj *find_qarti(struct obj *) NO_NNARGS; -static const char *neminame(void); -static const char *guardname(void); -static const char *homebase(void); -static void qtext_pronoun(char, char); -static void convert_arg(char); -static void convert_line(char *,char *); -static void deliver_by_pline(const char *); -static void deliver_by_window(const char *, int); -static boolean skip_pager(boolean); -static boolean com_pager_core(const char *, const char *, boolean, char **); +staticfn struct obj *find_qarti(struct obj *) NO_NNARGS; +staticfn const char *neminame(void); +staticfn const char *guardname(void); +staticfn const char *homebase(void); +staticfn void qtext_pronoun(char, char); +staticfn void convert_arg(char); +staticfn void convert_line(char *,char *); +staticfn void deliver_by_pline(const char *); +staticfn void deliver_by_window(const char *, int); +staticfn boolean skip_pager(boolean); +staticfn boolean com_pager_core(const char *, const char *, boolean, char **); short quest_info(int typ) @@ -57,7 +57,7 @@ ldrname(void) } /* return your intermediate target string */ -static const char * +staticfn const char * intermed(void) { return gu.urole.intermed; @@ -69,7 +69,7 @@ is_quest_artifact(struct obj *otmp) return (boolean) (otmp->oartifact == gu.urole.questarti); } -static struct obj * +staticfn struct obj * find_qarti(struct obj *ochain) { struct obj *otmp, *qarti; @@ -120,7 +120,7 @@ find_quest_artifact(unsigned whichchains) } /* return your role nemesis' name */ -static const char * +staticfn const char * neminame(void) { int i = gu.urole.neminum; @@ -130,7 +130,7 @@ neminame(void) return gn.nambuf; } -static const char * +staticfn const char * guardname(void) /* return your role leader's guard monster name */ { int i = gu.urole.guardnum; @@ -138,7 +138,7 @@ guardname(void) /* return your role leader's guard monster name */ return mons[i].pmnames[NEUTRAL]; } -static const char * +staticfn const char * homebase(void) /* return your role leader's location */ { return gu.urole.homebase; @@ -195,7 +195,7 @@ stinky_nemesis(struct monst *mon) /* replace deity, leader, nemesis, or artifact name with pronoun; overwrites cvt_buf[] */ -static void +staticfn void qtext_pronoun( char who, /* 'd' => deity, 'l' => leader, 'n' => nemesis, 'o' => arti */ char which) /* 'h'|'H'|'i'|'I'|'j'|'J' */ @@ -232,7 +232,7 @@ qtext_pronoun( return; } -static void +staticfn void convert_arg(char c) { const char *str; @@ -324,7 +324,7 @@ convert_arg(char c) Strcpy(gc.cvt_buf, str); } -static void +staticfn void convert_line(char *in_line, char *out_line) { char *c, *cc; @@ -416,7 +416,7 @@ convert_line(char *in_line, char *out_line) return; } -static void +staticfn void deliver_by_pline(const char *str) { char in_line[BUFSZ], out_line[BUFSZ]; @@ -432,7 +432,7 @@ deliver_by_pline(const char *str) } } -static void +staticfn void deliver_by_window(const char *msg, int how) { char in_line[BUFSZ], out_line[BUFSZ]; @@ -452,7 +452,7 @@ deliver_by_window(const char *msg, int how) destroy_nhwindow(datawin); } -static boolean +staticfn boolean skip_pager(boolean common UNUSED) { /* WIZKIT: suppress plot feedback if starting with quest artifact */ @@ -461,7 +461,7 @@ skip_pager(boolean common UNUSED) return FALSE; } -static boolean +staticfn boolean com_pager_core( const char *section, const char *msgid, diff --git a/src/read.c b/src/read.c index 127e0edac..c2bbc5b41 100644 --- a/src/read.c +++ b/src/read.c @@ -8,51 +8,51 @@ #define Your_Own_Role(mndx) ((mndx) == gu.urole.mnum) #define Your_Own_Race(mndx) ((mndx) == gu.urace.mnum) -static boolean learnscrolltyp(short); -static void cap_spe(struct obj *); -static char *erode_obj_text(struct obj *, char *); -static char *hawaiian_design(struct obj *, char *); -static int read_ok(struct obj *); -static void stripspe(struct obj *); -static void p_glow1(struct obj *); -static void p_glow2(struct obj *, const char *); -static void forget(int); -static int maybe_tame(struct monst *, struct obj *); -static boolean can_center_cloud(coordxy, coordxy); -static void display_stinking_cloud_positions(boolean); -static void seffect_enchant_armor(struct obj **); -static void seffect_destroy_armor(struct obj **); -static void seffect_confuse_monster(struct obj **); -static void seffect_scare_monster(struct obj **); -static void seffect_remove_curse(struct obj **); -static void seffect_create_monster(struct obj **); -static void seffect_enchant_weapon(struct obj **); -static void seffect_taming(struct obj **); -static void seffect_genocide(struct obj **); -static void seffect_light(struct obj **); -static void seffect_charging(struct obj **); -static void seffect_amnesia(struct obj **); -static void seffect_fire(struct obj **); -static void seffect_earth(struct obj **); -static void seffect_punishment(struct obj **); -static void seffect_stinking_cloud(struct obj **); -static void seffect_blank_paper(struct obj **); -static void seffect_teleportation(struct obj **); -static void seffect_gold_detection(struct obj **); -static void seffect_food_detection(struct obj **); -static void seffect_identify(struct obj **); -static void seffect_magic_mapping(struct obj **); +staticfn boolean learnscrolltyp(short); +staticfn void cap_spe(struct obj *); +staticfn char *erode_obj_text(struct obj *, char *); +staticfn char *hawaiian_design(struct obj *, char *); +staticfn int read_ok(struct obj *); +staticfn void stripspe(struct obj *); +staticfn void p_glow1(struct obj *); +staticfn void p_glow2(struct obj *, const char *); +staticfn void forget(int); +staticfn int maybe_tame(struct monst *, struct obj *); +staticfn boolean can_center_cloud(coordxy, coordxy); +staticfn void display_stinking_cloud_positions(boolean); +staticfn void seffect_enchant_armor(struct obj **); +staticfn void seffect_destroy_armor(struct obj **); +staticfn void seffect_confuse_monster(struct obj **); +staticfn void seffect_scare_monster(struct obj **); +staticfn void seffect_remove_curse(struct obj **); +staticfn void seffect_create_monster(struct obj **); +staticfn void seffect_enchant_weapon(struct obj **); +staticfn void seffect_taming(struct obj **); +staticfn void seffect_genocide(struct obj **); +staticfn void seffect_light(struct obj **); +staticfn void seffect_charging(struct obj **); +staticfn void seffect_amnesia(struct obj **); +staticfn void seffect_fire(struct obj **); +staticfn void seffect_earth(struct obj **); +staticfn void seffect_punishment(struct obj **); +staticfn void seffect_stinking_cloud(struct obj **); +staticfn void seffect_blank_paper(struct obj **); +staticfn void seffect_teleportation(struct obj **); +staticfn void seffect_gold_detection(struct obj **); +staticfn void seffect_food_detection(struct obj **); +staticfn void seffect_identify(struct obj **); +staticfn void seffect_magic_mapping(struct obj **); #ifdef MAIL_STRUCTURES -static void seffect_mail(struct obj **); +staticfn void seffect_mail(struct obj **); #endif /* MAIL_STRUCTURES */ -static void set_lit(coordxy, coordxy, genericptr); -static void do_class_genocide(void); -static void do_stinking_cloud(struct obj *, boolean); -static boolean create_particular_parse(char *, +staticfn void set_lit(coordxy, coordxy, genericptr); +staticfn void do_class_genocide(void); +staticfn void do_stinking_cloud(struct obj *, boolean); +staticfn boolean create_particular_parse(char *, struct _create_particular_data *); -static boolean create_particular_creation(struct _create_particular_data *); +staticfn boolean create_particular_creation(struct _create_particular_data *); -static boolean +staticfn boolean learnscrolltyp(short scrolltyp) { if (!objects[scrolltyp].oc_name_known) { @@ -74,7 +74,7 @@ learnscroll(struct obj *sobj) } /* max spe is +99, min is -99 */ -static void +staticfn void cap_spe(struct obj *obj) { if (obj) { @@ -83,7 +83,7 @@ cap_spe(struct obj *obj) } } -static char * +staticfn char * erode_obj_text(struct obj *otmp, char *buf) { int erosion = greatest_erosion(otmp); @@ -218,7 +218,7 @@ hawaiian_motif(struct obj *shirt, char *buf) return buf; } -static char * +staticfn char * hawaiian_design(struct obj *shirt, char *buf) { static const char *const hawaiian_bgs[] = { @@ -309,7 +309,7 @@ assign_candy_wrapper(struct obj *obj) } /* getobj callback for object to read */ -static int +staticfn int read_ok(struct obj *obj) { if (!obj) @@ -644,7 +644,7 @@ doread(void) RESTORE_WARNING_FORMAT_NONLITERAL -static void +staticfn void stripspe(struct obj *obj) { if (obj->blessed || obj->spe <= 0) { @@ -659,13 +659,13 @@ stripspe(struct obj *obj) } } -static void +staticfn void p_glow1(struct obj *otmp) { pline("%s briefly.", Yobjnam2(otmp, Blind ? "vibrate" : "glow")); } -static void +staticfn void p_glow2(struct obj *otmp, const char *color) { pline("%s%s%s for a moment.", Yobjnam2(otmp, Blind ? "vibrate" : "glow"), @@ -999,7 +999,7 @@ recharge(struct obj *obj, int curse_bless) * Other things are subject to flags: * howmuch & ALL_SPELLS = forget all spells */ -static void +staticfn void forget(int howmuch) { struct monst *mtmp; @@ -1023,7 +1023,7 @@ forget(int howmuch) } /* monster is hit by scroll of taming's effect */ -static int +staticfn int maybe_tame(struct monst *mtmp, struct obj *sobj) { int was_tame = mtmp->mtame; @@ -1058,7 +1058,7 @@ valid_cloud_pos(coordxy x, coordxy y) /* Callback for getpos_sethilite, also used in determining whether a scroll * should have its regular effects, or not because it was out of range. */ -static boolean +staticfn boolean can_center_cloud(coordxy x, coordxy y) { if (!valid_cloud_pos(x, y)) @@ -1066,7 +1066,7 @@ can_center_cloud(coordxy x, coordxy y) return (cansee(x, y) && distu(x, y) < 32); } -static void +staticfn void display_stinking_cloud_positions(boolean on_off) { coordxy x, y, dx, dy; @@ -1093,7 +1093,7 @@ display_stinking_cloud_positions(boolean on_off) } } -static void +staticfn void seffect_enchant_armor(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1243,7 +1243,7 @@ seffect_enchant_armor(struct obj **sobjp) Blind ? "again" : "unexpectedly"); } -static void +staticfn void seffect_destroy_armor(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1291,7 +1291,7 @@ seffect_destroy_armor(struct obj **sobjp) } } -static void +staticfn void seffect_confuse_monster(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1346,7 +1346,7 @@ seffect_confuse_monster(struct obj **sobjp) } } -static void +staticfn void seffect_scare_monster(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1381,7 +1381,7 @@ seffect_scare_monster(struct obj **sobjp) } } -static void +staticfn void seffect_remove_curse(struct obj **sobjp) { struct obj *sobj = *sobjp; /* scroll or fake spellbook */ @@ -1500,7 +1500,7 @@ seffect_remove_curse(struct obj **sobjp) update_inventory(); } -static void +staticfn void seffect_create_monster(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1519,7 +1519,7 @@ seffect_create_monster(struct obj **sobjp) */ } -static void +staticfn void seffect_enchant_weapon(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1569,7 +1569,7 @@ seffect_enchant_weapon(struct obj **sobjp) cap_spe(uwep); } -static void +staticfn void seffect_taming(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1612,7 +1612,7 @@ seffect_taming(struct obj **sobjp) } } -static void +staticfn void seffect_genocide(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1631,7 +1631,7 @@ seffect_genocide(struct obj **sobjp) do_genocide((!scursed) | (2 * !!Confusion)); } -static void +staticfn void seffect_light(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1678,7 +1678,7 @@ seffect_light(struct obj **sobjp) } } -static void +staticfn void seffect_charging(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1720,7 +1720,7 @@ seffect_charging(struct obj **sobjp) recharge(otmp, scursed ? -1 : sblessed ? 1 : 0); } -static void +staticfn void seffect_amnesia(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1740,7 +1740,7 @@ seffect_amnesia(struct obj **sobjp) exercise(A_WIS, FALSE); } -static void +staticfn void seffect_fire(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1809,7 +1809,7 @@ seffect_fire(struct obj **sobjp) #undef ZT_SPELL_O_FIRE } -static void +staticfn void seffect_earth(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1866,7 +1866,7 @@ seffect_earth(struct obj **sobjp) } } -static void +staticfn void seffect_punishment(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1881,7 +1881,7 @@ seffect_punishment(struct obj **sobjp) punish(sobj); } -static void +staticfn void seffect_stinking_cloud(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1895,7 +1895,7 @@ seffect_stinking_cloud(struct obj **sobjp) do_stinking_cloud(sobj, already_known); } -static void +staticfn void seffect_blank_paper(struct obj **sobjp UNUSED) { if (Blind) @@ -1905,7 +1905,7 @@ seffect_blank_paper(struct obj **sobjp UNUSED) gk.known = TRUE; } -static void +staticfn void seffect_teleportation(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1925,7 +1925,7 @@ seffect_teleportation(struct obj **sobjp) } } -static void +staticfn void seffect_gold_detection(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1936,7 +1936,7 @@ seffect_gold_detection(struct obj **sobjp) *sobjp = 0; /* failure: strange_feeling() -> useup() */ } -static void +staticfn void seffect_food_detection(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1945,7 +1945,7 @@ seffect_food_detection(struct obj **sobjp) *sobjp = 0; /* nothing detected: strange_feeling -> useup */ } -static void +staticfn void seffect_identify(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -1992,7 +1992,7 @@ seffect_identify(struct obj **sobjp) } } -static void +staticfn void seffect_magic_mapping(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -2044,7 +2044,7 @@ seffect_magic_mapping(struct obj **sobjp) } #ifdef MAIL_STRUCTURES -static void +staticfn void seffect_mail(struct obj **sobjp) { struct obj *sobj = *sobjp; @@ -2357,7 +2357,7 @@ static struct litmon *gremlins = 0; /* * Low-level lit-field update routine. */ -static void +staticfn void set_lit(coordxy x, coordxy y, genericptr_t val) { struct monst *mtmp; @@ -2513,7 +2513,7 @@ litroom( return; } -static void +staticfn void do_class_genocide(void) { int i, j, immunecnt, gonecnt, goodcnt, class, feel_dead = 0; @@ -2950,7 +2950,7 @@ unpunish(void) /* prompt the player to create a stinking cloud and then create it if they give a location */ -static void +staticfn void do_stinking_cloud(struct obj *sobj, boolean mention_stinking) { coord cc; @@ -3005,7 +3005,7 @@ cant_revive( return FALSE; } -static boolean +staticfn boolean create_particular_parse( char *str, struct _create_particular_data *d) @@ -3120,7 +3120,7 @@ create_particular_parse( return FALSE; } -static boolean +staticfn boolean create_particular_creation( struct _create_particular_data *d) { diff --git a/src/rect.c b/src/rect.c index e0009777d..801af1343 100644 --- a/src/rect.c +++ b/src/rect.c @@ -6,7 +6,7 @@ int get_rect_ind(NhRect *); -static boolean intersect(NhRect *, NhRect *, NhRect *); +staticfn boolean intersect(NhRect *, NhRect *, NhRect *); /* * In this file, we will handle the various rectangle functions we @@ -111,7 +111,7 @@ rnd_rect(void) * otherwise returns FALSE */ -static boolean +staticfn boolean intersect(NhRect *r1, NhRect *r2, NhRect *r3) { if (r2->lx > r1->hx || r2->ly > r1->hy || r2->hx < r1->lx diff --git a/src/region.c b/src/region.c index f7755181d..523fb38af 100644 --- a/src/region.c +++ b/src/region.c @@ -37,8 +37,8 @@ boolean enter_force_field(genericptr,genericptr); NhRegion *create_force_field(coordxy,coordxy,int,long); #endif -static void reset_region_mids(NhRegion *); -static boolean is_hero_inside_gas_cloud(void); +staticfn void reset_region_mids(NhRegion *); +staticfn boolean is_hero_inside_gas_cloud(void); static const callback_proc callbacks[] = { #define INSIDE_GAS_CLOUD 0 @@ -875,7 +875,7 @@ region_stats( RESTORE_WARNING_FORMAT_NONLITERAL /* update monster IDs for region being loaded from bones; `ghostly' implied */ -static void +staticfn void reset_region_mids(NhRegion *reg) { int i = 0, n = reg->n_monst; @@ -1109,7 +1109,7 @@ inside_gas_cloud(genericptr_t p1, genericptr_t p2) return FALSE; /* Monster is still alive */ } -static boolean +staticfn boolean is_hero_inside_gas_cloud(void) { int i; diff --git a/src/report.c b/src/report.c index 77a06fe82..4b6992216 100644 --- a/src/report.c +++ b/src/report.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 report.c $NHDT-Date: 1710949744 2024/03/20 15:49:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.7 $ */ +/* NetHack 3.7 report.c $NHDT-Date: 1710525914 2024/03/15 18:05:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.7 $ */ /* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2024 */ /* NetHack may be freely redistributed. See license for details. */ @@ -219,7 +219,7 @@ crashreport_bidshow(void) mark = uend; \ if (utmp >= urem) \ goto full; \ - strncpy(uend, str, utmp); \ + memcpy(uend, str, utmp); \ uend += utmp; urem -= utmp; \ *uend = '\0'; diff --git a/src/restore.c b/src/restore.c index b74473062..c4e136c98 100644 --- a/src/restore.c +++ b/src/restore.c @@ -12,30 +12,30 @@ extern int dotrow; /* shared with save */ #endif #ifdef ZEROCOMP -static void zerocomp_minit(void); -static void zerocomp_mread(int, genericptr_t, unsigned int); -static int zerocomp_mgetc(void); +staticfn void zerocomp_minit(void); +staticfn void zerocomp_mread(int, genericptr_t, unsigned int); +staticfn int zerocomp_mgetc(void); #endif -static void find_lev_obj(void); -static void restlevchn(NHFILE *); -static void restdamage(NHFILE *); -static void restobj(NHFILE *, struct obj *); -static struct obj *restobjchn(NHFILE *, boolean); -static void restmon(NHFILE *, struct monst *); -static struct monst *restmonchn(NHFILE *); -static struct fruit *loadfruitchn(NHFILE *); -static void freefruitchn(struct fruit *); -static void ghostfruit(struct obj *); -static boolean restgamestate(NHFILE *); -static void restlevelstate(void); -static int restlevelfile(xint8); -static void rest_bubbles(NHFILE *); -static void restore_gamelog(NHFILE *); -static void restore_msghistory(NHFILE *); -static void reset_oattached_mids(boolean); -static void rest_levl(NHFILE *, boolean); -static void rest_stairs(NHFILE *); +staticfn void find_lev_obj(void); +staticfn void restlevchn(NHFILE *); +staticfn void restdamage(NHFILE *); +staticfn void restobj(NHFILE *, struct obj *); +staticfn struct obj *restobjchn(NHFILE *, boolean); +staticfn void restmon(NHFILE *, struct monst *); +staticfn struct monst *restmonchn(NHFILE *); +staticfn struct fruit *loadfruitchn(NHFILE *); +staticfn void freefruitchn(struct fruit *); +staticfn void ghostfruit(struct obj *); +staticfn boolean restgamestate(NHFILE *); +staticfn void restlevelstate(void); +staticfn int restlevelfile(xint8); +staticfn void rest_bubbles(NHFILE *); +staticfn void restore_gamelog(NHFILE *); +staticfn void restore_msghistory(NHFILE *); +staticfn void reset_oattached_mids(boolean); +staticfn void rest_levl(NHFILE *, boolean); +staticfn void rest_stairs(NHFILE *); /* * Save a mapping of IDs from ghost levels to the current level. This @@ -50,8 +50,8 @@ struct bucket { } map[N_PER_BUCKET]; }; -static void clear_id_mapping(void); -static void add_id_mapping(unsigned, unsigned); +staticfn void clear_id_mapping(void); +staticfn void add_id_mapping(unsigned, unsigned); #ifdef AMII_GRAPHICS void amii_setpens(int); /* use colors from save file */ @@ -68,7 +68,7 @@ extern int amii_numcolors; #define Mread(fd,adr,siz) mread((fd), (genericptr_t) (adr), (unsigned) (siz)) /* Recalculate gl.level.objects[x][y], since this info was not saved. */ -static void +staticfn void find_lev_obj(void) { struct obj *fobjtmp = (struct obj *) 0; @@ -125,7 +125,7 @@ inven_inuse(boolean quietly) } } -static void +staticfn void restlevchn(NHFILE *nhfp) { int cnt = 0; @@ -151,7 +151,7 @@ restlevchn(NHFILE *nhfp) } } -static void +staticfn void restdamage(NHFILE *nhfp) { unsigned int dmgcount = 0; @@ -179,7 +179,7 @@ restdamage(NHFILE *nhfp) } /* restore one object */ -static void +staticfn void restobj(NHFILE *nhfp, struct obj *otmp) { int buflen = 0; @@ -234,7 +234,7 @@ restobj(NHFILE *nhfp, struct obj *otmp) } } -static struct obj * +staticfn struct obj * restobjchn(NHFILE *nhfp, boolean frozen) { struct obj *otmp, *otmp2 = 0; @@ -303,7 +303,7 @@ restobjchn(NHFILE *nhfp, boolean frozen) } /* restore one monster */ -static void +staticfn void restmon(NHFILE *nhfp, struct monst *mtmp) { int buflen = 0; @@ -373,7 +373,7 @@ restmon(NHFILE *nhfp, struct monst *mtmp) } /* mextra */ } -static struct monst * +staticfn struct monst * restmonchn(NHFILE *nhfp) { struct monst *mtmp, *mtmp2 = 0; @@ -451,7 +451,7 @@ restmonchn(NHFILE *nhfp) return first; } -static struct fruit * +staticfn struct fruit * loadfruitchn(NHFILE *nhfp) { struct fruit *flist, *fnext; @@ -471,7 +471,7 @@ loadfruitchn(NHFILE *nhfp) return flist; } -static void +staticfn void freefruitchn(struct fruit *flist) { struct fruit *fnext; @@ -483,7 +483,7 @@ freefruitchn(struct fruit *flist) } } -static void +staticfn void ghostfruit(struct obj *otmp) { struct fruit *oldf; @@ -504,8 +504,7 @@ ghostfruit(struct obj *otmp) #define SYSOPT_CHECK_SAVE_UID TRUE #endif -static -boolean +staticfn boolean restgamestate(NHFILE *nhfp) { struct flag newgameflags; @@ -700,7 +699,7 @@ restgamestate(NHFILE *nhfp) /* update game state pointers to those valid for the current level (so we don't dereference a wild u.ustuck when saving game state, for instance) */ -static void +staticfn void restlevelstate(void) { /* @@ -711,7 +710,7 @@ restlevelstate(void) } /*ARGSUSED*/ -static int +staticfn int restlevelfile(xint8 ltmp) { char whynot[BUFSZ]; @@ -882,7 +881,7 @@ dorecover(NHFILE *nhfp) return 1; } -static void +staticfn void rest_stairs(NHFILE *nhfp) { int buflen = 0; @@ -937,7 +936,7 @@ restcemetery(NHFILE *nhfp, struct cemetery **cemeteryaddr) } /*ARGSUSED*/ -static void +staticfn void rest_levl( NHFILE *nhfp, #ifdef RLECOMP @@ -1249,7 +1248,7 @@ get_plname_from_file(NHFILE *nhfp, char *plbuf) } /* restore Plane of Water's air bubbles and Plane of Air's clouds */ -static void +staticfn void rest_bubbles(NHFILE *nhfp) { xint8 bbubbly; @@ -1265,7 +1264,7 @@ rest_bubbles(NHFILE *nhfp) restore_waterlevel(nhfp); } -static void +staticfn void restore_gamelog(NHFILE *nhfp) { int slen = 0; @@ -1288,7 +1287,7 @@ restore_gamelog(NHFILE *nhfp) } } -static void +staticfn void restore_msghistory(NHFILE *nhfp) { int msgsize = 0, msgcount = 0; @@ -1313,7 +1312,7 @@ restore_msghistory(NHFILE *nhfp) } /* Clear all structures for object and monster ID mapping. */ -static void +staticfn void clear_id_mapping(void) { struct bucket *curr; @@ -1326,7 +1325,7 @@ clear_id_mapping(void) } /* Add a mapping to the ID map. */ -static void +staticfn void add_id_mapping(unsigned int gid, unsigned int nid) { int idx; @@ -1376,7 +1375,7 @@ lookup_id_mapping(unsigned int gid, unsigned int *nidp) return FALSE; } -static void +staticfn void reset_oattached_mids(boolean ghostly) { struct obj *otmp; diff --git a/src/rip.c b/src/rip.c index 6cd352f3e..dc237d4b2 100644 --- a/src/rip.c +++ b/src/rip.c @@ -19,7 +19,7 @@ #endif #ifdef TEXT_TOMBSTONE -static void center(int, char *); +staticfn void center(int, char *); #ifndef NH320_DEDICATION /* A normal tombstone for end of game display. */ @@ -70,7 +70,7 @@ static const char *const rip_txt[] = { #define DEATH_LINE 8 /* *char[] line # for death description */ #define YEAR_LINE 12 /* *char[] line # for year */ -static void +staticfn void center(int line, char *text) { char *ip, *op; diff --git a/src/rnd.c b/src/rnd.c index 6c9854c0b..beb4992ed 100644 --- a/src/rnd.c +++ b/src/rnd.c @@ -7,8 +7,9 @@ #ifdef USE_ISAAC64 #include "isaac64.h" -static int whichrng(int (*fn)(int)); -static int RND(int); +staticfn int whichrng(int (*fn)(int)); +staticfn int RND(int); +staticfn void set_random(unsigned long, int (*)(int)); #if 0 static isaac64_ctx rng_state; @@ -27,7 +28,7 @@ static struct rnglist_t rnglist[] = { { rn2_on_display_rng, FALSE, { 0 } }, /* DISP */ }; -static int +staticfn int whichrng(int (*fn)(int)) { int i; @@ -56,7 +57,7 @@ init_isaac64(unsigned long seed, int (*fn)(int)) (int) sizeof seed); } -static int +staticfn int RND(int x) { return (isaac64_next_uint64(&rnglist[CORE].rng_state) % x); @@ -230,7 +231,7 @@ rnz(int i) /* Sets the seed for the random number generator */ #ifdef USE_ISAAC64 -static void +staticfn void set_random(unsigned long seed, int (*fn)(int)) { @@ -240,7 +241,7 @@ set_random(unsigned long seed, #else /* USE_ISAAC64 */ /*ARGSUSED*/ -static void +staticfn void set_random(unsigned long seed, int (*fn)(int) UNUSED) { diff --git a/src/role.c b/src/role.c index ec03a8b03..608086965 100644 --- a/src/role.c +++ b/src/role.c @@ -696,10 +696,10 @@ const struct Align aligns[] = { { "evil", "unaligned", "Una", 0, A_NONE } }; -static int randrole_filtered(void); -static char *promptsep(char *, int); -static int role_gendercount(int); -static int race_alignmentcount(int); +staticfn int randrole_filtered(void); +staticfn char *promptsep(char *, int); +staticfn int role_gendercount(int); +staticfn int race_alignmentcount(int); /* used by str2XXX() */ static char NEARDATA randomstr[] = "random"; @@ -722,7 +722,7 @@ randrole(boolean for_display) return res; } -static int +staticfn int randrole_filtered(void) { int i, n = 0, set[SIZE(roles)]; @@ -1374,7 +1374,7 @@ clearrolefilter(int which) } } -static char * +staticfn char * promptsep(char *buf, int num_post_attribs) { const char *conjuct = "and "; @@ -1389,7 +1389,7 @@ promptsep(char *buf, int num_post_attribs) return buf; } -static int +staticfn int role_gendercount(int rolenum) { int gendcount = 0; @@ -1405,7 +1405,7 @@ role_gendercount(int rolenum) return gendcount; } -static int +staticfn int race_alignmentcount(int racenum) { int aligncount = 0; diff --git a/src/rumors.c b/src/rumors.c index 643a73968..82794b04b 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -41,14 +41,14 @@ * and placed there by 'makedefs'. */ -static void unpadline(char *); -static void init_rumors(dlb *); -static char *get_rnd_line(dlb *, char *, unsigned, int (*)(int), +staticfn void unpadline(char *); +staticfn void init_rumors(dlb *); +staticfn char *get_rnd_line(dlb *, char *, unsigned, int (*)(int), long, long, unsigned); -static void init_oracles(dlb *); -static void others_check(const char *ftype, const char *, winid *); -static void couldnt_open_file(const char *); -static void init_CapMons(void); +staticfn void init_oracles(dlb *); +staticfn void others_check(const char *ftype, const char *, winid *); +staticfn void couldnt_open_file(const char *); +staticfn void init_CapMons(void); /* used by CapitalMon(); set up by init_CapMons(), released by free_CapMons(); there's no need for these to be put into 'struct instance_globals g' */ @@ -62,7 +62,7 @@ extern const char bogon_codes[]; /* from do_name.c */ /* makedefs pads short rumors, epitaphs, engravings, and hallucinatory monster names with trailing underscores; strip those off */ -static void +staticfn void unpadline(char *line) { char *p = eos(line); @@ -80,7 +80,7 @@ unpadline(char *line) DISABLE_WARNING_FORMAT_NONLITERAL -static void +staticfn void init_rumors(dlb *fp) { static const char rumors_header[] = "%d,%ld,%lx;%d,%ld,%lx;0,0,%lx\n"; @@ -303,7 +303,7 @@ rumor_check(void) DISABLE_WARNING_FORMAT_NONLITERAL /* 3.7: augments rumors_check(); test 'engrave' or 'epitaph' or 'bogusmon' */ -static void +staticfn void others_check( const char *ftype, /* header: "{Engravings|Epitaphs|Bogus monsters}:" */ const char *fname, /* filename: {ENGRAVEFILE|EPITAPHFILE|BOGUSMONFILE} */ @@ -415,7 +415,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL chosen; however, if padlength is 0, lines following long lines are more likely than average to be picked, and lines after short lines are less likely */ -static char * +staticfn char * get_rnd_line( dlb *fh, /* already opened file */ char *buf, /* output buffer */ @@ -571,7 +571,7 @@ outrumor( pline1(line); } -static void +staticfn void init_oracles(dlb *fp) { int i; @@ -760,7 +760,7 @@ doconsult(struct monst *oracl) return ECMD_TIME; } -static void +staticfn void couldnt_open_file(const char *filename) { int save_something = gp.program_state.something_worth_saving; @@ -819,7 +819,7 @@ CapitalMon( having a capitalized type name like Green-elf or Archon, plus unique monsters whose "name" is a title rather than a personal name, plus hallucinatory monster names that fall into either of those categories */ -static void +staticfn void init_CapMons(void) { unsigned pass; diff --git a/src/save.c b/src/save.c index 7c800b2f9..f5fe3e496 100644 --- a/src/save.c +++ b/src/save.c @@ -16,28 +16,28 @@ int dotcnt, dotrow; /* also used in restore */ #endif -static void savelevchn(NHFILE *); -static void savelevl(NHFILE *,boolean); -static void savedamage(NHFILE *); -static void save_bubbles(NHFILE *, xint8); -static void save_stairs(NHFILE *); -static void save_bc(NHFILE *); -static void saveobj(NHFILE *, struct obj *); -static void saveobjchn(NHFILE *, struct obj **) NO_NNARGS; -static void savemon(NHFILE *, struct monst *); -static void savemonchn(NHFILE *, struct monst *) NO_NNARGS; -static void savetrapchn(NHFILE *, struct trap *) NO_NNARGS; -static void save_gamelog(NHFILE *); -static void savegamestate(NHFILE *); -static void savelev_core(NHFILE *, xint8); -static void save_msghistory(NHFILE *); +staticfn void savelevchn(NHFILE *); +staticfn void savelevl(NHFILE *,boolean); +staticfn void savedamage(NHFILE *); +staticfn void save_bubbles(NHFILE *, xint8); +staticfn void save_stairs(NHFILE *); +staticfn void save_bc(NHFILE *); +staticfn void saveobj(NHFILE *, struct obj *); +staticfn void saveobjchn(NHFILE *, struct obj **) NO_NNARGS; +staticfn void savemon(NHFILE *, struct monst *); +staticfn void savemonchn(NHFILE *, struct monst *) NO_NNARGS; +staticfn void savetrapchn(NHFILE *, struct trap *) NO_NNARGS; +staticfn void save_gamelog(NHFILE *); +staticfn void savegamestate(NHFILE *); +staticfn void savelev_core(NHFILE *, xint8); +staticfn void save_msghistory(NHFILE *); #ifdef ZEROCOMP -static void zerocomp_bufon(int); -static void zerocomp_bufoff(int); -static void zerocomp_bflush(int); -static void zerocomp_bwrite(int, genericptr_t, unsigned int); -static void zerocomp_bputc(int); +staticfn void zerocomp_bufon(int); +staticfn void zerocomp_bufoff(int); +staticfn void zerocomp_bflush(int); +staticfn void zerocomp_bwrite(int, genericptr_t, unsigned int); +staticfn void zerocomp_bputc(int); #endif #if defined(HANGUPHANDLING) @@ -238,7 +238,7 @@ dosave0(void) return res; } -static void +staticfn void save_gamelog(NHFILE *nhfp) { struct gamelog_line *tmp = gg.gamelog, *tmp2; @@ -271,7 +271,7 @@ save_gamelog(NHFILE *nhfp) gg.gamelog = NULL; } -static void +staticfn void savegamestate(NHFILE *nhfp) { unsigned long uid; @@ -462,7 +462,7 @@ savelev(NHFILE *nhfp, xint8 lev) gu.uz_save.dnum = gu.uz_save.dlevel = 0; /* unset */ } -static void +staticfn void savelev_core(NHFILE *nhfp, xint8 lev) { #ifdef TOS @@ -574,7 +574,7 @@ savelev_core(NHFILE *nhfp, xint8 lev) return; } -static void +staticfn void savelevl(NHFILE *nhfp, boolean rlecomp) { #ifdef RLECOMP @@ -635,7 +635,7 @@ savelevl(NHFILE *nhfp, boolean rlecomp) } /* save Plane of Water's air bubbles and Plane of Air's clouds */ -static void +staticfn void save_bubbles(NHFILE *nhfp, xint8 lev) { xint8 bbubbly; @@ -682,7 +682,7 @@ savecemetery(NHFILE *nhfp, struct cemetery **cemeteryaddr) *cemeteryaddr = 0; } -static void +staticfn void savedamage(NHFILE *nhfp) { struct damage *damageptr, *tmp_dam; @@ -709,7 +709,7 @@ savedamage(NHFILE *nhfp) gl.level.damagelist = 0; } -static void +staticfn void save_stairs(NHFILE *nhfp) { stairway *stway = gs.stairs; @@ -744,7 +744,7 @@ save_stairs(NHFILE *nhfp) /* if ball and/or chain are loose, make an object chain for it/them and save that separately from other objects */ -static void +staticfn void save_bc(NHFILE *nhfp) { struct obj *bc_objs = 0; @@ -774,7 +774,7 @@ save_bc(NHFILE *nhfp) /* save one object; caveat: this is only for perform_bwrite(); caller handles release_data() */ -static void +staticfn void saveobj(NHFILE *nhfp, struct obj *otmp) { int buflen, zerobuf = 0; @@ -818,7 +818,7 @@ saveobj(NHFILE *nhfp, struct obj *otmp) /* save an object chain; sets head of list to Null when done; handles release_data() for each object in the list */ -static void +staticfn void saveobjchn(NHFILE *nhfp, struct obj **obj_p) { struct obj *otmp = *obj_p; @@ -881,7 +881,7 @@ saveobjchn(NHFILE *nhfp, struct obj **obj_p) } } -static void +staticfn void savemon(NHFILE *nhfp, struct monst *mtmp) { int buflen; @@ -944,7 +944,7 @@ savemon(NHFILE *nhfp, struct monst *mtmp) } } -static void +staticfn void savemonchn(NHFILE *nhfp, struct monst *mtmp) { struct monst *mtmp2; @@ -981,7 +981,7 @@ savemonchn(NHFILE *nhfp, struct monst *mtmp) } /* save traps; gf.ftrap is the only trap chain so the 2nd arg is superfluous */ -static void +staticfn void savetrapchn(NHFILE *nhfp, struct trap *trap) { static struct trap zerotrap; @@ -1039,7 +1039,7 @@ savefruitchn(NHFILE *nhfp) gf.ffruit = 0; } -static void +staticfn void savelevchn(NHFILE *nhfp) { s_level *tmplev, *tmplev2; @@ -1079,7 +1079,7 @@ store_plname_in_file(NHFILE *nhfp) return; } -static void +staticfn void save_msghistory(NHFILE *nhfp) { char *msg; diff --git a/src/selvar.c b/src/selvar.c index eeacabf42..a746be28b 100644 --- a/src/selvar.c +++ b/src/selvar.c @@ -6,8 +6,9 @@ #include "selvar.h" #include "sp_lev.h" -static boolean sel_flood_havepoint(coordxy, coordxy, coordxy *, coordxy *, int); -static long line_dist_coord(long, long, long, long, long, long); +staticfn boolean sel_flood_havepoint(coordxy, coordxy, coordxy *, coordxy *, + int); +staticfn long line_dist_coord(long, long, long, long, long, long); /* selection */ struct selectionvar * @@ -358,7 +359,7 @@ selection_do_grow(struct selectionvar *ov, int dir) selection_free(tmp, TRUE); } -static int (*selection_flood_check_func)(coordxy, coordxy); +staticfn int (*selection_flood_check_func)(coordxy, coordxy); void set_selection_floodfillchk(int (*f)(coordxy, coordxy)) @@ -367,7 +368,7 @@ set_selection_floodfillchk(int (*f)(coordxy, coordxy)) } /* check whethere is already in xs[],ys[] */ -static boolean +staticfn boolean sel_flood_havepoint( coordxy x, coordxy y, coordxy xs[], coordxy ys[], @@ -530,7 +531,7 @@ selection_do_ellipse( } /* square of distance from line segment (x1,y1, x2,y2) to point (x3,y3) */ -static long +staticfn long line_dist_coord(long x1, long y1, long x2, long y2, long x3, long y3) { long px = x2 - x1; diff --git a/src/sfstruct.c b/src/sfstruct.c index 78fc6e694..5d84583bd 100644 --- a/src/sfstruct.c +++ b/src/sfstruct.c @@ -10,7 +10,7 @@ * These were moved here from save.c and restore.c between 3.6.3 and 3.7.0. */ -static int getidx(int, int); +staticfn int getidx(int, int); #if defined(UNIX) || defined(WIN32) #define USE_BUFFERING @@ -66,7 +66,7 @@ static FILE *bw_FILE[MAXFD] = {0,0,0,0,0}; * happen. */ -static int +staticfn int getidx(int fd, int flg) { int i, retval = -1; diff --git a/src/shk.c b/src/shk.c index 086024113..25fd6ebf4 100644 --- a/src/shk.c +++ b/src/shk.c @@ -11,9 +11,9 @@ #define PAY_SKIP (-1) #define PAY_BROKE (-2) -static void makekops(coord *); -static void call_kops(struct monst *, boolean); -static void kops_gone(boolean); +staticfn void makekops(coord *); +staticfn void call_kops(struct monst *, boolean); +staticfn void kops_gone(boolean); #define NOTANGRY(mon) ((mon)->mpeaceful) #define ANGRY(mon) (!NOTANGRY(mon)) @@ -26,61 +26,61 @@ extern const struct shclass shtypes[]; /* defined in shknam.c */ static const char and_its_contents[] = " and its contents"; static const char the_contents_of[] = "the contents of "; -static void append_honorific(char *); -static long addupbill(struct monst *); -static void pacify_shk(struct monst *, boolean); -static struct bill_x *onbill(struct obj *, struct monst *, boolean); -static struct monst *next_shkp(struct monst *, boolean); -static long shop_debt(struct eshk *); -static char *shk_owns(char *, struct obj *); -static char *mon_owns(char *, struct obj *); -static void clear_unpaid_obj(struct monst *, struct obj *); -static void clear_unpaid(struct monst *, struct obj *); -static void clear_no_charge_obj(struct monst *, struct obj *); -static void clear_no_charge(struct monst *, struct obj *); -static long check_credit(long, struct monst *); -static void pay(long, struct monst *); -static long get_cost(struct obj *, struct monst *); -static long set_cost(struct obj *, struct monst *); -static const char *shk_embellish(struct obj *, long); -static long cost_per_charge(struct monst *, struct obj *, boolean); -static long cheapest_item(struct monst *); -static int menu_pick_pay_items(struct monst *); -static int dopayobj(struct monst *, struct bill_x *, struct obj **, int, +staticfn void append_honorific(char *); +staticfn long addupbill(struct monst *); +staticfn void pacify_shk(struct monst *, boolean); +staticfn struct bill_x *onbill(struct obj *, struct monst *, boolean); +staticfn struct monst *next_shkp(struct monst *, boolean); +staticfn long shop_debt(struct eshk *); +staticfn char *shk_owns(char *, struct obj *); +staticfn char *mon_owns(char *, struct obj *); +staticfn void clear_unpaid_obj(struct monst *, struct obj *); +staticfn void clear_unpaid(struct monst *, struct obj *); +staticfn void clear_no_charge_obj(struct monst *, struct obj *); +staticfn void clear_no_charge(struct monst *, struct obj *); +staticfn long check_credit(long, struct monst *); +staticfn void pay(long, struct monst *); +staticfn long get_cost(struct obj *, struct monst *); +staticfn long set_cost(struct obj *, struct monst *); +staticfn const char *shk_embellish(struct obj *, long); +staticfn long cost_per_charge(struct monst *, struct obj *, boolean); +staticfn long cheapest_item(struct monst *); +staticfn int menu_pick_pay_items(struct monst *); +staticfn int dopayobj(struct monst *, struct bill_x *, struct obj **, int, boolean); -static long stolen_container(struct obj *, struct monst *, long, boolean); -static long corpsenm_price_adj(struct obj *); -static long getprice(struct obj *, boolean); -static void shk_names_obj(struct monst *, struct obj *, const char *, long, +staticfn long stolen_container(struct obj *, struct monst *, long, boolean); +staticfn long corpsenm_price_adj(struct obj *); +staticfn long getprice(struct obj *, boolean); +staticfn void shk_names_obj(struct monst *, struct obj *, const char *, long, const char *); -static boolean inherits(struct monst *, int, int, boolean); -static void set_repo_loc(struct monst *); -static struct obj *bp_to_obj(struct bill_x *); -static long get_pricing_units(struct obj *); -static boolean angry_shk_exists(void); -static void home_shk(struct monst *, boolean); -static void rile_shk(struct monst *); -static void rouse_shk(struct monst *, boolean); -static boolean shk_impaired(struct monst *); -static boolean repairable_damage(struct damage *, struct monst *); -static struct damage *find_damage(struct monst *); -static void discard_damage_struct(struct damage *); -static void discard_damage_owned_by(struct monst *); -static void shk_fixes_damage(struct monst *); -static uint8 litter_getpos(uint8 *, coordxy, coordxy, struct monst *); -static void litter_scatter(uint8 *, coordxy, coordxy, struct monst *); -static void litter_newsyms(uint8 *, coordxy, coordxy); -static int repair_damage(struct monst *, struct damage *, boolean); -static void sub_one_frombill(struct obj *, struct monst *); -static void add_one_tobill(struct obj *, boolean, struct monst *); -static void dropped_container(struct obj *, struct monst *, boolean); -static void add_to_billobjs(struct obj *); -static void bill_box_content(struct obj *, boolean, boolean, +staticfn boolean inherits(struct monst *, int, int, boolean); +staticfn void set_repo_loc(struct monst *); +staticfn struct obj *bp_to_obj(struct bill_x *); +staticfn long get_pricing_units(struct obj *); +staticfn boolean angry_shk_exists(void); +staticfn void home_shk(struct monst *, boolean); +staticfn void rile_shk(struct monst *); +staticfn void rouse_shk(struct monst *, boolean); +staticfn boolean shk_impaired(struct monst *); +staticfn boolean repairable_damage(struct damage *, struct monst *); +staticfn struct damage *find_damage(struct monst *); +staticfn void discard_damage_struct(struct damage *); +staticfn void discard_damage_owned_by(struct monst *); +staticfn void shk_fixes_damage(struct monst *); +staticfn uint8 litter_getpos(uint8 *, coordxy, coordxy, struct monst *); +staticfn void litter_scatter(uint8 *, coordxy, coordxy, struct monst *); +staticfn void litter_newsyms(uint8 *, coordxy, coordxy); +staticfn int repair_damage(struct monst *, struct damage *, boolean); +staticfn void sub_one_frombill(struct obj *, struct monst *); +staticfn void add_one_tobill(struct obj *, boolean, struct monst *); +staticfn void dropped_container(struct obj *, struct monst *, boolean); +staticfn void add_to_billobjs(struct obj *); +staticfn void bill_box_content(struct obj *, boolean, boolean, struct monst *); -static boolean rob_shop(struct monst *); -static void deserted_shop(char *); -static boolean special_stock(struct obj *, struct monst *, boolean); -static const char *cad(boolean); +staticfn boolean rob_shop(struct monst *); +staticfn void deserted_shop(char *); +staticfn boolean special_stock(struct obj *, struct monst *, boolean); +staticfn const char *cad(boolean); /* invariants: obj->unpaid iff onbill(obj) [unless bp->useup] @@ -162,7 +162,7 @@ money2u(struct monst *mon, long amount) } } -static struct monst * +staticfn struct monst * next_shkp(struct monst *shkp, boolean withbill) { for (; shkp; shkp = shkp->nmon) { @@ -256,7 +256,7 @@ restshk(struct monst *shkp, boolean ghostly) } /* clear the unpaid bit on a single object and its contents */ -static void +staticfn void clear_unpaid_obj(struct monst *shkp, struct obj *otmp) { if (Has_contents(otmp)) @@ -266,7 +266,7 @@ clear_unpaid_obj(struct monst *shkp, struct obj *otmp) } /* clear the unpaid bit on all of the objects in the list */ -static void +staticfn void clear_unpaid(struct monst *shkp, struct obj *list) { while (list) { @@ -276,7 +276,7 @@ clear_unpaid(struct monst *shkp, struct obj *list) } /* clear the no_charge bit on a single object and its contents */ -static void +staticfn void clear_no_charge_obj( struct monst *shkp, /* if null, clear regardless of shop */ struct obj *otmp) @@ -324,7 +324,7 @@ clear_no_charge_obj( } /* clear the no_charge bit on all of the objects in the list */ -static void +staticfn void clear_no_charge(struct monst *shkp, struct obj *list) { while (list) { @@ -373,7 +373,7 @@ setpaid(struct monst *shkp) } } -static long +staticfn long addupbill(struct monst *shkp) { int ct = ESHK(shkp)->billct; @@ -387,7 +387,7 @@ addupbill(struct monst *shkp) return total; } -static void +staticfn void call_kops(struct monst *shkp, boolean nearshop) { /* Keystone Kops srt@ucla */ @@ -564,7 +564,7 @@ remote_burglary(coordxy x, coordxy y) /* shop merchandise has been taken; pay for it with any credit available; return false if the debt is fully covered by credit, true otherwise */ -static boolean +staticfn boolean rob_shop(struct monst *shkp) { struct eshk *eshkp; @@ -600,7 +600,7 @@ rob_shop(struct monst *shkp) } /* give a message when entering an untended shop (caller has verified that) */ -static void +staticfn void deserted_shop(/*const*/ char *enterstring) { struct monst *mtmp; @@ -867,7 +867,7 @@ same_price(struct obj *obj1, struct obj *obj2) * turning the `$' command into a way to discover that the current * level is bones data which has a shk on the warpath. */ -static long +staticfn long shop_debt(struct eshk *eshkp) { struct bill_x *bp; @@ -1003,7 +1003,7 @@ tended_shop(struct mkroom *sroom) return !mtmp ? FALSE : (boolean) inhishop(mtmp); } -static struct bill_x * +staticfn struct bill_x * onbill(struct obj *obj, struct monst *shkp, boolean silent) { if (shkp) { @@ -1150,7 +1150,7 @@ obfree(struct obj *obj, struct obj *merge) dealloc_obj(obj); } -static long +staticfn long check_credit(long tmp, struct monst *shkp) { long credit = ESHK(shkp)->credit; @@ -1169,7 +1169,7 @@ check_credit(long tmp, struct monst *shkp) return tmp; } -static void +staticfn void pay(long tmp, struct monst *shkp) { long robbed = ESHK(shkp)->robbed; @@ -1189,7 +1189,7 @@ pay(long tmp, struct monst *shkp) } /* return shkp to home position */ -static void +staticfn void home_shk(struct monst *shkp, boolean killkops) { coordxy x = ESHK(shkp)->shk.x, y = ESHK(shkp)->shk.y; @@ -1203,7 +1203,7 @@ home_shk(struct monst *shkp, boolean killkops) after_shk_move(shkp); } -static boolean +staticfn boolean angry_shk_exists(void) { struct monst *shkp; @@ -1216,7 +1216,7 @@ angry_shk_exists(void) } /* remove previously applied surcharge from all billed items */ -static void +staticfn void pacify_shk(struct monst *shkp, boolean clear_surcharge) { NOTANGRY(shkp) = TRUE; /* make peaceful */ @@ -1234,7 +1234,7 @@ pacify_shk(struct monst *shkp, boolean clear_surcharge) } /* add aggravation surcharge to all billed items */ -static void +staticfn void rile_shk(struct monst *shkp) { NOTANGRY(shkp) = FALSE; /* make angry */ @@ -1253,7 +1253,7 @@ rile_shk(struct monst *shkp) } /* wakeup and/or unparalyze shopkeeper */ -static void +staticfn void rouse_shk(struct monst *shkp, boolean verbosely) { if (helpless(shkp)) { @@ -1368,7 +1368,7 @@ static const char not_enough_money[] = "Besides, you don't have enough to interest %s."; /* delivers the cheapest item on the list */ -static long +staticfn long cheapest_item(struct monst *shkp) { int ct = ESHK(shkp)->billct; @@ -1385,7 +1385,7 @@ cheapest_item(struct monst *shkp) /* show items on your bill in a menu, and ask which to pay. returns the number of entries selected. */ -static int +staticfn int menu_pick_pay_items(struct monst *shkp) { struct eshk *eshkp = ESHK(shkp); @@ -1819,7 +1819,7 @@ dopay(void) * -1 if skip this object * -2 if no money/credit left */ -static int +staticfn int dopayobj( struct monst *shkp, struct bill_x *bp, @@ -2026,7 +2026,7 @@ paybill( when this returns True, it should call set_repo_loc() before returning; when it returns False, it should not do such because that might have already been called for some shopkeeper */ -static boolean +staticfn boolean inherits( struct monst *shkp, int numsk, @@ -2131,7 +2131,7 @@ inherits( return taken; } -static void +staticfn void set_repo_loc(struct monst *shkp) { coordxy ox, oy; @@ -2208,7 +2208,7 @@ finish_paybill(void) } /* find obj on one of the lists */ -static struct obj * +staticfn struct obj * bp_to_obj(struct bill_x *bp) { struct obj *obj; @@ -2295,7 +2295,7 @@ get_cost_of_shop_item( return cost; } -static long +staticfn long get_pricing_units(struct obj *obj) { long units = obj->quan; @@ -2326,7 +2326,7 @@ oid_price_adjustment(struct obj *obj, unsigned int oid) } /* calculate the value that the shk will charge for [one of] an object */ -static long +staticfn long get_cost( struct obj *obj, struct monst *shkp) /* if angry, impose a surcharge */ @@ -2506,7 +2506,7 @@ contained_gold( return value; } -static void +staticfn void dropped_container( struct obj *obj, struct monst *shkp, @@ -2545,7 +2545,7 @@ picked_container(struct obj *obj) } } -static boolean +staticfn boolean special_stock( struct obj *obj, struct monst *shkp, @@ -2590,7 +2590,7 @@ special_stock( } /* calculate how much the shk will pay when buying [all of] an object */ -static long +staticfn long set_cost(struct obj *obj, struct monst *shkp) { long tmp, unit_price = getprice(obj, TRUE), multiplier = 1L, divisor = 1L; @@ -2744,7 +2744,7 @@ unpaid_cost( return amt; } -static void +staticfn void add_one_tobill(struct obj *obj, boolean dummy, struct monst *shkp) { struct eshk *eshkp; @@ -2793,7 +2793,7 @@ add_one_tobill(struct obj *obj, boolean dummy, struct monst *shkp) obj->unpaid = 1; } -static void +staticfn void add_to_billobjs(struct obj *obj) { if (obj->where != OBJ_FREE) @@ -2814,7 +2814,7 @@ add_to_billobjs(struct obj *obj) } /* recursive billing of objects within containers. */ -static void +staticfn void bill_box_content( struct obj *obj, boolean ininv, @@ -2840,7 +2840,7 @@ bill_box_content( DISABLE_WARNING_FORMAT_NONLITERAL /* shopkeeper tells you what you bought or sold, sometimes partly IDing it */ -static void +staticfn void shk_names_obj( struct monst *shkp, struct obj *obj, @@ -3026,7 +3026,7 @@ addtobill( } } -static void +staticfn void append_honorific(char *buf) { /* (chooses among [0]..[3] normally; [1]..[4] after the @@ -3085,7 +3085,7 @@ splitbill(struct obj *obj, struct obj *otmp) } } -static void +staticfn void sub_one_frombill(struct obj *obj, struct monst *shkp) { struct bill_x *bp; @@ -3144,7 +3144,7 @@ subfrombill(struct obj *obj, struct monst *shkp) } } -static long +staticfn long stolen_container( struct obj *obj, struct monst *shkp, @@ -3700,7 +3700,7 @@ doinvbill( } /* adjust tin, egg, or corpse price based on monster data */ -static long +staticfn long corpsenm_price_adj(struct obj *obj) { long val = 0L; @@ -3744,7 +3744,7 @@ corpsenm_price_adj(struct obj *obj) return val; } -static long +staticfn long getprice(struct obj *obj, boolean shk_buying) { long tmp = (long) objects[obj->otyp].oc_cost; @@ -3866,7 +3866,7 @@ add_damage( } /* is shopkeeper impaired, so they cannot act? */ -static boolean +staticfn boolean shk_impaired(struct monst *shkp) { if (!shkp || !shkp->isshk || !inhishop(shkp)) @@ -3877,7 +3877,7 @@ shk_impaired(struct monst *shkp) } /* is damage dam repairable by shopkeeper shkp? */ -static boolean +staticfn boolean repairable_damage(struct damage *dam, struct monst *shkp) { coordxy x, y; @@ -3916,7 +3916,7 @@ repairable_damage(struct damage *dam, struct monst *shkp) } /* find any damage shopkeeper shkp could repair. returns NULL is none found */ -static struct damage * +staticfn struct damage * find_damage(struct monst *shkp) { struct damage *dam = gl.level.damagelist; @@ -3934,7 +3934,7 @@ find_damage(struct monst *shkp) return NULL; } -static void +staticfn void discard_damage_struct(struct damage *dam) { if (!dam) @@ -3955,7 +3955,7 @@ discard_damage_struct(struct damage *dam) } /* discard all damage structs owned by shopkeeper */ -static void +staticfn void discard_damage_owned_by(struct monst *shkp) { struct damage *dam = gl.level.damagelist, *dam2, *prevdam = NULL; @@ -3982,7 +3982,7 @@ discard_damage_owned_by(struct monst *shkp) } /* Shopkeeper tries to repair damage belonging to them */ -static void +staticfn void shk_fixes_damage(struct monst *shkp) { struct damage *dam = find_damage(shkp); @@ -4017,7 +4017,7 @@ shk_fixes_damage(struct monst *shkp) shop (possibly in the "free spot" or even in doorway or an adjacent wall gap), but if they are in a gap in a wall shared by two shops they might have started in the other shop */ -static uint8 +staticfn uint8 litter_getpos( uint8 *litter, /* array of 9 uint8's */ coordxy x, coordxy y, @@ -4048,7 +4048,7 @@ litter_getpos( litter[] guarantees that items will end up inside shkp's shop, but if the wall being repaired is shared by two shops the items might have started in the other shop */ -static void +staticfn void litter_scatter( uint8 *litter, coordxy x, coordxy y, @@ -4138,7 +4138,7 @@ litter_scatter( } } -static void +staticfn void litter_newsyms(uint8 *litter, coordxy x, coordxy y) { int i; @@ -4158,7 +4158,7 @@ litter_newsyms(uint8 *litter, coordxy x, coordxy y) * 0: repair postponed, 1: silent repair (no messages), 2: normal repair * 3: untrap */ -static int +staticfn int repair_damage( struct monst *shkp, struct damage *tmp_dam, @@ -4538,7 +4538,7 @@ shopdig(int fall) } } -static void +staticfn void makekops(coord *mm) { static const short k_mndx[4] = { PM_KEYSTONE_KOP, PM_KOP_SERGEANT, @@ -4882,7 +4882,7 @@ price_quote(struct obj *first_obj) destroy_nhwindow(tmpwin); } -static const char * +staticfn const char * shk_embellish(struct obj *itm, long cost) { if (!rn2(3)) { @@ -4923,7 +4923,7 @@ shk_embellish(struct obj *itm, long cost) DISABLE_WARNING_FORMAT_NONLITERAL /* First 4 supplied by Ronen and Tamar, remainder by development team */ -const char *Izchak_speaks[] = { +static const char *Izchak_speaks[] = { "%s says: 'These shopping malls give me a headache.'", "%s says: 'Slow down. Think clearly.'", "%s says: 'You need to take things one at a time.'", @@ -5020,7 +5020,7 @@ shk_chat(struct monst *shkp) RESTORE_WARNING_FORMAT_NONLITERAL -static void +staticfn void kops_gone(boolean silent) { int cnt = 0; @@ -5041,7 +5041,7 @@ kops_gone(boolean silent) plur(cnt), (cnt == 1) ? "es" : ""); } -static long +staticfn long cost_per_charge( struct monst *shkp, struct obj *otmp, @@ -5299,7 +5299,7 @@ Shk_Your(char *buf, struct obj *obj) return buf; } -static char * +staticfn char * shk_owns(char *buf, struct obj *obj) { struct monst *shkp; @@ -5314,7 +5314,7 @@ shk_owns(char *buf, struct obj *obj) return (char *) 0; } -static char * +staticfn char * mon_owns(char *buf, struct obj *obj) { if (obj->where == OBJ_MINVENT) @@ -5322,7 +5322,7 @@ mon_owns(char *buf, struct obj *obj) return (char *) 0; } -static const char * +staticfn const char * cad( boolean altusage) /* used as a verbalized exclamation: \"Cad! ...\" */ { diff --git a/src/shknam.c b/src/shknam.c index 6a4833942..10cfac363 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -7,14 +7,14 @@ #include "hack.h" -static boolean stock_room_goodpos(struct mkroom *, int, int, int, int); -static boolean veggy_item(struct obj * obj, int); -static int shkveg(void); -static void mkveggy_at(int, int); -static void mkshobj_at(const struct shclass *, int, int, boolean); -static void nameshk(struct monst *, const char *const *); -static int good_shopdoor(struct mkroom *, coordxy *, coordxy *); -static int shkinit(const struct shclass *, struct mkroom *); +staticfn boolean stock_room_goodpos(struct mkroom *, int, int, int, int); +staticfn boolean veggy_item(struct obj * obj, int); +staticfn int shkveg(void); +staticfn void mkveggy_at(int, int); +staticfn void mkshobj_at(const struct shclass *, int, int, boolean); +staticfn void nameshk(struct monst *, const char *const *); +staticfn int good_shopdoor(struct mkroom *, coordxy *, coordxy *); +staticfn int shkinit(const struct shclass *, struct mkroom *); #define VEGETARIAN_CLASS (MAXOCLASSES + 1) @@ -201,6 +201,7 @@ static const char *const shkhealthfoods[] = { * *_CLASS enum value) or a specific object enum value. * In the latter case, prepend it with a unary minus so the code can know * (by testing the sign) whether to use mkobj() or mksobj(). + * shtypes[] is externally referenced from mkroom.c, mon.c and shk.c. */ const struct shclass shtypes[] = { { "general store", @@ -372,7 +373,7 @@ init_shop_selection() /* decide whether an object or object type is considered vegetarian; for types, items which might go either way are assumed to be veggy */ -static boolean +staticfn boolean veggy_item(struct obj* obj, int otyp /* used iff obj is null */) { int corpsenm; @@ -400,7 +401,7 @@ veggy_item(struct obj* obj, int otyp /* used iff obj is null */) return FALSE; } -static int +staticfn int shkveg(void) { int i, j, maxprob, prob; @@ -435,7 +436,7 @@ shkveg(void) } /* make a random item for health food store */ -static void +staticfn void mkveggy_at(int sx, int sy) { struct obj *obj = mksobj_at(shkveg(), sx, sy, TRUE, TRUE); @@ -446,7 +447,7 @@ mkveggy_at(int sx, int sy) } /* make an object of the appropriate type for a shop square */ -static void +staticfn void mkshobj_at(const struct shclass *shp, int sx, int sy, boolean mkspecl) { struct monst *mtmp; @@ -479,7 +480,7 @@ mkshobj_at(const struct shclass *shp, int sx, int sy, boolean mkspecl) } /* extract a shopkeeper name for the given shop type */ -static void +staticfn void nameshk(struct monst *shk, const char *const *nlp) { int i, trycnt, names_avail; @@ -573,7 +574,7 @@ free_eshk(struct monst *mtmp) /* find a door in room sroom which is good for shop entrance. returns -1 if no good door found, or the gd.doors index and the door coordinates in sx, sy */ -static int +staticfn int good_shopdoor(struct mkroom *sroom, coordxy *sx, coordxy *sy) { int i; @@ -619,7 +620,7 @@ good_shopdoor(struct mkroom *sroom, coordxy *sx, coordxy *sy) } /* create a new shopkeeper in the given room */ -static int +staticfn int shkinit(const struct shclass *shp, struct mkroom *sroom) { int sh; @@ -682,7 +683,7 @@ shkinit(const struct shclass *shp, struct mkroom *sroom) return sh; } -static boolean +staticfn boolean stock_room_goodpos(struct mkroom *sroom, int rmno, int sh, int sx, int sy) { if (sroom->irregular) { diff --git a/src/sit.c b/src/sit.c index 288eb4ffb..d39bd10fd 100644 --- a/src/sit.c +++ b/src/sit.c @@ -6,8 +6,8 @@ #include "hack.h" #include "artifact.h" -static void throne_sit_effect(void); -static int lay_an_egg(void); +staticfn void throne_sit_effect(void); +staticfn int lay_an_egg(void); /* take away the hero's money */ void @@ -33,7 +33,7 @@ take_gold(void) } /* maybe do something when hero sits on a throne */ -static void +staticfn void throne_sit_effect(void) { if (rnd(6) > 4) { @@ -194,7 +194,7 @@ throne_sit_effect(void) } /* hero lays an egg */ -static int +staticfn int lay_an_egg(void) { struct obj *uegg; diff --git a/src/sounds.c b/src/sounds.c index 5c34ffd97..a6b078d7e 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -4,20 +4,20 @@ #include "hack.h" -static boolean throne_mon_sound(struct monst *); -static boolean beehive_mon_sound(struct monst *); -static boolean morgue_mon_sound(struct monst *); -static boolean zoo_mon_sound(struct monst *); -static boolean temple_priest_sound(struct monst *); -static boolean mon_is_gecko(struct monst *); -static int domonnoise(struct monst *); -static int dochat(void); -static struct monst *responsive_mon_at(int, int); -static int mon_in_room(struct monst *, int); -static boolean oracle_sound(struct monst *); +staticfn boolean throne_mon_sound(struct monst *); +staticfn boolean beehive_mon_sound(struct monst *); +staticfn boolean morgue_mon_sound(struct monst *); +staticfn boolean zoo_mon_sound(struct monst *); +staticfn boolean temple_priest_sound(struct monst *); +staticfn boolean mon_is_gecko(struct monst *); +staticfn int domonnoise(struct monst *); +staticfn int dochat(void); +staticfn struct monst *responsive_mon_at(int, int); +staticfn int mon_in_room(struct monst *, int); +staticfn boolean oracle_sound(struct monst *); /* this easily could be a macro, but it might overtax dumb compilers */ -static int +staticfn int mon_in_room(struct monst *mon, int rmtyp) { int rno = levl[mon->mx][mon->my].roomno; @@ -27,7 +27,7 @@ mon_in_room(struct monst *mon, int rmtyp) } -static boolean +staticfn boolean throne_mon_sound(struct monst *mtmp) { if ((mtmp->msleeping || is_lord(mtmp->data) @@ -59,7 +59,7 @@ throne_mon_sound(struct monst *mtmp) } -static boolean +staticfn boolean beehive_mon_sound(struct monst *mtmp) { if ((mtmp->data->mlet == S_ANT && is_flyer(mtmp->data)) @@ -86,7 +86,7 @@ beehive_mon_sound(struct monst *mtmp) return FALSE; } -static boolean +staticfn boolean morgue_mon_sound(struct monst *mtmp) { if ((is_undead(mtmp->data) || is_vampshifter(mtmp)) @@ -112,7 +112,7 @@ morgue_mon_sound(struct monst *mtmp) return FALSE; } -static boolean +staticfn boolean zoo_mon_sound(struct monst *mtmp) { if ((mtmp->msleeping || is_animal(mtmp->data)) @@ -128,7 +128,7 @@ zoo_mon_sound(struct monst *mtmp) return FALSE; } -static boolean +staticfn boolean temple_priest_sound(struct monst *mtmp) { if (mtmp->ispriest && inhistemple(mtmp) @@ -178,7 +178,7 @@ temple_priest_sound(struct monst *mtmp) return FALSE; } -static boolean +staticfn boolean oracle_sound(struct monst *mtmp) { if (mtmp->data != &mons[PM_ORACLE]) @@ -655,7 +655,7 @@ cry_sound(struct monst *mtmp) } /* return True if mon is a gecko or seems to look like one (hallucination) */ -static boolean +staticfn boolean mon_is_gecko(struct monst *mon) { int glyph; @@ -675,7 +675,7 @@ mon_is_gecko(struct monst *mon) DISABLE_WARNING_FORMAT_NONLITERAL -static int /* check calls to this */ +staticfn int /* check calls to this */ domonnoise(struct monst *mtmp) { char verbuf[BUFSZ]; @@ -1248,7 +1248,7 @@ dotalk(void) return result; } -static int +staticfn int dochat(void) { struct monst *mtmp; @@ -1403,7 +1403,7 @@ dochat(void) } /* is there a monster at that can see the hero and react? */ -static struct monst * +staticfn struct monst * responsive_mon_at(int x, int y) { struct monst *mtmp = isok(x, y) ? m_at(x, y) : 0; @@ -1616,7 +1616,7 @@ add_sound_mapping(const char *mapping) return 1; } -static audio_mapping * +staticfn audio_mapping * sound_matches_message(const char *msg) { audio_mapping *snd = soundmap; @@ -1714,7 +1714,7 @@ extern struct sound_procs macsound_procs; extern struct sound_procs qtsound_procs; #endif -struct sound_procs nosound_procs = { +static struct sound_procs nosound_procs = { SOUNDID(nosound), 0L, (void (*)(void)) 0, /* init_nhsound */ @@ -1796,7 +1796,7 @@ assign_soundlib(int idx) } #if 0 -static void +staticfn void choose_soundlib(const char *s) { int i; @@ -1878,54 +1878,54 @@ get_soundlib_name(char *dest, int maxlen) */ #if 0 -static void nosound_init_nhsound(void); -static void nosound_exit_nhsound(const char *); -static void nosound_suspend_nhsound(const char *); -static void nosound_resume_nhsound(void); -static void nosound_achievement(schar, schar, int32_t); -static void nosound_soundeffect(int32_t, int32_t); -static void nosound_play_usersound(char *, int32_t, int32_t); -static void nosound_ambience(int32_t, int32_t, int32_t); -static void nosound_verbal(char *text, int32_t gender, int32_t tone, +staticfn void nosound_init_nhsound(void); +staticfn void nosound_exit_nhsound(const char *); +staticfn void nosound_suspend_nhsound(const char *); +staticfn void nosound_resume_nhsound(void); +staticfn void nosound_achievement(schar, schar, int32_t); +staticfn void nosound_soundeffect(int32_t, int32_t); +staticfn void nosound_play_usersound(char *, int32_t, int32_t); +staticfn void nosound_ambience(int32_t, int32_t, int32_t); +staticfn void nosound_verbal(char *text, int32_t gender, int32_t tone, int32_t vol, int32_t moreinfo); -static void +staticfn void nosound_init_nhsound(void) { } -static void +staticfn void nosound_exit_nhsound(const char *reason) { } -static void +staticfn void nosound_achievement(schar ach1, schar ach2, int32_t repeat) { } -static void +staticfn void nosound_soundeffect(int32_t seid, int volume) { } -static void +staticfn void nosound_hero_playnotes(int32_t instr, const char *notes, int32_t vol) { } -static void +staticfn void nosound_play_usersound(char *filename, int volume, int idx) { } -static void +staticfn void nosound_ambience(int32_t ambienceid, int32_t ambience_action, int32_t hero_proximity) { } -static void +staticfn void nosound_verbal(char *text, int32_t gender, int32_t tone, int32_t vol, int32_t moreinfo) { @@ -1933,6 +1933,10 @@ nosound_verbal(char *text, int32_t gender, int32_t tone, #endif #ifdef SND_SOUNDEFFECTS_AUTOMAP + +/* prototype in case a build defines staticfn to nothing */ +staticfn void initialize_semap_basenames(void); + struct soundeffect_automapping { enum sound_effect_entries seid; const char *base_filename; @@ -1949,7 +1953,7 @@ static const struct soundeffect_automapping static const char *semap_basenames[SIZE(se_mappings_init)]; static boolean basenames_initialized = FALSE; -static void +staticfn void initialize_semap_basenames(void) { int i; diff --git a/src/sp_lev.c b/src/sp_lev.c index 28648f8ac..444407e63 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -16,114 +16,114 @@ extern void mkmap(lev_init *); -static void solidify_map(void); -static void map_cleanup(void); -static void lvlfill_maze_grid(int, int, int, int, schar); -static void lvlfill_solid(schar, schar); -static void lvlfill_swamp(schar, schar, schar); -static void flip_dbridge_horizontal(struct rm *); -static void flip_dbridge_vertical(struct rm *); -static void flip_visuals(int, int, int, int, int); -static int flip_encoded_dir_bits(int, int); -static void flip_vault_guard(int, struct monst *, +staticfn void solidify_map(void); +staticfn void map_cleanup(void); +staticfn void lvlfill_maze_grid(int, int, int, int, schar); +staticfn void lvlfill_solid(schar, schar); +staticfn void lvlfill_swamp(schar, schar, schar); +staticfn void flip_dbridge_horizontal(struct rm *); +staticfn void flip_dbridge_vertical(struct rm *); +staticfn void flip_visuals(int, int, int, int, int); +staticfn int flip_encoded_dir_bits(int, int); +staticfn void flip_vault_guard(int, struct monst *, coordxy, coordxy, coordxy, coordxy); -static void sel_set_wall_property(coordxy, coordxy, genericptr_t); -static void set_wall_property(coordxy, coordxy, coordxy, coordxy, int); -static void remove_boundary_syms(void); -static void set_door_orientation(int, int); -static boolean shared_with_room(int, int, struct mkroom *); -static void maybe_add_door(int, int, struct mkroom *); -static void link_doors_rooms(void); -static int rnddoor(void); -static int rndtrap(void); -static void get_location(coordxy *, coordxy *, getloc_flags_t, +staticfn void sel_set_wall_property(coordxy, coordxy, genericptr_t); +staticfn void set_wall_property(coordxy, coordxy, coordxy, coordxy, int); +staticfn void remove_boundary_syms(void); +staticfn void set_door_orientation(int, int); +staticfn boolean shared_with_room(int, int, struct mkroom *); +staticfn void maybe_add_door(int, int, struct mkroom *); +staticfn void link_doors_rooms(void); +staticfn int rnddoor(void); +staticfn int rndtrap(void); +staticfn void get_location(coordxy *, coordxy *, getloc_flags_t, struct mkroom *); -static void set_ok_location_func(boolean (*)(coordxy, coordxy)); -static boolean is_ok_location(coordxy, coordxy, getloc_flags_t); -static unpacked_coord get_unpacked_coord(long, int); -static void get_room_loc(coordxy *, coordxy *, struct mkroom *); -static void get_free_room_loc(coordxy *, coordxy *, struct mkroom *, +staticfn void set_ok_location_func(boolean (*)(coordxy, coordxy)); +staticfn boolean is_ok_location(coordxy, coordxy, getloc_flags_t); +staticfn unpacked_coord get_unpacked_coord(long, int); +staticfn void get_room_loc(coordxy *, coordxy *, struct mkroom *); +staticfn void get_free_room_loc(coordxy *, coordxy *, struct mkroom *, packed_coord); -static boolean create_subroom(struct mkroom *, coordxy, coordxy, coordxy, +staticfn boolean create_subroom(struct mkroom *, coordxy, coordxy, coordxy, coordxy, xint16, xint16); -static void create_door(room_door *, struct mkroom *); -static void create_trap(spltrap *, struct mkroom *); -static int noncoalignment(aligntyp); -static boolean m_bad_boulder_spot(coordxy, coordxy); -static int pm_to_humidity(struct permonst *); -static unsigned int sp_amask_to_amask(unsigned int sp_amask); -static void create_monster(monster *, struct mkroom *); -static struct obj *create_object(object *, struct mkroom *); -static void create_altar(altar *, struct mkroom *); -static boolean search_door(struct mkroom *, coordxy *, coordxy *, xint16, int); -static void create_corridor(corridor *); -static struct mkroom *build_room(room *, struct mkroom *); -static void light_region(region *); -static void maze1xy(coord *, int); -static void fill_empty_maze(void); -static void splev_initlev(lev_init *); -static boolean generate_way_out_method(coordxy nx, coordxy ny, +staticfn void create_door(room_door *, struct mkroom *); +staticfn void create_trap(spltrap *, struct mkroom *); +staticfn int noncoalignment(aligntyp); +staticfn boolean m_bad_boulder_spot(coordxy, coordxy); +staticfn int pm_to_humidity(struct permonst *); +staticfn unsigned int sp_amask_to_amask(unsigned int sp_amask); +staticfn void create_monster(monster *, struct mkroom *); +staticfn struct obj *create_object(object *, struct mkroom *); +staticfn void create_altar(altar *, struct mkroom *); +staticfn boolean search_door(struct mkroom *, coordxy *, coordxy *, xint16, int); +staticfn void create_corridor(corridor *); +staticfn struct mkroom *build_room(room *, struct mkroom *); +staticfn void light_region(region *); +staticfn void maze1xy(coord *, int); +staticfn void fill_empty_maze(void); +staticfn void splev_initlev(lev_init *); +staticfn boolean generate_way_out_method(coordxy nx, coordxy ny, struct selectionvar *ov); -static void l_push_wid_hei_table(lua_State *, int, int); -static boolean good_stair_loc(coordxy, coordxy); -static void ensure_way_out(void); +staticfn void l_push_wid_hei_table(lua_State *, int, int); +staticfn boolean good_stair_loc(coordxy, coordxy); +staticfn void ensure_way_out(void); #if 0 /* macosx complains that these are unused */ -static long sp_code_jmpaddr(long, long); -static void spo_room(struct sp_coder *); -static void spo_trap(struct sp_coder *); -static void spo_gold(struct sp_coder *); -static void spo_corridor(struct sp_coder *); -static void spo_feature(struct sp_coder *); -static void spo_terrain(struct sp_coder *); -static void spo_replace_terrain(struct sp_coder *); -static void spo_levregion(struct sp_coder *); -static void spo_region(struct sp_coder *); -static void spo_drawbridge(struct sp_coder *); -static void spo_mazewalk(struct sp_coder *); -static void spo_wall_property(struct sp_coder *); -static void spo_room_door(struct sp_coder *); -static void spo_wallify(struct sp_coder *); -static void sel_set_wallify(coordxy, coordxy, genericptr_t); +staticfn long sp_code_jmpaddr(long, long); +staticfn void spo_room(struct sp_coder *); +staticfn void spo_trap(struct sp_coder *); +staticfn void spo_gold(struct sp_coder *); +staticfn void spo_corridor(struct sp_coder *); +staticfn void spo_feature(struct sp_coder *); +staticfn void spo_terrain(struct sp_coder *); +staticfn void spo_replace_terrain(struct sp_coder *); +staticfn void spo_levregion(struct sp_coder *); +staticfn void spo_region(struct sp_coder *); +staticfn void spo_drawbridge(struct sp_coder *); +staticfn void spo_mazewalk(struct sp_coder *); +staticfn void spo_wall_property(struct sp_coder *); +staticfn void spo_room_door(struct sp_coder *); +staticfn void spo_wallify(struct sp_coder *); +staticfn void sel_set_wallify(coordxy, coordxy, genericptr_t); #endif -static void spo_end_moninvent(void); -static void spo_pop_container(void); -static int l_create_stairway(lua_State *, boolean); -static void spo_endroom(struct sp_coder *); -static void l_table_getset_feature_flag(lua_State *, int, int, const char *, +staticfn void spo_end_moninvent(void); +staticfn void spo_pop_container(void); +staticfn int l_create_stairway(lua_State *, boolean); +staticfn void spo_endroom(struct sp_coder *); +staticfn void l_table_getset_feature_flag(lua_State *, int, int, const char *, int); -static void l_get_lregion(lua_State *, lev_region *); -static void sel_set_lit(coordxy, coordxy, genericptr_t); -static void add_doors_to_room(struct mkroom *); -static void get_table_coords_or_region(lua_State *, +staticfn void l_get_lregion(lua_State *, lev_region *); +staticfn void sel_set_lit(coordxy, coordxy, genericptr_t); +staticfn void add_doors_to_room(struct mkroom *); +staticfn void get_table_coords_or_region(lua_State *, coordxy *, coordxy *, coordxy *, coordxy *); -static void sel_set_ter(coordxy, coordxy, genericptr_t); -static void sel_set_door(coordxy, coordxy, genericptr_t); -static void sel_set_feature(coordxy, coordxy, genericptr_t); -static void levregion_add(lev_region *); -static void get_table_xy_or_coord(lua_State *, lua_Integer *, lua_Integer *); -static int get_table_region(lua_State *, const char *, lua_Integer *, +staticfn void sel_set_ter(coordxy, coordxy, genericptr_t); +staticfn void sel_set_door(coordxy, coordxy, genericptr_t); +staticfn void sel_set_feature(coordxy, coordxy, genericptr_t); +staticfn void levregion_add(lev_region *); +staticfn void get_table_xy_or_coord(lua_State *, lua_Integer *, lua_Integer *); +staticfn int get_table_region(lua_State *, const char *, lua_Integer *, lua_Integer *, lua_Integer *, lua_Integer *, boolean); -static void set_wallprop_in_selection(lua_State *, int); -static int floodfillchk_match_under(coordxy, coordxy); -static int floodfillchk_match_accessible(coordxy, coordxy); -static void l_push_mkroom_table(lua_State *, struct mkroom *); -static int get_table_align(lua_State *); -static int get_table_monclass(lua_State *); -static int find_montype(lua_State *, const char *, int *); -static int get_table_montype(lua_State *, int *); -static lua_Integer get_table_int_or_random(lua_State *, const char *, int); -static int get_table_buc(lua_State *); -static int get_table_objclass(lua_State *); -static int find_objtype(lua_State *, const char *); -static int get_table_objtype(lua_State *); -static const char *get_mkroom_name(int) NONNULL; -static int get_table_roomtype_opt(lua_State *, const char *, int); -static int get_table_traptype_opt(lua_State *, const char *, int); -static int get_traptype_byname(const char *); -static lua_Integer get_table_intarray_entry(lua_State *, int, int); -static struct sp_coder *sp_level_coder_init(void); +staticfn void set_wallprop_in_selection(lua_State *, int); +staticfn int floodfillchk_match_under(coordxy, coordxy); +staticfn int floodfillchk_match_accessible(coordxy, coordxy); +staticfn void l_push_mkroom_table(lua_State *, struct mkroom *); +staticfn int get_table_align(lua_State *); +staticfn int get_table_monclass(lua_State *); +staticfn int find_montype(lua_State *, const char *, int *); +staticfn int get_table_montype(lua_State *, int *); +staticfn lua_Integer get_table_int_or_random(lua_State *, const char *, int); +staticfn int get_table_buc(lua_State *); +staticfn int get_table_objclass(lua_State *); +staticfn int find_objtype(lua_State *, const char *); +staticfn int get_table_objtype(lua_State *); +staticfn const char *get_mkroom_name(int) NONNULL; +staticfn int get_table_roomtype_opt(lua_State *, const char *, int); +staticfn int get_table_traptype_opt(lua_State *, const char *, int); +staticfn int get_traptype_byname(const char *); +staticfn lua_Integer get_table_intarray_entry(lua_State *, int, int); +staticfn struct sp_coder *sp_level_coder_init(void); /* lua_CFunction prototypes */ int lspo_altar(lua_State *); @@ -311,7 +311,7 @@ mapfrag_match(struct mapfragment *mf, int x, int y) return TRUE; } -static void +staticfn void solidify_map(void) { coordxy x, y; @@ -324,7 +324,7 @@ solidify_map(void) /* do a post-level-creation cleanup of map, such as removing boulders and traps from lava */ -static void +staticfn void map_cleanup(void) { struct obj *otmp; @@ -355,7 +355,7 @@ map_cleanup(void) } } -static void +staticfn void lvlfill_maze_grid(int x1, int y1, int x2, int y2, schar filling) { int x, y; @@ -370,7 +370,7 @@ lvlfill_maze_grid(int x1, int y1, int x2, int y2, schar filling) } } -static void +staticfn void lvlfill_solid(schar filling, schar lit) { int x, y; @@ -387,7 +387,7 @@ lvlfill_solid(schar filling, schar lit) } } -static void +staticfn void lvlfill_swamp(schar fg, schar bg, schar lit) { int x, y; @@ -424,7 +424,7 @@ lvlfill_swamp(schar fg, schar bg, schar lit) } } -static void +staticfn void flip_dbridge_horizontal(struct rm *lev) { if (IS_DRAWBRIDGE(lev->typ)) { @@ -438,7 +438,7 @@ flip_dbridge_horizontal(struct rm *lev) } } -static void +staticfn void flip_dbridge_vertical(struct rm *lev) { if (IS_DRAWBRIDGE(lev->typ)) { @@ -454,7 +454,7 @@ flip_dbridge_vertical(struct rm *lev) /* for #wizfliplevel; not needed when flipping during level creation; update seen vector for whole flip area and glyph for known walls */ -static void +staticfn void flip_visuals(int flp, int minx, int miny, int maxx, int maxy) { struct rm *lev; @@ -495,7 +495,7 @@ flip_visuals(int flp, int minx, int miny, int maxx, int maxy) } /* transpose an encoded direction */ -static int +staticfn int flip_encoded_dir_bits(int flp, int val) { /* these depend on xdir[] and ydir[] order */ @@ -897,7 +897,7 @@ flip_level( } /* for #wizfliplevel, flip guard's egd data; not needed for level creation */ -static void +staticfn void flip_vault_guard( int flp, /* 1: transpose vertically, 2: transpose horizontally, 3: both */ struct monst *grd, /* the vault guard, has monst->mextra->egd data */ @@ -957,7 +957,7 @@ flip_level_rnd(int flp, boolean extras) } -static void +staticfn void sel_set_wall_property(coordxy x, coordxy y, genericptr_t arg) { int prop = *(int *) arg; @@ -972,7 +972,7 @@ sel_set_wall_property(coordxy x, coordxy y, genericptr_t arg) /* * Make walls of the area (x1, y1, x2, y2) non diggable/non passwall-able */ -static void +staticfn void set_wall_property(coordxy x1, coordxy y1, coordxy x2, coordxy y2, int prop) { coordxy x, y; @@ -987,7 +987,7 @@ set_wall_property(coordxy x1, coordxy y1, coordxy x2, coordxy y2, int prop) } } -static void +staticfn void remove_boundary_syms(void) { /* @@ -1013,7 +1013,7 @@ remove_boundary_syms(void) } /* used by sel_set_door() and link_doors_rooms() */ -static void +staticfn void set_door_orientation(int x, int y) { boolean wleft, wright, wup, wdown; @@ -1060,7 +1060,7 @@ set_door_orientation(int x, int y) } /* is x,y right next to room droom? */ -static boolean +staticfn boolean shared_with_room(int x, int y, struct mkroom *droom) { int rmno = (droom - gr.rooms) + ROOMOFFSET; @@ -1081,7 +1081,7 @@ shared_with_room(int x, int y, struct mkroom *droom) } /* maybe add door at x,y to room droom */ -static void +staticfn void maybe_add_door(int x, int y, struct mkroom *droom) { if (droom->hx >= 0 @@ -1093,7 +1093,7 @@ maybe_add_door(int x, int y, struct mkroom *droom) } /* link all doors in the map to their corresponding rooms */ -static void +staticfn void link_doors_rooms(void) { int x, y; @@ -1119,7 +1119,7 @@ link_doors_rooms(void) /* * Choose randomly the state (nodoor, open, closed or locked) for a door */ -static int +staticfn int rnddoor(void) { static int state[] = { D_NODOOR, D_BROKEN, D_ISOPEN, D_CLOSED, D_LOCKED }; @@ -1130,7 +1130,7 @@ rnddoor(void) /* * Select a random trap */ -static int +staticfn int rndtrap(void) { int rtrap; @@ -1173,7 +1173,7 @@ rndtrap(void) * The "humidity" flag is used to ensure that engravings aren't created * underwater, or eels on dry land. */ -static void +staticfn void get_location( coordxy *x, coordxy *y, getloc_flags_t humidity, @@ -1245,13 +1245,13 @@ get_location( static boolean (*is_ok_location_func)(coordxy, coordxy) = NULL; -static void +staticfn void set_ok_location_func(boolean (*func)(coordxy, coordxy)) { is_ok_location_func = func; } -static boolean +staticfn boolean is_ok_location(coordxy x, coordxy y, getloc_flags_t humidity) { int typ = levl[x][y].typ; @@ -1288,7 +1288,7 @@ pm_good_location(coordxy x, coordxy y, struct permonst *pm) return is_ok_location(x, y, pm_to_humidity(pm)); } -static unpacked_coord +staticfn unpacked_coord get_unpacked_coord(long loc, int defhumidity) { static unpacked_coord c; @@ -1331,7 +1331,7 @@ get_location_coord( * Get a relative position inside a room. * negative values for x or y means RANDOM! */ -static void +staticfn void get_room_loc(coordxy *x, coordxy *y, struct mkroom *croom) { coord c; @@ -1356,7 +1356,7 @@ get_room_loc(coordxy *x, coordxy *y, struct mkroom *croom) * Get a relative position inside a room. * negative values for x or y means RANDOM! */ -static void +staticfn void get_free_room_loc( coordxy *x, coordxy *y, struct mkroom *croom, @@ -1638,7 +1638,7 @@ create_room( * Create a subroom in room proom at pos x,y with width w & height h. * x & y are relative to the parent room. */ -static boolean +staticfn boolean create_subroom( struct mkroom *proom, coordxy x, coordxy y, @@ -1684,7 +1684,7 @@ create_subroom( * Create a new door in a room. * It's placed on a wall (north, south, east or west). */ -static void +staticfn void create_door(room_door *dd, struct mkroom *broom) { int x = 0, y = 0; @@ -1782,7 +1782,7 @@ create_door(room_door *dd, struct mkroom *broom) /* * Create a trap in a room. */ -static void +staticfn void create_trap(spltrap *t, struct mkroom *croom) { coordxy x = -1, y = -1; @@ -1822,7 +1822,7 @@ create_trap(spltrap *t, struct mkroom *croom) /* * Create a monster in a room. */ -static int +staticfn int noncoalignment(aligntyp alignment) { int k; @@ -1834,7 +1834,7 @@ noncoalignment(aligntyp alignment) } /* attempt to screen out locations where a mimic-as-boulder shouldn't occur */ -static boolean +staticfn boolean m_bad_boulder_spot(coordxy x, coordxy y) { struct rm *lev; @@ -1854,7 +1854,7 @@ m_bad_boulder_spot(coordxy x, coordxy y) return FALSE; } -static int +staticfn int pm_to_humidity(struct permonst *pm) { int loc = DRY; @@ -1878,7 +1878,7 @@ pm_to_humidity(struct permonst *pm) * * When random: there is an 80% chance that the altar will be co-aligned. */ -static unsigned int +staticfn unsigned int sp_amask_to_amask(unsigned int sp_amask) { unsigned int amask; @@ -1895,7 +1895,7 @@ sp_amask_to_amask(unsigned int sp_amask) return amask; } -static void +staticfn void create_monster(monster *m, struct mkroom *croom) { struct monst *mtmp; @@ -2149,7 +2149,7 @@ create_monster(monster *m, struct mkroom *croom) /* * Create an object in a room. */ -static struct obj * +staticfn struct obj * create_object(object *o, struct mkroom *croom) { struct obj *otmp; @@ -2400,7 +2400,7 @@ create_object(object *o, struct mkroom *croom) /* * Create an altar in a room. */ -static void +staticfn void create_altar(altar *a, struct mkroom *croom) { schar sproom; @@ -2446,7 +2446,7 @@ create_altar(altar *a, struct mkroom *croom) /* * Search for a door in a room on a specified wall. */ -static boolean +staticfn boolean search_door( struct mkroom *croom, coordxy *x, coordxy *y, @@ -2618,7 +2618,7 @@ dig_corridor( * Basically we search for door coordinates or for endpoints coordinates * (from a distance). */ -static void +staticfn void create_corridor(corridor *c) { coord org, dest; @@ -2754,7 +2754,7 @@ fill_special_room(struct mkroom *croom) } } -static struct mkroom * +staticfn struct mkroom * build_room(room *r, struct mkroom *mkr) { boolean okroom; @@ -2786,7 +2786,7 @@ build_room(room *r, struct mkroom *mkr) /* * set lighting in a region that will not become a room. */ -static void +staticfn void light_region(region *tmpregion) { boolean litstate = tmpregion->rlit ? 1 : 0; @@ -2847,7 +2847,7 @@ wallify_map(coordxy x1, coordxy y1, coordxy x2, coordxy y2) * We want a place not 'touched' by the loader. That is, a place in * the maze outside every part of the special level. */ -static void +staticfn void maze1xy(coord *m, int humidity) { int x, y, tryct = 2000; @@ -2873,7 +2873,7 @@ maze1xy(coord *m, int humidity) * Makes the number of traps, monsters, etc. proportional * to the size of the maze. */ -static void +staticfn void fill_empty_maze(void) { int mapcountmax, mapcount, mapfact; @@ -2924,7 +2924,7 @@ fill_empty_maze(void) } } -static void +staticfn void splev_initlev(lev_init *linit) { switch (linit->init_style) { @@ -2964,7 +2964,7 @@ splev_initlev(lev_init *linit) } #if 0 -static long +staticfn long sp_code_jmpaddr(long curpos, long jmpaddr) { return (curpos + jmpaddr); @@ -2973,7 +2973,7 @@ sp_code_jmpaddr(long curpos, long jmpaddr) /*ARGUSED*/ -static void +staticfn void spo_end_moninvent(void) { if (invent_carrying_monster) @@ -2982,7 +2982,7 @@ spo_end_moninvent(void) } /*ARGUSED*/ -static void +staticfn void spo_pop_container(void) { if (container_idx > 0) { @@ -2992,7 +2992,7 @@ spo_pop_container(void) } /* push a table on lua stack: {width=wid, height=hei} */ -static void +staticfn void l_push_wid_hei_table(lua_State *L, int wid, int hei) { lua_newtable(L); @@ -3001,7 +3001,7 @@ l_push_wid_hei_table(lua_State *L, int wid, int hei) } /* push a table on lua stack containing room data */ -static void +staticfn void l_push_mkroom_table(lua_State *L, struct mkroom *tmpr) { lua_newtable(L); @@ -3056,7 +3056,7 @@ lspo_message(lua_State *L) RESTORE_WARNING_UNREACHABLE_CODE -static int +staticfn int get_table_align(lua_State *L) { static const char *const gtaligns[] = { @@ -3073,7 +3073,7 @@ get_table_align(lua_State *L) return a; } -static int +staticfn int get_table_monclass(lua_State *L) { char *s = get_table_str_opt(L, "class", NULL); @@ -3085,7 +3085,7 @@ get_table_monclass(lua_State *L) return ret; } -static int +staticfn int find_montype( lua_State *L UNUSED, const char *s, @@ -3109,7 +3109,7 @@ find_montype( return NON_PM; } -static int +staticfn int get_table_montype(lua_State *L, int *mgender) { char *s = get_table_str_opt(L, "id", NULL); @@ -3130,7 +3130,7 @@ get_table_montype(lua_State *L, int *mgender) * Returns absolute rather than map-relative coordinates; the caller of this * function must decide if it wants to interpret the coordinates as * map-relative and adjust accordingly. */ -static void +staticfn void get_table_xy_or_coord( lua_State *L, lua_Integer *x, @@ -3332,7 +3332,7 @@ DISABLE_WARNING_UNREACHABLE_CODE /* the hash key 'name' is an integer or "random", or if not existent, also return rndval */ -static lua_Integer +staticfn lua_Integer get_table_int_or_random(lua_State *L, const char *name, int rndval) { lua_Integer ret; @@ -3367,7 +3367,7 @@ get_table_int_or_random(lua_State *L, const char *name, int rndval) RESTORE_WARNING_UNREACHABLE_CODE -static int +staticfn int get_table_buc(lua_State *L) { static const char *const bucs[] = { @@ -3380,7 +3380,7 @@ get_table_buc(lua_State *L) return curse_state; } -static int +staticfn int get_table_objclass(lua_State *L) { char *s = get_table_str_opt(L, "class", NULL); @@ -3392,7 +3392,7 @@ get_table_objclass(lua_State *L) return ret; } -static int +staticfn int find_objtype(lua_State *L, const char *s) { if (s && *s) { @@ -3460,7 +3460,7 @@ find_objtype(lua_State *L, const char *s) return STRANGE_OBJECT; } -static int +staticfn int get_table_objtype(lua_State *L) { char *s = get_table_str_opt(L, "id", NULL); @@ -3909,7 +3909,7 @@ static const struct { { 0, 0 } }; -static const char * +staticfn const char * get_mkroom_name(int rtype) { int i; @@ -3922,7 +3922,7 @@ get_mkroom_name(int rtype) return "unknown"; /* not NULL */ } -static int +staticfn int get_table_roomtype_opt(lua_State *L, const char *name, int defval) { char *roomstr = get_table_str_opt(L, name, emptystr); @@ -4037,7 +4037,7 @@ lspo_room(lua_State *L) return 0; } -static void +staticfn void spo_endroom(struct sp_coder *coder UNUSED) { if (gc.coder->n_subroom > 1) { @@ -4057,7 +4057,7 @@ spo_endroom(struct sp_coder *coder UNUSED) /* callback for is_ok_location. stairs generated at random location shouldn't overwrite special terrain */ -static boolean +staticfn boolean good_stair_loc(coordxy x, coordxy y) { schar typ = levl[x][y].typ; @@ -4065,7 +4065,7 @@ good_stair_loc(coordxy x, coordxy y) return (typ == ROOM || typ == CORR || typ == ICE); } -static int +staticfn int l_create_stairway(lua_State *L, boolean using_ladder) { static const char *const stairdirs[] = { "down", "up", NULL }; @@ -4268,7 +4268,7 @@ static const struct { { "random", -1 }, { 0, NO_TRAP } }; -static int +staticfn int get_table_traptype_opt(lua_State *L, const char *name, int defval) { char *trapstr = get_table_str_opt(L, name, emptystr); @@ -4297,7 +4297,7 @@ get_trapname_bytype(int ttyp) return NULL; } -static int +staticfn int get_traptype_byname(const char *trapname) { int i; @@ -4493,7 +4493,7 @@ random_wdir(void) static schar floodfillchk_match_under_typ; -static int +staticfn int floodfillchk_match_under(coordxy x, coordxy y) { return (floodfillchk_match_under_typ == levl[x][y].typ); @@ -4506,7 +4506,7 @@ set_floodfillchk_match_under(coordxy typ) set_selection_floodfillchk(floodfillchk_match_under); } -static int +staticfn int floodfillchk_match_accessible(coordxy x, coordxy y) { return (ACCESSIBLE(levl[x][y].typ) @@ -4515,7 +4515,7 @@ floodfillchk_match_accessible(coordxy x, coordxy y) } /* change map location terrain type during level creation */ -static void +staticfn void sel_set_ter(coordxy x, coordxy y, genericptr_t arg) { terrain terr; @@ -4539,7 +4539,7 @@ sel_set_ter(coordxy x, coordxy y, genericptr_t arg) } } -static void +staticfn void sel_set_feature(coordxy x, coordxy y, genericptr_t arg) { if (!isok(x, y)) { @@ -4553,7 +4553,7 @@ sel_set_feature(coordxy x, coordxy y, genericptr_t arg) levl[x][y].typ = (*(int *) arg); } -static void +staticfn void sel_set_door(coordxy dx, coordxy dy, genericptr_t arg) { coordxy typ = *(coordxy *) arg; @@ -4644,7 +4644,7 @@ lspo_door(lua_State *L) RESTORE_WARNING_UNREACHABLE_CODE -static void +staticfn void l_table_getset_feature_flag( lua_State *L, int x, int y, @@ -5051,7 +5051,7 @@ lspo_replace_terrain(lua_State *L) return 0; } -static boolean +staticfn boolean generate_way_out_method( coordxy nx, coordxy ny, struct selectionvar *ov) @@ -5122,7 +5122,7 @@ generate_way_out_method( return res; } -static void +staticfn void ensure_way_out(void) { struct selectionvar *ov = selection_new(); @@ -5165,7 +5165,7 @@ ensure_way_out(void) DISABLE_WARNING_UNREACHABLE_CODE -static lua_Integer +staticfn lua_Integer get_table_intarray_entry(lua_State *L, int tableidx, int entrynum) { lua_Integer ret = 0; @@ -5187,7 +5187,7 @@ get_table_intarray_entry(lua_State *L, int tableidx, int entrynum) return ret; } -static int +staticfn int get_table_region( lua_State *L, const char *name, @@ -5276,7 +5276,7 @@ get_coord(lua_State *L, int i, lua_Integer *x, lua_Integer *y) RESTORE_WARNING_UNREACHABLE_CODE -static void +staticfn void levregion_add(lev_region *lregion) { if (!lregion->in_islev) { @@ -5315,7 +5315,7 @@ levregion_add(lev_region *lregion) - exclude = {x1,y1,x2,y2} (optional) - region_islev=true, exclude_islev=true (optional) - negative x and y are invalid */ -static void +staticfn void l_get_lregion(lua_State *L, lev_region *tmplregion) { lua_Integer x1,y1,x2,y2; @@ -5431,7 +5431,7 @@ lspo_exclusion(lua_State *L) return 0; } -static void +staticfn void sel_set_lit(coordxy x, coordxy y, genericptr_t arg) { int lit = *(int *) arg; @@ -5440,7 +5440,7 @@ sel_set_lit(coordxy x, coordxy y, genericptr_t arg) } /* Add to the room any doors within/bordering it */ -static void +staticfn void add_doors_to_room(struct mkroom *croom) { coordxy x, y; @@ -5457,7 +5457,7 @@ add_doors_to_room(struct mkroom *croom) DISABLE_WARNING_UNREACHABLE_CODE /* inside a lua table, get fields x1,y1,x2,y2 or region table */ -static void +staticfn void get_table_coords_or_region(lua_State *L, coordxy *dx1, coordxy *dy1, coordxy *dx2, coordxy *dy2) @@ -5807,7 +5807,7 @@ lspo_wall_property(lua_State *L) return 0; } -static void +staticfn void set_wallprop_in_selection(lua_State *L, int prop) { int argc = lua_gettop(L); @@ -5851,7 +5851,7 @@ lspo_non_passwall(lua_State *L) #if 0 /*ARGSUSED*/ -static void +staticfn void sel_set_wallify(coordxy x, coordxy y, genericptr_t arg UNUSED) { wallify_map(x, y, x, y); @@ -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; @@ -6227,7 +6227,7 @@ update_croom(void) gc.coder->croom = NULL; } -static struct sp_coder * +staticfn struct sp_coder * sp_level_coder_init(void) { int tmpi; diff --git a/src/spell.c b/src/spell.c index 0ea9adfe9..47ce6633f 100644 --- a/src/spell.c +++ b/src/spell.c @@ -28,30 +28,30 @@ struct chain_lightning_queue; struct chain_lightning_zap; -static int spell_let_to_idx(char); -static boolean cursed_book(struct obj * bp); -static boolean confused_book(struct obj *); -static void deadbook_pacify_undead(struct monst *); -static void deadbook(struct obj *); -static int learn(void); -static boolean rejectcasting(void); -static boolean getspell(int *); -static int QSORTCALLBACK spell_cmp(const genericptr, const genericptr); -static void sortspells(void); -static boolean spellsortmenu(void); -static boolean dospellmenu(const char *, int, int *); -static int percent_success(int); -static char *spellretention(int, char *); -static int throwspell(void); -static void cast_protection(void); -static void cast_chain_lightning(void); -static void spell_backfire(int); -static boolean spelleffects_check(int, int *, int *); -static const char *spelltypemnemonic(int); -static boolean can_center_spell_location(coordxy, coordxy); -static void display_spell_target_positions(boolean); -static boolean spell_aim_step(genericptr_t, coordxy, coordxy); -static void propagate_chain_lightning(struct chain_lightning_queue *, +staticfn int spell_let_to_idx(char); +staticfn boolean cursed_book(struct obj * bp); +staticfn boolean confused_book(struct obj *); +staticfn void deadbook_pacify_undead(struct monst *); +staticfn void deadbook(struct obj *); +staticfn int learn(void); +staticfn boolean rejectcasting(void); +staticfn boolean getspell(int *); +staticfn int QSORTCALLBACK spell_cmp(const genericptr, const genericptr); +staticfn void sortspells(void); +staticfn boolean spellsortmenu(void); +staticfn boolean dospellmenu(const char *, int, int *); +staticfn int percent_success(int); +staticfn char *spellretention(int, char *); +staticfn int throwspell(void); +staticfn void cast_protection(void); +staticfn void cast_chain_lightning(void); +staticfn void spell_backfire(int); +staticfn boolean spelleffects_check(int, int *, int *); +staticfn const char *spelltypemnemonic(int); +staticfn boolean can_center_spell_location(coordxy, coordxy); +staticfn void display_spell_target_positions(boolean); +staticfn boolean spell_aim_step(genericptr_t, coordxy, coordxy); +staticfn void propagate_chain_lightning(struct chain_lightning_queue *, struct chain_lightning_zap); /* The roles[] table lists the role-specific values for tuning @@ -110,7 +110,7 @@ static void propagate_chain_lightning(struct chain_lightning_queue *, static const char explodes[] = "radiates explosive energy"; /* convert a letter into a number in the range 0..51, or -1 if not a letter */ -static int +staticfn int spell_let_to_idx(char ilet) { int indx; @@ -125,7 +125,7 @@ spell_let_to_idx(char ilet) } /* TRUE: book should be destroyed by caller */ -static boolean +staticfn boolean cursed_book(struct obj *bp) { boolean was_in_use; @@ -184,7 +184,7 @@ cursed_book(struct obj *bp) } /* study while confused: returns TRUE if the book is destroyed */ -static boolean +staticfn boolean confused_book(struct obj *spellbook) { boolean gone = FALSE; @@ -206,7 +206,7 @@ confused_book(struct obj *spellbook) } /* pacify or tame an undead monster */ -static void +staticfn void deadbook_pacify_undead(struct monst *mtmp) { if ((is_undead(mtmp->data) || is_vampshifter(mtmp)) @@ -226,7 +226,7 @@ deadbook_pacify_undead(struct monst *mtmp) /* special effects for The Book of the Dead; reading it while blind is allowed so that needs to be taken into account too */ -static void +staticfn void deadbook(struct obj *book2) { struct monst *mtmp; @@ -352,7 +352,7 @@ book_cursed(struct obj *book) DISABLE_WARNING_FORMAT_NONLITERAL -static int +staticfn int learn(void) { int i; @@ -669,7 +669,7 @@ age_spells(void) /* return True if spellcasting is inhibited; only covers a small subset of reasons why casting won't work */ -static boolean +staticfn boolean rejectcasting(void) { /* rejections which take place before selecting a particular spell */ @@ -697,7 +697,7 @@ rejectcasting(void) * Return TRUE if a spell was picked, with the spell index in the return * parameter. Otherwise return FALSE. */ -static boolean +staticfn boolean getspell(int *spell_no) { int nspells, idx; @@ -808,7 +808,7 @@ docast(void) return ECMD_FAIL; } -static const char * +staticfn const char * spelltypemnemonic(int skill) { switch (skill) { @@ -922,7 +922,7 @@ struct chain_lightning_queue { zap is passed by value, so the move-forward doesn't change the passed argument. */ -static void +staticfn void propagate_chain_lightning( struct chain_lightning_queue *clq, struct chain_lightning_zap zap) @@ -973,7 +973,7 @@ propagate_chain_lightning( tmp_at(zap.x, zap.y); } -static void +staticfn void cast_chain_lightning(void) { struct chain_lightning_queue clq = { @@ -1054,7 +1054,7 @@ cast_chain_lightning(void) } -static void +staticfn void cast_protection(void) { int l = u.ulevel, loglev = 0, @@ -1131,7 +1131,7 @@ cast_protection(void) } /* attempting to cast a forgotten spell will cause disorientation */ -static void +staticfn void spell_backfire(int spell) { long duration = (long) ((spellev(spell) + 1) * 3), /* 6..24 */ @@ -1170,7 +1170,7 @@ spell_backfire(int spell) return; } -static boolean +staticfn boolean spelleffects_check(int spell, int *res, int *energy) { int chance; @@ -1542,7 +1542,7 @@ spelleffects(int spell_otyp, boolean atme, boolean force) } /*ARGSUSED*/ -static boolean +staticfn boolean spell_aim_step(genericptr_t arg UNUSED, coordxy x, coordxy y) { if (!isok(x,y)) @@ -1554,7 +1554,7 @@ spell_aim_step(genericptr_t arg UNUSED, coordxy x, coordxy y) } /* not quite the same as throwspell limits, but close enough */ -static boolean +staticfn boolean can_center_spell_location(coordxy x, coordxy y) { if (distmin(u.ux, u.uy, x, y) > 10) @@ -1562,7 +1562,7 @@ can_center_spell_location(coordxy x, coordxy y) return (isok(x, y) && cansee(x, y) && !(IS_STWALL(levl[x][y].typ))); } -static void +staticfn void display_spell_target_positions(boolean on_off) { coordxy x, y, dx, dy; @@ -1590,7 +1590,7 @@ display_spell_target_positions(boolean on_off) } /* Choose location where spell takes effect. */ -static int +staticfn int throwspell(void) { coord cc, uc; @@ -1805,7 +1805,7 @@ static const char *const spl_sortchoices[NUM_SPELL_SORTBY] = { }; /* qsort callback routine */ -static int QSORTCALLBACK +staticfn int QSORTCALLBACK spell_cmp(const genericptr vptr1, const genericptr vptr2) { /* @@ -1862,7 +1862,7 @@ spell_cmp(const genericptr vptr1, const genericptr vptr2) /* sort the index used for display order of the "view known spells" list (sortmode == SORTBY_xxx), or sort the spellbook itself to make the current display order stick (sortmode == SORTRETAINORDER) */ -static void +staticfn void sortspells(void) { int i; @@ -1911,7 +1911,7 @@ sortspells(void) } /* called if the [sort spells] entry in the view spells menu gets chosen */ -static boolean +staticfn boolean spellsortmenu(void) { winid tmpwin; @@ -1996,7 +1996,7 @@ DISABLE_WARNING_FORMAT_NONLITERAL /* shows menu of known spells, with options to sort them. return FALSE on cancel, TRUE otherwise. spell_no is set to the internal spl_book index, if any selected */ -static boolean +staticfn boolean dospellmenu( const char *prompt, int splaction, /* SPELLMENU_CAST, SPELLMENU_VIEW, or gs.spl_book[] index */ @@ -2089,7 +2089,7 @@ dospellmenu( RESTORE_WARNING_FORMAT_NONLITERAL -static int +staticfn int percent_success(int spell) { /* Intrinsic and learned ability are combined to calculate @@ -2211,7 +2211,7 @@ percent_success(int spell) return chance; } -static char * +staticfn char * spellretention(int idx, char * outbuf) { long turnsleft, percent, accuracy; diff --git a/src/steal.c b/src/steal.c index 8327b6147..a183f504b 100644 --- a/src/steal.c +++ b/src/steal.c @@ -5,12 +5,12 @@ #include "hack.h" -static const char *equipname(struct obj *); -static int unstolenarm(void); -static int stealarm(void); -static void worn_item_removal(struct monst *, struct obj *); +staticfn const char *equipname(struct obj *); +staticfn int unstolenarm(void); +staticfn int stealarm(void); +staticfn void worn_item_removal(struct monst *, struct obj *); -static const char * +staticfn const char * equipname(struct obj *otmp) { return ((otmp == uarmu) ? shirt_simple_name(otmp) @@ -156,7 +156,7 @@ unresponsive(void) /* called via (*ga.afternmv)() when hero finishes taking off armor that was slated to be stolen but the thief died in the interim */ -static int +staticfn int unstolenarm(void) { struct obj *obj; @@ -174,7 +174,7 @@ unstolenarm(void) } /* finish stealing an item of armor which takes multiple turns to take off */ -static int +staticfn int stealarm(void) { struct monst *mtmp; @@ -313,7 +313,7 @@ remove_worn_item( } /* during theft of a worn item: remove_worn_item(), prefaced by a message */ -static void +staticfn void worn_item_removal( struct monst *mon, struct obj *obj) diff --git a/src/steed.c b/src/steed.c index bd2b3ec24..7866939f9 100644 --- a/src/steed.c +++ b/src/steed.c @@ -9,8 +9,8 @@ static NEARDATA const char steeds[] = { S_QUADRUPED, S_UNICORN, S_ANGEL, S_CENTAUR, S_DRAGON, S_JABBERWOCK, '\0' }; -static boolean landing_spot(coord *, int, int); -static void maybewakesteed(struct monst *); +staticfn boolean landing_spot(coord *, int, int); +staticfn void maybewakesteed(struct monst *); /* caller has decided that hero can't reach something while mounted */ void @@ -444,7 +444,7 @@ kick_steed(void) * room's walls, which is not what we want. * Adapted from mail daemon code. */ -static boolean +staticfn boolean landing_spot( coord *spot, /* landing position (we fill it in) */ int reason, @@ -810,7 +810,7 @@ dismount_steed( /* when attempting to saddle or mount a sleeping steed, try to wake it up (for the saddling case, it won't be u.usteed yet) */ -static void +staticfn void maybewakesteed(struct monst *steed) { int frozen = (int) steed->mfrozen; diff --git a/src/strutil.c b/src/strutil.c index 82b10d11b..b12e5b194 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -97,11 +97,11 @@ Strlen_( return (unsigned) len; } -static boolean pmatch_internal(const char *, const char *, boolean, +staticfn boolean pmatch_internal(const char *, const char *, boolean, const char *); /* guts of pmatch(), pmatchi(), and pmatchz(); match a string against a pattern */ -static boolean +staticfn boolean pmatch_internal(const char *patrn, const char *strng, boolean ci, /* True => case-insensitive, False => case-sensitive */ diff --git a/src/symbols.c b/src/symbols.c index c11dfe81b..f700cbf52 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -5,10 +5,10 @@ #include "hack.h" #include "tcap.h" -static void savedsym_add(const char *, const char *, int); -static struct _savedsym *savedsym_find(const char *, int); +staticfn void savedsym_add(const char *, const char *, int); +staticfn struct _savedsym *savedsym_find(const char *, int); #ifdef ENHANCED_SYMBOLS -static void purge_custom_entries(enum graphics_sets which_set); +staticfn void purge_custom_entries(enum graphics_sets which_set); #endif extern const uchar def_r_oc_syms[MAXOCLASSES]; /* drawing.c */ @@ -373,6 +373,7 @@ symset_is_compatible( * particular types of symset "handling", define a * H_XXX macro in include/sym.h and add the name * to this array at the matching offset. + * Externally referenced from files.c, options.c, utf8map.c. */ const char *const known_handling[] = { "UNKNOWN", /* H_UNK */ @@ -425,7 +426,7 @@ const struct symparse loadsyms[] = { { SYM_OTH, SYM_INVISIBLE + SYM_OFF_X, "S_invisible" }, { SYM_OTH, SYM_PET_OVERRIDE + SYM_OFF_X, "S_pet_override" }, { SYM_OTH, SYM_HERO_OVERRIDE + SYM_OFF_X, "S_hero_override" }, - { 0, 0, (const char *) 0 } /* fence post */ + { SYM_INVALID, 0, (const char *) 0 } /* fence post */ }; boolean @@ -716,7 +717,7 @@ savedsym_free(void) } } -static struct _savedsym * +staticfn struct _savedsym * savedsym_find(const char *name, int which_set) { struct _savedsym *tmp = saved_symbols; @@ -729,7 +730,7 @@ savedsym_find(const char *name, int which_set) return NULL; } -static void +staticfn void savedsym_add(const char *name, const char *val, int which_set) { struct _savedsym *tmp = NULL; @@ -1113,7 +1114,7 @@ struct customization_detail *find_display_urep_customization( const char *customization_name, int glyphidx, enum graphics_sets which_set); extern glyph_map glyphmap[MAX_GLYPH]; -static void shuffle_customizations(void); +staticfn void shuffle_customizations(void); void apply_customizations_to_symset(enum graphics_sets which_set) @@ -1141,7 +1142,7 @@ apply_customizations_to_symset(enum graphics_sets which_set) /* Shuffle the customizations to match shuffled object descriptions, * so a red potion isn't displayed with a blue customization, and so on. */ -static void +staticfn void shuffle_customizations(void) { static const int offsets[2] = { GLYPH_OBJ_OFF, GLYPH_OBJ_PILETOP_OFF }; @@ -1209,7 +1210,7 @@ find_matching_symset_customiz( return (struct customization_detail *) 0; } -static void +staticfn void purge_custom_entries(enum graphics_sets which_set) { struct symset_customization *gdc = &gs.sym_customizations[which_set]; diff --git a/src/teleport.c b/src/teleport.c index 2d5b22b8a..cb3b518ec 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -6,18 +6,18 @@ #include "hack.h" #define NEW_ENEXTO -static boolean goodpos_onscary(coordxy, coordxy, struct permonst *); -static boolean tele_jump_ok(coordxy, coordxy, coordxy, coordxy); -static boolean teleok(coordxy, coordxy, boolean); -static void vault_tele(void); -static boolean rloc_pos_ok(coordxy, coordxy, struct monst *); -static void rloc_to_core(struct monst *, coordxy, coordxy, unsigned); -static void mvault_tele(struct monst *); -static boolean m_blocks_teleporting(struct monst *); -static stairway *stairway_find_forwiz(boolean, boolean); +staticfn boolean goodpos_onscary(coordxy, coordxy, struct permonst *); +staticfn boolean tele_jump_ok(coordxy, coordxy, coordxy, coordxy); +staticfn boolean teleok(coordxy, coordxy, boolean); +staticfn void vault_tele(void); +staticfn boolean rloc_pos_ok(coordxy, coordxy, struct monst *); +staticfn void rloc_to_core(struct monst *, coordxy, coordxy, unsigned); +staticfn void mvault_tele(struct monst *); +staticfn boolean m_blocks_teleporting(struct monst *); +staticfn stairway *stairway_find_forwiz(boolean, boolean); /* does monster block others from teleporting? */ -static boolean +staticfn boolean m_blocks_teleporting(struct monst *mtmp) { if (is_dlord(mtmp->data) || is_dprince(mtmp->data)) @@ -44,7 +44,7 @@ noteleport_level(struct monst *mon) /* this is an approximation of onscary() that doesn't use any 'struct monst' fields aside from 'monst->data'; used primarily for new monster creation and monster teleport destination, not for ordinary monster movement */ -static boolean +staticfn boolean goodpos_onscary( coordxy x, coordxy y, struct permonst *mptr) @@ -363,7 +363,7 @@ enexto_core( * need to be augmented to allow deliberate passage in wizard mode, but * only for explicitly chosen destinations.) */ -static boolean +staticfn boolean tele_jump_ok(coordxy x1, coordxy y1, coordxy x2, coordxy y2) { if (!isok(x2, y2)) @@ -397,7 +397,7 @@ tele_jump_ok(coordxy x1, coordxy y1, coordxy x2, coordxy y2) return TRUE; } -static boolean +staticfn boolean teleok(coordxy x, coordxy y, boolean trapok) { if (!trapok) { @@ -750,7 +750,7 @@ safe_teleds(int teleds_flags) return FALSE; } -static void +staticfn void vault_tele(void) { struct mkroom *croom = search_special(VAULT); @@ -1491,7 +1491,7 @@ level_tele_trap(struct trap *trap, unsigned int trflags) } /* check whether monster can arrive at location via Tport (or fall) */ -static boolean +staticfn boolean rloc_pos_ok( coordxy x, coordxy y, /* coordinates of candidate location */ struct monst *mtmp) @@ -1558,7 +1558,7 @@ rloc_pos_ok( * a value because mtmp is a migrating_mon. Worm tails are always * placed randomly around the head of the worm. */ -static void +staticfn void rloc_to_core( struct monst *mtmp, coordxy x, coordxy y, @@ -1689,7 +1689,7 @@ rloc_to_flag( rloc_to_core(mtmp, x, y, rlocflags); } -static stairway * +staticfn stairway * stairway_find_forwiz(boolean isladder, boolean up) { stairway *stway = gs.stairs; @@ -1840,7 +1840,7 @@ control_mon_tele( return FALSE; } -static void +staticfn void mvault_tele(struct monst *mtmp) { struct mkroom *croom = search_special(VAULT); diff --git a/src/timeout.c b/src/timeout.c index 1d1605766..69f72999d 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -5,20 +5,20 @@ #include "hack.h" -static void stoned_dialogue(void); -static void vomiting_dialogue(void); -static void sleep_dialogue(void); -static void choke_dialogue(void); -static void levitation_dialogue(void); -static void slime_dialogue(void); -static void slimed_to_death(struct kinfo *) NO_NNARGS; -static void sickness_dialogue(void); -static void phaze_dialogue(void); -static void done_timeout(int, int); -static void slip_or_trip(void); -static void see_lamp_flicker(struct obj *, const char *) NONNULLPTRS; -static void lantern_message(struct obj *) NONNULLARG1; -static void cleanup_burn(ANY_P *, long) NONNULLARG1; +staticfn void stoned_dialogue(void); +staticfn void vomiting_dialogue(void); +staticfn void sleep_dialogue(void); +staticfn void choke_dialogue(void); +staticfn void levitation_dialogue(void); +staticfn void slime_dialogue(void); +staticfn void slimed_to_death(struct kinfo *) NO_NNARGS; +staticfn void sickness_dialogue(void); +staticfn void phaze_dialogue(void); +staticfn void done_timeout(int, int); +staticfn void slip_or_trip(void); +staticfn void see_lamp_flicker(struct obj *, const char *) NONNULLPTRS; +staticfn void lantern_message(struct obj *) NONNULLARG1; +staticfn void cleanup_burn(ANY_P *, long) NONNULLARG1; /* used by wizard mode #timeout and #wizintrinsic; order by 'interest' for timeout countdown, where most won't occur in normal play */ @@ -129,7 +129,7 @@ static NEARDATA const char *const stoned_texts[] = { "You are a statue." /* 1 */ }; -static void +staticfn void stoned_dialogue(void) { long i = (Stoned & TIMEOUT); @@ -189,7 +189,7 @@ static NEARDATA const char *const vomiting_texts[] = { "are about to vomit." /* 2 */ }; -static void +staticfn void vomiting_dialogue(void) { const char *txt = 0; @@ -259,7 +259,7 @@ vomiting_dialogue(void) exercise(A_CON, FALSE); } -static void +staticfn void sleep_dialogue(void) { long i = (HSleepy & TIMEOUT); @@ -286,7 +286,7 @@ static NEARDATA const char *const choke_texts2[] = { "You suffocate." }; -static void +staticfn void choke_dialogue(void) { long i = (Strangled & TIMEOUT); @@ -314,7 +314,7 @@ static NEARDATA const char *const sickness_texts[] = { "You are at Death's door.", }; -static void +staticfn void sickness_dialogue(void) { long j = (Sick & TIMEOUT), i = j / 2L; @@ -344,7 +344,7 @@ static NEARDATA const char *const levi_texts[] = { "You wobble unsteadily %s the %s." }; -static void +staticfn void levitation_dialogue(void) { /* -1 because the last message comes via float_down() */ @@ -380,7 +380,7 @@ static NEARDATA const char *const slime_texts[] = { "You have become %s." /* 1 */ }; -static void +staticfn void slime_dialogue(void) { long t = (Slimed & TIMEOUT), i = t / 2L; @@ -448,7 +448,7 @@ burn_away_slime(void) } /* countdown timer for turning into green slime has run out; kill our hero */ -static void +staticfn void slimed_to_death(struct kinfo *kptr) { uchar save_mvflags; @@ -525,7 +525,7 @@ static NEARDATA const char *const phaze_texts[] = { "You are feeling rather flabby.", }; -static void +staticfn void phaze_dialogue(void) { long i = ((HPasses_walls & TIMEOUT) / 2L); @@ -540,7 +540,7 @@ phaze_dialogue(void) /* when a status timeout is fatal, keep the status line indicator shown during end of game rundown (and potential dumplog); timeout has already counted down to 0 by the time we get here */ -static void +staticfn void done_timeout(int how, int which) { long *intrinsic_p = &u.uprops[which].intrinsic; @@ -1169,7 +1169,7 @@ attach_fig_transform_timeout(struct obj *figurine) } /* give a fumble message */ -static void +staticfn void slip_or_trip(void) { struct obj *otmp = vobj_at(u.ux, u.uy), *otmp2, *saddle; @@ -1292,7 +1292,7 @@ slip_or_trip(void) } /* Print a lamp flicker message with tailer. Only called if seen. */ -static void +staticfn void see_lamp_flicker(struct obj *obj, const char *tailer) { switch (obj->where) { @@ -1307,7 +1307,7 @@ see_lamp_flicker(struct obj *obj, const char *tailer) } /* Print a dimming message for brass lanterns. Only called if seen. */ -static void +staticfn void lantern_message(struct obj *obj) { /* from adventure */ @@ -1771,7 +1771,7 @@ end_burn(struct obj *obj, boolean timer_attached) /* * Cleanup a burning object if timer stopped. */ -static void +staticfn void cleanup_burn(anything *arg, long expire_time) { struct obj *obj = arg->a_obj; @@ -1897,14 +1897,14 @@ do_storms(void) * Check whether object has a timer of type timer_type. */ -static const char *kind_name(short); -static void print_queue(winid, timer_element *); -static void insert_timer(timer_element *); -static timer_element *remove_timer(timer_element **, short, ANY_P *); -static void write_timer(NHFILE *, timer_element *); -static boolean mon_is_local(struct monst *); -static boolean timer_is_local(timer_element *); -static int maybe_write_timer(NHFILE *, int, boolean); +staticfn const char *kind_name(short); +staticfn void print_queue(winid, timer_element *); +staticfn void insert_timer(timer_element *); +staticfn timer_element *remove_timer(timer_element **, short, ANY_P *); +staticfn void write_timer(NHFILE *, timer_element *); +staticfn boolean mon_is_local(struct monst *); +staticfn boolean timer_is_local(timer_element *); +staticfn int maybe_write_timer(NHFILE *, int, boolean); /* If defined, then include names when printing out the timer queue */ #define VERBOSE_TIMER @@ -1938,7 +1938,7 @@ static const ttable timeout_funcs[NUM_TIME_FUNCS] = { }; #undef TTAB -static const char * +staticfn const char * kind_name(short kind) { switch (kind) { @@ -1954,7 +1954,7 @@ kind_name(short kind) return "unknown"; } -static void +staticfn void print_queue(winid win, timer_element *base) { timer_element *curr; @@ -2386,7 +2386,7 @@ spot_time_left(coordxy x, coordxy y, short func_index) } /* Insert timer into the global queue */ -static void +staticfn void insert_timer(timer_element *gnu) { timer_element *curr, *prev; @@ -2402,7 +2402,7 @@ insert_timer(timer_element *gnu) gt.timer_base = gnu; } -static timer_element * +staticfn timer_element * remove_timer( timer_element **base, short func_index, @@ -2424,7 +2424,7 @@ remove_timer( return curr; } -static void +staticfn void write_timer(NHFILE *nhfp, timer_element *timer) { anything arg_save; @@ -2508,7 +2508,7 @@ obj_is_local(struct obj *obj) * Return TRUE if the given monster will stay on the level when the * level is saved. */ -static boolean +staticfn boolean mon_is_local(struct monst *mon) { struct monst *curr; @@ -2527,7 +2527,7 @@ mon_is_local(struct monst *mon) * Return TRUE if the timer is attached to something that will stay on the * level when the level is saved. */ -static boolean +staticfn boolean timer_is_local(timer_element *timer) { switch (timer->kind) { @@ -2551,7 +2551,7 @@ RESTORE_WARNING_UNREACHABLE_CODE * Part of the save routine. Count up the number of timers that would * be written. If write_it is true, actually write the timer. */ -static int +staticfn int maybe_write_timer(NHFILE *nhfp, int range, boolean write_it) { int count = 0; diff --git a/src/topten.c b/src/topten.c index 2d608a8cb..92f8388da 100644 --- a/src/topten.c +++ b/src/topten.c @@ -52,36 +52,37 @@ struct toptenentry { char plalign[ROLESZ + 1]; char name[NAMSZ + 1]; char death[DTHSZ + 1]; -} *tt_head; +}; +static struct toptenentry *tt_head; /* size big enough to read in all the string fields at once; includes room for separating space or trailing newline plus string terminator */ #define SCANBUFSZ (4 * (ROLESZ + 1) + (NAMSZ + 1) + (DTHSZ + 1) + 1) static struct toptenentry zerott; -static void topten_print(const char *); -static void topten_print_bold(const char *); -static void outheader(void); -static void outentry(int, struct toptenentry *, boolean); -static void discardexcess(FILE *); -static void readentry(FILE *, struct toptenentry *); -static void writeentry(FILE *, struct toptenentry *); +staticfn void topten_print(const char *); +staticfn void topten_print_bold(const char *); +staticfn void outheader(void); +staticfn void outentry(int, struct toptenentry *, boolean); +staticfn void discardexcess(FILE *); +staticfn void readentry(FILE *, struct toptenentry *); +staticfn void writeentry(FILE *, struct toptenentry *); #ifdef XLOGFILE -static void writexlentry(FILE *, struct toptenentry *, int); -static long encodexlogflags(void); -static long encodeconduct(void); -static long encodeachieve(boolean); -static void add_achieveX(char *, const char *, boolean); -static char *encode_extended_achievements(char *); -static char *encode_extended_conducts(char *); +staticfn void writexlentry(FILE *, struct toptenentry *, int); +staticfn long encodexlogflags(void); +staticfn long encodeconduct(void); +staticfn long encodeachieve(boolean); +staticfn void add_achieveX(char *, const char *, boolean); +staticfn char *encode_extended_achievements(char *); +staticfn char *encode_extended_conducts(char *); #endif -static void free_ttlist(struct toptenentry *); -static int classmon(char *); -static int score_wanted(boolean, int, struct toptenentry *, int, +staticfn void free_ttlist(struct toptenentry *); +staticfn int classmon(char *); +staticfn int score_wanted(boolean, int, struct toptenentry *, int, const char **, int); #ifdef NO_SCAN_BRACK -static void nsb_mung_line(char *); -static void nsb_unmung_line(char *); +staticfn void nsb_mung_line(char *); +staticfn void nsb_unmung_line(char *); #endif /* "killed by",&c ["an"] 'gk.killer.name' */ @@ -158,7 +159,7 @@ formatkiller( } } -static void +staticfn void topten_print(const char *x) { if (gt.toptenwin == WIN_ERR) @@ -167,7 +168,7 @@ topten_print(const char *x) putstr(gt.toptenwin, ATR_NONE, x); } -static void +staticfn void topten_print_bold(const char *x) { if (gt.toptenwin == WIN_ERR) @@ -201,7 +202,7 @@ observable_depth(d_level *lev) } /* throw away characters until current record has been entirely consumed */ -static void +staticfn void discardexcess(FILE *rfile) { int c; @@ -213,7 +214,7 @@ discardexcess(FILE *rfile) DISABLE_WARNING_FORMAT_NONLITERAL -static void +staticfn void readentry(FILE *rfile, struct toptenentry *tt) { char inbuf[SCANBUFSZ], s1[SCANBUFSZ], s2[SCANBUFSZ], s3[SCANBUFSZ], @@ -294,7 +295,7 @@ readentry(FILE *rfile, struct toptenentry *tt) } } -static void +staticfn void writeentry(FILE *rfile, struct toptenentry *tt) { static const char fmt32[] = "%c%c "; /* role,gender */ @@ -333,7 +334,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL #ifdef XLOGFILE /* as tab is never used in eg. gp.plname or death, no need to mangle those. */ -static void +staticfn void writexlentry(FILE *rfile, struct toptenentry *tt, int how) { #define Fprintf (void) fprintf @@ -386,7 +387,7 @@ writexlentry(FILE *rfile, struct toptenentry *tt, int how) #undef XLOG_SEP } -static long +staticfn long encodexlogflags(void) { long e = 0L; @@ -401,7 +402,7 @@ encodexlogflags(void) return e; } -static long +staticfn long encodeconduct(void) { long e = 0L; @@ -445,7 +446,7 @@ encodeconduct(void) return e; } -static long +staticfn long encodeachieve( boolean secondlong) /* False: handle achievements 1..31, True: 32..62 */ { @@ -470,7 +471,7 @@ encodeachieve( } /* add the achievement or conduct comma-separated to string */ -static void +staticfn void add_achieveX(char *buf, const char *achievement, boolean condition) { if (condition) { @@ -481,7 +482,7 @@ add_achieveX(char *buf, const char *achievement, boolean condition) } } -static char * +staticfn char * encode_extended_achievements(char *buf) { char rnkbuf[40]; @@ -574,7 +575,7 @@ encode_extended_achievements(char *buf) return buf; } -static char * +staticfn char * encode_extended_conducts(char *buf) { buf[0] = '\0'; @@ -603,7 +604,7 @@ encode_extended_conducts(char *buf) #endif /* XLOGFILE */ -static void +staticfn void free_ttlist(struct toptenentry *tt) { struct toptenentry *ttnext; @@ -917,7 +918,7 @@ topten(int how, time_t when) } } -static void +staticfn void outheader(void) { char linebuf[BUFSZ]; @@ -934,7 +935,7 @@ outheader(void) DISABLE_WARNING_FORMAT_NONLITERAL /* so>0: standout line; so=0: ordinary line */ -static void +staticfn void outentry(int rank, struct toptenentry *t1, boolean so) { boolean second_line = TRUE; @@ -1100,7 +1101,7 @@ outentry(int rank, struct toptenentry *t1, boolean so) RESTORE_WARNING_FORMAT_NONLITERAL -static int +staticfn int score_wanted( boolean current_ver, int rank, @@ -1344,7 +1345,7 @@ prscore(int argc, char **argv) #endif } -static int +staticfn int classmon(char *plch) { int i; @@ -1459,7 +1460,7 @@ tt_doppel(struct monst *mon) { /* Lattice scanf isn't up to reading the scorefile. What */ /* follows deals with that; I admit it's ugly. (KL) */ /* Now generally available (KL) */ -static void +staticfn void nsb_mung_line(p) char *p; { @@ -1467,7 +1468,7 @@ char *p; *p = '|'; } -static void +staticfn void nsb_unmung_line(p) char *p; { diff --git a/src/trap.c b/src/trap.c index 6a036aee8..15633bd87 100644 --- a/src/trap.c +++ b/src/trap.c @@ -7,70 +7,70 @@ extern const char *const destroy_strings[][3]; /* from zap.c */ -static void mk_trap_statue(coordxy, coordxy); -static int dng_bottom(d_level *lev); -static void hole_destination(d_level *); -static boolean keep_saddle_with_steedcorpse(unsigned, struct obj *, +staticfn void mk_trap_statue(coordxy, coordxy); +staticfn int dng_bottom(d_level *lev); +staticfn void hole_destination(d_level *); +staticfn boolean keep_saddle_with_steedcorpse(unsigned, struct obj *, struct obj *); -static boolean mu_maybe_destroy_web(struct monst *, boolean, struct trap *); -static struct obj *t_missile(int, struct trap *); -static boolean floor_trigger(int); -static boolean check_in_air(struct monst *, unsigned); -static int trapeffect_arrow_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_dart_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_rocktrap(struct monst *, struct trap *, unsigned); -static int trapeffect_sqky_board(struct monst *, struct trap *, unsigned); -static int trapeffect_bear_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_slp_gas_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_rust_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_fire_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_pit(struct monst *, struct trap *, unsigned); -static int trapeffect_hole(struct monst *, struct trap *, unsigned); -static int trapeffect_telep_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_level_telep(struct monst *, struct trap *, unsigned); -static int trapeffect_web(struct monst *, struct trap *, unsigned); -static int trapeffect_statue_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_magic_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_anti_magic(struct monst *, struct trap *, unsigned); -static int trapeffect_poly_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_landmine(struct monst *, struct trap *, unsigned); -static int trapeffect_rolling_boulder_trap(struct monst *, struct trap *, +staticfn boolean mu_maybe_destroy_web(struct monst *, boolean, struct trap *); +staticfn struct obj *t_missile(int, struct trap *); +staticfn boolean floor_trigger(int); +staticfn boolean check_in_air(struct monst *, unsigned); +staticfn int trapeffect_arrow_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_dart_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_rocktrap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_sqky_board(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_bear_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_slp_gas_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_rust_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_fire_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_pit(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_hole(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_telep_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_level_telep(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_web(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_statue_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_magic_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_anti_magic(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_poly_trap(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_landmine(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_rolling_boulder_trap(struct monst *, struct trap *, unsigned); -static int trapeffect_magic_portal(struct monst *, struct trap *, unsigned); -static int trapeffect_vibrating_square(struct monst *, struct trap *, - unsigned); -static int trapeffect_selector(struct monst *, struct trap *, unsigned); -static char *trapnote(struct trap *, boolean); -static int choose_trapnote(struct trap *); -static int steedintrap(struct trap *, struct obj *); -static void launch_drop_spot(struct obj *, coordxy, coordxy); -static boolean find_random_launch_coord(struct trap *, coord *); -static int mkroll_launch(struct trap *, coordxy, coordxy, short, long); -static boolean isclearpath(coord *, int, schar, schar); -static void dofiretrap(struct obj *); -static void domagictrap(void); -static void pot_acid_damage(struct obj *, boolean, boolean); -static boolean emergency_disrobe(boolean *); -static int untrap_prob(struct trap *); -static void move_into_trap(struct trap *); -static int try_disarm(struct trap *, boolean); -static void reward_untrap(struct trap *, struct monst *); -static int disarm_holdingtrap(struct trap *); -static int disarm_landmine(struct trap *); -static int unsqueak_ok(struct obj *); -static int disarm_squeaky_board(struct trap *); -static int disarm_shooting_trap(struct trap *, int); -static void clear_conjoined_pits(struct trap *); -static boolean adj_nonconjoined_pit(struct trap *); -static int try_lift(struct monst *, struct trap *, int, boolean); -static int help_monster_out(struct monst *, struct trap *); -static void untrap_box(struct obj *, boolean, boolean); +staticfn int trapeffect_magic_portal(struct monst *, struct trap *, unsigned); +staticfn int trapeffect_vibrating_square(struct monst *, struct trap *, + unsigned); +staticfn int trapeffect_selector(struct monst *, struct trap *, unsigned); +staticfn char *trapnote(struct trap *, boolean); +staticfn int choose_trapnote(struct trap *); +staticfn int steedintrap(struct trap *, struct obj *); +staticfn void launch_drop_spot(struct obj *, coordxy, coordxy); +staticfn boolean find_random_launch_coord(struct trap *, coord *); +staticfn int mkroll_launch(struct trap *, coordxy, coordxy, short, long); +staticfn boolean isclearpath(coord *, int, schar, schar); +staticfn void dofiretrap(struct obj *); +staticfn void domagictrap(void); +staticfn void pot_acid_damage(struct obj *, boolean, boolean); +staticfn boolean emergency_disrobe(boolean *); +staticfn int untrap_prob(struct trap *); +staticfn void move_into_trap(struct trap *); +staticfn int try_disarm(struct trap *, boolean); +staticfn void reward_untrap(struct trap *, struct monst *); +staticfn int disarm_holdingtrap(struct trap *); +staticfn int disarm_landmine(struct trap *); +staticfn int unsqueak_ok(struct obj *); +staticfn int disarm_squeaky_board(struct trap *); +staticfn int disarm_shooting_trap(struct trap *, int); +staticfn void clear_conjoined_pits(struct trap *); +staticfn boolean adj_nonconjoined_pit(struct trap *); +staticfn int try_lift(struct monst *, struct trap *, int, boolean); +staticfn int help_monster_out(struct monst *, struct trap *); +staticfn void untrap_box(struct obj *, boolean, boolean); #if 0 -static void join_adjacent_pits(struct trap *); +staticfn void join_adjacent_pits(struct trap *); #endif -static boolean thitm(int, struct monst *, struct obj *, int, +staticfn boolean thitm(int, struct monst *, struct obj *, int, boolean) NONNULLARG2; -static void maybe_finish_sokoban(void); +staticfn void maybe_finish_sokoban(void); static const char *const a_your[2] = { "a", "your" }; static const char *const A_Your[2] = { "A", "Your" }; @@ -384,7 +384,7 @@ grease_protect( } /* create a "living" statue at x,y */ -static void +staticfn void mk_trap_statue(coordxy x, coordxy y) { struct monst *mtmp; @@ -412,7 +412,7 @@ mk_trap_statue(coordxy x, coordxy y) } /* find "bottom" level of specified dungeon, stopping at quest locate */ -static int +staticfn int dng_bottom(d_level *lev) { int bottom = dunlevs_in_dungeon(lev); @@ -436,7 +436,7 @@ dng_bottom(d_level *lev) } /* destination dlevel for holes or trapdoors */ -static void +staticfn void hole_destination(d_level *dst) { int bottom = dng_bottom(&u.uz); @@ -895,7 +895,7 @@ activate_statue_trap( return mtmp; } -static boolean +staticfn boolean keep_saddle_with_steedcorpse( unsigned steed_mid, struct obj *objchn, @@ -928,7 +928,7 @@ keep_saddle_with_steedcorpse( /* monster or you go through and possibly destroy a web. return TRUE if could go through. */ -static boolean +staticfn boolean mu_maybe_destroy_web( struct monst *mtmp, boolean domsg, @@ -972,7 +972,7 @@ mu_maybe_destroy_web( } /* make a single arrow/dart/rock for a trap to shoot or drop */ -static struct obj * +staticfn struct obj * t_missile(int otyp, struct trap *trap) { struct obj *otmp = mksobj(otyp, TRUE, FALSE); @@ -1015,7 +1015,7 @@ reset_utrap(boolean msg) } /* is trap type ttyp triggered by touching the floor? */ -static boolean +staticfn boolean floor_trigger(int ttyp) { switch (ttyp) { @@ -1040,7 +1040,7 @@ floor_trigger(int ttyp) } /* return TRUE if monster mtmp is up in the air, considering trap flags */ -static boolean +staticfn boolean check_in_air(struct monst *mtmp, unsigned trflags) { boolean is_you = mtmp == &gy.youmonst, @@ -1133,7 +1133,7 @@ m_harmless_trap(struct monst *mtmp, struct trap *ttmp) return FALSE; } -static int +staticfn int trapeffect_arrow_trap( struct monst *mtmp, struct trap *trap, @@ -1191,7 +1191,7 @@ trapeffect_arrow_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_dart_trap( struct monst *mtmp, struct trap *trap, @@ -1262,7 +1262,7 @@ trapeffect_dart_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_rocktrap( struct monst *mtmp, struct trap *trap, @@ -1340,7 +1340,7 @@ trapeffect_rocktrap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_sqky_board( struct monst *mtmp, struct trap *trap, @@ -1414,7 +1414,7 @@ trapeffect_sqky_board( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_bear_trap( struct monst *mtmp, struct trap *trap, @@ -1492,7 +1492,7 @@ trapeffect_bear_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_slp_gas_trap( struct monst *mtmp, struct trap *trap, @@ -1523,7 +1523,7 @@ trapeffect_slp_gas_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_rust_trap( struct monst *mtmp, struct trap *trap, @@ -1653,7 +1653,7 @@ trapeffect_rust_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_fire_trap( struct monst *mtmp, struct trap *trap, @@ -1745,7 +1745,7 @@ trapeffect_fire_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_pit( struct monst *mtmp, struct trap *trap, @@ -1926,7 +1926,7 @@ trapeffect_pit( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_hole( struct monst *mtmp, struct trap *trap, @@ -1985,7 +1985,7 @@ trapeffect_hole( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_telep_trap( struct monst *mtmp, struct trap *trap, @@ -2003,7 +2003,7 @@ trapeffect_telep_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_level_telep( struct monst *mtmp, struct trap *trap, @@ -2021,7 +2021,7 @@ trapeffect_level_telep( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_web( struct monst *mtmp, struct trap *trap, @@ -2190,7 +2190,7 @@ trapeffect_web( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_statue_trap( struct monst *mtmp, struct trap *trap, @@ -2204,7 +2204,7 @@ trapeffect_statue_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_magic_trap( struct monst *mtmp, struct trap *trap, @@ -2234,7 +2234,7 @@ trapeffect_magic_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_anti_magic( struct monst *mtmp, /* monster, possibly youmonst */ struct trap *trap, /* trap->ttyp == ANTI_MAGIC */ @@ -2345,7 +2345,7 @@ trapeffect_anti_magic( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_poly_trap( struct monst *mtmp, struct trap *trap, @@ -2396,7 +2396,7 @@ trapeffect_poly_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_landmine( struct monst *mtmp, struct trap *trap, @@ -2521,7 +2521,7 @@ trapeffect_landmine( } #undef MINE_TRIGGER_WT -static int +staticfn int trapeffect_rolling_boulder_trap( struct monst *mtmp, struct trap *trap, @@ -2571,7 +2571,7 @@ trapeffect_rolling_boulder_trap( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_magic_portal( struct monst *mtmp, struct trap *trap, @@ -2586,7 +2586,7 @@ trapeffect_magic_portal( return Trap_Effect_Finished; } -static int +staticfn int trapeffect_vibrating_square( struct monst *mtmp, struct trap *trap, @@ -2795,7 +2795,7 @@ immune_to_trap(struct monst *mon, unsigned ttype) return TRAP_NOT_IMMUNE; } -static int +staticfn int trapeffect_selector( struct monst *mtmp, struct trap *trap, @@ -2916,7 +2916,7 @@ dotrap(struct trap *trap, unsigned trflags) (void) trapeffect_selector(&gy.youmonst, trap, trflags); } -static char * +staticfn char * trapnote(struct trap *trap, boolean noprefix) { static const char *const tnnames[] = { @@ -2936,7 +2936,7 @@ trapnote(struct trap *trap, boolean noprefix) /* choose a note not used by any trap on current level, ignoring ttmp; if all are in use, pick a random one */ -static int +staticfn int choose_trapnote(struct trap *ttmp) { int tavail[12], tpick[12], tcnt = 0, k; @@ -2955,7 +2955,7 @@ choose_trapnote(struct trap *ttmp) return ((tcnt > 0) ? tpick[rn2(tcnt)] : rn2(12)); } -static int +staticfn int steedintrap(struct trap *trap, struct obj *otmp) { struct monst *steed = u.usteed; @@ -3071,7 +3071,7 @@ blow_up_landmine(struct trap *trap) spot_checks(x, y, old_typ); } -static void +staticfn void launch_drop_spot(struct obj *obj, coordxy x, coordxy y) { if (!obj) { @@ -3418,7 +3418,7 @@ feeltrap(struct trap *trap) /* try to find a random coordinate where launching a rolling boulder could work. return TRUE if found, with coordinate in cc. */ -static boolean +staticfn boolean find_random_launch_coord(struct trap *ttmp, coord *cc) { int tmp; @@ -3478,7 +3478,7 @@ find_random_launch_coord(struct trap *ttmp, coord *cc) return success; } -static int +staticfn int mkroll_launch( struct trap *ttmp, coordxy x, @@ -3514,7 +3514,7 @@ mkroll_launch( return 1; } -static boolean +staticfn boolean isclearpath( coord *cc, int distance, @@ -4031,7 +4031,7 @@ climb_pit(void) } } -static void +staticfn void dofiretrap( struct obj *box) /* null for floor trap */ { @@ -4115,7 +4115,7 @@ dofiretrap( melt_ice(u.ux, u.uy, (char *) 0); } -static void +staticfn void domagictrap(void) { int fate = rnd(20); @@ -4450,7 +4450,7 @@ acid_damage(struct obj *obj) erode_obj(obj, (char *) 0, ERODE_CORRODE, EF_GREASE | EF_VERBOSE); } -static void +staticfn void pot_acid_damage( struct obj *obj, boolean in_invent, @@ -4698,7 +4698,7 @@ water_damage_chain( * Returns TRUE if disrobing made player unencumbered enough to * crawl out of the current predicament. */ -static boolean +staticfn boolean emergency_disrobe(boolean *lostsome) { int invc = inv_cnt(TRUE); @@ -5086,7 +5086,7 @@ could_untrap(boolean verbosely, boolean check_floor) /* Probability of disabling a trap. Helge Hafting; Returns 0 for success, non-0 for failure. */ -static int +staticfn int untrap_prob( struct trap *ttmp) /* must not be Null */ { @@ -5172,7 +5172,7 @@ cnv_trap_obj( } /* while attempting to disarm an adjacent trap, we've fallen into it */ -static void +staticfn void move_into_trap(struct trap *ttmp) { int bc = 0; @@ -5211,7 +5211,7 @@ move_into_trap(struct trap *ttmp) } /* 0: doesn't even try; 1: tries and fails; 2: succeeds */ -static int +staticfn int try_disarm( struct trap *ttmp, boolean force_failure) @@ -5300,7 +5300,7 @@ try_disarm( return 2; } -static void +staticfn void reward_untrap(struct trap *ttmp, struct monst *mtmp) { if (!ttmp->madeby_u) { @@ -5323,7 +5323,7 @@ reward_untrap(struct trap *ttmp, struct monst *mtmp) /* Help a monster out of a bear trap or web, or if no monster is present, disarm a bear trap or destroy a web. Helge Hafting */ -static int +staticfn int disarm_holdingtrap(struct trap *ttmp) { struct monst *mtmp; @@ -5364,7 +5364,7 @@ disarm_holdingtrap(struct trap *ttmp) return 1; } -static int +staticfn int disarm_landmine(struct trap *ttmp) /* Helge Hafting */ { int fails = try_disarm(ttmp, FALSE); @@ -5377,7 +5377,7 @@ disarm_landmine(struct trap *ttmp) /* Helge Hafting */ } /* getobj callback for object to disarm a squeaky board with */ -static int +staticfn int unsqueak_ok(struct obj *obj) { if (!obj) @@ -5400,7 +5400,7 @@ unsqueak_ok(struct obj *obj) } /* it may not make much sense to use grease on floor boards, but so what? */ -static int +staticfn int disarm_squeaky_board(struct trap *ttmp) { struct obj *obj; @@ -5434,7 +5434,7 @@ disarm_squeaky_board(struct trap *ttmp) } /* removes traps that shoot arrows, darts, etc. */ -static int +staticfn int disarm_shooting_trap(struct trap *ttmp, int otyp) { int fails = try_disarm(ttmp, FALSE); @@ -5447,7 +5447,7 @@ disarm_shooting_trap(struct trap *ttmp, int otyp) } /* trying to #untrap a monster from a pit; is the weight too heavy? */ -static int +staticfn int try_lift( struct monst *mtmp, /* trapped monster */ struct trap *ttmp, /* pit, possibly made by hero, or spiked pit */ @@ -5470,7 +5470,7 @@ try_lift( } /* Help trapped monster (out of a (spiked) pit) */ -static int +staticfn int help_monster_out( struct monst *mtmp, struct trap *ttmp) @@ -5565,7 +5565,7 @@ help_monster_out( } /* check a particular container for a trap and optionally disarm it */ -static void +staticfn void untrap_box( struct obj *box, boolean force, @@ -6304,7 +6304,7 @@ conjoined_pits( return FALSE; } -static void +staticfn void clear_conjoined_pits(struct trap *trap) { int diridx, adjidx; @@ -6328,7 +6328,7 @@ clear_conjoined_pits(struct trap *trap) } } -static boolean +staticfn boolean adj_nonconjoined_pit(struct trap *adjtrap) { struct trap *trap_with_u = t_at(u.ux0, u.uy0); @@ -6346,7 +6346,7 @@ adj_nonconjoined_pit(struct trap *adjtrap) * Mark all neighboring pits as conjoined pits. * (currently not called from anywhere) */ -static void +staticfn void join_adjacent_pits(struct trap *trap) { struct trap *t; @@ -6435,7 +6435,7 @@ b_trapped(const char *item, int bodypart) } /* Monster is hit by trap. */ -static boolean +staticfn boolean thitm( int tlev, /* missile's attack level */ struct monst *mon, /* target */ @@ -6777,7 +6777,7 @@ sokoban_guilt(void) } /* called when a trap has been deleted or had its ttyp replaced */ -static void +staticfn void maybe_finish_sokoban(void) { struct trap *t; diff --git a/src/u_init.c b/src/u_init.c index 8167213dc..910e32eea 100644 --- a/src/u_init.c +++ b/src/u_init.c @@ -13,19 +13,19 @@ struct trobj { Bitfield(trbless, 2); }; -static struct obj *ini_inv_mkobj_filter(int, boolean); -static short ini_inv_obj_substitution(struct trobj *, +staticfn struct obj *ini_inv_mkobj_filter(int, boolean); +staticfn short ini_inv_obj_substitution(struct trobj *, struct obj *) NONNULLPTRS; -static void ini_inv_adjust_obj(struct trobj *, +staticfn void ini_inv_adjust_obj(struct trobj *, struct obj *) NONNULLPTRS; -static void ini_inv_use_obj(struct obj *) NONNULLARG1; -static void ini_inv(struct trobj *) NONNULLARG1; -static void knows_object(int); -static void knows_class(char); -static void u_init_role(void); -static void u_init_race(void); -static void u_init_carry_attr_boost(void); -static boolean restricted_spell_discipline(int); +staticfn void ini_inv_use_obj(struct obj *) NONNULLARG1; +staticfn void ini_inv(struct trobj *) NONNULLARG1; +staticfn void knows_object(int); +staticfn void knows_class(char); +staticfn void u_init_role(void); +staticfn void u_init_race(void); +staticfn void u_init_carry_attr_boost(void); +staticfn boolean restricted_spell_discipline(int); #define UNDEF_TYP 0 #define UNDEF_SPE '\177' @@ -558,7 +558,7 @@ static const struct def_skill Skill_W[] = { { P_NONE, 0 } }; -static void +staticfn void knows_object(int obj) { discover_object(obj, TRUE, FALSE); @@ -567,7 +567,7 @@ knows_object(int obj) /* Know ordinary (non-magical) objects of a certain class, like all gems except the loadstone and luckstone. */ -static void +staticfn void knows_class(char sym) { struct obj odummy, *o; @@ -609,7 +609,7 @@ knows_class(char sym) } /* role-specific initializations */ -static void +staticfn void u_init_role(void) { int i; @@ -766,7 +766,7 @@ u_init_role(void) } /* race-specific initializations */ -static void +staticfn void u_init_race(void) { switch (Race_switch) { @@ -839,7 +839,7 @@ u_init_race(void) } /* boost STR and CON until hero can carry inventory */ -static void +staticfn void u_init_carry_attr_boost(void) { /* make sure you can carry all you have - especially for Tourists */ @@ -968,7 +968,7 @@ u_init(void) } /* skills aren't initialized, so we use the role-specific skill lists */ -static boolean +staticfn boolean restricted_spell_discipline(int otyp) { const struct def_skill *skills; @@ -1028,7 +1028,7 @@ restricted_spell_discipline(int otyp) } /* create random object of certain class, filtering out too powerful items */ -static struct obj * +staticfn struct obj * ini_inv_mkobj_filter(int oclass, boolean got_level1_spellbook) { struct obj *obj; @@ -1092,7 +1092,7 @@ ini_inv_mkobj_filter(int oclass, boolean got_level1_spellbook) /* substitute object with something else based on race. only changes otyp, and returns it. */ -static short +staticfn short ini_inv_obj_substitution(struct trobj *trop, struct obj *obj) { if (gu.urace.mnum != PM_HUMAN) { @@ -1116,7 +1116,7 @@ ini_inv_obj_substitution(struct trobj *trop, struct obj *obj) return obj->otyp; } -static void +staticfn void ini_inv_adjust_obj(struct trobj *trop, struct obj *obj) { if (trop->trclass == COIN_CLASS) { @@ -1159,7 +1159,7 @@ ini_inv_adjust_obj(struct trobj *trop, struct obj *obj) } /* initial inventory: wear, wield, learn the spell/obj */ -static void +staticfn void ini_inv_use_obj(struct obj *obj) { /* Make the type known if necessary */ @@ -1206,7 +1206,7 @@ ini_inv_use_obj(struct obj *obj) initialspell(obj); } -static void +staticfn void ini_inv(struct trobj *trop) { struct obj *obj; diff --git a/src/uhitm.c b/src/uhitm.c index 6932d12af..2fdb59841 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -8,66 +8,67 @@ static const char brief_feeling[] = "have a %s feeling for a moment, then it passes."; -static boolean mhitm_mgc_atk_negated(struct monst *, struct monst *, +staticfn boolean mhitm_mgc_atk_negated(struct monst *, struct monst *, boolean) NONNULLPTRS; -static boolean known_hitum(struct monst *, struct obj *, int *, int, int, +staticfn boolean known_hitum(struct monst *, struct obj *, int *, int, int, struct attack *, int) NONNULLARG13; -static boolean theft_petrifies(struct obj *) NONNULLARG1; -static void steal_it(struct monst *, struct attack *) NONNULLARG1; +staticfn boolean theft_petrifies(struct obj *) NONNULLARG1; +staticfn void steal_it(struct monst *, struct attack *) NONNULLARG1; /* hitum_cleave() has contradictory information. There's a comment * beside the 1st arg 'target' stating non-null, but later on there * is a test for 'target' being null */ -static boolean hitum_cleave(struct monst *, struct attack *) NO_NNARGS; -static boolean double_punch(void); -static boolean hitum(struct monst *, struct attack *) NONNULLARG1; -static void hmon_hitmon_barehands(struct _hitmon_data *, - struct monst *) NONNULLARG12; -static void hmon_hitmon_weapon_ranged(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG123; -static void hmon_hitmon_weapon_melee(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG123; -static void hmon_hitmon_weapon(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG123; -static void hmon_hitmon_potion(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG123; -static void hmon_hitmon_misc_obj(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG123; -static void hmon_hitmon_do_hit(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG12; -static void hmon_hitmon_dmg_recalc(struct _hitmon_data *, struct obj *); -static void hmon_hitmon_poison(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG123; -static void hmon_hitmon_jousting(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG123; -static void hmon_hitmon_stagger(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG12; -static void hmon_hitmon_pet(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG12; -static void hmon_hitmon_splitmon(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG12; -static void hmon_hitmon_msg_hit(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG12; -static void hmon_hitmon_msg_silver(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG12; -static void hmon_hitmon_msg_lightobj(struct _hitmon_data *, struct monst *, - struct obj *) NONNULLARG12; -static boolean hmon_hitmon(struct monst *, struct obj *, int, int) NONNULLARG1; -static int joust(struct monst *, struct obj *) NONNULLARG12; -static void demonpet(void); -static boolean m_slips_free(struct monst *, struct attack *) NONNULLPTRS; -static void start_engulf(struct monst *) NONNULLARG1; -static void end_engulf(void); -static int gulpum(struct monst *, struct attack *) NONNULLPTRS; -static boolean hmonas(struct monst *) NONNULLARG1; -static void nohandglow(struct monst *) NONNULLARG1; -static boolean mhurtle_to_doom(struct monst *, int, - struct permonst **) NONNULLARG13; -static void first_weapon_hit(struct obj *) NONNULLARG1; -static boolean shade_aware(struct obj *) NO_NNARGS; +staticfn boolean hitum_cleave(struct monst *, struct attack *) NO_NNARGS; +staticfn boolean double_punch(void); +staticfn boolean hitum(struct monst *, struct attack *) NONNULLARG1; +staticfn void hmon_hitmon_barehands(struct _hitmon_data *, + struct monst *) NONNULLARG12; +staticfn void hmon_hitmon_weapon_ranged(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG123; +staticfn void hmon_hitmon_weapon_melee(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG123; +staticfn void hmon_hitmon_weapon(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG123; +staticfn void hmon_hitmon_potion(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG123; +staticfn void hmon_hitmon_misc_obj(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG123; +staticfn void hmon_hitmon_do_hit(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG12; +staticfn void hmon_hitmon_dmg_recalc(struct _hitmon_data *, struct obj *); +staticfn void hmon_hitmon_poison(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG123; +staticfn void hmon_hitmon_jousting(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG123; +staticfn void hmon_hitmon_stagger(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG12; +staticfn void hmon_hitmon_pet(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG12; +staticfn void hmon_hitmon_splitmon(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG12; +staticfn void hmon_hitmon_msg_hit(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG12; +staticfn void hmon_hitmon_msg_silver(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG12; +staticfn void hmon_hitmon_msg_lightobj(struct _hitmon_data *, struct monst *, + struct obj *) NONNULLARG12; +staticfn boolean hmon_hitmon(struct monst *, struct obj *, int, int) + NONNULLARG1; +staticfn int joust(struct monst *, struct obj *) NONNULLARG12; +staticfn void demonpet(void); +staticfn boolean m_slips_free(struct monst *, struct attack *) NONNULLPTRS; +staticfn void start_engulf(struct monst *) NONNULLARG1; +staticfn void end_engulf(void); +staticfn int gulpum(struct monst *, struct attack *) NONNULLPTRS; +staticfn boolean hmonas(struct monst *) NONNULLARG1; +staticfn void nohandglow(struct monst *) NONNULLARG1; +staticfn boolean mhurtle_to_doom(struct monst *, int, + struct permonst **) NONNULLARG13; +staticfn void first_weapon_hit(struct obj *) NONNULLARG1; +staticfn boolean shade_aware(struct obj *) NO_NNARGS; #define PROJECTILE(obj) ((obj) && is_ammo(obj)) -static boolean +staticfn boolean mhitm_mgc_atk_negated( struct monst *magr, struct monst *mdef, boolean verbosely) /* give mesg if magical cancellation prevents damage */ @@ -578,7 +579,7 @@ do_attack(struct monst *mtmp) } /* really hit target monster; returns TRUE if it still lives */ -static boolean +staticfn boolean known_hitum( struct monst *mon, /* target */ struct obj *weapon, /* uwep or uswapwep */ @@ -642,7 +643,7 @@ known_hitum( /* hit the monster next to you and the monsters to the left and right of it; return False if the primary target is killed, True otherwise */ -static boolean +staticfn boolean hitum_cleave( struct monst *target, /* non-Null; forcefight at nothing doesn't cleave +*/ struct attack *uattk) /*+ but we don't enforce that here; Null works ok */ @@ -727,7 +728,7 @@ hitum_cleave( /* returns True if hero is fighting without a weapon and without a shield and has sufficient skill in bare-handed/martial arts to attack twice */ -static boolean +staticfn boolean double_punch(void) { /* note: P_BARE_HANDED_COMBAT and P_MARTIAL_ARTS are equivalent */ @@ -749,7 +750,7 @@ double_punch(void) } /* hit target monster; returns TRUE if it still lives */ -static boolean +staticfn boolean hitum(struct monst *mon, struct attack *uattk) { boolean malive, wep_was_destroyed = FALSE; @@ -829,7 +830,7 @@ hmon(struct monst *mon, } /* hero hits monster bare handed */ -static void +staticfn void hmon_hitmon_barehands(struct _hitmon_data *hmd, struct monst *mon) { long spcdmgflg, silverhit = 0L; /* worn masks */ @@ -876,7 +877,7 @@ hmon_hitmon_barehands(struct _hitmon_data *hmd, struct monst *mon) hmd->silvermsg = TRUE; } -static void +staticfn void hmon_hitmon_weapon_ranged( struct _hitmon_data *hmd, struct monst *mon, @@ -911,7 +912,7 @@ hmon_hitmon_weapon_ranged( } } -static void +staticfn void hmon_hitmon_weapon_melee( struct _hitmon_data *hmd, struct monst *mon, @@ -1023,7 +1024,7 @@ hmon_hitmon_weapon_melee( } } -static void +staticfn void hmon_hitmon_weapon( struct _hitmon_data *hmd, struct monst *mon, @@ -1047,7 +1048,7 @@ hmon_hitmon_weapon( } } -static void +staticfn void hmon_hitmon_potion( struct _hitmon_data *hmd, struct monst *mon, @@ -1071,7 +1072,7 @@ hmon_hitmon_potion( hmd->dmg = (hmd->mdat == &mons[PM_SHADE]) ? 0 : 1; } -static void +staticfn void hmon_hitmon_misc_obj( struct _hitmon_data *hmd, struct monst *mon, @@ -1323,7 +1324,7 @@ hmon_hitmon_misc_obj( } /* do the actual hitting monster with obj/fists */ -static void +staticfn void hmon_hitmon_do_hit( struct _hitmon_data *hmd, struct monst *mon, @@ -1372,7 +1373,7 @@ hmon_hitmon_do_hit( } } -static void +staticfn void hmon_hitmon_dmg_recalc(struct _hitmon_data *hmd, struct obj *obj) { int dmgbonus = 0, strbonus, absbonus; @@ -1446,7 +1447,7 @@ hmon_hitmon_dmg_recalc(struct _hitmon_data *hmd, struct obj *obj) hmd->dmg = 1; } -static void +staticfn void hmon_hitmon_poison( struct _hitmon_data *hmd, struct monst *mon, @@ -1477,7 +1478,7 @@ hmon_hitmon_poison( hmd->poiskilled = TRUE; } -static void +staticfn void hmon_hitmon_jousting( struct _hitmon_data *hmd, struct monst *mon, /* target */ @@ -1506,7 +1507,7 @@ hmon_hitmon_jousting( hmd->hittxt = TRUE; } -static void +staticfn void hmon_hitmon_stagger( struct _hitmon_data *hmd, struct monst *mon, @@ -1524,7 +1525,7 @@ hmon_hitmon_stagger( } } -static void +staticfn void hmon_hitmon_pet( struct _hitmon_data *hmd, struct monst *mon, @@ -1540,7 +1541,7 @@ hmon_hitmon_pet( } } -static void +staticfn void hmon_hitmon_splitmon( struct _hitmon_data *hmd, struct monst *mon, @@ -1573,7 +1574,7 @@ hmon_hitmon_splitmon( } } -static void +staticfn void hmon_hitmon_msg_hit( struct _hitmon_data *hmd, struct monst *mon, @@ -1599,7 +1600,7 @@ hmon_hitmon_msg_hit( } } -static void +staticfn void hmon_hitmon_msg_silver( struct _hitmon_data *hmd, struct monst *mon, @@ -1638,7 +1639,7 @@ hmon_hitmon_msg_silver( RESTORE_WARNING_FORMAT_NONLITERAL } -static void +staticfn void hmon_hitmon_msg_lightobj( struct _hitmon_data *hmd, struct monst *mon, @@ -1690,7 +1691,7 @@ hmon_hitmon_msg_lightobj( */ /* guts of hmon(); returns True if 'mon' survives */ -static boolean +staticfn boolean hmon_hitmon( struct monst *mon, struct obj *obj, @@ -1849,7 +1850,7 @@ hmon_hitmon( /* joust or martial arts punch is knocking the target back; that might kill 'mon' (via trap) before known_hitum() has a chance to do so; return True if we kill mon, False otherwise */ -static boolean +staticfn boolean mhurtle_to_doom( struct monst *mon, /* target monster */ int tmp, /* amount of pending damage */ @@ -1870,7 +1871,7 @@ mhurtle_to_doom( /* gamelog version of "you've broken never-hit-with-wielded-weapon conduct; the conduct is tracked in known_hitum(); we're called by hmon_hitmon() */ -static void +staticfn void first_weapon_hit(struct obj *weapon) { char buf[BUFSZ]; @@ -1899,7 +1900,7 @@ first_weapon_hit(struct obj *weapon) "hit with a wielded weapon (%s) for the first time", buf); } -static boolean +staticfn boolean shade_aware(struct obj *obj) { if (!obj) @@ -1963,7 +1964,7 @@ shade_miss( /* check whether slippery clothing protects from hug or wrap attack */ /* [currently assumes that you are the attacker] */ -static boolean +staticfn boolean m_slips_free(struct monst *mdef, struct attack *mattk) { struct obj *obj; @@ -2005,7 +2006,7 @@ m_slips_free(struct monst *mdef, struct attack *mattk) /* used when hitting a monster with a lance while mounted; 1: joust hit; 0: ordinary hit; -1: joust but break lance */ -static int +staticfn int joust(struct monst *mon, /* target */ struct obj *obj) /* weapon */ { @@ -2035,7 +2036,7 @@ joust(struct monst *mon, /* target */ } /* send in a demon pet for the hero; exercise wisdom */ -static void +staticfn void demonpet(void) { int i; @@ -2050,7 +2051,7 @@ demonpet(void) exercise(A_WIS, TRUE); } -static boolean +staticfn boolean theft_petrifies(struct obj *otmp) { if (uarmg || otmp->otyp != CORPSE @@ -2076,7 +2077,7 @@ theft_petrifies(struct obj *otmp) * If the target is wearing body armor, take all of its possessions; * otherwise, take one object. [Is this really the behavior we want?] */ -static void +staticfn void steal_it(struct monst *mdef, struct attack *mattk) { struct obj *otmp, *gold = 0, *ustealo, **minvent_ptr; @@ -3723,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; @@ -3830,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; @@ -4783,7 +4784,7 @@ explum(struct monst *mdef, struct attack *mattk) return M_ATTK_HIT; } -static void +staticfn void start_engulf(struct monst *mdef) { boolean u_digest = digests(gy.youmonst.data), @@ -4801,7 +4802,7 @@ start_engulf(struct monst *mdef) nh_delay_output(); } -static void +staticfn void end_engulf(void) { if (!Invisible) { @@ -4810,7 +4811,7 @@ end_engulf(void) } } -static int +staticfn int gulpum(struct monst *mdef, struct attack *mattk) { static char msgbuf[BUFSZ]; /* for gn.nomovemsg */ @@ -5244,7 +5245,7 @@ mhitm_knockback( } /* attack monster as a monster; returns True if mon survives */ -static boolean +staticfn boolean hmonas(struct monst *mon) { struct attack *mattk, alt_attk; @@ -6050,7 +6051,7 @@ stumble_onto_mimic(struct monst *mtmp) RESTORE_WARNING_FORMAT_NONLITERAL -static void +staticfn void nohandglow(struct monst *mon) { char *hands; diff --git a/src/utf8map.c b/src/utf8map.c index 1dcd8fc21..8ab54129e 100644 --- a/src/utf8map.c +++ b/src/utf8map.c @@ -28,7 +28,7 @@ struct find_struct { enum reserved_activities restype; genericptr_t reserved; }; -const struct find_struct zero_find = { 0 }; +static const struct find_struct zero_find = { 0 }; struct glyphid_cache_t { int glyphnum; char *id; @@ -36,25 +36,26 @@ struct glyphid_cache_t { static struct glyphid_cache_t *glyphid_cache; static unsigned glyphid_cache_lsize; static size_t glyphid_cache_size; -struct find_struct glyphcache_find, to_custom_symbol_find; -static void init_glyph_cache(void); -static void add_glyph_to_cache(int glyphnum, const char *id); -static int find_glyph_in_cache(const char *id); -static uint32 glyph_hash(const char *id); -static void to_custom_symset_entry_callback(int glyph, +static struct find_struct glyphcache_find, to_custom_symbol_find; + +staticfn void init_glyph_cache(void); +staticfn void add_glyph_to_cache(int glyphnum, const char *id); +staticfn int find_glyph_in_cache(const char *id); +staticfn uint32 glyph_hash(const char *id); +staticfn void to_custom_symset_entry_callback(int glyph, struct find_struct *findwhat); -static int unicode_val(const char *cp); -static int parse_id(const char *id, struct find_struct *findwhat); -static int glyph_find_core(const char *id, struct find_struct *findwhat); -static char *fix_glyphname(char *str); -static int32_t rgbstr_to_int32(const char *rgbstr); +staticfn int unicode_val(const char *cp); +staticfn int parse_id(const char *id, struct find_struct *findwhat); +staticfn int glyph_find_core(const char *id, struct find_struct *findwhat); +staticfn char *fix_glyphname(char *str); +staticfn int32_t rgbstr_to_int32(const char *rgbstr); boolean closest_color(uint32_t lcolor, uint32_t *closecolor, int *clridx); -static int color_distance(uint32_t, uint32_t); -static boolean onlyhexdigits(const char *buf); +staticfn int color_distance(uint32_t, uint32_t); +staticfn boolean onlyhexdigits(const char *buf); static const long nonzero_black = CLR_BLACK | NH_BASIC_COLOR; -static void +staticfn void to_custom_symset_entry_callback(int glyph, struct find_struct *findwhat) { #ifdef NO_PARSING_SYMSET @@ -146,7 +147,7 @@ glyphrep_to_custom_map_entries(const char *op, int *glyphptr) static const char hex[] = "00112233445566778899aAbBcCdDeEfF"; -static boolean +staticfn boolean onlyhexdigits(const char *buf) { const char *dp = buf; @@ -158,7 +159,7 @@ onlyhexdigits(const char *buf) return TRUE; } -static int32_t +staticfn int32_t rgbstr_to_int32(const char *rgbstr) { int r, g, b, milestone = 0; @@ -214,7 +215,7 @@ rgbstr_to_int32(const char *rgbstr) return -1; } -static char * +staticfn char * fix_glyphname(char *str) { char *c; @@ -230,7 +231,7 @@ fix_glyphname(char *str) return str; } -static int +staticfn int unicode_val(const char *cp) { const char *dp; @@ -278,7 +279,7 @@ set_map_u(glyph_map *gmap, uint32 utf32ch, const uint8 *utf8str, long ucolor) } -static int +staticfn int glyph_find_core(const char *id, struct find_struct *findwhat) { int glyph; @@ -374,7 +375,7 @@ void fill_glyphid_cache(void) * to traverse the entire table. */ -static void +staticfn void init_glyph_cache(void) { size_t glyph; @@ -411,7 +412,7 @@ void free_glyphid_cache(void) glyphid_cache = (struct glyphid_cache_t *) 0; } -static void +staticfn void add_glyph_to_cache(int glyphnum, const char *id) { uint32 hash = glyph_hash(id); @@ -434,7 +435,7 @@ add_glyph_to_cache(int glyphnum, const char *id) panic("glyphid_cache full"); } -static int +staticfn int find_glyph_in_cache(const char *id) { uint32 hash = glyph_hash(id); @@ -457,7 +458,7 @@ find_glyph_in_cache(const char *id) return -1; } -static uint32 +staticfn uint32 glyph_hash(const char *id) { uint32 hash = 0; @@ -669,7 +670,7 @@ add_custom_urep_entry( return 1; } -static int +staticfn int parse_id(const char *id, struct find_struct *findwhat) { FILE *fp = (FILE *) 0; @@ -1107,7 +1108,7 @@ static struct { * https://www.compuphase.com/cmetric.htm **/ -static int +staticfn int color_distance(uint32_t rgb1, uint32_t rgb2) { int r1 = (rgb1 >> 16) & 0xFF; @@ -1165,12 +1166,12 @@ static struct { #undef PCHAR_TILES }; -static int glyphs_to_unicode(const char *id, const char *unicode_val, +staticfn int glyphs_to_unicode(const char *id, const char *unicode_val, long clr); -static int find_glyphs(const char *id); -static void just_find_callback(int glyph, struct find_struct *findwhat); -static void to_unicode_callback(int glyph, struct find_struct *findwhat); -static struct customization_detail *find_display_urep_customization( +staticfn int find_glyphs(const char *id); +staticfn void just_find_callback(int glyph, struct find_struct *findwhat); +staticfn void to_unicode_callback(int glyph, struct find_struct *findwhat); +staticfn struct customization_detail *find_display_urep_customization( const char *customization_name, int glyphidx, enum graphics_sets which_set); @@ -1187,13 +1188,13 @@ test_glyphnames(void) reslt = glyphs_to_unicode("S_dog", "U+130E6", 0L); } -static void +staticfn void just_find_callback(int glyph UNUSED, struct find_struct *findwhat UNUSED) { return; } -static int +staticfn int find_glyphs(const char *id) { struct find_struct find_only = zero_find; @@ -1203,7 +1204,7 @@ find_glyphs(const char *id) return glyph_find_core(id, &find_only); } -static void +staticfn void to_unicode_callback(int glyph UNUSED, struct find_struct *findwhat) { int uval; diff --git a/src/vault.c b/src/vault.c index c2b279738..667b657df 100644 --- a/src/vault.c +++ b/src/vault.c @@ -5,18 +5,19 @@ #include "hack.h" -static boolean clear_fcorr(struct monst *, boolean) NONNULLARG1; -static void blackout(coordxy, coordxy); -static void restfakecorr(struct monst *) NONNULLARG1; -static void parkguard(struct monst *) NONNULLARG1; -static boolean in_fcorridor(struct monst *, coordxy, coordxy) NONNULLARG1; -static boolean find_guard_dest(struct monst *, coordxy *, coordxy *) NONNULLARG23; -static void move_gold(struct obj *, int) NONNULLARG1; -static void wallify_vault(struct monst *) NONNULLARG1; -static void gd_mv_monaway(struct monst *, int, int) NONNULLARG1; -static void gd_pick_corridor_gold(struct monst *, int, int) NONNULLARG1; -static int gd_move_cleanup(struct monst *, boolean, boolean) NONNULLARG1; -static void gd_letknow(struct monst *) NONNULLARG1; +staticfn boolean clear_fcorr(struct monst *, boolean) NONNULLARG1; +staticfn void blackout(coordxy, coordxy); +staticfn void restfakecorr(struct monst *) NONNULLARG1; +staticfn void parkguard(struct monst *) NONNULLARG1; +staticfn boolean in_fcorridor(struct monst *, coordxy, coordxy) NONNULLARG1; +staticfn boolean find_guard_dest(struct monst *, coordxy *, coordxy *) + NONNULLARG23; +staticfn void move_gold(struct obj *, int) NONNULLARG1; +staticfn void wallify_vault(struct monst *) NONNULLARG1; +staticfn void gd_mv_monaway(struct monst *, int, int) NONNULLARG1; +staticfn void gd_pick_corridor_gold(struct monst *, int, int) NONNULLARG1; +staticfn int gd_move_cleanup(struct monst *, boolean, boolean) NONNULLARG1; +staticfn void gd_letknow(struct monst *) NONNULLARG1; void newegd(struct monst *mtmp) @@ -42,7 +43,7 @@ free_egd(struct monst *mtmp) /* try to remove the temporary corridor (from vault to rest of map) being maintained by guard 'grd'; if guard is still in it, removal will fail, to be tried again later */ -static boolean +staticfn boolean clear_fcorr(struct monst *grd, boolean forceshow) { coordxy fcx, fcy, fcbeg; @@ -118,7 +119,7 @@ clear_fcorr(struct monst *grd, boolean forceshow) spots to unlit; if player used scroll/wand/spell of light while inside the corridor, we don't want the light to reappear if/when a new tunnel goes through the same area */ -static void +staticfn void blackout(coordxy x, coordxy y) { struct rm *lev; @@ -139,7 +140,7 @@ blackout(coordxy x, coordxy y) } } -static void +staticfn void restfakecorr(struct monst *grd) { /* it seems you left the corridor - let the guard disappear */ @@ -150,7 +151,7 @@ restfakecorr(struct monst *grd) } /* move guard--dead to alive--to <0,0> until temporary corridor is removed */ -static void +staticfn void parkguard(struct monst *grd) { /* either guard is dead or will now be treated as if so; @@ -187,7 +188,7 @@ grddead(struct monst *grd) return dispose; } -static boolean +staticfn boolean in_fcorridor(struct monst *grd, coordxy x, coordxy y) { int fci; @@ -276,7 +277,7 @@ uleftvault(struct monst *grd) } } -static boolean +staticfn boolean find_guard_dest(struct monst *guard, coordxy *rx, coordxy *ry) { coordxy x, y, dd, lx, ly; @@ -615,7 +616,7 @@ invault(void) } } -static void +staticfn void move_gold(struct obj *gold, int vroom) { coordxy nx, ny; @@ -629,7 +630,7 @@ move_gold(struct obj *gold, int vroom) newsym(nx, ny); } -static void +staticfn void wallify_vault(struct monst *grd) { int typ; @@ -716,7 +717,7 @@ wallify_vault(struct monst *grd) } } -static void +staticfn void gd_mv_monaway(struct monst *grd, int nx, int ny) { struct monst *mtmp = m_at(nx, ny); @@ -733,7 +734,7 @@ gd_mv_monaway(struct monst *grd, int nx, int ny) /* have guard pick gold off the floor, possibly moving to the gold's position before message and back to his current spot after */ -static void +staticfn void gd_pick_corridor_gold(struct monst *grd, int goldx, int goldy) { struct obj *gold; @@ -817,7 +818,7 @@ gd_pick_corridor_gold(struct monst *grd, int goldx, int goldy) /* return 1: guard moved, -2: died */ -static int +staticfn int gd_move_cleanup( struct monst *grd, boolean semi_dead, @@ -850,7 +851,7 @@ gd_move_cleanup( return -2; } -static void +staticfn void gd_letknow(struct monst *grd) { if (!cansee(grd->mx, grd->my) || !mon_visible(grd)) diff --git a/src/version.c b/src/version.c index c25785069..33eb254bf 100644 --- a/src/version.c +++ b/src/version.c @@ -10,7 +10,7 @@ #define OPTIONS_AT_RUNTIME #endif -static void insert_rtoption(char *) NONNULLARG1; +staticfn void insert_rtoption(char *) NONNULLARG1; /* fill buffer with short version (so caller can avoid including date.h) * buf cannot be NULL */ @@ -340,7 +340,7 @@ static struct rt_opt { * it depends which of several object files got linked into the * game image, so we insert those options here. */ -static void +staticfn void insert_rtoption(char *buf) { int i; diff --git a/src/vision.c b/src/vision.c index 64b1aaea1..b7caaba2b 100644 --- a/src/vision.c +++ b/src/vision.c @@ -22,7 +22,8 @@ * ....X +4 * @...X +4 * - */ + * Externally referenced from light.c +*/ const coordxy circle_data[] = { /* 0*/ 0, /* 1*/ 1, 1, @@ -86,14 +87,14 @@ static coordxy left_ptrs[ROWNO][COLNO]; /* LOS algorithm helpers */ static coordxy right_ptrs[ROWNO][COLNO]; /* Forward declarations. */ -static void fill_point(int, int); -static void dig_point(int, int); -static void view_init(void); -static void view_from(coordxy, coordxy, seenV **, coordxy *, coordxy *, int, +staticfn void fill_point(int, int); +staticfn void dig_point(int, int); +staticfn void view_init(void); +staticfn void view_from(coordxy, coordxy, seenV **, coordxy *, coordxy *, int, void (*)(coordxy, coordxy, genericptr_t), genericptr_t); -static void get_unused_cs(seenV ***, coordxy **, coordxy **); -static void rogue_vision(seenV **, coordxy *, coordxy *); +staticfn void get_unused_cs(seenV ***, coordxy **, coordxy **); +staticfn void rogue_vision(seenV **, coordxy *, coordxy *); /* Macro definitions that I can't find anywhere. */ #define sign(z) ((z) < 0 ? -1 : ((z) ? 1 : 0)) @@ -260,7 +261,7 @@ vision_reset(void) * Called from vision_recalc() and at least one light routine. Get pointers * to the unused vision work area. */ -static void +staticfn void get_unused_cs(seenV ***rows, coordxy **rmin, coordxy **rmax) { int row; @@ -300,7 +301,7 @@ get_unused_cs(seenV ***rows, coordxy **rmin, coordxy **rmax) * We set the in_sight bit here as well to escape a bug that shows up * due to the one-sided lit wall hack. */ -static void +staticfn void rogue_vision(seenV **next, coordxy *rmin, coordxy *rmax) { int rnum = levl[u.ux][u.uy].roomno - ROOMOFFSET; /* no SHARED... */ @@ -357,7 +358,7 @@ rogue_vision(seenV **next, coordxy *rmin, coordxy *rmax) #ifdef EXTEND_SPINE -static int new_angle(struct rm *, unsigned char *, int, int); +staticfn int new_angle(struct rm *, unsigned char *, int, int); /* * new_angle() * @@ -400,7 +401,7 @@ static int new_angle(struct rm *, unsigned char *, int, int); * many exceptions. I may have to bite the bullet and do more * checks. - Dean 2/11/93 */ -static int +staticfn int new_angle(struct rm *lev, unsigned char *sv, int row, int col) { int res = *sv; @@ -933,7 +934,7 @@ unblock_point(int x, int y) * This means that a right-edge (a blocked spot that has an open * spot on its right) will point to itself. */ -static void +staticfn void dig_point(int row, int col) { int i; @@ -1017,7 +1018,7 @@ dig_point(int row, int col) } } -static void +staticfn void fill_point(int row, int col) { int i; @@ -1372,10 +1373,10 @@ static genericptr_t varg; #else /* !MACRO_CPATH -- quadrants are really functions */ -static int _q1_path(int, int, int, int); -static int _q2_path(int, int, int, int); -static int _q3_path(int, int, int, int); -static int _q4_path(int, int, int, int); +staticfn int _q1_path(int, int, int, int); +staticfn int _q2_path(int, int, int, int); +staticfn int _q3_path(int, int, int, int); +staticfn int _q4_path(int, int, int, int); #define q1_path(sy, sx, y, x, dummy) result = _q1_path(sy, sx, y, x) #define q2_path(sy, sx, y, x, dummy) result = _q2_path(sy, sx, y, x) @@ -1385,7 +1386,7 @@ static int _q4_path(int, int, int, int); /* * Quadrant I (step < 0). */ -static int +staticfn int _q1_path(int scol, int srow, int y2, int x2) { int dx, dy; @@ -1432,7 +1433,7 @@ _q1_path(int scol, int srow, int y2, int x2) /* * Quadrant IV (step > 0). */ -static int +staticfn int _q4_path(int scol, int srow, int y2, int x2) { int dx, dy; @@ -1479,7 +1480,7 @@ _q4_path(int scol, int srow, int y2, int x2) /* * Quadrant II (step < 0). */ -static int +staticfn int _q2_path(int scol, int srow, int y2, int x2) { int dx, dy; @@ -1526,7 +1527,7 @@ _q2_path(int scol, int srow, int y2, int x2) /* * Quadrant III (step > 0). */ -static int +staticfn int _q3_path(int scol, int srow, int y2, int x2) { int dx, dy; @@ -1613,11 +1614,11 @@ clear_path(int col1, int row1, int col2, int row2) /* * Defines local to Algorithm C. */ -static void right_side(int, int, int, const coordxy *); -static void left_side(int, int, int, const coordxy *); +staticfn void right_side(int, int, int, const coordxy *); +staticfn void left_side(int, int, int, const coordxy *); /* Initialize algorithm C (nothing). */ -static void +staticfn void view_init(void) { } @@ -1632,7 +1633,7 @@ view_init(void) * right_mark last (right side) visible spot on prev row * limits points at range limit for current row, or NULL */ -static void +staticfn void right_side( int row, int left, @@ -1824,7 +1825,7 @@ right_side( * This routine is the mirror image of right_side(). See right_side() for * extensive comments. */ -static void +staticfn void left_side( int row, int left_mark, @@ -1968,7 +1969,7 @@ left_side( * func function to call on each spot * arg argument for func */ -static void +staticfn void view_from( coordxy srow, coordxy scol, seenV **loc_cs_rows, diff --git a/src/weapon.c b/src/weapon.c index e98386cb2..85622a3e7 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -10,12 +10,12 @@ */ #include "hack.h" -static void give_may_advance_msg(int); -static void finish_towel_change(struct obj *obj, int); -static boolean could_advance(int); -static boolean peaked_skill(int); -static int slots_required(int); -static void skill_advance(int); +staticfn void give_may_advance_msg(int); +staticfn void finish_towel_change(struct obj *obj, int); +staticfn boolean could_advance(int); +staticfn boolean peaked_skill(int); +staticfn int slots_required(int); +staticfn void skill_advance(int); /* Categories whose names don't come from OBJ_NAME(objects[type]) */ @@ -69,7 +69,7 @@ static NEARDATA const char *const barehands_or_martial[] = { static NEARDATA const char kebabable[] = { S_XORN, S_DRAGON, S_JABBERWOCK, S_NAGA, S_GIANT, '\0' }; -static void +staticfn void give_may_advance_msg(int skill) { You_feel("more confident in your %sskills.", @@ -461,14 +461,14 @@ silver_sears(struct monst *magr UNUSED, struct monst *mdef, } } -static struct obj *oselect(struct monst *, int); +staticfn struct obj *oselect(struct monst *, int); #define Oselect(x) \ do { \ if ((otmp = oselect(mtmp, x)) != 0) \ return otmp; \ } while (0) -static struct obj * +staticfn struct obj * oselect(struct monst *mtmp, int type) { struct obj *otmp; @@ -957,7 +957,7 @@ dbon(void) } /* called when wet_a_towel() or dry_a_towel() is changing a towel's wetness */ -static void +staticfn void finish_towel_change(struct obj *obj, int newspe) { /* towel wetness is always between 0 (dry) and 7, inclusive */ @@ -1069,7 +1069,7 @@ skill_name(int skill) } /* return the # of slots required to advance the skill */ -static int +staticfn int slots_required(int skill) { int tmp = P_SKILL(skill); @@ -1110,7 +1110,7 @@ can_advance(int skill, boolean speedy) } /* return true if this skill could be advanced if more slots were available */ -static boolean +staticfn boolean could_advance(int skill) { if (P_RESTRICTED(skill) @@ -1124,7 +1124,7 @@ could_advance(int skill) /* return true if this skill has reached its maximum and there's been enough practice to become eligible for the next step if that had been possible */ -static boolean +staticfn boolean peaked_skill(int skill) { if (P_RESTRICTED(skill)) @@ -1135,7 +1135,7 @@ peaked_skill(int skill) >= practice_needed_to_advance(P_SKILL(skill)))); } -static void +staticfn void skill_advance(int skill) { u.weapon_slots -= slots_required(skill); diff --git a/src/wield.c b/src/wield.c index dd040020b..6bb329367 100644 --- a/src/wield.c +++ b/src/wield.c @@ -52,10 +52,10 @@ * No item may be in more than one of these slots. */ -static boolean cant_wield_corpse(struct obj *) NONNULLARG1; -static int ready_weapon(struct obj *) NO_NNARGS; -static int ready_ok(struct obj *) NO_NNARGS; -static int wield_ok(struct obj *) NO_NNARGS; +staticfn boolean cant_wield_corpse(struct obj *) NONNULLARG1; +staticfn int ready_weapon(struct obj *) NO_NNARGS; +staticfn int ready_ok(struct obj *) NO_NNARGS; +staticfn int wield_ok(struct obj *) NO_NNARGS; /* used by will_weld() */ /* probably should be renamed */ @@ -128,7 +128,7 @@ setuwep(struct obj *obj) gu.unweapon = TRUE; /* for "bare hands" message */ } -static boolean +staticfn boolean cant_wield_corpse(struct obj *obj) { char kbuf[BUFSZ]; @@ -159,7 +159,7 @@ empty_handed(void) : "not wielding anything"; } -static int +staticfn int ready_weapon(struct obj *wep) { /* Separated function so swapping works easily */ @@ -284,7 +284,7 @@ setuswapwep(struct obj *obj) /* getobj callback for object to ready for throwing/shooting; this filter lets worn items through so that caller can reject them */ -static int +staticfn int ready_ok(struct obj *obj) { if (!obj) /* '-', will empty quiver slot if chosen */ @@ -321,7 +321,7 @@ ready_ok(struct obj *obj) } /* getobj callback for object to wield */ -static int +staticfn int wield_ok(struct obj *obj) { if (!obj) diff --git a/src/windows.c b/src/windows.c index 525bb00da..0c37ec988 100644 --- a/src/windows.c +++ b/src/windows.c @@ -60,25 +60,23 @@ extern void *trace_procs_chain(int, int, void *, void *, void *); #endif #if defined(WINCHAIN) || defined(TTY_GRAPHICS) -static struct win_choices *win_choices_find(const char *s) NONNULLARG1; +staticfn struct win_choices *win_choices_find(const char *s) NONNULLARG1; #endif -static void def_raw_print(const char *s) NONNULLARG1; -static void def_wait_synch(void); -static boolean get_menu_coloring(const char *, int *, int *) NONNULLPTRS; +staticfn void def_raw_print(const char *s) NONNULLARG1; +staticfn void def_wait_synch(void); +staticfn boolean get_menu_coloring(const char *, int *, int *) NONNULLPTRS; -#ifdef DUMPLOG -static winid dump_create_nhwindow(int); -static void dump_clear_nhwindow(winid); -static void dump_display_nhwindow(winid, boolean); -static void dump_destroy_nhwindow(winid); -static void dump_start_menu(winid, unsigned long); -static void dump_add_menu(winid, const glyph_info *, const ANY_P *, char, +staticfn winid dump_create_nhwindow(int); +staticfn void dump_clear_nhwindow(winid); +staticfn void dump_display_nhwindow(winid, boolean); +staticfn void dump_destroy_nhwindow(winid); +staticfn void dump_start_menu(winid, unsigned long); +staticfn void dump_add_menu(winid, const glyph_info *, const ANY_P *, char, char, int, int, const char *, unsigned int); -static void dump_end_menu(winid, const char *); -static int dump_select_menu(winid, int, MENU_ITEM_P **); -static void dump_putstr(winid, int, const char *); -#endif /* DUMPLOG */ +staticfn void dump_end_menu(winid, const char *); +staticfn int dump_select_menu(winid, int, MENU_ITEM_P **); +staticfn void dump_putstr(winid, int, const char *); #ifdef HANGUPHANDLING volatile @@ -155,7 +153,7 @@ struct winlink { static struct winlink *chain = 0; -static struct winlink * +staticfn struct winlink * wl_new(void) { struct winlink *wl = (struct winlink *) alloc(sizeof *wl); @@ -167,14 +165,14 @@ wl_new(void) return wl; } -static void +staticfn void wl_addhead(struct winlink *wl) { wl->nextlink = chain; chain = wl; } -static void +staticfn void wl_addtail(struct winlink *wl) { struct winlink *p = chain; @@ -203,14 +201,14 @@ genl_can_suspend_yes(void) return TRUE; } -static +staticfn void def_raw_print(const char *s) { puts(s); } -static +staticfn void def_wait_synch(void) { @@ -249,7 +247,7 @@ check_tty_wincap2(unsigned long wincap2) #endif #if defined(WINCHAIN) || defined(TTY_GRAPHICS) -static struct win_choices * +staticfn struct win_choices * win_choices_find(const char *s) { int i; @@ -520,44 +518,44 @@ genl_putmsghistory(const char *msg, boolean is_restoring) * in order to avoid all terminal I/O after hangup/disconnect. */ -static int hup_nhgetch(void); -static char hup_yn_function(const char *, const char *, char); -static int hup_nh_poskey(coordxy *, coordxy *, int *); -static void hup_getlin(const char *, char *); -static void hup_init_nhwindows(int *, char **); -static void hup_exit_nhwindows(const char *); -static winid hup_create_nhwindow(int); -static int hup_select_menu(winid, int, MENU_ITEM_P **); -static void hup_add_menu(winid, const glyph_info *, const anything *, char, +staticfn int hup_nhgetch(void); +staticfn char hup_yn_function(const char *, const char *, char); +staticfn int hup_nh_poskey(coordxy *, coordxy *, int *); +staticfn void hup_getlin(const char *, char *); +staticfn void hup_init_nhwindows(int *, char **); +staticfn void hup_exit_nhwindows(const char *); +staticfn winid hup_create_nhwindow(int); +staticfn int hup_select_menu(winid, int, MENU_ITEM_P **); +staticfn void hup_add_menu(winid, const glyph_info *, const anything *, char, char, int, int, const char *, unsigned int); -static void hup_end_menu(winid, const char *); -static void hup_putstr(winid, int, const char *); -static void hup_print_glyph(winid, coordxy, coordxy, const glyph_info *, +staticfn void hup_end_menu(winid, const char *); +staticfn void hup_putstr(winid, int, const char *); +staticfn void hup_print_glyph(winid, coordxy, coordxy, const glyph_info *, const glyph_info *); -static void hup_outrip(winid, int, time_t); -static void hup_curs(winid, int, int); -static void hup_display_nhwindow(winid, boolean); -static void hup_display_file(const char *, boolean); +staticfn void hup_outrip(winid, int, time_t); +staticfn void hup_curs(winid, int, int); +staticfn void hup_display_nhwindow(winid, boolean); +staticfn void hup_display_file(const char *, boolean); #ifdef CLIPPING -static void hup_cliparound(int, int); +staticfn void hup_cliparound(int, int); #endif #ifdef CHANGE_COLOR -static void hup_change_color(int, long, int); +staticfn void hup_change_color(int, long, int); #ifdef MAC -static short hup_set_font_name(winid, char *); +staticfn short hup_set_font_name(winid, char *); #endif -static char *hup_get_color_string(void); +staticfn char *hup_get_color_string(void); #endif /* CHANGE_COLOR */ -static void hup_status_update(int, genericptr_t, int, int, int, +staticfn void hup_status_update(int, genericptr_t, int, int, int, unsigned long *); -static int hup_int_ndecl(void); -static void hup_void_ndecl(void); -static void hup_void_fdecl_int(int); -static void hup_void_fdecl_winid(winid); -static void hup_void_fdecl_winid_ulong(winid, unsigned long); -static void hup_void_fdecl_constchar_p(const char *); -static win_request_info *hup_ctrl_nhwindow(winid, int, win_request_info *); +staticfn int hup_int_ndecl(void); +staticfn void hup_void_ndecl(void); +staticfn void hup_void_fdecl_int(int); +staticfn void hup_void_fdecl_winid(winid); +staticfn void hup_void_fdecl_winid_ulong(winid, unsigned long); +staticfn void hup_void_fdecl_constchar_p(const char *); +staticfn win_request_info *hup_ctrl_nhwindow(winid, int, win_request_info *); static struct window_procs hup_procs = { WPID(hup), 0L, 0L, @@ -641,7 +639,7 @@ nhwindows_hangup(void) windowprocs.win_getmsghistory = previnterface_getmsghistory; } -static void +staticfn void hup_exit_nhwindows(const char *lastgasp) { /* core has called exit_nhwindows(); call the previous interface's @@ -655,14 +653,14 @@ hup_exit_nhwindows(const char *lastgasp) iflags.window_inited = FALSE; } -static int +staticfn int hup_nhgetch(void) { return '\033'; /* ESC */ } /*ARGSUSED*/ -static char +staticfn char hup_yn_function( const char *prompt UNUSED, const char *resp UNUSED, @@ -674,35 +672,35 @@ hup_yn_function( } /*ARGSUSED*/ -static int +staticfn int hup_nh_poskey(coordxy *x UNUSED, coordxy *y UNUSED, int *mod UNUSED) { return '\033'; } /*ARGSUSED*/ -static void +staticfn void hup_getlin(const char *prompt UNUSED, char *outbuf) { Strcpy(outbuf, "\033"); } /*ARGSUSED*/ -static void +staticfn void hup_init_nhwindows(int *argc_p UNUSED, char **argv UNUSED) { iflags.window_inited = TRUE; } /*ARGUSED*/ -static winid +staticfn winid hup_create_nhwindow(int type UNUSED) { return WIN_ERR; } /*ARGSUSED*/ -static int +staticfn int hup_select_menu( winid window UNUSED, int how UNUSED, @@ -712,7 +710,7 @@ hup_select_menu( } /*ARGSUSED*/ -static void +staticfn void hup_add_menu( winid window UNUSED, const glyph_info *glyphinfo UNUSED, @@ -728,21 +726,21 @@ hup_add_menu( } /*ARGSUSED*/ -static void +staticfn void hup_end_menu(winid window UNUSED, const char *prompt UNUSED) { return; } /*ARGSUSED*/ -static void +staticfn void hup_putstr(winid window UNUSED, int attr UNUSED, const char *text UNUSED) { return; } /*ARGSUSED*/ -static void +staticfn void hup_print_glyph( winid window UNUSED, coordxy x UNUSED, coordxy y UNUSED, @@ -753,28 +751,28 @@ hup_print_glyph( } /*ARGSUSED*/ -static void +staticfn void hup_outrip(winid tmpwin UNUSED, int how UNUSED, time_t when UNUSED) { return; } /*ARGSUSED*/ -static void +staticfn void hup_curs(winid window UNUSED, int x UNUSED, int y UNUSED) { return; } /*ARGSUSED*/ -static void +staticfn void hup_display_nhwindow(winid window UNUSED, boolean blocking UNUSED) { return; } /*ARGSUSED*/ -static void +staticfn void hup_display_file(const char *fname UNUSED, boolean complain UNUSED) { return; @@ -782,7 +780,7 @@ hup_display_file(const char *fname UNUSED, boolean complain UNUSED) #ifdef CLIPPING /*ARGSUSED*/ -static void +staticfn void hup_cliparound(int x UNUSED, int y UNUSED) { return; @@ -791,7 +789,7 @@ hup_cliparound(int x UNUSED, int y UNUSED) #ifdef CHANGE_COLOR /*ARGSUSED*/ -static void +staticfn void hup_change_color(int color, int reverse, long rgb) { return; @@ -799,14 +797,14 @@ hup_change_color(int color, int reverse, long rgb) #ifdef MAC /*ARGSUSED*/ -static short +staticfn short hup_set_font_name(winid window, char *fontname) { return 0; } #endif /* MAC */ -static char * +staticfn char * hup_get_color_string(void) { return (char *) 0; @@ -814,7 +812,7 @@ hup_get_color_string(void) #endif /* CHANGE_COLOR */ /*ARGSUSED*/ -static void +staticfn void hup_status_update( int idx UNUSED, genericptr_t ptr UNUSED, int chg UNUSED, int pc UNUSED, @@ -827,34 +825,34 @@ hup_status_update( * Non-specific stubs. */ -static int +staticfn int hup_int_ndecl(void) { return -1; } -static void +staticfn void hup_void_ndecl(void) { return; } /*ARGUSED*/ -static void +staticfn void hup_void_fdecl_int(int arg UNUSED) { return; } /*ARGUSED*/ -static void +staticfn void hup_void_fdecl_winid(winid window UNUSED) { return; } /*ARGUSED*/ -static void +staticfn void hup_void_fdecl_winid_ulong( winid window UNUSED, unsigned long mbehavior UNUSED) @@ -863,7 +861,7 @@ hup_void_fdecl_winid_ulong( } /*ARGUSED*/ -static void +staticfn void hup_void_fdecl_constchar_p(const char *string UNUSED) { return; @@ -1283,49 +1281,49 @@ dump_forward_putstr(winid win, int attr, const char *str, int no_forward) } /*ARGSUSED*/ -static void +staticfn void dump_putstr(winid win UNUSED, int attr UNUSED, const char *str) { if (dumplog_file) fprintf(dumplog_file, "%s\n", str); } -static winid +staticfn winid dump_create_nhwindow(int type UNUSED) { return WIN_ERR; } /*ARGUSED*/ -static void +staticfn void dump_clear_nhwindow(winid win UNUSED) { return; } /*ARGSUSED*/ -static void +staticfn void dump_display_nhwindow(winid win UNUSED, boolean p UNUSED) { return; } /*ARGUSED*/ -static void +staticfn void dump_destroy_nhwindow(winid win UNUSED) { return; } /*ARGUSED*/ -static void +staticfn void dump_start_menu(winid win UNUSED, unsigned long mbehavior UNUSED) { return; } /*ARGSUSED*/ -static void +staticfn void dump_add_menu(winid win UNUSED, const glyph_info *glyphinfo, const anything *identifier UNUSED, @@ -1345,7 +1343,7 @@ dump_add_menu(winid win UNUSED, } /*ARGSUSED*/ -static void +staticfn void dump_end_menu(winid win UNUSED, const char *str) { if (dumplog_file) { @@ -1356,7 +1354,7 @@ dump_end_menu(winid win UNUSED, const char *str) } } -static int +staticfn int dump_select_menu(winid win UNUSED, int how UNUSED, menu_item **item) { *item = (menu_item *) 0; @@ -1830,7 +1828,7 @@ add_menu_str(winid tmpwin, const char *buf) buf, MENU_ITEMFLAGS_NONE); } -static boolean +staticfn boolean get_menu_coloring(const char *str, int *color, int *attr) { struct menucoloring *tmpmc; diff --git a/src/wizard.c b/src/wizard.c index b5101f96d..0a35f66f9 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -10,16 +10,16 @@ #include "hack.h" -static short which_arti(int); -static boolean mon_has_arti(struct monst *, short) NONNULLARG1; +staticfn short which_arti(int); +staticfn boolean mon_has_arti(struct monst *, short) NONNULLARG1; /* other_mon_has_arti() won't blow up if passed a NULL monst, * but its caller target_on() passes it a nonnull monst; * it may return a NULL monst pointer */ -static struct monst *other_mon_has_arti(struct monst *, short) NONNULLARG1; -static struct obj *on_ground(short); /* might return NULL obj pointer */ -static boolean you_have(int); -static unsigned long target_on(int, struct monst *) NONNULLARG2; -static unsigned long strategy(struct monst *) NONNULLARG1; +staticfn struct monst *other_mon_has_arti(struct monst *, short) NONNULLARG1; +staticfn struct obj *on_ground(short); /* might return NULL obj pointer */ +staticfn boolean you_have(int); +staticfn unsigned long target_on(int, struct monst *) NONNULLARG2; +staticfn unsigned long strategy(struct monst *) NONNULLARG1; /* adding more neutral creatures will tend to reduce the number of monsters summoned by nasty(); adding more lawful creatures will reduce the number @@ -141,7 +141,7 @@ mon_has_special(struct monst *mtmp) #define M_Wants(mask) (mtmp->data->mflags3 & (mask)) -static short +staticfn short which_arti(int mask) { switch (mask) { @@ -164,7 +164,7 @@ which_arti(int mask) * since bell, book, candle, and amulet are all objects, not really * artifacts right now. [MRS] */ -static boolean +staticfn boolean mon_has_arti(struct monst *mtmp, short otyp) { struct obj *otmp; @@ -183,7 +183,7 @@ mon_has_arti(struct monst *mtmp, short otyp) * Returns some monster other than mtmp that * has artifact, or NULL monst pointer. */ -static struct monst * +staticfn struct monst * other_mon_has_arti(struct monst *mtmp, short otyp) { struct monst *mtmp2; @@ -201,7 +201,7 @@ other_mon_has_arti(struct monst *mtmp, short otyp) * Returns obj of type specified if there is one * on the ground, otherwise returns NULL obj pointer. */ -static struct obj * +staticfn struct obj * on_ground(short otyp) { struct obj *otmp; @@ -215,7 +215,7 @@ on_ground(short otyp) return (struct obj *) 0; } -static boolean +staticfn boolean you_have(int mask) { switch (mask) { @@ -235,7 +235,7 @@ you_have(int mask) return 0; } -static unsigned long +staticfn unsigned long target_on(int mask, struct monst *mtmp) { short otyp; @@ -261,7 +261,7 @@ target_on(int mask, struct monst *mtmp) return (unsigned long) STRAT_NONE; } -static unsigned long +staticfn unsigned long strategy(struct monst *mtmp) { unsigned long strat, dstrat; diff --git a/src/wizcmds.c b/src/wizcmds.c index b663e5d82..fbcee86c4 100644 --- a/src/wizcmds.c +++ b/src/wizcmds.c @@ -8,21 +8,21 @@ extern const char unavailcmd[]; /* cmd.c [27] */ extern const char *levltyp[MAX_TYPE + 2]; /* cmd.c */ -static int size_monst(struct monst *, boolean); -static int size_obj(struct obj *); -static void count_obj(struct obj *, long *, long *, boolean, boolean); -static void obj_chain(winid, const char *, struct obj *, boolean, long *, +staticfn int size_monst(struct monst *, boolean); +staticfn int size_obj(struct obj *); +staticfn void count_obj(struct obj *, long *, long *, boolean, boolean); +staticfn void obj_chain(winid, const char *, struct obj *, boolean, long *, long *); -static void mon_invent_chain(winid, const char *, struct monst *, long *, +staticfn void mon_invent_chain(winid, const char *, struct monst *, long *, long *); -static void mon_chain(winid, const char *, struct monst *, boolean, long *, +staticfn void mon_chain(winid, const char *, struct monst *, boolean, long *, long *); -static void contained_stats(winid, const char *, long *, long *); -static void misc_stats(winid, long *, long *); -static void you_sanity_check(void); -static void makemap_unmakemon(struct monst *, boolean); -static int QSORTCALLBACK migrsort_cmp(const genericptr, const genericptr); -static void list_migrating_mons(d_level *); +staticfn void contained_stats(winid, const char *, long *, long *); +staticfn void misc_stats(winid, long *, long *); +staticfn void you_sanity_check(void); +staticfn void makemap_unmakemon(struct monst *, boolean); +staticfn int QSORTCALLBACK migrsort_cmp(const genericptr, const genericptr); +staticfn void list_migrating_mons(d_level *); DISABLE_WARNING_FORMAT_NONLITERAL @@ -1099,7 +1099,7 @@ static const char template[] = "%-27s %4ld %6ld"; static const char stats_hdr[] = " count bytes"; static const char stats_sep[] = "--------------------------- ----- -------"; -static int +staticfn int size_obj(struct obj *otmp) { int sz = (int) sizeof (struct obj); @@ -1117,7 +1117,7 @@ size_obj(struct obj *otmp) return sz; } -static void +staticfn void count_obj(struct obj *chain, long *total_count, long *total_size, boolean top, boolean recurse) { @@ -1138,7 +1138,7 @@ count_obj(struct obj *chain, long *total_count, long *total_size, DISABLE_WARNING_FORMAT_NONLITERAL /* RESTORE_WARNING follows wiz_show_stats */ -static void +staticfn void obj_chain( winid win, const char *src, @@ -1159,7 +1159,7 @@ obj_chain( } } -static void +staticfn void mon_invent_chain( winid win, const char *src, @@ -1181,7 +1181,7 @@ mon_invent_chain( } } -static void +staticfn void contained_stats( winid win, const char *src, @@ -1210,7 +1210,7 @@ contained_stats( } } -static int +staticfn int size_monst(struct monst *mtmp, boolean incl_wsegs) { int sz = (int) sizeof (struct monst); @@ -1237,7 +1237,7 @@ size_monst(struct monst *mtmp, boolean incl_wsegs) return sz; } -static void +staticfn void mon_chain( winid win, const char *src, @@ -1264,7 +1264,7 @@ mon_chain( } } -static void +staticfn void misc_stats( winid win, long *total_count, long *total_size) @@ -1382,7 +1382,7 @@ misc_stats( } } -static void +staticfn void you_sanity_check(void) { struct monst *mtmp; @@ -1428,7 +1428,7 @@ sanity_check(void) } /* qsort() comparison routine for use in list_migrating_mons() */ -static int QSORTCALLBACK +staticfn int QSORTCALLBACK migrsort_cmp(const genericptr vptr1, const genericptr vptr2) { const struct monst *m1 = *(const struct monst **) vptr1, @@ -1449,7 +1449,7 @@ migrsort_cmp(const genericptr vptr1, const genericptr vptr2) /* called by #migratemons; displays count of migrating monsters, optionally displays them as well */ -static void +staticfn void list_migrating_mons( d_level *nextlevl) /* default destination for wiz_migrate_mons() */ { diff --git a/src/worm.c b/src/worm.c index 6d1266ed9..479c9d75e 100644 --- a/src/worm.c +++ b/src/worm.c @@ -14,12 +14,12 @@ struct wseg { coordxy wx, wy; /* the segment's position */ }; -static void toss_wsegs(struct wseg *, boolean) NO_NNARGS; -static void shrink_worm(int); +staticfn void toss_wsegs(struct wseg *, boolean) NO_NNARGS; +staticfn void shrink_worm(int); #if 0 -static void random_dir(int, int, int *, int *); +staticfn void random_dir(int, int, int *, int *); #endif -static struct wseg *create_worm_tail(int); /* may return NULL */ +staticfn struct wseg *create_worm_tail(int); /* may return NULL */ /* Description of long worm implementation. * @@ -138,8 +138,7 @@ initworm(struct monst *worm, int wseg_count) * Get rid of all worm segments on and following the given pointer curr. * The display may or may not need to be updated as we free the segments. */ -static -void +staticfn void toss_wsegs(struct wseg *curr, boolean display_update) { struct wseg *nxtseg; @@ -168,8 +167,7 @@ toss_wsegs(struct wseg *curr, boolean display_update) * * Remove the tail segment of the worm (the starting segment of the list). */ -static -void +staticfn void shrink_worm(int wnum) /* worm number */ { struct wseg *seg; @@ -803,7 +801,7 @@ place_worm_tail_randomly(struct monst *worm, coordxy x, coordxy y) * This function, and the loop it serves, could be eliminated by coding * enexto() with a search radius. */ -static void +staticfn void random_dir(int x, int y, int *nx, int *ny) { *nx = x + (x > 1 /* extreme left ? */ @@ -852,8 +850,7 @@ count_wsegs(struct monst *mtmp) /* create_worm_tail() * will create a worm tail chain of (num_segs + 1) and return pointer to it. */ -static -struct wseg * +staticfn struct wseg * create_worm_tail(int num_segs) { int i = 0; diff --git a/src/worn.c b/src/worn.c index be646bbdf..e356fb8e2 100644 --- a/src/worn.c +++ b/src/worn.c @@ -5,12 +5,12 @@ #include "hack.h" -static void m_lose_armor(struct monst *, struct obj *, boolean) NONNULLPTRS; -static void clear_bypass(struct obj *) NO_NNARGS; -static void m_dowear_type(struct monst *, long, boolean, boolean) NONNULLARG1; -static int extra_pref(struct monst *, struct obj *) NONNULLARG1; +staticfn void m_lose_armor(struct monst *, struct obj *, boolean) NONNULLPTRS; +staticfn void clear_bypass(struct obj *) NO_NNARGS; +staticfn void m_dowear_type(struct monst *, long, boolean, boolean) NONNULLARG1; +staticfn int extra_pref(struct monst *, struct obj *) NONNULLARG1; -const struct worn { +static const struct worn { long w_mask; struct obj **w_obj; const char *w_what; /* for failing sanity check's feedback */ @@ -698,7 +698,7 @@ m_dowear(struct monst *mon, boolean creation) m_dowear_type(mon, W_ARM, creation, RACE_EXCEPTION); } -static void +staticfn void m_dowear_type( struct monst *mon, long flag, /* wornmask value */ @@ -922,7 +922,7 @@ which_armor(struct monst *mon, long flag) } /* remove an item of armor and then drop it */ -static void +staticfn void m_lose_armor( struct monst *mon, struct obj *obj, @@ -937,7 +937,7 @@ m_lose_armor( } /* clear bypass bits for an object chain, plus contents if applicable */ -static void +staticfn void clear_bypass(struct obj *objchn) { struct obj *o; @@ -1214,7 +1214,7 @@ mon_break_armor(struct monst *mon, boolean polyspot) } /* bias a monster's preferences towards armor that has special benefits. */ -static int +staticfn int extra_pref(struct monst *mon, struct obj *obj) { /* currently only does speed boots, but might be expanded if monsters diff --git a/src/write.c b/src/write.c index 1d060fdd7..4536b864e 100644 --- a/src/write.c +++ b/src/write.c @@ -3,15 +3,15 @@ #include "hack.h" -static int cost(struct obj *) NONNULLARG1; -static boolean label_known(int, struct obj *) NO_NNARGS; -static int write_ok(struct obj *) NO_NNARGS; -static char *new_book_description(int, char *) NONNULL NONNULLPTRS; +staticfn int cost(struct obj *) NONNULLARG1; +staticfn boolean label_known(int, struct obj *) NO_NNARGS; +staticfn int write_ok(struct obj *) NO_NNARGS; +staticfn char *new_book_description(int, char *) NONNULL NONNULLPTRS; /* * returns basecost of a scroll or a spellbook */ -static int +staticfn int cost(struct obj *otmp) { if (otmp->oclass == SPBOOK_CLASS) @@ -61,7 +61,7 @@ cost(struct obj *otmp) unfortunately, we can't track things that haven't been added to the discoveries list and aren't present in current inventory, so some scrolls with ought to yield True will end up False */ -static boolean +staticfn boolean label_known(int scrolltype, struct obj *objlist) { struct obj *otmp; @@ -86,7 +86,7 @@ label_known(int scrolltype, struct obj *objlist) } /* getobj callback for object to write on */ -static int +staticfn int write_ok(struct obj *obj) { if (!obj || (obj->oclass != SCROLL_CLASS && obj->oclass != SPBOOK_CLASS)) @@ -421,7 +421,7 @@ dowrite(struct obj *pen) looks funny, so we want to insert "into " prior to such descriptions; even that's rather iffy, indicating that such descriptions probably ought to be eliminated (especially "cloth"!) */ -static char * +staticfn char * new_book_description(int booktype, char *outbuf) { /* subset of description strings from objects.c; if it grows diff --git a/src/zap.c b/src/zap.c index c2cdca866..d13695a26 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 zap.c $NHDT-Date: 1704316449 2024/01/03 21:14:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.508 $ */ +/* NetHack 3.7 zap.c $NHDT-Date: 1710344449 2024/03/13 15:40:49 $ $NHDT-Branch: keni-staticfn $:$NHDT-Revision: 1.525 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -12,33 +12,33 @@ */ #define MAGIC_COOKIE 1000 -static int zaptype(int); -static void probe_objchain(struct obj *) NO_NNARGS; -static boolean zombie_can_dig(coordxy x, coordxy y); -static void polyuse(struct obj *, int, int) NO_NNARGS; -static void create_polymon(struct obj *, int) NO_NNARGS; -static int stone_to_flesh_obj(struct obj *) NONNULLARG1; -static boolean zap_updown(struct obj *) NONNULLARG1; -static void zhitu(int, int, const char *, coordxy, coordxy) NO_NNARGS; -static void revive_egg(struct obj *) NONNULLARG1; -static boolean zap_steed(struct obj *) NONNULLARG1; -static void skiprange(int, int *, int *) NONNULLPTRS; -static void maybe_explode_trap(struct trap *, struct obj *, +staticfn int zaptype(int); +staticfn void probe_objchain(struct obj *) NO_NNARGS; +staticfn boolean zombie_can_dig(coordxy x, coordxy y); +staticfn void polyuse(struct obj *, int, int) NO_NNARGS; +staticfn void create_polymon(struct obj *, int) NO_NNARGS; +staticfn int stone_to_flesh_obj(struct obj *) NONNULLARG1; +staticfn boolean zap_updown(struct obj *) NONNULLARG1; +staticfn void zhitu(int, int, const char *, coordxy, coordxy) NO_NNARGS; +staticfn void revive_egg(struct obj *) NONNULLARG1; +staticfn boolean zap_steed(struct obj *) NONNULLARG1; +staticfn void skiprange(int, int *, int *) NONNULLPTRS; +staticfn void maybe_explode_trap(struct trap *, struct obj *, boolean *) NONNULLARG3; -static void zap_map(coordxy, coordxy, struct obj *) NONNULLARG3; -static int zap_hit(int, int); -static void disintegrate_mon(struct monst *, int, const char *) NONNULLARG1; -static int adtyp_to_prop(int); -static void backfire(struct obj *) NONNULLARG1; -static int zap_ok(struct obj *) NO_NNARGS; +staticfn void zap_map(coordxy, coordxy, struct obj *) NONNULLARG3; +staticfn int zap_hit(int, int); +staticfn void disintegrate_mon(struct monst *, int, const char *) NONNULLARG1; +staticfn int adtyp_to_prop(int); +staticfn void backfire(struct obj *) NONNULLARG1; +staticfn int zap_ok(struct obj *) NO_NNARGS; /* all callers of boxlock_invent() pass a NONNULL obj, and boxlock * boxlock_invent() calls boxlock() which has nonnull arg. */ -static void boxlock_invent(struct obj *) NONNULLARG1; -static int spell_hit_bonus(int); -static int maybe_destroy_item(struct monst *, struct obj *, int) NONNULLPTRS; -static boolean destroyable(struct obj *, int); +staticfn void boxlock_invent(struct obj *) NONNULLARG1; +staticfn int spell_hit_bonus(int); +staticfn int maybe_destroy_item(struct monst *, struct obj *, int) NONNULLPTRS; +staticfn boolean destroyable(struct obj *, int); -static void wishcmdassist(int); +staticfn void wishcmdassist(int); #define ZT_MAGIC_MISSILE (AD_MAGM - 1) #define ZT_FIRE (AD_FIRE - 1) @@ -83,7 +83,7 @@ static const char *const flash_types[] = { }; /* convert monster zap/spell/breath value to hero zap/spell/breath value */ -static int +staticfn int zaptype(int type) { if (type <= -30 && -39 <= type) /* monster wand zap */ @@ -565,7 +565,7 @@ release_hold(void) } } -static void +staticfn void probe_objchain(struct obj *otmp) { for (; otmp; otmp = otmp->nobj) { @@ -816,7 +816,7 @@ get_container_location( } /* can zombie dig the location at x,y */ -static boolean +staticfn boolean zombie_can_dig(coordxy x, coordxy y) { if (isok(x, y)) { @@ -1095,7 +1095,7 @@ revive(struct obj *corpse, boolean by_hero) return mtmp; } -static void +staticfn void revive_egg(struct obj *obj) /* nonnull */ { /* @@ -1439,7 +1439,7 @@ obj_shudders(struct obj *obj) * there's a random factor here to keep from always using the stuff * at the top of the pile. */ -static void +staticfn void polyuse(struct obj *objhdr, int mat, int minwt) { struct obj *otmp, *otmp2; @@ -1480,7 +1480,7 @@ polyuse(struct obj *objhdr, int mat, int minwt) * Polymorph some of the stuff in this pile into a monster, preferably * a golem of the kind okind. */ -static void +staticfn void create_polymon(struct obj *obj, int okind) { struct permonst *mdat = (struct permonst *) 0; @@ -1622,7 +1622,7 @@ obj_unpolyable(struct obj *obj) /* classes of items whose current charge count carries over across polymorph */ -static const char charged_objs[] = { WAND_CLASS, WEAPON_CLASS, ARMOR_CLASS, +staticfn const char charged_objs[] = { WAND_CLASS, WEAPON_CLASS, ARMOR_CLASS, '\0' }; /* @@ -1918,7 +1918,7 @@ poly_obj(struct obj *obj, int id) } /* stone-to-flesh spell hits and maybe transforms or animates obj */ -static int +staticfn int stone_to_flesh_obj(struct obj *obj) /* nonnull */ { struct permonst *ptr; @@ -2501,7 +2501,7 @@ zapnodir(struct obj *obj) } } -static void +staticfn void backfire(struct obj *otmp) { int dmg; @@ -2514,7 +2514,7 @@ backfire(struct obj *otmp) } /* getobj callback for object to zap */ -static int +staticfn int zap_ok(struct obj *obj) { if (obj && obj->oclass == WAND_CLASS) @@ -2583,7 +2583,7 @@ dozap(void) } /* Lock or unlock all boxes in inventory */ -static void +staticfn void boxlock_invent(struct obj *obj) { struct obj *otmp; @@ -2970,7 +2970,7 @@ flashburn(long duration) * Return TRUE if the steed was hit by the wand. * Return FALSE if the steed was not hit by the wand. */ -static boolean +staticfn boolean zap_steed(struct obj *obj) /* wand or spell */ { int steedhit = FALSE; @@ -3102,7 +3102,7 @@ cancel_monst(struct monst *mdef, struct obj *obj, boolean youattack, } /* you've zapped an immediate type wand up or down */ -static boolean +staticfn boolean zap_updown(struct obj *obj) /* wand or spell, nonnull */ { boolean striking = FALSE, disclose = FALSE, map_zapped = FALSE; @@ -3391,7 +3391,7 @@ spell_damage_bonus( * Generate the to hit bonus for a spell. Based on the hero's skill in * spell class and dexterity. */ -static int +staticfn int spell_hit_bonus(int skill) { int hit_bon = 0; @@ -3463,7 +3463,7 @@ miss(const char *str, struct monst *mtmp) && flags.verbose) ? mon_nam(mtmp) : "it"); } -static void +staticfn void skiprange(int range, int *skipstart, int *skipend) { int tr = (range / 4); @@ -3478,7 +3478,7 @@ skiprange(int range, int *skipstart, int *skipend) /* Maybe explode a trap hit by object otmp's effect; cancellation beam hitting a magical trap causes an explosion. Might delete the trap; won't destroy otmp. */ -static void +staticfn void maybe_explode_trap( struct trap *ttmp, struct obj *otmp, @@ -3512,7 +3512,7 @@ maybe_explode_trap( /* zap_map() occurs before hitting monsters or objects and handles wands or spells that don't dish out 'elemental' damage */ -static void +staticfn void zap_map( coordxy x, coordxy y, struct obj *obj) /* zapped wand, or book for cast spell */ @@ -4255,7 +4255,7 @@ zhitm( return tmp; } -static void +staticfn void zhitu( int type, int nd, const char *fltxt, @@ -4514,7 +4514,7 @@ burn_floor_objects( } /* will zap/spell/breath attack score a hit against armor class `ac'? */ -static int +staticfn int zap_hit(int ac, int type) /* either hero cast spell type or 0 */ { @@ -4531,7 +4531,7 @@ zap_hit(int ac, return (3 - chance < ac + spell_bonus); } -static void +staticfn void disintegrate_mon( struct monst *mon, int type, /* hero vs other */ @@ -5429,7 +5429,7 @@ break_statue(struct obj *obj) * Note that things like the Book of the Dead are eligible even though they * won't get destroyed, because it will attempt to be destroyed but print a * special message instead. */ -static boolean +staticfn boolean destroyable(struct obj *obj, int adtyp) { if (obj->oartifact) { @@ -5470,7 +5470,7 @@ destroyable(struct obj *obj, int adtyp) } /* convert attack damage AD_foo to property resistance */ -static int +staticfn int adtyp_to_prop(int dmgtyp) { switch (dmgtyp) { @@ -5589,6 +5589,7 @@ item_what(int dmgtyp) * [6] shocked wand * (books, rings, and wands don't stack so don't need plural form; * crumbling ring doesn't do damage so doesn't need killer reason) + * externally referenced from trap.c. */ const char *const destroy_strings[][3] = { /* also used in trap.c */ @@ -5609,7 +5610,7 @@ const char *const destroy_strings[][3] = { whether it's the player or a monster having an item destroyed: players lose the HP and possibly die in this function, and the return value is unused, whereas monsters return the damage to their caller to be taken off later */ -static int +staticfn int maybe_destroy_item( struct monst *carrier, struct obj *obj, @@ -5973,7 +5974,7 @@ resist(struct monst *mtmp, char oclass, int damage, int tell) DISABLE_WARNING_FORMAT_NONLITERAL -static void +staticfn void wishcmdassist(int triesleft) { static NEARDATA const char * diff --git a/sys/msdos/Makefile.GCC b/sys/msdos/Makefile.GCC index eec43acdd..81283f7bc 100644 --- a/sys/msdos/Makefile.GCC +++ b/sys/msdos/Makefile.GCC @@ -446,7 +446,7 @@ endif #========================================== # ifeq "$(ADD_CURSES)" "Y" -CURSESDEF=-D"CURSES_GRAPHICS" -D"CURSES_BRIEF_INCLUDE" +CURSESDEF=-D"CURSES_GRAPHICS" -D"CURSES_BRIEF_INCLUDE" -DPDC_RGB ifdef WANT_DOSVGA CURSESDEF += -DCURSES_UNICODE -DPDC_WIDE endif @@ -538,13 +538,13 @@ $(OBJ)/%.o : $(WCURSES)/%.c #========================================== $(OBJ)/%.o : $(PDCURSES_TOP)/%.c - $(CC) $(cflags) -o$@ $< + $(CC) $(cflags) -o$@ $< $(OBJ)/%.o : $(PDCSRC)/%.c - $(CC) $(cflags) -o$@ $< + $(CC) $(cflags) -o$@ $< $(OBJ)/%.o : $(PDCDOS)/%.c - $(CC) $(cflags) -o$@ $< + $(CC) $(cflags) -o$@ $< #========================================== # Rules for LUA files diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 46766aa9c..9a31be3c5 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -447,30 +447,9 @@ QUIETCC=0 # NB: This is not used for all .c files (see explicit rules in # dependencies). -# if NOSTATICCORE # A normal or cross compile. -# else -# NOSTATICCORE: A compile that makes all functions non-static. -# Rule /=/ allows 2 definitions of char array brief_feeling -# fi $(TARGETPFX)%.o : %.c - @if [ x$(NOSTATICCORE) = 'x' ]; then \ - echo $(TARGET_CC) $(TARGET_CFLAGS) -c -o $@ $< ; \ - $(TARGET_CC) $(TARGET_CFLAGS) -c -o $@ $< ; \ - else \ - ( \ - echo "Generating " intermediate file .$< ; \ - $(AWK) ' \ - BEGIN{print "#line 1 \"$<\""}; \ - /=/{print;next}; \ - sub(/^static inline/, ""){print;next}; \ - sub(/^static( |$$)/, ""){print;next}; \ - {print}; \ - ' < $< > .$< && \ - echo $(TARGET_CC) $(TARGET_CFLAGS) -c -o $@ .$< ; \ - $(TARGET_CC) $(TARGET_CFLAGS) -c -o $@ .$< ; \ - ) \ - fi + $(TARGET_CC) $(TARGET_CFLAGS) -c -o $@ $< # Verbosity definitions, begin # Set QUIETCC=1 above to output less feedback while building. @@ -1171,8 +1150,8 @@ $(TARGETPFX)engrave.o: engrave.c $(HACK_H) $(TARGETPFX)exper.o: exper.c $(HACK_H) $(TARGETPFX)explode.o: explode.c $(HACK_H) $(TARGETPFX)extralev.o: extralev.c $(HACK_H) -$(TARGETPFX)files.o: files.c #zlib.h $(HACK_H) ../include/dlb.h \ - ../include/wintty.h +$(TARGETPFX)files.o: files.c $(HACK_H) ../include/dlb.h ../include/wintty.h \ + #zlib.h $(TARGETPFX)fountain.o: fountain.c $(HACK_H) $(TARGETPFX)getpos.o: getpos.c $(HACK_H) $(TARGETPFX)hack.o: hack.c $(HACK_H) diff --git a/sys/unix/depend.awk b/sys/unix/depend.awk index 6b9bc5ebd..afe86a0ad 100644 --- a/sys/unix/depend.awk +++ b/sys/unix/depend.awk @@ -11,7 +11,6 @@ # cd .. ; sh sys/unix/setup.sh [sys/unix/hints/FOO] ) # newer usage: # cd sys/unix ; make -f Makefile.src updatedepend - # # This awk program scans each file in sequence, looking for lines beginning # with `#include "' and recording the name inside the quotes. For .h files, @@ -19,6 +18,10 @@ # corresponding .o file; dependencies in nested header files are propagated # to the .o target. # +# Variables that can be set on the command line: +# -v dontsortdeps=1 do not sort the dependencies +# -v dontsortfules=1 do not sort the rules +# # config.h and hack.h get special handling because of their heavy use; # timestamps for them allow make to avoid rechecking dates on # subsidiary headers for every source file; @@ -34,8 +37,6 @@ # zlib.h ditto # BEGIN { FS = "\"" #for `#include "X"', $2 is X - dosort = 1 - dorulesort = 1 special[++sp_cnt] = "../include/config.h" special[++sp_cnt] = "../include/hack.h" alt_deps["../include/extern.h"] = "" @@ -91,7 +92,7 @@ END { # function output_dep(){ - if(dorulesort){ + if(!dontsortrules){ worklist[++worklistctr] = file } else { output_final2() @@ -100,7 +101,7 @@ function output_dep(){ function output_final( x) { - if(dorulesort){ + if(!dontsortrules){ nhsort(worklist, 1, worklistctr, 1) for(x=1;x<=worklistctr;x++){ file = worklist[x] @@ -173,7 +174,7 @@ function format_dep(target, source, col, n, i, list, prefix, moc) #files duplicate the target as next element but we need to skip that too first = moc ? 3 : 2 source = list[first] - if (dosort){ + if (!dontsortdeps){ nhsort(list, first, n, 0) } for (i = first; i <= n; i++) { @@ -250,6 +251,9 @@ function nhsort(list, first, last, cmpid, i,j,temp) function nhcmp(a,b,cmpid) { if(cmpid == 0){ # sort dependencies + # commented out entry (there can be only one) MUST be last + if (a ~ /^#/){ return 1} + if (b ~ /^#/){ return 0} # 2 .c or .cpp files if (a ~ /\.c(pp)?$/ && b ~ /\.c(pp)?$/ ){ return a > b } # a .c or .cpp file and anything else diff --git a/sys/unix/hints/include/cross-pre2.370 b/sys/unix/hints/include/cross-pre2.370 index 2b1c9ef91..55294e286 100644 --- a/sys/unix/hints/include/cross-pre2.370 +++ b/sys/unix/hints/include/cross-pre2.370 @@ -50,7 +50,7 @@ ifdef WANT_DOSVGA PDCPORT = $(PDCTOP)/dosvga PDCURSESDEF= -I$(PDCTOP) -I$(PDCPORT) \ -D"CURSES_GRAPHICS" -D"CURSES_BRIEF_INCLUDE" \ - -D"PDC_WIDE" -D"CURSES_UNICODE" + -D"PDC_WIDE" -D"PDC_RGB" -D"CURSES_UNICODE" else PDCPORT = $(PDCTOP)/dos PDCURSESDEF= -I$(PDCTOP) -I$(PDCPORT) \ diff --git a/sys/unix/hints/linux.370 b/sys/unix/hints/linux.370 index 279b177cf..06c69b7be 100755 --- a/sys/unix/hints/linux.370 +++ b/sys/unix/hints/linux.370 @@ -45,8 +45,11 @@ GAMEGRP = games # This gives better backtraces by making all core functions global; this # works around a limitation in glibc's backtrace(3) function. -# Recommended with CRASHREPORT. -#NOSTATICCORE = 1 +# This will be turned on automatically with CRASHREPROT. +# 1 to enable, 0 to disable +USE_NOSTATICFN = 1 +# If you want CRASHREPORT but absolutely don't want NOSTATICFN, define this: +#USE_NONOSTATICFN = 1 #----------------------------------------------------------------------------- #-INCLUDE cross-pre1.370 @@ -344,6 +347,14 @@ POSTINSTALL+= sed -i -e 's;^GDBPATH=/usr/bin/gdb;\#GDBPATH=/usr/bin/gdb;' \ -e 's;PANICTRACE_GDB=1;PANICTRACE_GDB=0;' $(INSTDIR)/sysconf; endif +ifeq 'USENONOSTATICFN' '1' +CFLAGS += -DNONOSTATICFN +else +ifeq 'USE_NOSTATICFN' '1' +CFLAGS += -DNOSTATICFN +endif +endif + # Lua # when building liblua.a, avoid warning that use of tmpnam() should be # replaced by mkstemp(); the lua code doesn't use nethack's config.h so diff --git a/sys/windows/Makefile.mingw32 b/sys/windows/Makefile.mingw32 index b9227f640..73519fa1a 100644 --- a/sys/windows/Makefile.mingw32 +++ b/sys/windows/Makefile.mingw32 @@ -118,7 +118,7 @@ GIT_AVAILABLE=Y endif PDCURSES=pdcursesmod -PDCURSESFLAGS = -DPDC_WIDE +PDCURSESFLAGS = -DPDC_WIDE -DPDC_RGB # #============================================================================== diff --git a/sys/windows/Makefile.nmake b/sys/windows/Makefile.nmake index 2173d95db..0e5b9e0db 100644 --- a/sys/windows/Makefile.nmake +++ b/sys/windows/Makefile.nmake @@ -602,7 +602,7 @@ WINDHDR = $(MSWSYS)\win10.h $(MSWSYS)\winos.h $(MSWSYS)\win32api.h # !IF "$(ADD_CURSES)" == "Y" -PDCURSESFLAGS = -DPDC_WIDE +PDCURSESFLAGS = -DPDC_WIDE -DPDC_RGB CURSESOBJ= $(OTTY)cursdial.o $(OTTY)cursinit.o $(OTTY)cursinvt.o \ $(OTTY)cursmain.o $(OTTY)cursmesg.o $(OTTY)cursmisc.o \ $(OTTY)cursstat.o $(OTTY)curswins.o diff --git a/sys/windows/vs/PDCurses/PDCurses.vcxproj b/sys/windows/vs/PDCurses/PDCurses.vcxproj index bf2ca014c..8b5f7901c 100644 --- a/sys/windows/vs/PDCurses/PDCurses.vcxproj +++ b/sys/windows/vs/PDCurses/PDCurses.vcxproj @@ -90,14 +90,14 @@ Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;_DEBUG;_LIB;PDC_RGB;%(PreprocessorDefinitions) MultiThreadedDebug Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) + _DEBUG;_LIB;PDC_RGB;%(PreprocessorDefinitions) @@ -105,7 +105,7 @@ MaxSpeed true true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;NDEBUG;_LIB;PDC_RGB;%(PreprocessorDefinitions) true @@ -117,7 +117,7 @@ MaxSpeed true true - NDEBUG;_LIB;%(PreprocessorDefinitions) + NDEBUG;_LIB;PDC_RGB;%(PreprocessorDefinitions) true diff --git a/sys/windows/vs/PDCursesGui/pdcursesgui.vcxproj b/sys/windows/vs/PDCursesGui/pdcursesgui.vcxproj index 9f661e18c..e28db5b80 100644 --- a/sys/windows/vs/PDCursesGui/pdcursesgui.vcxproj +++ b/sys/windows/vs/PDCursesGui/pdcursesgui.vcxproj @@ -84,14 +84,14 @@ Disabled - WIN32;_DEBUG;_LIB;PDC_WIDE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_LIB;PDC_WIDE;PDC_RGB;%(PreprocessorDefinitions) MultiThreadedDebug Disabled - _DEBUG;_LIB;PDC_WIDE;%(PreprocessorDefinitions) + _DEBUG;_LIB;PDC_WIDE;PDC_RGB;%(PreprocessorDefinitions) @@ -99,7 +99,7 @@ MaxSpeed true true - WIN32;NDEBUG;_LIB;PDC_WIDE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_LIB;PDC_WIDE;PDC_RGB;%(PreprocessorDefinitions) true @@ -111,7 +111,7 @@ MaxSpeed true true - NDEBUG;_LIB;PDC_WIDE;%(PreprocessorDefinitions) + NDEBUG;_LIB;PDC_WIDE;PDC_RGB;%(PreprocessorDefinitions) true diff --git a/test/testwish.lua b/test/testwish.lua index 2fe5d869b..dc9bbca51 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 = "=" }, + ["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"); 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/util/panic.c b/util/panic.c index d15bec88c..50fe43705 100644 --- a/util/panic.c +++ b/util/panic.c @@ -19,7 +19,7 @@ extern void vms_abort(void); #endif /*VARARGS1*/ -boolean panicking; +static boolean panicking; void panic(const char *, ...); DISABLE_WARNING_FORMAT_NONLITERAL diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index e2ca1f265..f93707463 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -6,6 +6,9 @@ #include "curses.h" #include "hack.h" #include "wincurs.h" +#include "cursinit.h" +#include "curswins.h" +#include "cursmisc.h" #include "cursdial.h" #include "func_tab.h" #include @@ -151,8 +154,9 @@ curses_line_input_dialog( free(tmpstr); } - bwin = curses_create_window(prompt_width, height, + bwin = curses_create_window(TEXT_WIN, prompt_width, height, iflags.window_inited ? UP : CENTER); + curses_set_wid_colors(TEXT_WIN, bwin); wrefresh(bwin); getbegyx(bwin, winy, winx); askwin = newwin(height, prompt_width, winy + 1, winx + 1); @@ -277,7 +281,7 @@ curses_character_input_dialog( } if (iflags.wc_popup_dialog /*|| curses_stupid_hack*/) { - askwin = curses_create_window(prompt_width, prompt_height, UP); + askwin = curses_create_window(TEXT_WIN, prompt_width, prompt_height, UP); activemenu = askwin; for (count = 0; count < prompt_height; count++) { @@ -286,6 +290,7 @@ curses_character_input_dialog( free(linestr); } + curses_set_wid_colors(TEXT_WIN, askwin); wrefresh(askwin); } else { /* TODO: add SUPPRESS_HISTORY flag, then after getting a response, @@ -392,7 +397,8 @@ curses_ext_cmd(void) if (iflags.wc_popup_dialog) { /* Prompt in popup window */ int x0, y0, w, h; /* bounding coords of popup */ - extwin2 = curses_create_window(25, 1, UP); + extwin2 = curses_create_window(TEXT_WIN, 25, 1, UP); + curses_set_wid_colors(TEXT_WIN, extwin2); wrefresh(extwin2); /* create window inside window to prevent overwriting of border */ getbegyx(extwin2, y0, x0); @@ -784,13 +790,14 @@ curses_display_nhmenu( /* Display pre and post-game menus centered */ if ((gm.moves <= 1 && !gi.invent) || gp.program_state.gameover) { - win = curses_create_window(current_menu->width, + win = curses_create_window(wid, current_menu->width, current_menu->height, CENTER); } else { /* Display during-game menus on the right out of the way */ - win = curses_create_window(current_menu->width, + win = curses_create_window(wid, current_menu->width, current_menu->height, RIGHT); } + curses_set_wid_colors(wid, win); num_chosen = menu_get_selections(win, current_menu, how); curses_destroy_win(win); @@ -1337,9 +1344,11 @@ menu_display_page( curses_toggle_color_attr(win, HIGHLIGHT_COLOR, NONE, OFF); } } - curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, ON); + if (curses_win_clr_inited(MENU_WIN) < 1) + curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, ON); box(win, 0, 0); - curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, OFF); + if (curses_win_clr_inited(MENU_WIN) < 1) + curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, OFF); wrefresh(win); } diff --git a/win/curses/cursinit.c b/win/curses/cursinit.c index 40bf3f8cb..de1811e7f 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 */ @@ -297,70 +297,76 @@ curses_create_main_windows(void) } } +static int pairs_used = 0; +static int colors_used = 0; + +/* create a new color */ +int +curses_init_rgb(int r, int g, int b) +{ + if (!can_change_color()) + return 0; + + if (colors_used < COLORS - 1) { + colors_used++; + init_color(colors_used, r*4, g*4, b*4); + return colors_used; + } + return 0; +} + +/* create a new foreground/background combination */ +int +curses_init_pair(int fg, int bg) +{ + if (pairs_used < COLOR_PAIRS - 1) { + pairs_used++; + init_pair(pairs_used, fg, bg); + return pairs_used; + } + return 0; +} + /* Initialize curses colors to colors used by NetHack */ void curses_init_nhcolors(void) { - if (has_colors()) { - use_default_colors(); - init_pair(1, COLOR_BLACK, -1); - init_pair(2, COLOR_RED, -1); - init_pair(3, COLOR_GREEN, -1); - init_pair(4, COLOR_YELLOW, -1); - init_pair(5, COLOR_BLUE, -1); - init_pair(6, COLOR_MAGENTA, -1); - init_pair(7, COLOR_CYAN, -1); - init_pair(8, -1, -1); + /* COLOR_foo + 8 means COLOR | A_BOLD when COLORS < 16 */ + /* otherwise assume the terminal has least 16 different colors */ + /* these map to the NetHack CLR_ defines */ + static const int fg_clr[16] = { + COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, + COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE, + -1, COLOR_RED + 8, COLOR_GREEN + 8, COLOR_YELLOW + 8, + COLOR_BLUE + 8, COLOR_MAGENTA + 8, COLOR_CYAN + 8, COLOR_WHITE + 8 + }; + static const int bg_clr[8] = { + -1, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, + COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE + }; + int bg, nhclr; + int maxc = (COLORS >= 16) ? 16 : 8; - { - int i; - boolean hicolor = FALSE; + if (!has_colors()) + return; - static const int clr_remap[16] = { - COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, - COLOR_BLUE, - COLOR_MAGENTA, COLOR_CYAN, -1, COLOR_WHITE, - COLOR_RED + 8, COLOR_GREEN + 8, COLOR_YELLOW + 8, - COLOR_BLUE + 8, - COLOR_MAGENTA + 8, COLOR_CYAN + 8, COLOR_WHITE + 8 - }; + use_default_colors(); - for (i = 0; i < (COLORS >= 16 ? 16 : 8); i++) { - init_pair(17 + (i * 2) + 0, clr_remap[i], COLOR_RED); - init_pair(17 + (i * 2) + 1, clr_remap[i], COLOR_BLUE); - } - - if (COLORS >= 16) - hicolor = TRUE; - - /* Work around the crazy definitions above for more background - colors... */ - for (i = 0; i < (COLORS >= 16 ? 16 : 8); i++) { - init_pair((hicolor ? 49 : 9) + i, clr_remap[i], COLOR_GREEN); - init_pair((hicolor ? 65 : 33) + i, clr_remap[i], COLOR_YELLOW); - init_pair((hicolor ? 81 : 41) + i, clr_remap[i], COLOR_MAGENTA); - init_pair((hicolor ? 97 : 49) + i, clr_remap[i], COLOR_CYAN); - init_pair((hicolor ? 113 : 57) + i, clr_remap[i], COLOR_WHITE); - } - } - - - if (COLORS >= 16) { -# ifdef USE_DARKGRAY - if (iflags.wc2_darkgray) { - init_pair(1, COLOR_BLACK + 8, -1); - } -# endif - init_pair(9, COLOR_WHITE, -1); - init_pair(10, COLOR_RED + 8, -1); - init_pair(11, COLOR_GREEN + 8, -1); - init_pair(12, COLOR_YELLOW + 8, -1); - init_pair(13, COLOR_BLUE + 8, -1); - init_pair(14, COLOR_MAGENTA + 8, -1); - init_pair(15, COLOR_CYAN + 8, -1); - init_pair(16, COLOR_WHITE + 8, -1); + for (nhclr = CLR_BLACK; nhclr < maxc; nhclr++) { + for (bg = 0; bg < 8; bg++) { + init_pair((maxc * bg) + nhclr + 1, fg_clr[nhclr], bg_clr[bg]); } } + +#ifdef USE_DARKGRAY + if (COLORS >= 16) { + if (iflags.wc2_darkgray) { + init_pair(CLR_BLACK + 1, COLOR_BLACK + 8, -1); + } + } +#endif + colors_used = maxc; + pairs_used = (maxc * 8) + 16 + 1; } #if 0 /* curses_choose_character + curses_character_dialog no longer used */ diff --git a/win/curses/cursinit.h b/win/curses/cursinit.h index ba3b5a7ee..fbc9abe08 100644 --- a/win/curses/cursinit.h +++ b/win/curses/cursinit.h @@ -9,6 +9,8 @@ /* Global declarations */ void curses_create_main_windows(void); +int curses_init_rgb(int r, int g, int b); +int curses_init_pair(int fg, int bg); void curses_init_nhcolors(void); void curses_choose_character(void); int curses_character_dialog(const char **choices, const char *prompt); diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 385b1bca0..eea0afc2f 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -54,7 +54,7 @@ static char *dummy_get_color_string(void); struct window_procs curses_procs = { WPID(curses), (WC_ALIGN_MESSAGE | WC_ALIGN_STATUS | WC_COLOR | WC_INVERSE - | WC_HILITE_PET + | WC_HILITE_PET | WC_WINDOWCOLORS #ifdef NCURSES_MOUSE_VERSION /* (this macro name works for PDCURSES too) */ | WC_MOUSE_SUPPORT #endif @@ -426,6 +426,12 @@ curses_create_nhwindow(int type) { winid wid = curses_get_wid(type); + if (curses_is_menu(wid)) + curses_parse_wid_colors(MENU_WIN, iflags.wcolors[wcolor_menu].fg, + iflags.wcolors[wcolor_menu].bg); + else if (curses_is_text(wid)) + curses_parse_wid_colors(TEXT_WIN, iflags.wcolors[wcolor_text].fg, + iflags.wcolors[wcolor_text].bg); if (curses_is_menu(wid) || curses_is_text(wid)) { curses_start_menu(wid, MENU_BEHAVE_STANDARD); curses_add_wid(wid); diff --git a/win/curses/cursmesg.c b/win/curses/cursmesg.c index 3cf16af09..894a33721 100644 --- a/win/curses/cursmesg.c +++ b/win/curses/cursmesg.c @@ -7,6 +7,7 @@ #include "hack.h" #include "wincurs.h" #include "cursmesg.h" +#include "curswins.h" #include /* defined in sys//tty.c or cursmain.c as last resort; @@ -106,6 +107,7 @@ curses_message_win_puts(const char *message, boolean recursed) return; /* user has typed ESC to avoid seeing remaining messages. */ } + curses_set_wid_colors(MESSAGE_WIN, NULL); curses_get_window_size(MESSAGE_WIN, &height, &width); border_space = (border ? 1 : 0); if (mx < border_space) @@ -322,6 +324,7 @@ curses_block( } moreattr = !iflags.wc2_guicolor ? (int) A_REVERSE : NONE; curses_toggle_color_attr(win, MORECOLOR, moreattr, ON); + curses_set_wid_colors(MESSAGE_WIN, NULL); if (blink) { wattron(win, A_BLINK); mvwprintw(win, my, mx, ">"), mx += 1; @@ -331,6 +334,7 @@ curses_block( mvwprintw(win, my, mx, ">>"), mx += 2; } curses_toggle_color_attr(win, MORECOLOR, moreattr, OFF); + curses_set_wid_colors(MESSAGE_WIN, NULL); wrefresh(win); /* cancel mesg suppression; all messages will have had chance to be read */ @@ -379,6 +383,7 @@ curses_clear_unhighlight_message_window(void) WINDOW *win = curses_get_nhwin(MESSAGE_WIN); turn_lines = 0; + curses_set_wid_colors(MESSAGE_WIN, NULL); curses_get_window_size(MESSAGE_WIN, &mh, &mw); if (mh == 1) { @@ -390,9 +395,8 @@ curses_clear_unhighlight_message_window(void) for (ry = brdroffset; ry < mh; ry++) { for (rx = brdroffset; rx < mw; rx++) { chtype cht = mvwinch(win, ry, rx); - short clr = cht & A_COLOR; - mvwchgat(win, ry, rx, 1, A_NORMAL, PAIR_NUMBER(clr), NULL); + mvwchgat(win, ry, rx, 1, A_NORMAL, PAIR_NUMBER(cht), NULL); } } @@ -413,6 +417,7 @@ curses_last_messages(void) int border = curses_window_has_border(MESSAGE_WIN) ? 1 : 0; WINDOW *win = curses_get_nhwin(MESSAGE_WIN); + curses_set_wid_colors(MESSAGE_WIN, NULL); curses_get_window_size(MESSAGE_WIN, &height, &width); werase(win); mx = my = border; @@ -605,6 +610,7 @@ curses_count_window(const char *count_text) but not for dolook's autodescribe when it refers to a named monster */ if (!countwin) countwin = newwin(1, messagew, winy, winx); + curses_set_wid_colors(MESSAGE_WIN, NULL); werase(countwin); mvwprintw(countwin, 0, 0, "%s", count_text); @@ -880,6 +886,7 @@ directional_scroll(winid wid, int nlines) boolean border = curses_window_has_border(wid); WINDOW *win = curses_get_nhwin(wid); + curses_set_wid_colors(wid, NULL); curses_get_window_size(wid, &wh, &ww); if (wh == 1) { curses_clear_nhwin(wid); @@ -1103,7 +1110,7 @@ curses_putmsghistory(const char *msg, boolean restoring_msghist) * right) brings up an initial display where the border around * the message window is missing. This draws it. */ - if (restoring_msghist) + if (restoring_msghist && !msg) curses_last_messages(); } diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index 2e3f3bd42..40585e448 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -78,6 +78,7 @@ curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff) color = NONE; int curses_color; + boolean use_bold = FALSE; /* if color is disabled, just show attribute */ if ((win == mapwin) ? !iflags.wc_color @@ -93,7 +94,7 @@ curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff) return; } - if (color == 0) { /* make black fg visible */ + if (color == CLR_BLACK) { /* make black fg visible */ # ifdef USE_DARKGRAY if (iflags.wc2_darkgray) { if (COLORS > 16) { @@ -105,17 +106,23 @@ curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff) # endif/* USE_DARKGRAY */ color = CLR_BLUE; } - curses_color = color + 1; + if (COLORS < 16) { - if (curses_color > 8 && curses_color < 17) - curses_color -= 8; - else if (curses_color > (17 + 16)) - curses_color -= 16; + /* convert NetHack's 16 colors to 8 colors + BOLD */ + int fg = color % 16; + int bg = color / 16; + + if (fg > 7) + use_bold = TRUE; + + curses_color = (8 * (bg % 8)) + (fg % 8) + 1; + } else { + curses_color = color + 1; } + if (onoff == ON) { /* Turn on color/attributes */ if (color != NONE) { - if ((((color > 7) && (color < 17)) || - (color > 17 + 17)) && (COLORS < 16)) { + if (use_bold) { wattron(win, A_BOLD); } wattron(win, COLOR_PAIR(curses_color)); @@ -127,7 +134,7 @@ curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff) } else { /* Turn off color/attributes */ if (color != NONE) { - if ((color > 7) && (COLORS < 16)) { + if (use_bold) { wattroff(win, A_BOLD); } # ifdef USE_DARKGRAY 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; } diff --git a/win/curses/curswins.c b/win/curses/curswins.c index 8e4d03b39..f8f72247c 100644 --- a/win/curses/curswins.c +++ b/win/curses/curswins.c @@ -9,7 +9,10 @@ #include "curses.h" #include "hack.h" #include "wincurs.h" +#include "cursinit.h" +#include "cursmisc.h" #include "curswins.h" +#include "cursstat.h" /* Window handling for curses interface */ @@ -23,6 +26,9 @@ typedef struct nhw { int x; /* start of window on terminal (left) */ int y; /* start of window on terminal (top) */ int orientation; /* Placement of window relative to map */ + boolean clr_inited; /* fg/bg/colorpair inited? */ + int fg, bg; /* foreground, background color index */ + int colorpair; /* color pair of fg, bg */ boolean border; /* Whether window has a visible border */ } nethack_window; @@ -52,7 +58,7 @@ static void clear_map(void); /* Create a window with the specified size and orientation */ WINDOW * -curses_create_window(int width, int height, orient orientation) +curses_create_window(int wid, int width, int height, orient orientation) { int mapx = 0, mapy = 0, maph = 0, mapw = 0; int startx = 0; @@ -142,20 +148,57 @@ curses_create_window(int width, int height, orient orientation) } win = newwin(height, width, starty, startx); - curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, ON); + + if (curses_is_text(wid)) + wid = TEXT_WIN; + else if (curses_is_menu(wid)) + wid = MENU_WIN; + + if (nhwins[wid].clr_inited < 1) + curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, ON); box(win, 0, 0); - curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, OFF); + if (nhwins[wid].clr_inited < 1) + curses_toggle_color_attr(win, DIALOG_BORDER_COLOR, NONE, OFF); return win; } +int +curses_win_clr_inited(int wid) +{ + if (curses_is_text(wid)) { + wid = TEXT_WIN; + } else if (curses_is_menu(wid)) { + wid = MENU_WIN; + } + return nhwins[wid].clr_inited; +} + +void +curses_set_wid_colors(int wid, WINDOW *win) +{ + if (wid == TEXT_WIN || curses_is_text(wid)) { + wid = TEXT_WIN; + if (!nhwins[wid].clr_inited) + curses_parse_wid_colors(wid, iflags.wcolors[wcolor_text].fg, + iflags.wcolors[wcolor_text].bg); + } else if (wid == MENU_WIN || curses_is_menu(wid)) { + wid = MENU_WIN; + if (!nhwins[wid].clr_inited) + curses_parse_wid_colors(wid, iflags.wcolors[wcolor_menu].fg, + iflags.wcolors[wcolor_menu].bg); + } + /* FIXME: colors and nhwins[] entry for perm invent window */ + if (nhwins[wid].clr_inited > 0) { + wbkgd(win ? win : nhwins[wid].curwin, + COLOR_PAIR(nhwins[wid].colorpair)); + } +} /* Erase and delete curses window, and refresh standard windows */ void curses_destroy_win(WINDOW *win) { - werase(win); - wrefresh(win); delwin(win); if (win == activemenu) activemenu = NULL; @@ -185,6 +228,7 @@ curses_refresh_nethack_windows(void) refresh(); } else { if (status_window != NULL) { + curses_set_wid_colors(STATUS_WIN, NULL); touchwin(status_window); wnoutrefresh(status_window); } @@ -193,6 +237,7 @@ curses_refresh_nethack_windows(void) wnoutrefresh(map_window); } if (message_window != NULL) { + curses_set_wid_colors(MESSAGE_WIN, NULL); touchwin(message_window); wnoutrefresh(message_window); } @@ -219,6 +264,67 @@ curses_get_nhwin(winid wid) return nhwins[wid].curwin; } +boolean +parse_hexstr(char *colorbuf, int *red, int *green, int *blue) +{ + int len = colorbuf ? strlen(colorbuf) : 0; + + if (len == 7 && colorbuf[0] == '#') { + char tmpbuf[16]; + + Sprintf(tmpbuf, "0x%c%c", colorbuf[1], colorbuf[2]); + *red = strtol(tmpbuf, NULL, 0); + Sprintf(tmpbuf, "0x%c%c", colorbuf[3], colorbuf[4]); + *green = strtol(tmpbuf, NULL, 0); + Sprintf(tmpbuf, "0x%c%c", colorbuf[5], colorbuf[6]); + *blue = strtol(tmpbuf, NULL, 0); + return TRUE; + } + return FALSE; +} + +void +curses_parse_wid_colors(int wid, char *fg, char *bg) +{ + + if (curses_is_text(wid)) { + wid = TEXT_WIN; + } else if (curses_is_menu(wid)) { + wid = MENU_WIN; + } + + if (nhwins[wid].clr_inited) + return; + + int nh_fg = fg ? match_str2clr(fg, TRUE) : CLR_MAX; + int nh_bg = bg ? match_str2clr(bg, TRUE) : CLR_MAX; + int r, g, b; + + if (nh_fg == CLR_MAX) { + if (fg && parse_hexstr(fg, &r, &g, &b)) { + nh_fg = curses_init_rgb(r, g, b); + } else { + nh_fg = -1; + } + } + if (nh_bg == CLR_MAX) { + if (bg && parse_hexstr(bg, &r, &g, &b)) { + nh_bg = curses_init_rgb(r, g, b); + } else { + nh_bg = -1; + } + } + + nhwins[wid].fg = nh_fg; + nhwins[wid].bg = nh_bg; + if (nh_fg == -1 || nh_bg == -1) { + nhwins[wid].clr_inited = -1; + } else { + nhwins[wid].colorpair = curses_init_pair(nh_fg, nh_bg); + nhwins[wid].clr_inited = 1; + } +} + /* Add curses window pointer and window info to list for given NetHack winid */ @@ -243,6 +349,9 @@ curses_add_nhwin(winid wid, int height, int width, int y, int x, nhwins[wid].x = x; nhwins[wid].y = y; nhwins[wid].orientation = orientation; + nhwins[wid].fg = nhwins[wid].bg = 0; + nhwins[wid].colorpair = -1; + nhwins[wid].clr_inited = 0; if (border) { real_width += 2; /* leave room for bounding box */ @@ -250,13 +359,20 @@ curses_add_nhwin(winid wid, int height, int width, int y, int x, } win = newwin(real_height, real_width, y, x); + nhwins[wid].curwin = win; switch (wid) { case MESSAGE_WIN: messagewin = win; + curses_parse_wid_colors(wid, iflags.wcolors[wcolor_message].fg, + iflags.wcolors[wcolor_message].bg); + curses_set_wid_colors(wid, NULL); break; case STATUS_WIN: statuswin = win; + curses_parse_wid_colors(wid, iflags.wcolors[wcolor_status].fg, + iflags.wcolors[wcolor_status].bg); + curses_set_wid_colors(wid, NULL); break; case MAP_WIN: mapwin = win; @@ -268,7 +384,6 @@ curses_add_nhwin(winid wid, int height, int width, int y, int x, box(win, 0, 0); } - nhwins[wid].curwin = win; } @@ -303,6 +418,7 @@ curses_add_wid(winid wid) void curses_refresh_nhwin(winid wid) { + curses_set_wid_colors(wid, NULL); wnoutrefresh(curses_get_nhwin(wid)); doupdate(); } @@ -461,6 +577,10 @@ curses_get_window_size(winid wid, int *height, int *width) boolean curses_window_has_border(winid wid) { + if (curses_is_menu(wid)) + wid = MENU_WIN; + else if (curses_is_text(wid)) + wid = TEXT_WIN; return nhwins[wid].border; } @@ -525,6 +645,7 @@ curses_puts(winid wid, int attr, const char *text) } #endif + curses_set_wid_colors(wid, NULL); if (curses_is_menu(wid) || curses_is_text(wid)) { if (!curses_menu_exists(wid)) { impossible( @@ -555,6 +676,7 @@ curses_clear_nhwin(winid wid) clear_map(); } + curses_set_wid_colors(wid, NULL); werase(win); if (border) { @@ -570,6 +692,7 @@ curses_alert_win_border(winid wid, boolean onoff) if (!win || !curses_window_has_border(wid)) return; + curses_set_wid_colors(wid, NULL); if (onoff) curses_toggle_color_attr(win, ALERT_BORDER_COLOR, NONE, ON); box(win, 0, 0); @@ -607,23 +730,8 @@ coordinates without a refresh. Currently only used for the map. */ static int get_framecolor(int nhcolor, int framecolor) { - boolean hicolor = (COLORS >= 16), adj_framecolor = framecolor; - static int framecolors[16][8] = { - { 0, 16, 8, 32, 17, 40, 48, 0 }, { 1, 18, 9, 33, 19, 41, 49, 1 }, - { 2, 20, 10, 34, 21, 42, 50, 2 }, { 3, 22, 11, 35, 23, 43, 51, 3 }, - { 4, 24, 12, 36, 25, 44, 52, 4 }, { 5, 26, 13, 37, 27, 45, 53, 5 }, - { 6, 28, 14, 38, 29, 46, 54, 6 }, { 0, 30, 15, 72, 31, 88, 56, 0 }, - { 0, 30, 15, 39, 31, 47, 55, 0 }, { 1, 18, 9, 73, 19, 89, 57, 121 }, - { 2, 20, 10, 74, 21, 90, 58, 122 }, { 2, 22, 11, 75, 23, 91, 59, 123 }, - { 4, 24, 12, 76, 25, 44, 60, 124 }, { 5, 26, 13, 77, 27, 93, 61, 125 }, - { 6, 28, 14, 78, 29, 94, 62, 126 }, { 0, 30, 15, 79, 31, 95, 63, 127 }, - }; - - if (framecolor < 16 && framecolor >= 8) - adj_framecolor = framecolor - 8; - return ((nhcolor < (hicolor ? 16 : 8) && adj_framecolor < 8) - ? framecolors[nhcolor][adj_framecolor] - : nhcolor); + /* curses_toggle_color_attr() adds the +1 and takes care of COLORS < 16 */ + return (16 * (framecolor % 8)) + (nhcolor % 16); } static void diff --git a/win/curses/curswins.h b/win/curses/curswins.h index 589e81bb0..5842f52ed 100644 --- a/win/curses/curswins.h +++ b/win/curses/curswins.h @@ -9,11 +9,15 @@ /* Global declarations */ -WINDOW *curses_create_window(int width, int height, orient orientation); +WINDOW *curses_create_window(int wid, int width, int height, orient orientation); +int curses_win_clr_inited(int wid); +void curses_set_wid_colors(int wid, WINDOW *win); void curses_destroy_win(WINDOW * win); void curses_refresh_nethack_windows(void); WINDOW *curses_get_nhwin(winid wid); +void curses_parse_wid_colors(int wid, char *fg, char *bg); +boolean parse_hexstr(char *colorbuf, int *red, int *green, int *blue); void curses_add_nhwin(winid wid, int height, int width, int y, int x, orient orientation, boolean border); void curses_add_wid(winid wid); diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index e40c8a307..8f5f86c61 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -240,22 +240,22 @@ mswin_init_nhwindows(int *argc, char **argv) | WC_FONTSIZ_TEXT | WC_VARY_MSGCOUNT, set_in_game); - mswin_color_from_string(iflags.wc_foregrnd_menu, &menu_fg_brush, - &menu_fg_color); - mswin_color_from_string(iflags.wc_foregrnd_message, &message_fg_brush, - &message_fg_color); - mswin_color_from_string(iflags.wc_foregrnd_status, &status_fg_brush, - &status_fg_color); - mswin_color_from_string(iflags.wc_foregrnd_text, &text_fg_brush, - &text_fg_color); - mswin_color_from_string(iflags.wc_backgrnd_menu, &menu_bg_brush, - &menu_bg_color); - mswin_color_from_string(iflags.wc_backgrnd_message, &message_bg_brush, - &message_bg_color); - mswin_color_from_string(iflags.wc_backgrnd_status, &status_bg_brush, - &status_bg_color); - mswin_color_from_string(iflags.wc_backgrnd_text, &text_bg_brush, - &text_bg_color); + mswin_color_from_string(iflags.wcolors[wcolor_menu].fg, + &menu_fg_brush, &menu_fg_color); + mswin_color_from_string(iflags.wcolors[wcolor_message].fg, + &message_fg_brush, &message_fg_color); + mswin_color_from_string(iflags.wcolors[wcolor_status].fg, + &status_fg_brush, &status_fg_color); + mswin_color_from_string(iflags.wcolors[wcolor_text].fg, + &text_fg_brush, &text_fg_color); + mswin_color_from_string(iflags.wcolors[wcolor_menu].bg, + &menu_bg_brush, &menu_bg_color); + mswin_color_from_string(iflags.wcolors[wcolor_message].bg, + &message_bg_brush, &message_bg_color); + mswin_color_from_string(iflags.wcolors[wcolor_status].bg, + &status_bg_brush, &status_bg_color); + mswin_color_from_string(iflags.wcolors[wcolor_text].bg, + &text_bg_brush, &text_bg_color); if (iflags.wc_splash_screen) mswin_display_splash_window(FALSE);