PatR [Wed, 6 May 2015 07:59:15 +0000 (00:59 -0700)]
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.
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.
PatR [Tue, 5 May 2015 23:25:49 +0000 (16:25 -0700)]
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.
PatR [Mon, 4 May 2015 15:49:21 +0000 (08:49 -0700)]
more "deleting worn obj"
Lit candles and burning potions of oil can be on the migrating objects
list and get deleted before arrival, so they need the same cleanup as
rotting corpses to prevent obfree from complaining that they're worn.
PatR [Sun, 3 May 2015 23:57:09 +0000 (16:57 -0700)]
owornmask sanity_check fix and enhancement
Thinko fix: sanity checking for owornmask was mis-treating
OBJ_MIGRATING as OBJ_MINVENT of migrating monsters rather than as
unattended objects and would have had problems similar to obfree's
inappropriate impossible check.
Sanity checking for objects worn in invalid slots (amulet worn in
a ring slot and so forth) is extended to items worn by monsters.
Also add a check for wielded coins since the loophole that let them
become wielded has been closed.
PatR [Sun, 3 May 2015 23:54:53 +0000 (16:54 -0700)]
fix "deleting worn object" impossibility
Migrating objects overload obj->owornmask with a destination code,
so rot_corpse needs to clear that before deleting corpses. (Buried
objects don't touch owornmask, so rot_organic, which does the actual
object deletion, shouldn't need any similar change.)
The corpses with owornmask 3 that have been observed recently were
slated to arrive on the up stairs, so presumeably fell down the down
stairs of the current level and rotted before the hero went down.
Put plainly, it was the [post-3.4.3] impossible() check which was in
error, not the active game data.
PatR [Sun, 3 May 2015 08:22:25 +0000 (01:22 -0700)]
fix "gold wield inconsistency"
'w$' reported "you can't wield gold" but
'w*$', choosing from inventory and picking gold, let you wield gold.
The old code checked whether gold had been picked before checking
whether '?' or '*' had been picked to request selection from inventory.
This wasn't an issue with 3.4.3's !GOLDINV configuration (but probably
was for anyone who explicitly switched to GOLDINV) because getobj()'s
callers only inserted gold into inventory when they intended to accept
it as a valid choice.
Fix is just to swap two adjacent 'if' blocks in getobj() so that '*'
is processed before the test of whether '$' has been chosen. Most of
the diff is indentation and other minor reformatting.
PatR [Sun, 3 May 2015 07:47:10 +0000 (00:47 -0700)]
tiles-related build stuff
* Add missing entry for include/tile.h to (top)/Files; also
add new entry for generated file util/tiletxt.c (Unix only);
* Add several missing entries for tile utility programs that
can be built by sys/unix/Makefile.utl to util/.gitignore;
* Update sys/unix/Makefile.utl to build 'tilemap' differently so
that it won't leave behind an unwanted subdirectory tree under OSX:
util/tilemap.dSYM/
util/tilemap.dSYM/Contents/
util/tilemap.dSYM/Contents/Info.plist
util/tilemap.dSYM/Contents/Resources/
util/tilemap.dSYM/Contents/Resources/DWARF/
util/tilemap.dSYM/Contents/Resources/DWARF/tilemap
It now generates util/tiletxt.c on the fly, to be compiled into
tiletxt.o, so that tilemap.c can be compiled in the ordinary
manner and tilemap.o can be kept around for dependency checking.
(Creating real source file win/share/tiletxt.c would be a little
bit cleaner, but it's effectively two lines long so seems silly
to be in the source distribution.) I looked to see whether I
could find a linker or compiler option to suppress that stuff but
failed. I'm sure something of the sort must exist but didn't
pursue it. Someday I might actually learn about how OSX works....
nhmall [Sat, 2 May 2015 22:04:20 +0000 (18:04 -0400)]
permanent wiz_identify correction
wiz_identify (^I) is supposed to bring up the inventory list
with the items identified, in contrast to the regular (I)
inventory, but only for that inventory display.
It is intended that if you then hit ^I again while at that
wiz_identify inventory menu, you'll trigger permanent
identification of itemsand any other key is supposed to
leave them as they were.
In tty however, <space> was doing the same thing as the
second ^I, and permanently identifying everything.
So, for those that like to <space> through menus (like
me) this makes it work as originally intended and
requires a deliberate second ^I at the menu to permanently
identify. (It might also allow trigger permanent ID if you hit
underscore, but nobody "underscores" through menus,
so that's ok.)
PatR [Sat, 2 May 2015 09:44:57 +0000 (02:44 -0700)]
more owornmask sanity_check
Fix the problem with erroneously detecting wielded or quivered
chained ball which legitimately has more than one mask bit set.
Add an additional check for valid wornmask of an item somehow worn
in an invalid slot (such as an amulet in one of the ring slots).
Only lightly tested; it really needs debugger assistance to force
various invalid situations but I don't know gdb well enough for that.
PatR [Sat, 2 May 2015 02:44:56 +0000 (19:44 -0700)]
enlightenment for polymorph & lycanthropy
Fine-tune lycanthropy feedback by combining "you are a werecritter"
and "you are in beast form" into one message. Also, add some new
feedback when lycanthropy and intrinsic polymorph are blocked by
intrinsic unchanging.
PatR [Sat, 2 May 2015 01:01:12 +0000 (18:01 -0700)]
stabilize loss of gold
When gold is stolen by a leprechaun or lost when being "overwhelmed
by an urge to take a bath" while dipping in a fountain, if you had
99 gold pieces or less, you'd lose all of it (in the bath case, only
if it was at least 10 to start with), but if you had 100 or more,
you would lose a random amount which could be as little as 1. And
in the bath case, if the random amount was less than 10, you would
lose nothing but be told that "you lost some of your money in the
fountain". After this change, it is still possible to lose less
when starting with more, but not as likely and not as extreme a case
as maybe losing only 1 when starting with thousands.
The fountain-dip bath case has code to handle mutiple denominations
of coins, possibly the only place in the program where that exists.
I've left that alone although it should probably be taken out....
PatR [Fri, 1 May 2015 09:32:14 +0000 (02:32 -0700)]
sanity check owornmask
Extend the processing done by the wizard mode 'sanity_check' option
to look for anomalies with obj->owornmask since there seem to have
been a few lately. I haven't actually triggered any so this code
isn't very well exercized yet.
sanity_check uses pline() rather than impossible() or debugpline()
to deliver messages so might not be very useful with keymasking.
A sizeable chunk of this diff is just cleaning up indentation so
that I could see what I was working with....
Pasi Kallinen [Wed, 29 Apr 2015 13:28:01 +0000 (16:28 +0300)]
Prevent monsters throwing items out of map
If a monster was in the projectile's path, the projectile stopping
checks would not be reached. The thrown object could fly up to
the maximum range, through walls, or even outside the map.
Fix filtering used by the 'D' command, and a few other activities that
allow both object class filtering and bless/curse state filtering, so
that when both class(es) and state(s) are specified, objects need to
match both rather than either. D?C will present the player with cursed
scrolls to drop rather than all scrolls plus all other cursed objects.
This also fixes another instance when gold could end up with its bknown
flag set.
Alex Kompel [Sun, 26 Apr 2015 21:47:38 +0000 (14:47 -0700)]
bubble structure contains pointer into static array. Bubble objects
are being flat-dumped into save file and this causes segfault in restore()
whenever data segment layout changes (e.g. global variables added/removed).
bmask should either be stored with the objects.
Allow the 'I' command to show inventory of known blessed items via
pseudo object classes B, C, U, and X. That's instead of an showing
inventory of specific object class. The two can't be combined
because 'I' operates on single character input.
I had to modify tty_yn_function to prevent it from forcing a BUCX
character into lower case (simply using lower case would cause a
conflict with 'u' and 'x' for inventory of shopping bill), and did
that by checking whether any of the acceptable response characters
are upper case. Pretty straightforward and shouldn't impact any
other uses that don't specify upper case choices.
I did the same thing for X11. Other interfaces most likely need
to do something similar. If they don't, a response of 'B' or 'C'
(for menustyle:traditional or menustyle:combination) will simply
not work, without causing any problems, same as typing an invalid
choice, and 'U' or 'X' will give shop feedback instead of the
requested subset of inventory.
Pasi Kallinen [Sat, 25 Apr 2015 12:19:13 +0000 (15:19 +0300)]
Show only the short automatic glyph description
When you turn on the automatic description of a glyph under cursor,
we want to show the short description of what glyph it actually is.
The long full description of all possibilities is far too long, so
may cause more-prompts, and is awkward for blind players.
Replace most uses of isspace() with a simple test for ' ' after
processing the string buffer with mungspaces (which replaces tab
with space, converts instances of consecutive whitespace into a
single space, and removes leading and trailing spaces). The uses
where this wasn't done now cast their argument to (uchar) so that
platforms with signed chars will never pass negative values to it.
I didn't mess with the menu coloring code (except for casts to the
isspace() argument); it almost certainly could benefit from using
mungspaces. I did mess with the symset processing quite a bit,
and hope I haven't accidentally broken anything. Default symbols
and DECgraphics symbols still parse and display ok, so the rest of
dat/symbols should be ok too. I didn't test symbols in the user's
config file because I don't remember how that's supposed to work.
Avoid initializer for auto-class array since many pre-ANSI compilers
didn't support that. Also, when ESC is used to cancel inventory
selection, don't continue on searching for that selection in invent.