From 0dd715da114360a73a90ad3aad2933e3015b9837 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 5 May 2015 06:55:56 +0300 Subject: [PATCH 1/9] Revert previous, with a comment in code --- src/do.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/do.c b/src/do.c index d85859353..75cf52cf2 100644 --- a/src/do.c +++ b/src/do.c @@ -218,7 +218,8 @@ const char *verb; /* Globby things like puddings might stick together */ while (obj && (otmp = obj_nexto_xy(obj->otyp, x, y, obj->o_id)) != (struct obj*)0) { pudding_merge_message(obj, otmp); - obj = obj_meld(&obj, &otmp); + /* intentionally not getting the melded object; obj_meld may set obj to null. */ + (void) obj_meld(&obj, &otmp); } return (obj == NULL); } From fd8127dcf4da1a4ebb5a40b6793a1d53fe445dc1 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 5 May 2015 21:29:24 +0300 Subject: [PATCH 2/9] Fix impossible when quivered gold was stolen from you --- src/steal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/steal.c b/src/steal.c index e3f09f524..01036180b 100644 --- a/src/steal.c +++ b/src/steal.c @@ -115,6 +115,7 @@ register struct monst *mtmp; tmp = (somegold(money_cnt(invent)) + gold_price - 1) / gold_price; tmp = min(tmp, ygold->quan); if (tmp < ygold->quan) ygold = splitobj(ygold, tmp); + else setnotworn(ygold); freeinv(ygold); add_to_minv(mtmp, ygold); Your("purse feels lighter."); From 7b75da924e596fa1782033918e4fcb734049b090 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 5 May 2015 16:25:49 -0700 Subject: [PATCH 3/9] another pass at "gold wield inconsistency" Handle !fixinv by forcing gold to have slot '$' all the time; that particular type of object is 'fixed' regardless of user preference. Also add a couple of checks for non-'$' gold when selecting from inventory, just in case the issue of multiple gold stacks reappears. --- src/invent.c | 55 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/src/invent.c b/src/invent.c index 7b3861e62..c413d1399 100644 --- a/src/invent.c +++ b/src/invent.c @@ -425,8 +425,8 @@ struct obj *obj; goto added; } /* didn't merge, so insert into chain */ + assigninvlet(obj); if (flags.invlet_constant || !prev) { - if (flags.invlet_constant) assigninvlet(obj); obj->nobj = invent; /* insert at beginning */ invent = obj; if (flags.invlet_constant) reorder_invent(); @@ -1134,7 +1134,14 @@ register const char *let,*word; } /* they typed a letter (not a space) at the prompt */ } - if (ilet == def_oc_syms[COIN_CLASS].sym) { + /* find the item which was picked */ + for (otmp = invent; otmp; otmp = otmp->nobj) + if (otmp->invlet == ilet) break; + /* some items have restrictions */ + if (ilet == def_oc_syms[COIN_CLASS].sym + /* guard against the [hypothetical] chace of having more + than one invent slot of gold and picking the non-'$' one */ + || (otmp && otmp->oclass == COIN_CLASS)) { if (!usegold) { You("cannot %s gold.", word); return(struct obj *)0; @@ -1156,7 +1163,8 @@ register const char *let,*word; /* permit counts for throwing gold, but don't accept * counts for other things since the throw code will * split off a single item anyway */ - if (ilet != def_oc_syms[COIN_CLASS].sym) + if (ilet != def_oc_syms[COIN_CLASS].sym + && !(otmp && otmp->oclass == COIN_CLASS)) allowcnt = 1; if (cnt == 0 && prezero) return (struct obj *)0; if (cnt > 1) { @@ -1166,8 +1174,9 @@ register const char *let,*word; } context.botl = 1; /* May have changed the amount of money */ savech(ilet); - for (otmp = invent; otmp; otmp = otmp->nobj) - if (otmp->invlet == ilet) break; + /* [we used to set otmp (by finding ilet in invent) here, but + that's been moved above so that otmp can be checked earlier] */ + /* verify the chosen object */ if(!otmp) { You("don't have that object."); if (in_doagain) return((struct obj *) 0); @@ -2958,23 +2967,33 @@ free_invbuf() invbufsiz = 0; } -/* give consecutive letters to every item in inventory (for !fixinv mode) */ +/* give consecutive letters to every item in inventory (for !fixinv mode); + gold is always forced to '$' slot at head of list */ void reassign() { - register int i; - register struct obj *obj; + int i; + struct obj *obj, *prevobj, *goldobj; - for(obj = invent, i = 0; obj; obj = obj->nobj, i++) { - if (obj->oclass == COIN_CLASS && obj->invlet == GOLD_SYM) - --i; /* keep $ instead of using up i'th letter */ - else - if (i < 52) - obj->invlet = (i < 26) ? ('a'+i) : ('A'+i-26); - else if (obj->oclass == COIN_CLASS) - obj->invlet = GOLD_SYM; - else - obj->invlet = NOINVSYM; + /* first, remove [first instance of] gold from invent, if present */ + prevobj = goldobj = 0; + for (obj = invent; obj; prevobj = obj, obj = obj->nobj) + if (obj->oclass == COIN_CLASS) { + goldobj = obj; + if (prevobj) + prevobj->nobj = goldobj->nobj; + else + invent = goldobj->nobj; + break; + } + /* second, re-letter the rest of the list */ + for (obj = invent, i = 0; obj; obj = obj->nobj, i++) + obj->invlet = (i < 26) ? ('a'+i) : (i < 52) ? ('A'+i-26) : NOINVSYM; + /* third, assign gold the "letter" '$' and re-insert it at head */ + if (goldobj) { + goldobj->invlet = GOLD_SYM; + goldobj->nobj = invent; + invent = goldobj; } if (i >= 52) i = 52 - 1; lastinvnr = i; From 2a4bf5efa703024c78f57eafa6ebd0b07843db70 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 6 May 2015 09:54:28 +0300 Subject: [PATCH 4/9] Comment for the pudding glob order --- src/monst.c | 2 ++ src/objects.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/monst.c b/src/monst.c index 791cd57c5..21d585393 100644 --- a/src/monst.c +++ b/src/monst.c @@ -1818,6 +1818,8 @@ struct permonst _mons2[] = { M3_INFRAVISIBLE|M3_INFRAVISION, HI_LORD), /* * Puddings + * + * must be in the same order as the pudding globs in objects.c */ MON("gray ooze", S_PUDDING, LVL(3, 1, 8, 0, 0), (G_GENO|G_NOCORPSE|2), diff --git a/src/objects.c b/src/objects.c index b4c26041a..4d6f44709 100644 --- a/src/objects.c +++ b/src/objects.c @@ -675,7 +675,8 @@ OBJECT(OBJ("meat ring", (char *)0), BITS(1,0,0,0,0,0,0,0,0,0,0,0,FLESH), 0, FOOD_CLASS, 0, 1, 5, 1, 0, 0, 0, 0, 5, CLR_BROWN), -/* pudding 'corpses' will turn into these and combine */ +/* pudding 'corpses' will turn into these and combine. + must be in same order as the pudding monsters */ FOOD("glob of gray ooze", 0, 2, 20, 0, FLESH, 20, CLR_GRAY), FOOD("glob of brown pudding", 0, 2, 20, 0, FLESH, 20, CLR_BROWN), FOOD("glob of green slime", 0, 2, 20, 0, FLESH, 20, CLR_GREEN), From e72246f1d1dee91545bb45aa4f3609e6d788d562 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 6 May 2015 00:38:16 -0700 Subject: [PATCH 5/9] new file: include/lint.h modified files: include/hack.h, src/decl.c, sys/unix/Makefile.src Groundwork for cleaning up the X11 sources, where gcc with the option settings specified in the OSX hints file currently generates close to 400 warnings for win/X11/*.c. lint.h is included by hack.h, and I've moved the debugpline stuff from the latter to the former to hide it better. (By rights it belongs in debug.h or something of the sort, but I didn't want to go that far.) Makefile and project dependencies need to catch up. nhStr() hides a cast to char *, and is intended to by used on string literals where it isn't feasible to maintain the 'const' attribute. (A pernicious problem with X11 code, where the include situation can become very convoluted, and many, MANY string literals are hidden behind macros to look like keyword-type tokens.) nhUse() can be used to force a fake usage on something which triggers an unused parameter warning. There are a 6 or 8 or 10 places in the core code where that applies, but so far I have't touched any of them. There's a tradeoff since it will result in some worthless code being generated and executed, but is much simpler than tacking on compiler- specific workarounds like '#pragma unused' or gcc's __attribute__ hack. --- include/hack.h | 20 ++--------------- include/lint.h | 52 +++++++++++++++++++++++++++++++++++++++++++ src/decl.c | 5 ++++- sys/unix/Makefile.src | 9 ++++---- 4 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 include/lint.h diff --git a/include/hack.h b/include/hack.h index 2dcc91699..ac4703f2b 100644 --- a/include/hack.h +++ b/include/hack.h @@ -1,4 +1,4 @@ -/* NetHack 3.5 hack.h $NHDT-Date: 1426465431 2015/03/16 00:23:51 $ $NHDT-Branch: debug $:$NHDT-Revision: 1.52 $ */ +/* NetHack 3.5 hack.h $NHDT-Date: 1430897858 2015/05/06 07:37:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */ /* NetHack 3.5 hack.h $Date: 2009/05/06 10:44:46 $ $Revision: 1.49 $ */ /* SCCS Id: @(#)hack.h 3.5 2008/03/19 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ @@ -10,23 +10,7 @@ #ifndef CONFIG_H #include "config.h" #endif - -/* [DEBUG shouldn't be defined unless you know what you're doing...] */ -#ifdef DEBUG -# define ifdebug(stmt) do { if (showdebug(__FILE__)) stmt; } while (0) -/* these don't require compiler support for C99 variadic macros */ -# define debugpline0(str) ifdebug(pline(str)) -# define debugpline1(fmt,arg) ifdebug(pline(fmt,arg)) -# define debugpline2(fmt,a1,a2) ifdebug(pline(fmt,a1,a2)) -# define debugpline3(fmt,a1,a2,a3) ifdebug(pline(fmt,a1,a2,a3)) -# define debugpline4(fmt,a1,a2,a3,a4) ifdebug(pline(fmt,a1,a2,a3,a4)) -#else -# define debugpline0(str) /*empty*/ -# define debugpline1(fmt,arg) /*empty*/ -# define debugpline2(fmt,a1,a2) /*empty*/ -# define debugpline3(fmt,a1,a2,a3) /*empty*/ -# define debugpline4(fmt,a1,a2,a3,a4) /*empty*/ -#endif /*DEBUG*/ +#include "lint.h" #define TELL 1 #define NOTELL 0 diff --git a/include/lint.h b/include/lint.h new file mode 100644 index 000000000..abe98888c --- /dev/null +++ b/include/lint.h @@ -0,0 +1,52 @@ +/* NetHack 3.5 lint.h $NHDT-Date: 1430897871 2015/05/06 07:37:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.0 $ */ +/* NetHack may be freely redistributed. See license for details. */ + +/* + * Hacks to suppress compiler warnings. Use with caution. + * Assumes it has been preceded by '#include "config.h"' but + * not necessarily by '#include "hack.h"'. + */ +#ifndef LINT_H +#define LINT_H + +/* cast away implicit const from a string literal (caller's responsibility + to ensure that) in order to avoid a warning from 'gcc -Wwrite-strings' + (also caller's responsibility to ensure it isn't actually modified!) */ +#define nhStr(str) ((char *)str) + +#if defined(GCC_WARN) && !defined(FORCE_ARG_USAGE) +# define FORCE_ARG_USAGE +#endif + +#ifdef FORCE_ARG_USAGE +/* force an unused function argument to become used in an arbitrary + manner in order to suppress warning about unused function arguments; + viable for scalar and pointer arguments */ +# define nhUse(arg) nhUse_dummy += (unsigned)arg; +extern unsigned nhUse_dummy; +#else +# define nhUse(arg) /*empty*/ +#endif + +/* + * This stuff isn't related to lint suppression but lives here to + * avoid cluttering up hack.h. + */ +/* [DEBUG shouldn't be defined unless you know what you're doing...] */ +#ifdef DEBUG +# define ifdebug(stmt) do { if (showdebug(__FILE__)) stmt; } while (0) +/* these don't require compiler support for C99 variadic macros */ +# define debugpline0(str) ifdebug(pline(str)) +# define debugpline1(fmt,arg) ifdebug(pline(fmt,arg)) +# define debugpline2(fmt,a1,a2) ifdebug(pline(fmt,a1,a2)) +# define debugpline3(fmt,a1,a2,a3) ifdebug(pline(fmt,a1,a2,a3)) +# define debugpline4(fmt,a1,a2,a3,a4) ifdebug(pline(fmt,a1,a2,a3,a4)) +#else +# define debugpline0(str) /*empty*/ +# define debugpline1(fmt,arg) /*empty*/ +# define debugpline2(fmt,a1,a2) /*empty*/ +# define debugpline3(fmt,a1,a2,a3) /*empty*/ +# define debugpline4(fmt,a1,a2,a3,a4) /*empty*/ +#endif /*DEBUG*/ + +#endif /* LINT_H */ diff --git a/src/decl.c b/src/decl.c index 3508b2621..3bbced5cc 100644 --- a/src/decl.c +++ b/src/decl.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 decl.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 decl.c $NHDT-Date: 1430897862 2015/05/06 07:37:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.56 $ */ /* NetHack 3.5 decl.c $Date: 2012/04/09 02:56:30 $ $Revision: 1.37 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -331,6 +331,9 @@ NEARDATA struct savefile_info sfrestinfo, sfsaveinfo = { char *ARGV0; #endif +/* support for lint.h */ +unsigned nhUse_dummy = 0; + /* dummy routine used to force linkage */ void decl_init() diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 79d34fc64..be4c00d7c 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -1,5 +1,5 @@ # NetHack Makefile. -# NetHack 3.5 Makefile.src $NHDT-Date: 1428590253 2015/04/09 14:37:33 $ $NHDT-Branch: scshunt-regex $:$NHDT-Revision: 1.38 $ +# NetHack 3.5 Makefile.src $NHDT-Date: 1430897864 2015/05/06 07:37:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.39 $ # NetHack 3.5 Makefile.src $Date: 2012/01/20 03:41:33 $ $Revision: 1.37 $ # Root of source tree: @@ -369,7 +369,8 @@ CSOURCES = $(HACKCSRC) $(SYSCSRC) $(WINCSRC) $(CHAINSRC) $(GENCSRC) HACKINCL = align.h amiconf.h artifact.h artilist.h attrib.h beconf.h botl.h \ color.h config.h config1.h context.h coord.h decl.h def_os2.h \ display.h dlb.h dungeon.h engrave.h extern.h flag.h func_tab.h \ - global.h hack.h lev.h macconf.h mextra.h mfndpos.h micro.h mkroom.h \ + global.h hack.h lev.h lint.h macconf.h mextra.h mfndpos.h micro.h \ + mkroom.h \ monattk.h mondata.h monflag.h monst.h monsym.h obj.h objclass.h \ os2conf.h patchlevel.h pcconf.h permonst.h prop.h rect.h region.h rm.h \ sp_lev.h spell.h sys.h system.h tcap.h timeout.h tosconf.h tradstdc.h \ @@ -572,7 +573,7 @@ $(CONFIG_H): ../include/config.h ../include/config1.h ../include/tradstdc.h \ ../include/wceconf.h ../include/ntconf.h touch $(CONFIG_H) # hack.h timestamp -$(HACK_H): ../include/hack.h $(CONFIG_H) ../include/align.h \ +$(HACK_H): ../include/hack.h $(CONFIG_H) ../include/lint.h ../include/align.h \ ../include/dungeon.h ../include/monsym.h ../include/mkroom.h \ ../include/objclass.h ../include/youprop.h ../include/prop.h \ ../include/permonst.h ../include/monattk.h \ @@ -624,7 +625,7 @@ topl.o: ../win/tty/topl.c $(HACK_H) ../include/tcap.h wintty.o: ../win/tty/wintty.c $(HACK_H) ../include/dlb.h ../include/tcap.h $(CC) $(CFLAGS) -c ../win/tty/wintty.c Window.o: ../win/X11/Window.c ../include/xwindowp.h ../include/xwindow.h \ - $(CONFIG_H) + $(CONFIG_H) ../include/lint.h $(CC) $(CFLAGS) -c ../win/X11/Window.c dialogs.o: ../win/X11/dialogs.c $(CONFIG_H) $(CC) $(CFLAGS) -c ../win/X11/dialogs.c From 9de8b03c03bc3202b1449bea215de60c9d902261 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 6 May 2015 00:59:15 -0700 Subject: [PATCH 6/9] X11 lint suppression Suppress close to 400 warnings generated by gcc on the win/X11/*.c code, most due to -Wwrite-strings which makes string literals implicitly have the 'const' attribute. (Since modifying a string literal results in undefined behavior, that is an appropriate check to have enabled, but it can be troublesome since string literals have type 'char *' and code that uses them that way is correct provided it avoids modifying them.) 113 warning: initialization discards qualifiers from pointer target type 127 warning: assignment discards qualifiers from pointer target type 29 warning: passing argument discards qualifiers from pointer target type 109 warning: unused parameter 12 warning: comparison between signed and unsigned The nhStr() hack casts to 'char *', explicitly removing 'const', for situations where it isn't feasible to make code directly honor const. The vast marjority of uses are for the second parameter to XtSetArg(), which is a macro that actually performs an assignment with the second argument rather than passing it in a function. It takes values like 'XtNtop', which doesn't need to be altered (although in many places I changed that to nhStr(XtNtop) for uniformity with the surrounding code, and 'XtNbottom', which does need to have the extra const stripping to avoid a warning. Go figure. The nhUse() hack actually uses its argument in a meaningless way if the code is compiled with FORCE_ARG_USAGE defined. When GCC_WARN is defined, FORCE_ARG_USAGE will be enabled if it hasn't been already. Example: /*ARGUSED*/ int foo(arg) int arg; /* not used */ { + nhUse(arg); return 0; } The extra line will expand to ';' when FORCE_ARG_USAGE is not defined or too nhUse_dummy += (unsigned)arg; when it is. I figured direct assignment might lead to a different warning by some compilers in a situation like nhUse(arg); nhUse(otherarg); where the first assignment would be clobbered by the second, and using bitwise operations or safer '+= (arg != 0)' would most likely generate more non-useful code. Some tweaking might turn out to be necessary. --- include/winX.h | 4 +- win/X11/Window.c | 93 ++++++++------- win/X11/dialogs.c | 111 +++++++++--------- win/X11/winX.c | 280 +++++++++++++++++++++++++++++----------------- win/X11/winmap.c | 43 +++---- win/X11/winmenu.c | 160 ++++++++++++++++---------- win/X11/winmesg.c | 11 +- win/X11/winmisc.c | 64 +++++++++-- win/X11/winstat.c | 73 ++++++------ win/X11/wintext.c | 36 ++++-- win/X11/winval.c | 8 +- 11 files changed, 542 insertions(+), 341 deletions(-) diff --git a/include/winX.h b/include/winX.h index b80c6e245..e6b62c21b 100644 --- a/include/winX.h +++ b/include/winX.h @@ -1,4 +1,4 @@ -/* NetHack 3.5 winX.h $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 winX.h $NHDT-Date: 1430899132 2015/05/06 07:58:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */ /* NetHack 3.5 winX.h $Date: 2012/01/24 04:26:18 $ $Revision: 1.9 $ */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ @@ -356,7 +356,7 @@ E void FDECL(calculate_rip_text, (int,time_t)); /* ### winval.c ### */ E Widget FDECL(create_value,(Widget, const char*)); -E void FDECL(set_name,(Widget, char*)); +E void FDECL(set_name,(Widget, const char*)); E void FDECL(set_name_width,(Widget, int)); E int FDECL(get_name_width,(Widget)); E void FDECL(set_value,(Widget, const char*)); diff --git a/win/X11/Window.c b/win/X11/Window.c index 2fa400541..d33e62611 100644 --- a/win/X11/Window.c +++ b/win/X11/Window.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 Window.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 Window.c $NHDT-Date: 1430899134 2015/05/06 07:58:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */ /* NetHack 3.5 Window.c $Date: 2009/05/06 10:55:43 $ $Revision: 1.4 $ */ /* SCCS Id: @(#)Window.c 3.5 1993/02/02 */ /* Copyright (c) Dean Luick, 1992 */ @@ -34,55 +34,56 @@ #include "xwindowp.h" #include "config.h" +#include "lint.h" static XtResource resources[] = { #define offset(field) XtOffset(WindowWidget, window.field) /* {name, class, type, size, offset, default_type, default_addr}, */ - { XtNrows, XtCRows, XtRDimension, sizeof(Dimension), + { nhStr(XtNrows), nhStr(XtCRows), XtRDimension, sizeof(Dimension), offset(rows), XtRImmediate, (XtPointer) 21}, - { XtNcolumns, XtCColumns, XtRDimension, sizeof(Dimension), + { nhStr(XtNcolumns), nhStr(XtCColumns), XtRDimension, sizeof(Dimension), offset(columns), XtRImmediate, (XtPointer) 80}, - { XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), - offset(foreground), XtRString, XtDefaultForeground }, + { nhStr(XtNforeground), XtCForeground, XtRPixel, sizeof(Pixel), + offset(foreground), XtRString, (XtPointer) XtDefaultForeground }, - { XtNblack, XtCColor, XtRPixel, sizeof(Pixel), - offset(black), XtRString, "black"}, - { XtNred, XtCColor, XtRPixel, sizeof(Pixel), - offset(red), XtRString, "red" }, - { XtNgreen, XtCColor, XtRPixel, sizeof(Pixel), - offset(green), XtRString, "pale green" }, - { XtNbrown, XtCColor, XtRPixel, sizeof(Pixel), - offset(brown), XtRString, "brown" }, - { XtNblue, XtCColor, XtRPixel, sizeof(Pixel), - offset(blue), XtRString, "blue" }, - { XtNmagenta, XtCColor, XtRPixel, sizeof(Pixel), - offset(magenta), XtRString, "magenta" }, - { XtNcyan, XtCColor, XtRPixel, sizeof(Pixel), - offset(cyan), XtRString, "light cyan" }, - { XtNgray, XtCColor, XtRPixel, sizeof(Pixel), - offset(gray), XtRString, "gray" }, - { XtNorange, XtCColor, XtRPixel, sizeof(Pixel), - offset(orange), XtRString, "orange" }, - { XtNbright_green, XtCColor, XtRPixel, sizeof(Pixel), - offset(bright_green), XtRString, "green" }, - { XtNyellow, XtCColor, XtRPixel, sizeof(Pixel), - offset(yellow), XtRString, "yellow" }, - { XtNbright_blue, XtCColor, XtRPixel, sizeof(Pixel), - offset(bright_blue), XtRString, "royal blue" }, - { XtNbright_magenta, XtCColor, XtRPixel, sizeof(Pixel), - offset(bright_magenta), XtRString, "violet" }, - { XtNbright_cyan, XtCColor, XtRPixel, sizeof(Pixel), - offset(bright_cyan), XtRString, "cyan" }, - { XtNwhite, XtCColor, XtRPixel, sizeof(Pixel), - offset(white), XtRString, "white" }, + { nhStr(XtNblack), XtCColor, XtRPixel, sizeof(Pixel), + offset(black), XtRString, (XtPointer) "black"}, + { nhStr(XtNred), XtCColor, XtRPixel, sizeof(Pixel), + offset(red), XtRString, (XtPointer) "red" }, + { nhStr(XtNgreen), XtCColor, XtRPixel, sizeof(Pixel), + offset(green), XtRString, (XtPointer) "pale green" }, + { nhStr(XtNbrown), XtCColor, XtRPixel, sizeof(Pixel), + offset(brown), XtRString, (XtPointer) "brown" }, + { nhStr(XtNblue), XtCColor, XtRPixel, sizeof(Pixel), + offset(blue), XtRString, (XtPointer) "blue" }, + { nhStr(XtNmagenta), XtCColor, XtRPixel, sizeof(Pixel), + offset(magenta), XtRString, (XtPointer) "magenta" }, + { nhStr(XtNcyan), XtCColor, XtRPixel, sizeof(Pixel), + offset(cyan), XtRString, (XtPointer) "light cyan" }, + { nhStr(XtNgray), XtCColor, XtRPixel, sizeof(Pixel), + offset(gray), XtRString, (XtPointer) "gray" }, + { nhStr(XtNorange), XtCColor, XtRPixel, sizeof(Pixel), + offset(orange), XtRString, (XtPointer) "orange" }, + { nhStr(XtNbright_green), XtCColor, XtRPixel, sizeof(Pixel), + offset(bright_green), XtRString, (XtPointer) "green" }, + { nhStr(XtNyellow), XtCColor, XtRPixel, sizeof(Pixel), + offset(yellow), XtRString, (XtPointer) "yellow" }, + { nhStr(XtNbright_blue), XtCColor, XtRPixel, sizeof(Pixel), + offset(bright_blue), XtRString, (XtPointer) "royal blue" }, + { nhStr(XtNbright_magenta), XtCColor, XtRPixel, sizeof(Pixel), + offset(bright_magenta), XtRString, (XtPointer) "violet" }, + { nhStr(XtNbright_cyan), XtCColor, XtRPixel, sizeof(Pixel), + offset(bright_cyan), XtRString, (XtPointer) "cyan" }, + { nhStr(XtNwhite), XtCColor, XtRPixel, sizeof(Pixel), + offset(white), XtRString, (XtPointer) "white" }, - { XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), - offset(font), XtRString, XtDefaultFont }, - { XtNexposeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList), + { nhStr(XtNfont), XtCFont, XtRFontStruct, sizeof(XFontStruct *), + offset(font), XtRString, (XtPointer) XtDefaultFont }, + { nhStr(XtNexposeCallback), XtCCallback, XtRCallback, sizeof(XtCallbackList), offset(expose_callback), XtRCallback, (char *)0 }, - { XtNcallback, XtCCallback, XtRCallback, sizeof(XtCallbackList), + { nhStr(XtNcallback), XtCCallback, XtRCallback, sizeof(XtCallbackList), offset(input_callback), XtRCallback, (char *)0 }, - { XtNresizeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList), + { nhStr(XtNresizeCallback), XtCCallback, XtRCallback, sizeof(XtCallbackList), offset(resize_callback), XtRCallback, (char *)0 }, #undef offset }; @@ -94,11 +95,17 @@ static void no_op(w, event, params, num_params) String *params; /* unused */ Cardinal *num_params; /* unused */ { + nhUse(w); + nhUse(event); + nhUse(params); + nhUse(num_params); + + return; } static XtActionsRec actions[] = { - {"no-op", no_op}, + { nhStr("no-op"), no_op }, }; static char translations[] = @@ -111,6 +118,8 @@ static void Redisplay(w, event, region) XEvent *event; Region region; /* unused */ { + nhUse(region); + /* This isn't correct - we need to call the callback with region. */ XtCallCallbacks(w, XtNexposeCallback, (caddr_t) event); } @@ -126,7 +135,7 @@ static void Resize(w) WindowClassRec windowClassRec = { { /* core fields */ /* superclass */ (WidgetClass) &widgetClassRec, - /* class_name */ "Window", + /* class_name */ nhStr("Window"), /* widget_size */ sizeof(WindowRec), /* class_initialize */ 0, /* class_part_initialize */ 0, diff --git a/win/X11/dialogs.c b/win/X11/dialogs.c index 21552921d..65732556b 100644 --- a/win/X11/dialogs.c +++ b/win/X11/dialogs.c @@ -40,7 +40,15 @@ * + Changed the default width response text widget to be as wide as the * window itself. Suggestion from David E. Wexelblat, dwex@goblin.org. * - * $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ + * Modified 5/2015, anonymous. + * + Include nethack's lint.h to get nhStr() macro. + * + Use nhStr() on string literals (or macros from + * that hide string literals) to cast away implicit 'const' in order + * to suppress "warning: assignment discards qualifers from pointer + * target type" issued by 'gcc -Wwrite-strings' as used by nethack. + * (For this file, always the second parameter to XtSetArg().) + * + * $NHDT-Date: 1430899133 2015/05/06 07:58:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.3 $ * $Date: 2002/03/31 17:11:23 $ $Revision: 1.2 $ */ @@ -65,6 +73,7 @@ #endif #include "config.h" /* #define for const for non __STDC__ compilers */ +#include "lint.h" /* for nethack's nhStr() macro */ /* ":" added to both translations below to allow limited redefining of * keysyms before testing for keysym values -- dlc */ @@ -98,7 +107,7 @@ CreateDialog(parent, name, okay_callback, cancel_callback) num_args = 0; #ifdef SPECIAL_CMAP if (special_cmap) { - XtSetArg(args[num_args], XtNbackground, white); num_args++; + XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++; } #endif form = XtCreateManagedWidget(name, formWidgetClass, parent, args, num_args); @@ -106,52 +115,52 @@ CreateDialog(parent, name, okay_callback, cancel_callback) num_args = 0; #ifdef SPECIAL_CMAP if (special_cmap) { - XtSetArg(args[num_args], XtNforeground, black); num_args++; - XtSetArg(args[num_args], XtNbackground, white); num_args++; + XtSetArg(args[num_args], nhStr(XtNforeground), black); num_args++; + XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++; } #endif - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNresizable, True); num_args++; - XtSetArg(args[num_args], XtNborderWidth, 0); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++; + XtSetArg(args[num_args], nhStr(XtNborderWidth), 0); num_args++; prompt = XtCreateManagedWidget("prompt", labelWidgetClass, form, args, num_args); num_args = 0; #ifdef SPECIAL_CMAP if (special_cmap) { - XtSetArg(args[num_args], XtNforeground, black); num_args++; - XtSetArg(args[num_args], XtNbackground, white); num_args++; + XtSetArg(args[num_args], nhStr(XtNforeground), black); num_args++; + XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++; } #endif - XtSetArg(args[num_args], XtNfromVert, prompt); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNresizable, True); num_args++; - XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++; - XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++; - XtSetArg(args[num_args], XtNstring, ""); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), prompt); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++; + XtSetArg(args[num_args], nhStr(XtNeditType), XawtextEdit); num_args++; + XtSetArg(args[num_args], nhStr(XtNresize), XawtextResizeWidth); num_args++; + XtSetArg(args[num_args], nhStr(XtNstring), ""); num_args++; response = XtCreateManagedWidget("response", asciiTextWidgetClass, form, args, num_args); num_args = 0; #ifdef SPECIAL_CMAP if (special_cmap) { - XtSetArg(args[num_args], XtNforeground, black); num_args++; - XtSetArg(args[num_args], XtNbackground, white); num_args++; + XtSetArg(args[num_args], nhStr(XtNforeground), black); num_args++; + XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++; } #endif - XtSetArg(args[num_args], XtNfromVert, response); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNresizable, True); num_args++; - XtSetArg(args[num_args], XtNaccelerators, + XtSetArg(args[num_args], nhStr(XtNfromVert), response); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++; + XtSetArg(args[num_args], nhStr(XtNaccelerators), XtParseAcceleratorTable(okay_accelerators)); num_args++; okay = XtCreateManagedWidget("okay", commandWidgetClass, form, args, num_args); @@ -162,18 +171,18 @@ CreateDialog(parent, name, okay_callback, cancel_callback) num_args = 0; #ifdef SPECIAL_CMAP if (special_cmap) { - XtSetArg(args[num_args], XtNforeground, black); num_args++; - XtSetArg(args[num_args], XtNbackground, white); num_args++; + XtSetArg(args[num_args], nhStr(XtNforeground), black); num_args++; + XtSetArg(args[num_args], nhStr(XtNbackground), white); num_args++; } #endif - XtSetArg(args[num_args], XtNfromVert, response); num_args++; - XtSetArg(args[num_args], XtNfromHoriz, okay); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNresizable, True); num_args++; - XtSetArg(args[num_args], XtNaccelerators, + XtSetArg(args[num_args], nhStr(XtNfromVert), response); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), okay); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++; + XtSetArg(args[num_args], nhStr(XtNaccelerators), XtParseAcceleratorTable(cancel_accelerators)); num_args++; cancel = XtCreateManagedWidget("cancel", commandWidgetClass, form, args, num_args); @@ -199,7 +208,7 @@ GetDialogPrompt(w) String s; label = XtNameToWidget(w, "prompt"); - XtSetArg(args[0], XtNlabel, &s); + XtSetArg(args[0], nhStr(XtNlabel), &s); XtGetValues(label, args, ONE); return XtNewString(s); } @@ -215,7 +224,7 @@ SetDialogPrompt(w, newprompt) Widget label; label = XtNameToWidget(w, "prompt"); - XtSetArg(args[0], XtNlabel, newprompt); + XtSetArg(args[0], nhStr(XtNlabel), newprompt); XtSetValues(label, args, ONE); } @@ -229,7 +238,7 @@ GetDialogResponse(w) String s; response = XtNameToWidget(w, "response"); - XtSetArg(args[0], XtNstring, &s); + XtSetArg(args[0], nhStr(XtNstring), &s); XtGetValues(response, args, ONE); return XtNewString(s); } @@ -247,18 +256,18 @@ SetDialogResponse(w, s) Dimension width, nwidth, leftMargin, rightMargin; response = XtNameToWidget(w, "response"); - XtSetArg(args[0], XtNfont, &font); - XtSetArg(args[1], XtNleftMargin, &leftMargin); - XtSetArg(args[2], XtNrightMargin, &rightMargin); - XtSetArg(args[3], XtNwidth, &width); + XtSetArg(args[0], nhStr(XtNfont), &font); + XtSetArg(args[1], nhStr(XtNleftMargin), &leftMargin); + XtSetArg(args[2], nhStr(XtNrightMargin), &rightMargin); + XtSetArg(args[3], nhStr(XtNwidth), &width); XtGetValues(response, args, FOUR); /* width includes margins as per Xaw documentation */ nwidth = (font->max_bounds.width * strlen(s))+leftMargin+rightMargin; if (nwidth < width) nwidth = width; - XtSetArg(args[0], XtNstring, s); - XtSetArg(args[1], XtNwidth, nwidth); + XtSetArg(args[0], nhStr(XtNstring), s); + XtSetArg(args[1], nhStr(XtNwidth), nwidth); XtSetValues(response, args, TWO); XawTextSetInsertionPoint(response, strlen(s)); } @@ -273,8 +282,8 @@ ClearDialogResponse(w) Widget response; response = XtNameToWidget(w, "response"); - XtSetArg(args[0], XtNstring, ""); - XtSetArg(args[1], XtNwidth, 100); + XtSetArg(args[0], nhStr(XtNstring), ""); + XtSetArg(args[1], nhStr(XtNwidth), 100); XtSetValues(response, args, TWO); } #endif diff --git a/win/X11/winX.c b/win/X11/winX.c index 203822595..d6f5f35f8 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 winX.c $NHDT-Date: 1430040327 2015/04/26 09:25:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */ +/* NetHack 3.5 winX.c $NHDT-Date: 1430899139 2015/05/06 07:58:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.29 $ */ /* NetHack 3.5 winX.c $Date: 2012/01/24 04:26:26 $ $Revision: 1.27 $ */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ @@ -418,18 +418,17 @@ XtPointer *closure_ret; *closure_ret = (char*)True; done(Pixel, screenColor.pixel); } - type = "noColormap"; - msg = "Cannot allocate colormap entry for \"%s\""; - } - else { + type = nhStr("noColormap"); + msg = nhStr("Cannot allocate colormap entry for \"%s\""); + } else { /* some versions of XLookupColor also don't allow #xxyyzz names */ if(str[0] == '#' && (nhApproxColor(screen, colormap, (char*) str, &screenColor))) { *closure_ret = (char*)True; done(Pixel, screenColor.pixel); } - type = "badValue"; - msg = "Color name \"%s\" is not defined"; + type = nhStr("badValue"); + msg = nhStr("Color name \"%s\" is not defined"); } XtAppWarningMsg(app, type, "cvtStringToPixel", @@ -884,14 +883,24 @@ void X11_wait_synch() { if (x_inited) XFlush(XtDisplay(toplevel)); } /* Both resume_ and suspend_ are called from ioctl.c and unixunix.c. */ void X11_resume_nhwindows() { return; } - /* ARGSUSED */ -void X11_suspend_nhwindows(str) const char *str; { return; } +void X11_suspend_nhwindows(str) + const char *str; +{ + nhUse(str); + + return; +} /* Under X, we don't need to initialize the number pad. */ /* ARGSUSED */ -void X11_number_pad(state) int state; { return; } /* called from options.c */ +void X11_number_pad(state) /* called from options.c */ + int state; +{ + nhUse(state); + return; +} void X11_start_screen() { return; } /* called from setftty() in unixtty.c */ void X11_end_screen() { return; } /* called from settty() in unixtty.c */ @@ -924,60 +933,65 @@ Widget toplevel = (Widget) 0; /* toplevel widget */ Atom wm_delete_window; /* pop down windows */ static XtActionsRec actions[] = { - {"dismiss_file", dismiss_file}, /* action for file viewing widget */ - {"delete_file", delete_file}, /* action for file delete-window */ - {"dismiss_text", dismiss_text}, /* button action for text widget */ - {"delete_text", delete_text}, /* delete action for text widget */ - {"key_dismiss_text",key_dismiss_text},/* key action for text widget */ + {nhStr("dismiss_file"), dismiss_file}, /* file viewing widget */ + {nhStr("delete_file"), delete_file}, /* file delete-window */ + {nhStr("dismiss_text"), dismiss_text}, /* text widget button action */ + {nhStr("delete_text"), delete_text}, /* text widget delete action */ + {nhStr("key_dismiss_text"), key_dismiss_text}, /* text widget key action */ #ifdef GRAPHIC_TOMBSTONE - {"rip_dismiss_text",rip_dismiss_text},/* action for rip in text widget */ + {nhStr("rip_dismiss_text"), rip_dismiss_text}, /* rip in text widget */ #endif - {"menu_key", menu_key}, /* action for menu accelerators */ - {"yn_key", yn_key}, /* action for yn accelerators */ - {"yn_delete", yn_delete}, /* action for yn delete-window */ - {"askname_delete", askname_delete},/* action for askname delete-window */ - {"getline_delete", getline_delete},/* action for getline delete-window */ - {"menu_delete", menu_delete}, /* action for menu delete-window */ - {"ec_key", ec_key}, /* action for extended commands */ - {"ec_delete", ec_delete}, /* action for ext-com menu delete */ - {"ps_key", ps_key}, /* action for player selection */ - {"race_key", race_key}, /* action for race selection */ - {"gend_key", gend_key}, /* action for gender selection */ - {"algn_key", algn_key}, /* action for alignment selection */ - {"X11_hangup", X11_hangup}, /* action for delete of top-level */ - {"input", map_input}, /* action for key input */ - {"scroll", nh_keyscroll}, /* action for scrolling by keys */ + {nhStr("menu_key"), menu_key}, /* menu accelerators */ + {nhStr("yn_key"), yn_key}, /* yn accelerators */ + {nhStr("yn_delete"), yn_delete}, /* yn delete-window */ + {nhStr("askname_delete"), askname_delete}, /* askname delete-window */ + {nhStr("getline_delete"), getline_delete}, /* getline delete-window */ + {nhStr("menu_delete"), menu_delete}, /* menu delete-window */ + {nhStr("ec_key"), ec_key}, /* extended commands */ + {nhStr("ec_delete"), ec_delete}, /* ext-com menu delete */ + {nhStr("ps_key"), ps_key}, /* player selection */ + {nhStr("race_key"), race_key}, /* race selection */ + {nhStr("gend_key"), gend_key}, /* gender selection */ + {nhStr("algn_key"), algn_key}, /* alignment selection */ + {nhStr("X11_hangup"), X11_hangup}, /* delete of top-level */ + {nhStr("input"), map_input}, /* key input */ + {nhStr("scroll"), nh_keyscroll}, /* scrolling by keys */ }; static XtResource resources[] = { - { "slow", "Slow", XtRBoolean, sizeof(Boolean), - XtOffset(AppResources *,slow), XtRString, "True" }, - { "autofocus", "AutoFocus", XtRBoolean, sizeof(Boolean), - XtOffset(AppResources *,autofocus), XtRString, "False" }, - { "message_line", "Message_line", XtRBoolean, sizeof(Boolean), - XtOffset(AppResources *,message_line), XtRString, "False" }, - { "double_tile_size", "Double_tile_size", XtRBoolean, sizeof(Boolean), - XtOffset(AppResources *,double_tile_size), XtRString, "False" }, - { "tile_file", "Tile_file", XtRString, sizeof(String), - XtOffset(AppResources *,tile_file), XtRString, "x11tiles" }, - { "icon", "Icon", XtRString, sizeof(String), - XtOffset(AppResources *,icon), XtRString, "nh72" }, - { "message_lines", "Message_lines", XtRInt, sizeof(int), - XtOffset(AppResources *,message_lines), XtRString, "12" }, - { "pet_mark_bitmap", "Pet_mark_bitmap", XtRString, sizeof(String), - XtOffset(AppResources *,pet_mark_bitmap), XtRString, "pet_mark.xbm" }, - { "pet_mark_color", "Pet_mark_color", XtRPixel, sizeof(XtRPixel), - XtOffset(AppResources *,pet_mark_color), XtRString, "Red" }, + { nhStr("slow"), nhStr("Slow"), XtRBoolean, sizeof(Boolean), + XtOffset(AppResources *,slow), XtRString, nhStr("True") }, + { nhStr("autofocus"), nhStr("AutoFocus"), XtRBoolean, sizeof(Boolean), + XtOffset(AppResources *,autofocus), XtRString, nhStr("False") }, + { nhStr("message_line"), nhStr("Message_line"), XtRBoolean, + sizeof(Boolean), + XtOffset(AppResources *,message_line), XtRString, nhStr("False") }, + { nhStr("double_tile_size"), nhStr("Double_tile_size"), XtRBoolean, + sizeof(Boolean), + XtOffset(AppResources *,double_tile_size), XtRString, nhStr("False") }, + { nhStr("tile_file"), nhStr("Tile_file"), XtRString, sizeof(String), + XtOffset(AppResources *,tile_file), XtRString, nhStr("x11tiles") }, + { nhStr("icon"), nhStr("Icon"), XtRString, sizeof(String), + XtOffset(AppResources *,icon), XtRString, nhStr("nh72") }, + { nhStr("message_lines"), nhStr("Message_lines"), XtRInt, sizeof(int), + XtOffset(AppResources *,message_lines), XtRString, nhStr("12") }, + { nhStr("pet_mark_bitmap"), nhStr("Pet_mark_bitmap"), XtRString, + sizeof(String), + XtOffset(AppResources *,pet_mark_bitmap), XtRString, + nhStr("pet_mark.xbm") }, + { nhStr("pet_mark_color"), nhStr("Pet_mark_color"), XtRPixel, + sizeof(XtRPixel), + XtOffset(AppResources *,pet_mark_color), XtRString, nhStr("Red") }, #ifdef GRAPHIC_TOMBSTONE - { "tombstone", "Tombstone", XtRString, sizeof(String), + { nhStr("tombstone"), "Tombstone", XtRString, sizeof(String), XtOffset(AppResources *,tombstone), XtRString, "rip.xpm" }, - { "tombtext_x", "Tombtext_x", XtRInt, sizeof(int), + { nhStr("tombtext_x"), "Tombtext_x", XtRInt, sizeof(int), XtOffset(AppResources *,tombtext_x), XtRString, "155" }, - { "tombtext_y", "Tombtext_y", XtRInt, sizeof(int), + { nhStr("tombtext_y"), "Tombtext_y", XtRInt, sizeof(int), XtOffset(AppResources *,tombtext_y), XtRString, "78" }, - { "tombtext_dx", "Tombtext_dx", XtRInt, sizeof(int), + { nhStr("tombtext_dx"), "Tombtext_dx", XtRInt, sizeof(int), XtOffset(AppResources *,tombtext_dx), XtRString, "0" }, - { "tombtext_dy", "Tombtext_dy", XtRInt, sizeof(int), + { nhStr("tombtext_dy"), "Tombtext_dy", XtRInt, sizeof(int), XtOffset(AppResources *,tombtext_dy), XtRString, "13" }, #endif }; @@ -1085,6 +1099,8 @@ void X11_exit_nhwindows(dummy) { extern Pixmap tile_pixmap; /* from winmap.c */ + nhUse(dummy); + /* explicitly free the icon and tile pixmaps */ if (icon_pixmap != None) { XFreePixmap(XtDisplay(toplevel), icon_pixmap); @@ -1121,6 +1137,9 @@ X11_sig_cb(not_used, id) XEvent event; XClientMessageEvent *mesg; + nhUse(not_used); + nhUse(id); + /* Set up a fake message to the event handler. */ mesg = (XClientMessageEvent *) &event; mesg->type = ClientMessage; @@ -1150,6 +1169,9 @@ d_timeout(client_data, id) XEvent event; XClientMessageEvent *mesg; + nhUse(client_data); + nhUse(id); + /* Set up a fake message to the event handler. */ mesg = (XClientMessageEvent *) &event; mesg->type = ClientMessage; @@ -1188,6 +1210,11 @@ X11_hangup(w, event, params, num_params) String *params; Cardinal *num_params; { + nhUse(w); + nhUse(event); + nhUse(params); + nhUse(num_params); + hangup(1); /* 1 is commonly SIGHUP, but ignored anyway */ exit_x_event = TRUE; } @@ -1201,6 +1228,10 @@ askname_delete(w, event, params, num_params) String *params; Cardinal *num_params; { + nhUse(event); + nhUse(params); + nhUse(num_params); + nh_XtPopdown(w); (void) strcpy(plname, "Mumbles"); /* give them a name... ;-) */ exit_x_event = TRUE; @@ -1218,17 +1249,20 @@ askname_done(w, client_data, call_data) char *s; Widget dialog = (Widget) client_data; + nhUse(w); + nhUse(call_data); + s = (char *) GetDialogResponse(dialog); - len = strlen(s); + len = (int) strlen(s); if (len == 0) { X11_nhbell(); return; } /* Truncate name if necessary */ - if (len >= sizeof(plname)-1) - len = sizeof(plname)-1; + if (len >= (int) sizeof(plname)-1) + len = (int) sizeof(plname)-1; (void) strncpy(plname, s, len); plname[len] = '\0'; @@ -1251,11 +1285,11 @@ X11_askname() XtOverrideTranslations(popup, XtParseTranslationTable("WM_PROTOCOLS: askname_delete()")); - dialog = CreateDialog(popup, "dialog", + dialog = CreateDialog(popup, nhStr("dialog"), askname_done, (XtCallbackProc) 0); - SetDialogPrompt(dialog, "What is your name?"); /* set prompt */ - SetDialogResponse(dialog, ""); /* set default answer */ + SetDialogPrompt(dialog, nhStr("What is your name?")); /* set prompt */ + SetDialogResponse(dialog, nhStr("")); /* set default answer */ XtRealizeWidget(popup); positionpopup(popup, TRUE); /* center,bottom */ @@ -1288,6 +1322,9 @@ done_button(w, client_data, call_data) char *s; Widget dialog = (Widget) client_data; + nhUse(w); + nhUse(call_data); + s = (char *) GetDialogResponse(dialog); len = strlen(s); @@ -1310,6 +1347,10 @@ getline_delete(w, event, params, num_params) String *params; Cardinal *num_params; { + nhUse(event); + nhUse(params); + nhUse(num_params); + Strcpy(getline_input, CANCEL_STR); nh_XtPopdown(w); exit_x_event = TRUE; @@ -1325,6 +1366,9 @@ abort_button(w, client_data, call_data) { Widget dialog = (Widget) client_data; + nhUse(w); + nhUse(call_data); + Strcpy(getline_input, CANCEL_STR); nh_XtPopdown(XtParent(dialog)); exit_x_event = TRUE; @@ -1353,7 +1397,7 @@ X11_getlin(question, input) XtOverrideTranslations(getline_popup, XtParseTranslationTable("WM_PROTOCOLS: getline_delete()")); - getline_dialog = CreateDialog(getline_popup, "dialog", + getline_dialog = CreateDialog(getline_popup, nhStr("dialog"), done_button, abort_button); XtRealizeWidget(getline_popup); @@ -1361,7 +1405,7 @@ X11_getlin(question, input) &wm_delete_window, 1); } SetDialogPrompt(getline_dialog, (String)question); /* set prompt */ - SetDialogResponse(getline_dialog, ""); /* set default answer */ + SetDialogResponse(getline_dialog, nhStr("")); /* set default answer */ positionpopup(getline_popup, TRUE); /* center,bottom */ nh_XtPopup(getline_popup, (int)XtGrabExclusive, getline_dialog); @@ -1388,6 +1432,10 @@ delete_file(w, event, params, num_params) String *params; Cardinal *num_params; { + nhUse(event); + nhUse(params); + nhUse(num_params); + nh_XtPopdown(w); XtDestroyWidget(w); } @@ -1402,6 +1450,11 @@ dismiss_file(w, event, params, num_params) Cardinal *num_params; { Widget popup = XtParent(w); + + nhUse(event); + nhUse(params); + nhUse(num_params); + nh_XtPopdown(popup); XtDestroyWidget(popup); } @@ -1468,7 +1521,7 @@ X11_display_file(str, complain) (void) dlb_fclose(fp); num_args = 0; - XtSetArg(args[num_args], XtNtitle, str); num_args++; + XtSetArg(args[num_args], nhStr(XtNtitle), str); num_args++; popup = XtCreatePopupShell("display_file", topLevelShellWidgetClass, toplevel, args, num_args); @@ -1476,15 +1529,15 @@ X11_display_file(str, complain) XtParseTranslationTable("WM_PROTOCOLS: delete_file()")); num_args = 0; - XtSetArg(args[num_args], XtNscrollHorizontal, - XawtextScrollWhenNeeded); num_args++; - XtSetArg(args[num_args], XtNscrollVertical, - XawtextScrollAlways); num_args++; - XtSetArg(args[num_args], XtNtype, XawAsciiString); num_args++; - XtSetArg(args[num_args], XtNstring, textlines); num_args++; - XtSetArg(args[num_args], XtNdisplayCaret, False); num_args++; - XtSetArg(args[num_args], XtNtranslations, - XtParseTranslationTable(display_translations)); num_args++; + XtSetArg(args[num_args], nhStr(XtNscrollHorizontal), + XawtextScrollWhenNeeded); num_args++; + XtSetArg(args[num_args], nhStr(XtNscrollVertical), + XawtextScrollAlways); num_args++; + XtSetArg(args[num_args], nhStr(XtNtype), XawAsciiString); num_args++; + XtSetArg(args[num_args], nhStr(XtNstring), textlines); num_args++; + XtSetArg(args[num_args], nhStr(XtNdisplayCaret), False); num_args++; + XtSetArg(args[num_args], nhStr(XtNtranslations), + XtParseTranslationTable(display_translations)); num_args++; dispfile = XtCreateManagedWidget( "text", /* name */ @@ -1495,11 +1548,12 @@ X11_display_file(str, complain) /* Get font and border information. */ num_args = 0; - XtSetArg(args[num_args], XtNfont, &fs); num_args++; - XtSetArg(args[num_args], XtNtopMargin, &top_margin); num_args++; - XtSetArg(args[num_args], XtNbottomMargin, &bottom_margin); num_args++; - XtSetArg(args[num_args], XtNleftMargin, &left_margin); num_args++; - XtSetArg(args[num_args], XtNrightMargin, &right_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNfont), &fs); num_args++; + XtSetArg(args[num_args], nhStr(XtNtopMargin), &top_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottomMargin), + &bottom_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNleftMargin), &left_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNrightMargin), &right_margin); num_args++; XtGetValues(dispfile, args, num_args); /* @@ -1573,6 +1627,11 @@ yn_delete(w, event, params, num_params) String *params; Cardinal *num_params; { + nhUse(w); + nhUse(event); + nhUse(params); + nhUse(num_params); + yn_getting_num = FALSE; /* Only use yn_esc_map if we have choices. Otherwise, return ESC. */ yn_return = yn_choices ? yn_esc_map : '\033'; @@ -1808,6 +1867,10 @@ msgkey(w, data, event) XEvent *event; { Cardinal num = 0; + + nhUse(w); + nhUse(data); + map_input(window_list[WIN_MAP].w, event, (String*) 0, &num); } @@ -1821,6 +1884,9 @@ win_visible(w, data, event, flag) /* only called for autofocus */ { XVisibilityEvent *vis_event = (XVisibilityEvent *)event; + nhUse(data); + nhUse(flag); + if (vis_event->state != VisibilityFullyObscured) { /* one-time operation; cancel ourself */ XtRemoveEventHandler(toplevel, VisibilityChangeMask, False, @@ -1871,9 +1937,9 @@ init_standard_windows() /* Tell the form that contains it that resizes are OK. */ num_args = 0; - XtSetArg(args[num_args], XtNresizable, True); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; XtSetValues(message_viewport, args, num_args); if(appResources.slow) { @@ -1885,10 +1951,12 @@ init_standard_windows() form, args, num_args); num_args = 0; - XtSetArg(args[num_args], XtNfromVert, message_viewport); num_args++; - XtSetArg(args[num_args], XtNjustify, XtJustifyLeft); num_args++; - XtSetArg(args[num_args], XtNresizable, True); num_args++; - XtSetArg(args[num_args], XtNlabel, " "); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), + message_viewport); num_args++; + XtSetArg(args[num_args], nhStr(XtNjustify), + XtJustifyLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNresizable), True); num_args++; + XtSetArg(args[num_args], nhStr(XtNlabel), " "); num_args++; XtSetValues(yn_label, args, num_args); } @@ -1906,11 +1974,12 @@ init_standard_windows() /* Chain beneath message_viewport or yn window. */ num_args = 0; if(appResources.slow) { - XtSetArg(args[num_args], XtNfromVert, yn_label); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), yn_label); num_args++; } else { - XtSetArg(args[num_args], XtNfromVert, message_viewport);num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), + message_viewport); num_args++; } - XtSetArg(args[num_args], XtNbottom, XtChainBottom); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainBottom); num_args++; XtSetValues(map_viewport, args, num_args); /* Create the status window, with the form as it's parent. */ @@ -1929,11 +1998,11 @@ init_standard_windows() * will never expand or contract. */ num_args = 0; - XtSetArg(args[num_args], XtNfromVert, map_viewport); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainBottom); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainBottom); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), map_viewport); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainBottom); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainBottom); num_args++; XtSetValues(status, args, num_args); @@ -1980,13 +2049,13 @@ init_standard_windows() /* * Now get the default widths of the windows. */ - XtSetArg(args[0], XtNwidth, &message_vp_width); + XtSetArg(args[0], nhStr(XtNwidth), &message_vp_width); XtGetValues(message_viewport, args, ONE); - XtSetArg(args[0], XtNwidth, &map_vp_width); - XtSetArg(args[1], XtNhorizDistance, &map_vp_hd); + XtSetArg(args[0], nhStr(XtNwidth), &map_vp_width); + XtSetArg(args[1], nhStr(XtNhorizDistance), &map_vp_hd); XtGetValues(map_viewport, args, TWO); - XtSetArg(args[0], XtNwidth, &status_width); - XtSetArg(args[1], XtNhorizDistance, &status_hd); + XtSetArg(args[0], nhStr(XtNwidth), &status_width); + XtSetArg(args[1], nhStr(XtNhorizDistance), &status_hd); XtGetValues(status, args, TWO); /* @@ -1996,17 +2065,18 @@ init_standard_windows() */ if (map_vp_width < status_width || map_vp_width < message_vp_width) { if (status_width > message_vp_width) { - XtSetArg(args[0], XtNwidth, status_width); + XtSetArg(args[0], nhStr(XtNwidth), status_width); XtSetValues(message_viewport, args, ONE); max_width = status_width; } else { max_width = message_vp_width; } - XtSetArg(args[0], XtNhorizDistance, map_vp_hd+((int)(max_width-map_vp_width)/2)); + XtSetArg(args[0], nhStr(XtNhorizDistance), + map_vp_hd + ((int)(max_width - map_vp_width) / 2)); XtSetValues(map_viewport, args, ONE); } else { /* map is widest */ - XtSetArg(args[0], XtNwidth, map_vp_width); + XtSetArg(args[0], nhStr(XtNwidth), map_vp_width); XtSetValues(message_viewport, args, ONE); } /* @@ -2094,6 +2164,8 @@ nh_keyscroll(viewport, event, params, num_params) int direction; Cardinal in_nparams = (num_params ? *num_params : 0); + nhUse(event); + if (in_nparams != 1) return; /* bad translation */ direction=atoi(params[0]); @@ -2115,8 +2187,8 @@ nh_keyscroll(viewport, event, params, num_params) /* The V_DELTA is 1/2 the value of shown. */ if (horiz_sb) { - XtSetArg(arg[0], XtNshown, &shown); - XtSetArg(arg[1], XtNtopOfThumb, &top); + XtSetArg(arg[0], nhStr(XtNshown), &shown); + XtSetArg(arg[1], nhStr(XtNtopOfThumb), &top); XtGetValues(horiz_sb, arg, TWO); do_call = True; @@ -2138,8 +2210,8 @@ nh_keyscroll(viewport, event, params, num_params) } if (vert_sb) { - XtSetArg(arg[0], XtNshown, &shown); - XtSetArg(arg[1], XtNtopOfThumb, &top); + XtSetArg(arg[0], nhStr(XtNshown), &shown); + XtSetArg(arg[1], nhStr(XtNtopOfThumb), &top); XtGetValues(vert_sb, arg, TWO); do_call = True; diff --git a/win/X11/winmap.c b/win/X11/winmap.c index dd92ad680..504ea7563 100644 --- a/win/X11/winmap.c +++ b/win/X11/winmap.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 winmap.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 winmap.c $NHDT-Date: 1430899135 2015/05/06 07:58:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.17 $ */ /* NetHack 3.5 winmap.c $Date: 2009/05/06 10:55:49 $ $Revision: 1.14 $ */ /* SCCS Id: @(#)winmap.c 3.5 2005/11/12 */ /* Copyright (c) Dean Luick, 1992 */ @@ -66,7 +66,7 @@ static void FDECL(map_check_size_change, (struct xwindow *)); static void FDECL(map_update, (struct xwindow *,int,int,int,int,BOOLEAN_P)); static void FDECL(init_text, (struct xwindow *)); static void FDECL(map_exposed, (Widget,XtPointer,XtPointer)); -static void FDECL(set_gc, (Widget,Font,char *,Pixel,GC *,GC *)); +static void FDECL(set_gc, (Widget,Font,const char *,Pixel,GC *,GC *)); static void FDECL(get_text_gc, (struct xwindow *,Font)); static void FDECL(get_char_info, (struct xwindow *)); static void FDECL(display_cursor, (struct xwindow *)); @@ -249,7 +249,8 @@ init_tiles(wp) unsigned char *tb, *tile_bytes = (unsigned char *)0; int size; XColor *colors = (XColor *)0; - int i, x, y; + unsigned i; + int x, y; int bitmap_pad; int ddepth; #endif @@ -348,7 +349,7 @@ init_tiles(wp) goto tiledone; } - if (fread((char *) &header, sizeof(header), 1, fp) != 1) { + if ((int) fread((char *) &header, sizeof(header), 1, fp) != 1) { X11_raw_print("read of header failed"); result = FALSE; goto tiledone; @@ -374,7 +375,7 @@ init_tiles(wp) size = 3*header.ncolors; colormap = (unsigned char *) alloc((unsigned)size); - if (fread((char *) colormap, 1, size, fp) != size) { + if ((int) fread((char *) colormap, 1, size, fp) != size) { X11_raw_print("read of colormap failed"); result = FALSE; goto tiledone; @@ -410,13 +411,13 @@ init_tiles(wp) tile_count += header.per_row - (tile_count % header.per_row); } tile_bytes = (unsigned char *) alloc((unsigned)tile_count*size); - if (fread((char *) tile_bytes, size, tile_count, fp) != tile_count) { + if ((int) fread((char *) tile_bytes, size, tile_count, fp) != tile_count) { X11_raw_print("read of tile bytes failed"); result = FALSE; goto tiledone; } - if (header.ntiles < total_tiles_used) { + if (header.ntiles < (unsigned) total_tiles_used) { Sprintf(buf, "tile file incomplete, expecting %d tiles, found %lu", total_tiles_used, header.ntiles); X11_raw_print(buf); @@ -463,27 +464,27 @@ init_tiles(wp) if (appResources.double_tile_size) { unsigned long *expanded_row = - (unsigned long *)alloc(sizeof(unsigned long)*(unsigned)image_width); + (unsigned long *)alloc(sizeof (unsigned long) * image_width); tb = tile_bytes; - for (y = 0; y < image_height; y++) { - for (x = 0; x < image_width/2; x++) + for (y = 0; y < (int) image_height; y++) { + for (x = 0; x < (int) image_width / 2; x++) expanded_row[2*x] = expanded_row[(2*x)+1] = colors[*tb++].pixel; - for (x = 0; x < image_width; x++) + for (x = 0; x < (int) image_width; x++) XPutPixel(tile_image, x, y, expanded_row[x]); y++; /* duplicate row */ - for (x = 0; x < image_width; x++) + for (x = 0; x < (int) image_width; x++) XPutPixel(tile_image, x, y, expanded_row[x]); } free((genericptr_t)expanded_row); } else { - for (tb = tile_bytes, y = 0; y < image_height; y++) - for (x = 0; x < image_width; x++, tb++) + for (tb = tile_bytes, y = 0; y < (int) image_height; y++) + for (x = 0; x < (int) image_width; x++, tb++) XPutPixel(tile_image, x, y, colors[*tb].pixel); } #endif /* USE_XPM */ @@ -569,7 +570,7 @@ check_cursor_visibility(wp) if (horiz_sb) { XtSetArg(arg[0], XtNshown, &shown); - XtSetArg(arg[1], XtNtopOfThumb, &top); + XtSetArg(arg[1], nhStr(XtNtopOfThumb), &top); XtGetValues(horiz_sb, arg, TWO); /* [ALI] Don't assume map widget is the same size as actual map */ @@ -620,7 +621,7 @@ check_cursor_visibility(wp) if (vert_sb) { XtSetArg(arg[0], XtNshown, &shown); - XtSetArg(arg[1], XtNtopOfThumb, &top); + XtSetArg(arg[1], nhStr(XtNtopOfThumb), &top); XtGetValues(vert_sb, arg, TWO); if (wp->map_information->is_tile) @@ -742,7 +743,7 @@ static void set_gc(w, font, resource_name, bgpixel, regular, inverse) Widget w; Font font; - char *resource_name; + const char *resource_name; Pixel bgpixel; GC *regular, *inverse; { @@ -751,7 +752,7 @@ set_gc(w, font, resource_name, bgpixel, regular, inverse) Pixel curpixel; Arg arg[1]; - XtSetArg(arg[0], resource_name, &curpixel); + XtSetArg(arg[0], (char *) resource_name, &curpixel); XtGetValues(w, arg, ONE); values.foreground = curpixel; @@ -1124,6 +1125,8 @@ map_exposed(w, client_data, widget_data) XExposeEvent *event = (XExposeEvent *) widget_data; int t_height, t_width; /* tile/text height & width */ + nhUse(client_data); + if (!XtIsRealized(w) || event->count > 0) return; wp = find_widget(w); @@ -1489,8 +1492,8 @@ create_map_window(wp, create_popup, parent) * realized, then the map can resize to its normal size. */ num_args = 0; - XtSetArg(args[num_args], XtNrows, &rows); num_args++; - XtSetArg(args[num_args], XtNcolumns, &columns); num_args++; + XtSetArg(args[num_args], nhStr(XtNrows), &rows); num_args++; + XtSetArg(args[num_args], nhStr(XtNcolumns), &columns); num_args++; XtGetValues(wp->w, args, num_args); /* Don't bother with windows larger than ROWNOxCOLNO. */ diff --git a/win/X11/winmenu.c b/win/X11/winmenu.c index e21988c70..42deec057 100644 --- a/win/X11/winmenu.c +++ b/win/X11/winmenu.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 winmenu.c $NHDT-Date: 1428828477 2015/04/12 08:47:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */ +/* NetHack 3.5 winmenu.c $NHDT-Date: 1430899135 2015/05/06 07:58:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */ /* NetHack 3.5 winmenu.c $Date: 2009/05/06 10:55:53 $ $Revision: 1.5 $ */ /* SCCS Id: @(#)winmenu.c 3.5 1996/08/15 */ /* Copyright (c) Dean Luick, 1992 */ @@ -98,6 +98,8 @@ menu_select(w, client_data, call_data) #endif long how_many; + nhUse(client_data); + wp = find_widget(w); menu_info = wp->menu_information; how_many = menu_info->counting ? menu_info->menu_count : -1L; @@ -157,6 +159,10 @@ menu_delete(w, event, params, num_params) String *params; Cardinal *num_params; { + nhUse(event); + nhUse(params); + nhUse(num_params); + menu_cancel((Widget)None, (XtPointer) find_widget(w), (XtPointer) 0); } @@ -171,6 +177,9 @@ invert_line(wp, curr, which, how_many) int which; long how_many; { +#ifndef USE_FWF + nhUse(which); +#endif reset_menu_count(wp->menu_information); curr->selected = !curr->selected; if (curr->selected) { @@ -208,6 +217,9 @@ menu_key(w, event, params, num_params) int count; boolean selected_something; + nhUse(params); + nhUse(num_params); + wp = find_widget(w); menu_info = wp->menu_information; @@ -346,6 +358,9 @@ menu_ok(w, client_data, call_data) { struct xwindow *wp = (struct xwindow *) client_data; + nhUse(w); + nhUse(call_data); + menu_popdown(wp); } @@ -357,6 +372,9 @@ menu_cancel(w, client_data, call_data) { struct xwindow *wp = (struct xwindow *) client_data; + nhUse(w); + nhUse(call_data); + if (wp->menu_information->is_active) { select_none(wp); wp->menu_information->cancelled = TRUE; @@ -370,6 +388,9 @@ menu_all(w, client_data, call_data) Widget w; XtPointer client_data, call_data; { + nhUse(w); + nhUse(call_data); + select_all((struct xwindow *) client_data); } @@ -379,6 +400,9 @@ menu_none(w, client_data, call_data) Widget w; XtPointer client_data, call_data; { + nhUse(w); + nhUse(call_data); + select_none((struct xwindow *) client_data); } @@ -388,6 +412,9 @@ menu_invert(w, client_data, call_data) Widget w; XtPointer client_data, call_data; { + nhUse(w); + nhUse(call_data); + invert_all((struct xwindow *) client_data); } @@ -401,6 +428,9 @@ menu_search(w, client_data, call_data) struct menu_info_t *menu_info = wp->menu_information; char buf[BUFSZ+2], tmpbuf[BUFSZ]; + nhUse(w); + nhUse(call_data); + X11_getlin("Search for:", tmpbuf); if (!*tmpbuf || *tmpbuf == '\033') return; /* convert "string" into "*string*" for use with pmatch() */ @@ -614,6 +644,9 @@ X11_add_menu(window, glyph, identifier, ch, gch, attr, str, preselected) x11_menu_item *item; struct menu_info_t *menu_info; + nhUse(glyph); + nhUse(preselected); /*FIXME*/ + check_winid(window); menu_info = window_list[window].menu_information; if (!menu_info->is_menu) { @@ -805,10 +838,10 @@ X11_select_menu(window, how, menu_list) num_args = 0; XtSetArg(args[num_args], XtNborderWidth, 0); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; if (labeled) label = XtCreateManagedWidget(menu_info->new_menu.query, @@ -821,11 +854,11 @@ X11_select_menu(window, how, menu_list) * Create ok, cancel, all, none, invert, and search buttons.. */ num_args = 0; - XtSetArg(args[num_args], XtNfromVert, label); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; ok = XtCreateManagedWidget("OK", commandWidgetClass, form, @@ -833,13 +866,14 @@ X11_select_menu(window, how, menu_list) XtAddCallback(ok, XtNcallback, menu_ok, (XtPointer) wp); num_args = 0; - XtSetArg(args[num_args], XtNfromVert, label); num_args++; - XtSetArg(args[num_args], XtNfromHoriz, ok); num_args++; - XtSetArg(args[num_args], XtNsensitive, how!=PICK_NONE); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), ok); num_args++; + XtSetArg(args[num_args], nhStr(XtNsensitive), + how != PICK_NONE); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; cancel = XtCreateManagedWidget("cancel", commandWidgetClass, form, @@ -848,13 +882,13 @@ X11_select_menu(window, how, menu_list) sens = (how == PICK_ANY); num_args = 0; - XtSetArg(args[num_args], XtNfromVert, label); num_args++; - XtSetArg(args[num_args], XtNfromHoriz, cancel); num_args++; - XtSetArg(args[num_args], XtNsensitive, sens); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), cancel); num_args++; + XtSetArg(args[num_args], nhStr(XtNsensitive), sens); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; all = XtCreateManagedWidget("all", commandWidgetClass, form, @@ -862,13 +896,13 @@ X11_select_menu(window, how, menu_list) XtAddCallback(all, XtNcallback, menu_all, (XtPointer) wp); num_args = 0; - XtSetArg(args[num_args], XtNfromVert, label); num_args++; - XtSetArg(args[num_args], XtNfromHoriz, all); num_args++; - XtSetArg(args[num_args], XtNsensitive, sens); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), all); num_args++; + XtSetArg(args[num_args], nhStr(XtNsensitive), sens); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; none = XtCreateManagedWidget("none", commandWidgetClass, form, @@ -876,13 +910,13 @@ X11_select_menu(window, how, menu_list) XtAddCallback(none, XtNcallback, menu_none, (XtPointer) wp); num_args = 0; - XtSetArg(args[num_args], XtNfromVert, label); num_args++; - XtSetArg(args[num_args], XtNfromHoriz, none); num_args++; - XtSetArg(args[num_args], XtNsensitive, sens); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), none); num_args++; + XtSetArg(args[num_args], nhStr(XtNsensitive), sens); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; invert = XtCreateManagedWidget("invert", commandWidgetClass, form, @@ -890,13 +924,14 @@ X11_select_menu(window, how, menu_list) XtAddCallback(invert, XtNcallback, menu_invert, (XtPointer) wp); num_args = 0; - XtSetArg(args[num_args], XtNfromVert, label); num_args++; - XtSetArg(args[num_args], XtNfromHoriz, invert); num_args++; - XtSetArg(args[num_args], XtNsensitive, how!=PICK_NONE); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), invert); num_args++; + XtSetArg(args[num_args], nhStr(XtNsensitive), + how != PICK_NONE); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainLeft); num_args++; search = XtCreateManagedWidget("search", commandWidgetClass, form, @@ -904,18 +939,18 @@ X11_select_menu(window, how, menu_list) XtAddCallback(search, XtNcallback, menu_search, (XtPointer) wp); num_args = 0; - XtSetArg(args[num_args], XtNallowVert, True); num_args++; - XtSetArg(args[num_args], XtNallowHoriz, False); num_args++; - XtSetArg(args[num_args], XtNuseBottom, True); num_args++; - XtSetArg(args[num_args], XtNuseRight, True); num_args++; + XtSetArg(args[num_args], nhStr(XtNallowVert), True); num_args++; + XtSetArg(args[num_args], nhStr(XtNallowHoriz), False); num_args++; + XtSetArg(args[num_args], nhStr(XtNuseBottom), True); num_args++; + XtSetArg(args[num_args], nhStr(XtNuseRight), True); num_args++; /* - XtSetArg(args[num_args], XtNforceBars, True); num_args++; + XtSetArg(args[num_args], nhStr(XtNforceBars), True); num_args++; */ - XtSetArg(args[num_args], XtNfromVert, all); num_args++; - XtSetArg(args[num_args], XtNtop, XtChainTop); num_args++; - XtSetArg(args[num_args], XtNbottom, XtChainBottom); num_args++; - XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; - XtSetArg(args[num_args], XtNright, XtChainRight); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), all); num_args++; + XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottom), XtChainBottom); num_args++; + XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; + XtSetArg(args[num_args], nhStr(XtNright), XtChainRight); num_args++; viewport_widget = XtCreateManagedWidget( "menu_viewport", /* name */ viewportWidgetClass, @@ -926,15 +961,15 @@ X11_select_menu(window, how, menu_list) move_menu(&menu_info->new_menu, &menu_info->curr_menu); num_args = 0; - XtSetArg(args[num_args], XtNforceColumns, True); num_args++; - XtSetArg(args[num_args], XtNcolumnSpacing, 1); num_args++; - XtSetArg(args[num_args], XtNdefaultColumns, 1); num_args++; - XtSetArg(args[num_args], XtNlist, + XtSetArg(args[num_args], nhStr(XtNforceColumns), True); num_args++; + XtSetArg(args[num_args], nhStr(XtNcolumnSpacing), 1); num_args++; + XtSetArg(args[num_args], nhStr(XtNdefaultColumns), 1); num_args++; + XtSetArg(args[num_args], nhStr(XtNlist), menu_info->curr_menu.list_pointer); num_args++; #ifdef USE_FWF - XtSetArg(args[num_args], XtNsensitiveArray, + XtSetArg(args[num_args], nhStr(XtNsensitiveArray), menu_info->curr_menu.sensitive); num_args++; - XtSetArg(args[num_args], XtNmaxSelectable, + XtSetArg(args[num_args], nhStr(XtNmaxSelectable), menu_info->curr_menu.count); num_args++; #endif wp->w = XtCreateManagedWidget( @@ -957,7 +992,8 @@ X11_select_menu(window, how, menu_list) &menu_info->internal_height); num_args++; XtSetArg(args[num_args], XtNinternalWidth, &menu_info->internal_width); num_args++; - XtSetArg(args[num_args], XtNrowSpacing, &row_spacing); num_args++; + XtSetArg(args[num_args], nhStr(XtNrowSpacing), + &row_spacing); num_args++; XtGetValues(wp->w, args, num_args); /* font height is ascent + descent */ diff --git a/win/X11/winmesg.c b/win/X11/winmesg.c index 7acb61e14..3fd4388a6 100644 --- a/win/X11/winmesg.c +++ b/win/X11/winmesg.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 winmesg.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 winmesg.c $NHDT-Date: 1430899136 2015/05/06 07:58:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */ /* NetHack 3.5 winmesg.c $Date: 2009/05/06 10:55:57 $ $Revision: 1.4 $ */ /* SCCS Id: @(#)winmesg.c 3.5 1996/04/05 */ /* Copyright (c) Dean Luick, 1992 */ @@ -92,8 +92,8 @@ create_message_window(wp, create_popup, parent) mesg_info->dirty = False; mesg_info->viewport_width = mesg_info->viewport_height = 0; - if (iflags.msg_history < appResources.message_lines) - iflags.msg_history = appResources.message_lines; + if (iflags.msg_history < (unsigned) appResources.message_lines) + iflags.msg_history = (unsigned) appResources.message_lines; if (iflags.msg_history > MAX_HISTORY) /* a sanity check */ iflags.msg_history = MAX_HISTORY; @@ -534,6 +534,8 @@ mesg_exposed(w, client_data, widget_data) { XExposeEvent *event = (XExposeEvent *) widget_data; + nhUse(client_data); + if (XtIsRealized(w) && event->count == 0) { struct xwindow *wp; Display *dpy; @@ -603,6 +605,9 @@ mesg_resized(w, client_data, call_data) old_lines = wp->mesg_information->num_lines;; #endif + nhUse(call_data); + nhUse(client_data); + num_args = 0; XtSetArg(args[num_args], XtNwidth, &pixel_width); num_args++; XtSetArg(args[num_args], XtNheight, &pixel_height); num_args++; diff --git a/win/X11/winmisc.c b/win/X11/winmisc.c index f26c42615..850c3b527 100644 --- a/win/X11/winmisc.c +++ b/win/X11/winmisc.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 winmisc.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 winmisc.c $NHDT-Date: 1430899137 2015/05/06 07:58:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */ /* NetHack 3.5 winmisc.c $Date: 2009/05/06 10:55:57 $ $Revision: 1.7 $ */ /* SCCS Id: @(#)winmisc.c 3.5 2000/05/21 */ /* Copyright (c) Dean Luick, 1992 */ @@ -89,6 +89,10 @@ ps_quit(w, client_data, call_data) Widget w; XtPointer client_data, call_data; { + nhUse(w); + nhUse(client_data); + nhUse(call_data); + ps_selected = PS_QUIT; exit_x_event = TRUE; /* leave event loop */ } @@ -99,6 +103,10 @@ ps_random(w, client_data, call_data) Widget w; XtPointer client_data, call_data; { + nhUse(w); + nhUse(client_data); + nhUse(call_data); + ps_selected = PS_RANDOM; exit_x_event = TRUE; /* leave event loop */ } @@ -109,6 +117,9 @@ ps_select(w, client_data, call_data) Widget w; XtPointer client_data, call_data; { + nhUse(w); + nhUse(call_data); + ps_selected = (int) client_data; exit_x_event = TRUE; /* leave event loop */ } @@ -125,6 +136,10 @@ ps_key(w, event, params, num_params) char rolechars[QBUFSZ]; int i; + nhUse(w); + nhUse(params); + nhUse(num_params); + (void)memset(rolechars, '\0', sizeof rolechars); /* for index() */ for (i = 0; roles[i].name.m; ++i) { ch = lowc(*roles[i].name.m); @@ -167,6 +182,10 @@ race_key(w, event, params, num_params) char racechars[QBUFSZ]; int i; + nhUse(w); + nhUse(params); + nhUse(num_params); + (void)memset(racechars, '\0', sizeof racechars); /* for index() */ for (i = 0; races[i].noun; ++i) { ch = lowc(*races[i].noun); @@ -207,6 +226,10 @@ gend_key(w, event, params, num_params) char ch, *mark; static char gendchars[] = "mf"; + nhUse(w); + nhUse(params); + nhUse(num_params); + ch = key_event_to_char((XKeyEvent *) event); if (ch == '\0') { /* don't accept nul char/modifier event */ /* don't beep */ @@ -239,6 +262,10 @@ algn_key(w, event, params, num_params) char ch, *mark; static char algnchars[] = "LNC"; + nhUse(w); + nhUse(params); + nhUse(num_params); + ch = key_event_to_char((XKeyEvent *) event); if (ch == '\0') { /* don't accept nul char/modifier event */ /* don't beep */ @@ -565,6 +592,9 @@ extend_select(w, client_data, call_data) { int selected = (int) client_data; + nhUse(w); + nhUse(call_data); + if (extended_command_selected != selected) { /* visibly deselect old one */ if (extended_command_selected >= 0) @@ -588,6 +618,10 @@ extend_dismiss(w, client_data, call_data) Widget w; XtPointer client_data, call_data; { + nhUse(w); + nhUse(client_data); + nhUse(call_data); + ec_dismiss(); } @@ -597,6 +631,10 @@ extend_help(w, client_data, call_data) Widget w; XtPointer client_data, call_data; { + nhUse(w); + nhUse(client_data); + nhUse(call_data); + /* We might need to make it known that we already have one listed. */ (void) doextlist(); } @@ -624,6 +662,10 @@ popup_delete(w, event, params, num_params) String *params; Cardinal *num_params; { + nhUse(event); + nhUse(params); + nhUse(num_params); + ps_selected = PS_QUIT; nh_XtPopdown(w); exit_x_event = TRUE; /* leave event loop */ @@ -653,6 +695,10 @@ ec_key(w, event, params, num_params) int i; XKeyEvent *xkey = (XKeyEvent *) event; + nhUse(w); + nhUse(params); + nhUse(num_params); + ch = key_event_to_char(xkey); if (ch == '\0') { /* don't accept nul char/modifier event */ @@ -812,7 +858,7 @@ make_menu(popup_name, popup_label, popup_translations, /* Get the default distance between objects in the form widget. */ num_args = 0; - XtSetArg(args[num_args], XtNdefaultDistance, &distance); num_args++; + XtSetArg(args[num_args], nhStr(XtNdefaultDistance), &distance); num_args++; XtGetValues(form, args, num_args); /* @@ -829,9 +875,9 @@ make_menu(popup_name, popup_label, popup_translations, * Create the left button. */ num_args = 0; - XtSetArg(args[num_args], XtNfromVert, label); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++; /* - XtSetArg(args[num_args], XtNshapeStyle, + XtSetArg(args[num_args], nhStr(XtNshapeStyle), XmuShapeRoundedRectangle); num_args++; */ left = XtCreateManagedWidget(left_name, @@ -846,10 +892,10 @@ make_menu(popup_name, popup_label, popup_translations, * Create right button. */ num_args = 0; - XtSetArg(args[num_args], XtNfromHoriz, left); num_args++; - XtSetArg(args[num_args], XtNfromVert, label); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), left); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++; /* - XtSetArg(args[num_args], XtNshapeStyle, + XtSetArg(args[num_args], nhStr(XtNshapeStyle), XmuShapeRoundedRectangle); num_args++; */ right = XtCreateManagedWidget(right_name, @@ -867,10 +913,10 @@ make_menu(popup_name, popup_label, popup_translations, for (i = 0, above = left, curr = commands; i < num_names; i++) { if (!widget_names[i]) continue; num_args = 0; - XtSetArg(args[num_args], XtNfromVert, above); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), above); num_args++; if (above == left) { /* if first, we are farther apart */ - XtSetArg(args[num_args], XtNvertDistance, skip); num_args++; + XtSetArg(args[num_args], nhStr(XtNvertDistance), skip); num_args++; } *curr = XtCreateManagedWidget(widget_names[i], diff --git a/win/X11/winstat.c b/win/X11/winstat.c index 3267e26be..4a16b79ed 100644 --- a/win/X11/winstat.c +++ b/win/X11/winstat.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 winstat.c $NHDT-Date: 1425083083 2015/02/28 00:24:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */ +/* NetHack 3.5 winstat.c $NHDT-Date: 1430899137 2015/05/06 07:58:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.11 $ */ /* NetHack 3.5 winstat.c $Date: 2009/05/06 10:55:59 $ $Revision: 1.4 $ */ /* SCCS Id: @(#)winstat.c 3.5 1996/04/05 */ /* Copyright (c) Dean Luick, 1992 */ @@ -86,10 +86,10 @@ create_status_window(wp, create_popup, parent) */ num_args = 0; - XtSetArg(args[num_args], XtNdisplayCaret, False); num_args++; - XtSetArg(args[num_args], XtNscrollHorizontal, + XtSetArg(args[num_args], nhStr(XtNdisplayCaret), False); num_args++; + XtSetArg(args[num_args], nhStr(XtNscrollHorizontal), XawtextScrollWhenNeeded); num_args++; - XtSetArg(args[num_args], XtNscrollVertical, + XtSetArg(args[num_args], nhStr(XtNscrollVertical), XawtextScrollWhenNeeded); num_args++; wp->w = XtCreateManagedWidget( @@ -106,11 +106,15 @@ create_status_window(wp, create_popup, parent) /* Get the font and margin information. */ num_args = 0; - XtSetArg(args[num_args], XtNfont, &fs); num_args++; - XtSetArg(args[num_args], XtNtopMargin, &top_margin); num_args++; - XtSetArg(args[num_args], XtNbottomMargin, &bottom_margin); num_args++; - XtSetArg(args[num_args], XtNleftMargin, &left_margin); num_args++; - XtSetArg(args[num_args], XtNrightMargin, &right_margin); num_args++; + XtSetArg(args[num_args], XtNfont, &fs); num_args++; + XtSetArg(args[num_args], nhStr(XtNtopMargin), + &top_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottomMargin), + &bottom_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNleftMargin), + &left_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNrightMargin), + &right_margin); num_args++; XtGetValues(wp->w, args, num_args); wp->pixel_height = 2 * nhFontHeight(wp->w) + top_margin + bottom_margin; @@ -183,13 +187,14 @@ adjust_status(wp, str) static int hilight_time = 1; /* number of turns to hilight a changed value */ struct X_status_value { - char *name; /* text name */ - int type; /* status type */ - Widget w; /* widget of name/value pair */ - long last_value; /* value displayed */ - int turn_count; /* last time the value changed */ - boolean set; /* if hilighed */ - boolean after_init; /* don't hilight on first change (init) */ + /* we have to cast away 'const' when assigning new names */ + const char *name; /* text name */ + int type; /* status type */ + Widget w; /* widget of name/value pair */ + long last_value; /* value displayed */ + int turn_count; /* last time the value changed */ + boolean set; /* if hilighed */ + boolean after_init; /* don't hilight on first change (init) */ }; /* valid type values */ @@ -203,7 +208,7 @@ static const char *FDECL(width_string, (int)); static void FDECL(create_widget, (Widget,struct X_status_value *,int)); static void FDECL(get_widths, (struct X_status_value *,int *,int *)); static void FDECL(set_widths, (struct X_status_value *,int,int)); -static Widget FDECL(init_column, (char *,Widget,Widget,Widget,int *)); +static Widget FDECL(init_column, (const char *,Widget,Widget,Widget,int *)); static Widget FDECL(init_info_form, (Widget,Widget,Widget)); /* @@ -370,8 +375,9 @@ update_val(attr_rec, new_value) if (strcmp(buf, attr_rec->name) == 0) return; /* same */ - /* Set the label. */ - Strcpy(attr_rec->name, buf); + /* Set the label. 'name' field is const for most entries; + we need to cast away that const for this assignment */ + Strcpy((char *) attr_rec->name, buf); XtSetArg(args[0], XtNlabel, buf); XtSetValues(attr_rec->w, args, ONE); @@ -715,7 +721,8 @@ create_widget(parent, sv, sv_index) case SV_LABEL: /* Labels get their own buffer. */ sv->name = (char *) alloc(BUFSZ); - sv->name[0] = '\0'; + /* we need to cast away 'const' when assigning a value */ + *(char *)(sv->name) = '\0'; num_args = 0; XtSetArg(args[num_args], XtNborderWidth, 0); num_args++; @@ -792,7 +799,7 @@ set_widths(sv, width1, width2) static Widget init_column(name, parent, top, left, col_indices) - char *name; + const char *name; Widget parent, top, left; int *col_indices; { @@ -805,12 +812,12 @@ init_column(name, parent, top, left, col_indices) num_args = 0; if (top != (Widget) 0) { - XtSetArg(args[num_args], XtNfromVert, top); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), top); num_args++; } if (left != (Widget) 0) { - XtSetArg(args[num_args], XtNfromHoriz, left); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), left); num_args++; } - XtSetArg(args[num_args], XtNdefaultDistance, 0); num_args++; + XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0); num_args++; form = XtCreateManagedWidget(name, formWidgetClass, parent, args, num_args); @@ -821,8 +828,8 @@ init_column(name, parent, top, left, col_indices) create_widget(form, sv, *ip); /* will set init width */ if (ip != col_indices) { /* not first */ num_args = 0; - XtSetArg(args[num_args], XtNfromVert, shown_stats[*(ip-1)].w); - num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), + shown_stats[*(ip-1)].w); num_args++; XtSetValues(sv->w, args, num_args); } get_widths(sv, &width1, &width2); @@ -878,12 +885,12 @@ init_info_form(parent, top, left) num_args = 0; if (top != (Widget) 0) { - XtSetArg(args[num_args], XtNfromVert, top); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), top); num_args++; } if (left != (Widget) 0) { - XtSetArg(args[num_args], XtNfromHoriz, left); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), left); num_args++; } - XtSetArg(args[num_args], XtNdefaultDistance, 0); num_args++; + XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0); num_args++; form = XtCreateManagedWidget("status_info", formWidgetClass, parent, @@ -898,7 +905,7 @@ init_info_form(parent, top, left) create_widget(form, sv_dlevel, F_DLEVEL); num_args = 0; - XtSetArg(args[num_args], XtNfromVert, sv_name->w); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), sv_name->w); num_args++; XtSetValues(sv_dlevel->w, args, num_args); /* two columns beneath */ @@ -940,10 +947,10 @@ create_fancy_status(parent, top) num_args = 0; if (top != (Widget) 0) { - XtSetArg(args[num_args], XtNfromVert, top); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromVert), top); num_args++; } - XtSetArg(args[num_args], XtNdefaultDistance, 0); num_args++; - XtSetArg(args[num_args], XtNborderWidth, 0); num_args++; + XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0); num_args++; + XtSetArg(args[num_args], XtNborderWidth, 0); num_args++; XtSetArg(args[num_args], XtNorientation, XtorientHorizontal); num_args++; form = XtCreateManagedWidget("fancy_status", panedWidgetClass, diff --git a/win/X11/wintext.c b/win/X11/wintext.c index 795b765a7..ebe6443a2 100644 --- a/win/X11/wintext.c +++ b/win/X11/wintext.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 wintext.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 wintext.c $NHDT-Date: 1430899138 2015/05/06 07:58:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */ /* NetHack 3.5 wintext.c $Date: 2012/01/24 04:26:27 $ $Revision: 1.7 $ */ /* SCCS Id: @(#)wintext.c 3.5 1996/04/05 */ /* Copyright (c) Dean Luick, 1992 */ @@ -66,6 +66,10 @@ delete_text(w, event, params, num_params) struct xwindow *wp; struct text_info_t *text_info; + nhUse(event); + nhUse(params); + nhUse(num_params); + wp = find_widget(w); text_info = wp->text_information; @@ -94,6 +98,10 @@ dismiss_text(w, event, params, num_params) struct xwindow *wp; struct text_info_t *text_info; + nhUse(event); + nhUse(params); + nhUse(num_params); + wp = find_widget(w); text_info = wp->text_information; @@ -142,6 +150,8 @@ add_to_text_window(wp, attr, str) struct text_info_t *text_info = wp->text_information; int width; + nhUse(attr); + append_text_buffer(&text_info->text, str, FALSE); /* Calculate text width and save longest line */ @@ -223,12 +233,12 @@ display_text_window(wp, blocking) /* if added before the window is displayed, so do it afterward. */ num_args = 0; if (nlines < text_info->text.num_lines) { /* add vert scrollbar */ - XtSetArg(args[num_args], XtNscrollVertical, XawtextScrollAlways); - num_args++; + XtSetArg(args[num_args], nhStr(XtNscrollVertical), + XawtextScrollAlways); num_args++; } if (width >= (Dimension) (XtScreen(wp->w)->width-20)) { /* too wide */ - XtSetArg(args[num_args], XtNscrollHorizontal, XawtextScrollAlways); - num_args++; + XtSetArg(args[num_args], nhStr(XtNscrollHorizontal), + XawtextScrollAlways); num_args++; } if (num_args) XtSetValues(wp->w, args, num_args); @@ -286,7 +296,7 @@ create_text_window(wp) args, num_args); num_args = 0; - XtSetArg(args[num_args], XtNdisplayCaret, False); num_args++; + XtSetArg(args[num_args], nhStr(XtNdisplayCaret), False); num_args++; XtSetArg(args[num_args], XtNresize, XawtextResizeBoth); num_args++; XtSetArg(args[num_args], XtNtranslations, XtParseTranslationTable(text_translations)); num_args++; @@ -301,11 +311,15 @@ create_text_window(wp) /* Get the font and margin information. */ num_args = 0; - XtSetArg(args[num_args], XtNfont, &text_info->fs); num_args++; - XtSetArg(args[num_args], XtNtopMargin, &top_margin); num_args++; - XtSetArg(args[num_args], XtNbottomMargin, &bottom_margin); num_args++; - XtSetArg(args[num_args], XtNleftMargin, &left_margin); num_args++; - XtSetArg(args[num_args], XtNrightMargin, &right_margin); num_args++; + XtSetArg(args[num_args], XtNfont, &text_info->fs); num_args++; + XtSetArg(args[num_args], nhStr(XtNtopMargin), + &top_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNbottomMargin), + &bottom_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNleftMargin), + &left_margin); num_args++; + XtSetArg(args[num_args], nhStr(XtNrightMargin), + &right_margin); num_args++; XtGetValues(wp->w, args, num_args); text_info->extra_width = left_margin + right_margin; diff --git a/win/X11/winval.c b/win/X11/winval.c index a5b6463aa..8fc00a082 100644 --- a/win/X11/winval.c +++ b/win/X11/winval.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 winval.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 winval.c $NHDT-Date: 1430899139 2015/05/06 07:58:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */ /* NetHack 3.5 winval.c $Date: 2009/05/06 10:56:06 $ $Revision: 1.4 $ */ /* SCCS Id: @(#)winval.c 3.5 1992/3/7 */ /* Copyright (c) Dean Luick, 1992 */ @@ -45,7 +45,7 @@ create_value(parent, name_value) num_args = 0; XtSetArg(args[num_args], XtNborderWidth, 0); num_args++; - XtSetArg(args[num_args], XtNdefaultDistance, 0); num_args++; + XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0); num_args++; form = XtCreateManagedWidget(name_value, formWidgetClass, parent, args, num_args); @@ -62,7 +62,7 @@ create_value(parent, name_value) num_args = 0; XtSetArg(args[num_args], XtNjustify, XtJustifyRight); num_args++; XtSetArg(args[num_args], XtNborderWidth, 0); num_args++; - XtSetArg(args[num_args], XtNfromHoriz, name); num_args++; + XtSetArg(args[num_args], nhStr(XtNfromHoriz), name); num_args++; XtSetArg(args[num_args], XtNinternalHeight, 0); num_args++; (void) XtCreateManagedWidget(WVALUE, labelWidgetClass, @@ -73,7 +73,7 @@ create_value(parent, name_value) void set_name(w, new_label) Widget w; - char *new_label; + const char *new_label; { Arg args[1]; Widget name; From b8e0394a2e1fe55c97e3187b15245861f10de88e Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 6 May 2015 18:02:11 +0300 Subject: [PATCH 7/9] Hidden holes made by breaking a wand of digging Holes created via applying a wand of digging were not shown on the map, because holes are always marked as seen, and seetrap/feeltrap then do nothing. --- src/dig.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dig.c b/src/dig.c index d356668b2..5cb1c0baa 100644 --- a/src/dig.c +++ b/src/dig.c @@ -569,6 +569,7 @@ int ttyp; if (!ttmp) return; newobjs = level.objects[x][y]; ttmp->madeby_u = madeby_u; + ttmp->tseen = 0; if (cansee(x,y)) seetrap(ttmp); else if (madeby_u) feeltrap(ttmp); From 9c19f554038b431b5768d9dc1421b805e156eb76 Mon Sep 17 00:00:00 2001 From: "Derek S. Ray" Date: Tue, 5 May 2015 18:56:25 -0400 Subject: [PATCH 8/9] jonadab's patch for engraving on the drawbridge Should be splinters, not gravel. Addendum to C343-239 --- src/engrave.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engrave.c b/src/engrave.c index a29221549..4288f305a 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 engrave.c $NHDT-Date: 1429953062 2015/04/25 09:11:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.47 $ */ +/* NetHack 3.5 engrave.c $NHDT-Date: 1430866579 2015/05/05 22:56:19 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.49 $ */ /* NetHack 3.5 engrave.c $Date: 2012/12/20 01:48:36 $ $Revision: 1.39 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -708,6 +708,8 @@ doengrave() "Chips fly out from the headstone." : is_ice(u.ux,u.uy) ? "Ice chips fly up from the ice surface!" : + (level.locations[u.ux][u.uy].typ == DRAWBRIDGE_DOWN) ? + "Splinters fly up from the bridge." : "Gravel flies up from the floor."); else Strcpy(post_engr_text, "You hear drilling!"); From b7c5b33173a17e55d6ff6b391db32b0e5304414c Mon Sep 17 00:00:00 2001 From: Sean Hunt Date: Fri, 1 May 2015 23:37:17 -0400 Subject: [PATCH 9/9] Add a funny message for when a burrower eats food. --- src/dogmove.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/dogmove.c b/src/dogmove.c index 604c52267..029f41fa5 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -239,10 +239,15 @@ boolean devour; unseen spot to eat the food there, avoid referring to that pet as "it". However, we want "it" if invisible/unsensed pet eats visible food. */ - if (seeobj || sawpet) - pline("%s %s %s.", - (sawpet || canspotmon(mtmp)) ? noit_Monnam(mtmp) : "It", - devour ? "devours" : "eats", distant_name(obj, doname)); + if (sawpet || (seeobj && canspotmon(mtmp))) { + if (tunnels(mtmp->data)) + pline("%s digs in.", noit_Monnam(mtmp)); + else + pline("%s %s %s.", noit_Monnam(mtmp), + devour ? "devours" : "eats", distant_name(obj, doname)); + } else if (seeobj) + pline("It %s %s.", devour ? "devours" : "eats", + distant_name(obj, doname)); } if (obj->unpaid) { Strcpy(objnambuf, xname(obj));