PatR [Wed, 18 Nov 2015 11:04:35 +0000 (03:04 -0800)]
X11 pilemark.xbm
Update the unix Makefiles and the older OSX hints files to handle the
pile marker tile overlay. I didn't touch hints/macosx10.10 and .11
since I think there's still a merge for them pending.
A couple of formatting tweaks for bemain.c are included, for no
compelling reason. What are the odds that anyone will every build
that again?
PatR [Tue, 17 Nov 2015 11:09:20 +0000 (03:09 -0800)]
unix/Makefile.utl typo
Confusing build failure, explained by a typo in sys/unix/Makefile.utl.
dgn_lex.o didn't get rebuilt after modifying unixconf.h to take out
the #define MONITOR_HEAP I had in place, resulting in link failure for
dgn_comp because the old object file was referencing 'nhalloc' rather
than 'alloc'. dgn_lex.o accidentally didn't care about modifications
to config.h and the other headers that pulls in, such as unixconf.h.
This typo was already present when the last cvs repository was
initialized nearly 14 years ago.
PatR [Tue, 17 Nov 2015 10:26:17 +0000 (02:26 -0800)]
include/*.h formatting
I tracked down the widest lines, which sometimes occur due to mis-indent
of block comments (see tradstdc.h for an example), and fixed those up.
For the files affected, I also converted tabs to spaces.
PatR [Tue, 17 Nov 2015 02:57:11 +0000 (18:57 -0800)]
display.h reformatting
A couple of macros with comments in the midst of their expansions got
badly mangled by the automated reformat and one ended up with a line
that was over 150 characters wide.
PatR [Mon, 16 Nov 2015 05:57:15 +0000 (21:57 -0800)]
tribute enhancement
When reading a novel, select a random passage which hasn't been shown
already. Once you've run through all the passages, it resets to get
them all again (with new random order that might happen to the be same
order if there aren't many passages). Switching to a different novel--
even another copy of the same one--will cause the previous passage
selection to be discarded and restarted from scratch if the prior book
is read again. Passage tracking for the most recently read novel is
kept across save and restore. (That means I needed to bump EDITLEVEL,
so it will need to be reset to 0 again before release.)
PatR [Sun, 15 Nov 2015 08:32:56 +0000 (00:32 -0800)]
window cleanup at exit
exit_nhwindows() is called before terminate(), and the tty incarnation
destroys all windows--including 'pickinv_cache_win'--without setting
the various index variables used to access them to WIN_ERR, then
terminate() calls freedynamicdata() which calls free_pickinv_cache()
which tries to destroy 'pickinv_cache_win' since it isn't WIN_ERR (if
the perm_invent option has been enabled during that playing session).
Some of the other <interface>_exit_nhwindows() also tear things down
without resetting the variables used to track them, so fixing this in
exit_nhwindows() would have been pretty messy.
Call free_pickinv_cache() before exit_nhwindows() in done(). At the
moment it's only called from done(), so other exit paths won't release
the small chunk(s) of memory used for the alternate inventory window
(if it got created for perm_invent support).
PatR [Sat, 14 Nov 2015 08:46:19 +0000 (00:46 -0800)]
readobjnam()'s "overlapping strcat"
Replace the code that uses strcat with two pointers into the same buffer.
Treated separately, they point at distinct strings (no overlap possible),
but the C standard does disallow that in order to enable optimizations
using block transfer or such, so the tool that complained about it isn't
wrong. The characters getting appended to the output pointer can end
up overlapping the beginning of the other input pointer, conceivably
breaking an implementation that didn't use simple left-to-right byte-at-
a-time copying.
Also, I noticed that wishing for "luck stone" gave me a random gem.
There's code to strip off " stone" and compare against gem types, but it
prevents other code that accepts "foo bar" as a match for "foobar" and
vice versa from finding a match, since "luck" doesn't match anything
once "stone" is gone. So add the four gray stones into the array of
alternate spellings.
Another bit: it now accepts " gem" in addition to " stone" as optional
gem suffix, so "ruby", "ruby stone", and "ruby gem" all yield ruby.
("luck gem" won't work; you'll end up with a random gem-class object.)
And a last other bit: wishing for "lamp (lit) named foo" would yield
an unlit, unnamed lamp because "(lit)" followed by anything didn't match
"(lit)" and threw away everything past the opening paren. Now it will
produce "lamp named foo (lit)"--a lit lamp named "foo". (Wishing for
"lamp named foo (lit)" produces an unlit lamp named "foo (lit)". That's
acceptable to me... I'm not crawling any farther down this hole. Maybe
object formatting should be changed to keep the lit attribute in front
of the name?)
Pasi Kallinen [Sat, 14 Nov 2015 08:29:44 +0000 (10:29 +0200)]
Remove the useless FUN STUFF section
The fun stuff section in config.h contains nothing fun anymore,
so let's remove it. Move SCORE_ON_BOTL to the next section,
and add couple other defines there too.
PatR [Sat, 14 Nov 2015 04:39:10 +0000 (20:39 -0800)]
fix memory leak: obj->oextra->omonst->mextra
The memory leak (monst->mextra->edog, monst->mextra->mname,
monst->mextra for some monster were not released) I noticed recently
was due to recording a pet's full monster attributes with its corpse.
During save and restore, obj->oextra->omonst was being treated as a
full-fledged monster so worked as intended, but when freed, omonst
was treated as a black box and its mextra details weren't handled.
PatR [Fri, 13 Nov 2015 09:12:43 +0000 (01:12 -0800)]
tty build warning
Use casts to try to suppress a couple of assignments of long to short
that Michael's compiler warns about. 'cw->maxrow' might have a value
that's too big for 'short' (when dealing with really big menus), but
'cw->maxcol' never will (unless someone comes up with a terminal or
emulator that's wider that 32K-1 characters...).
PatR [Thu, 12 Nov 2015 07:46:19 +0000 (23:46 -0800)]
make depend
dungeon.o depending on lev.h is the only change found by 'make depend'.
(I'm a bit suspicious about that.)
I haven't attempted to reconcile the vms Makefiles with the Unix ones,
just put in this one new dependency. I know vms/Makefile.src lacks
handling for sys/share/*regex.c and vms/Makefile.top and install.com
both lack handling for 'sysconf'.
PatR [Thu, 12 Nov 2015 06:56:57 +0000 (22:56 -0800)]
fix PATCHLEVEL
> Somebody has changed versioning so that the game incorrectly states
> 3.6.1 in messages. It looks like someone updated patchlevel instead of
> editlevel?
Yes, that was me. I meant to increment EDITLEVEL and nobody noticed
the mistake until now....
This changes PATCHLEVEL back to the correct value of 0, and implicitly
resets EDITLEVEL to 0 for release (by not changing it to 1 as it was
supposed to have been for the past 3-4 weeks).
Data files from Oct. 18 through today are actually compatible but will
be rejected once anyone rebuilds with this fix, same as would happen
when EDITLEVEL changs. Data files from before Oct. 18 will be
incompatible but be accepted by nethack but not work correctly due to
a change in the 'context' structure.
nhmall [Thu, 12 Nov 2015 05:42:52 +0000 (00:42 -0500)]
Repair recent tile mapping error when MAIL is undefined
Changes to be committed:
modified: src/objects.c
modified: win/share/tilemap.c
Warnings during tile builds (and incorrect tile mappings
at run time when MAIL wasn't defined):
Creating 16x16 binary tile files (this may take some time)
warning: for tile 325 (numbered 325) of objects.txt,
found 'ETAOIN SHRDLU' while expecting 'stamped / mail'
warning: for tile 326 (numbered 326) of objects.txt,
found 'LOREM IPSUM' while expecting 'ETAOIN SHRDLU'
The recent addition of the first new extra scroll descriptions in a
very long time caused this problem to show up when MAIL was undefined.
There was a magic number in use that made an assumption that there
were only 4 such extra scroll descriptions, those being
"FOOBIE BLETCH", "TEMOV","GARVEN DEH","READ ME"
PatR [Wed, 11 Nov 2015 09:43:03 +0000 (01:43 -0800)]
tty memory management at program termination
Release some dynamically allocated memory prior to exit. These were
previously left alone due to assumed complexity (at least by me...),
but dealing with them turned out to be straightforward.
|#if FREE_ALL_MEMORY
free BASE_WINDOW -- tty-specific; other windows are drawn on top of it
free ttyDisplay -- tty's basic data structure
|#endif
free nh_HI, nh_HE -- termcap values handled differently from the rest
These are the last things that 'heaputil' always reported as not freed
for the basic Unix+tty configuration. (I've observed other things not
being freed; those are post-3.4.3 bugs that need to be found and fixed.)
PatR [Wed, 11 Nov 2015 09:28:04 +0000 (01:28 -0800)]
doset() -> special_handling() -> free(NULL)
This isn't urgent, but I figure that until the mac build stuff gets
merged in, the core is still fair game....
'O' command's autopickup_exceptions was freeing a menu pick-list even
when it hadn't been allocated (for the list case, and for the remove
case if nothing was chosen for removal). That code was evidently used
as the model for msgtype and menucolors; they had the same situation.
I think ANSI and ISO sanction free(NULL) as a no-op, but pre-ANSI free
implementations don't necessarily handle that benignly. Even if they
all do, freeing something--even if that 'something' is nothing--which
hasn't been allocated is a bug on our end.
PatR [Tue, 10 Nov 2015 09:49:21 +0000 (01:49 -0800)]
README and dat/history update
README - add VMS back as a tested platform; thanks KevinS!
dat/history - add VMS update, remove trailing whitespace, two spaces;
instead of just one (recently added stuff) for sentence separation;
sys/vms/Install.vms - minimal update;
Files - reformat the win32 project section to fit within 80 columns.
PatR [Tue, 10 Nov 2015 03:20:19 +0000 (19:20 -0800)]
options.c cleanup
Replace several 'foo = alloc(strlen(bar)+1), strcpy(foo,bar)' sequences
with 'foo = dupstr(bar)' calls.
Change 'free(foo)' into 'free((genericptr_t) foo)' to possibly pacify
'lint' and/or really old compilers.
Add braces around 'if something;' when 'else { otherwise; }' has braces.
Simplify option value formatting for 'sortloot'.
PatR [Tue, 10 Nov 2015 02:37:00 +0000 (18:37 -0800)]
update util/.gitignore
Tell git to ignore the presence of the heaputil program in util/.
(It lives in NHinternal/devteam/util/heaputil.c but working with it
from there is inconvenient.)
PatR [Mon, 9 Nov 2015 09:47:18 +0000 (01:47 -0800)]
fix makedefs
If makedefs.c is compiled with MONITOR_HEAP defined, attempted calls to
free() resulted in link failure. Since makedefs doesn't use alloc(),
call free() directly instead of redirecting to nhfree().
PatR [Sun, 8 Nov 2015 09:41:43 +0000 (01:41 -0800)]
last of the reformatting...
This one has a couple of code changes included, but they shouldn't
produce any change in game play. If anyone adds a new shirt or shield
they'll have to update the corresponding foo_on() and foo_off() routines
to avoid an 'impossible' when putting on or taking off the new item(s),
the same situation as already happens for other subclasses of armor.
PatR [Sat, 7 Nov 2015 09:12:30 +0000 (01:12 -0800)]
formatting: casts involving typedefs
The automated reformatting put a space in casts of the form
'(type)(expression)', yielding '(type) (expression)', but it didn't
do that for '(typedef)(expression)'. There are lots of instances of
'(boolean)(expression)'; (uchar) and (xchar) also occur. I haven't
noticed other types, but I haven't looked in very many files yet.
PatR [Sat, 7 Nov 2015 00:39:29 +0000 (16:39 -0800)]
couple of string concatenations in win/tty/
Plus a modest amount (really!) of reformatting.
Also got rid of 'copy_of()' since dupstr() does the same thing [except
for the 'treat Null as ""' part; when needed, that can be done in the
call: dupstr(!str ? "" : str)].
PatR [Fri, 6 Nov 2015 23:57:23 +0000 (15:57 -0800)]
eliminate implicit concatenation of strings
Explicitly combine adjacent string literals so that pre-ANSI compilers
still have a chance to compile the code. I thought these had already
been dealt with, but I kept stumbling across them while reformatting,
so am trying to get them all out of the way now.
PatR [Fri, 6 Nov 2015 11:14:50 +0000 (03:14 -0800)]
more src reformatting
Fixing up mis-indented block comments, but hit some files that hadn't
had the earlier mixture of tab replacement, etc, so it's bigger than I
expected. If I get to it, they'll be another round of this tomorrow.
PatR [Fri, 6 Nov 2015 02:39:02 +0000 (18:39 -0800)]
fix scroll of charging
The intended change was that you'd get an increase to max energy if
current was sufficiently close to max rather than only when it was
already at max. It wasn't intended that you'd fail to have current
boosted all the way to max in the case where it wasn't sufficiently
close. That's fixed here.
PatR [Thu, 5 Nov 2015 08:54:13 +0000 (00:54 -0800)]
formatting - last of the trailing continuations
Last few && or || followed by end-of-line comments, plus tab replacement
and 'return' parentheses. Not as many of those; some of these files had
already had that done.
Also, tweaked non-cursed scroll of charging read while confused to be a
tiny bit more effective.
To do: find and fix block comments that immediately follow a line with
an end-of-line comment and got misindented to line up with that comment.
Pasi Kallinen [Wed, 4 Nov 2015 19:13:34 +0000 (21:13 +0200)]
Allow some variance in corridors and reduce predictability
The corridors used to head towards the goal using the straightest
possible line, often making a zig-zag beeline. Allow some slight variance,
sometimes going straight instead of turning, reducing the predictability,
and making those monotonously turning corridors less likely.
PatR [Wed, 4 Nov 2015 10:57:40 +0000 (02:57 -0800)]
multishot throwing/shooting feedback
While the topic of strprepend() is current, make good use of it.
Simplify code which inserts "the Nth " in front of "<arrow,&c>".
I'm pretty sure there are one or two other places where I assumed that
the outpuf of xname() was a char array which is BUFSZ in length rather
than BUFSZ-PREFIX, and reused the buffer, but I don't know where they
occur. (BUFSZ-PREFIX is still big enough to hold most things, so it
might not lead to trouble.)
PatR [Wed, 4 Nov 2015 10:27:59 +0000 (02:27 -0800)]
spellcasting bug fix: confusion duration
Fix the reported bug that attempting to cast an expired spell, which
causes confusion and/or stun, was replacing the duration of any existing
confusion or stun with the new amount rather than increasing it by that
amount.
Attempting to cast any spell while stunned will now fail immediately,
and casting an expired spell while confused will increase confusion
duration (and/or set stun duration) rather than override it.
PatR [Wed, 4 Nov 2015 02:28:53 +0000 (18:28 -0800)]
another batch of formatting
Same sort of stuff as before: some continuation lines with operator
followed by end of line comment (only a few files with those still to
go...), plus tab replaced by spaces in comments, excess parenthesis
removal for return statements, and force function name to be in column
one in function definitions:
type name(args) /* comment */
argtype args;
{
to
/* comment */
type
name(args)
argtype args;
{
I've been spotting those by eye rather than rexexp, so probably missed
some.
PatR [Wed, 4 Nov 2015 02:13:00 +0000 (18:13 -0800)]
potions of gain energy
When doing some more reformatting I came across something I've been
meaning to tweak for a long time, and since the change is only a couple
of lines I'm putting it in now instead of waiting. Make potions of
gain energy more useful for actually regaining energy so they might not
be relegated to alchemy all the time. The adjustment is probably too
low to really achieve that, but I didn't want to risk going too high.
Increase to max energy is only a little higher (average 10.5 vs 9 for
blessed, 7 vs 4 for uncursed) but to current energy is noticeably higher
(31.5 vs 9 for blessed, 21 vs 4 for uncursed; capped by max energy so
bigger increase only matters if current is below max when quaffing).
PatR [Tue, 3 Nov 2015 02:14:57 +0000 (18:14 -0800)]
releasing inventory window(s)
This should address the issue that the problem patch to display_pickinv()
was trying to deal with: releasing the inventory window before exiting
the program so Pasi's memory checker doesn't think it's a memory leak.
Not related, but in the same file:
The older qsort comparison routines are tagged with CFDECLSPEC to deal
with some C vs C++ interaction issue. I added that to the relatively
recently added 'sortloot' qsort compare callback.
I also changed worn_wield_only(), although it isn't actually called.
(display_minventory() has provisions to call it, but both of the latter's
callers pass in MINV_ALL so allow_all() gets used instead.)
PatR [Mon, 2 Nov 2015 09:53:38 +0000 (01:53 -0800)]
fix can_carry()
Noticed while going through more reformatting: can_carry() was changed
to return a number rather than yes/no, but it's trying to return a long
value (obj->quan) as an int.
Gold is the only thing likely to exceed LARGEST_INT in actual play
(although rocks could manage it if somebody tried hard enough). This
makes sure that the value returned doesn't exceed LARGEST_INT, but only
tame monsters honor the resulting subset value (at least for gold) and
split the stack. The proper fix is to convert can_carry() and all its
uses to long, but I'd rather spend my time on other stuff.