Commit Graph

3269 Commits

Author SHA1 Message Date
PatR
2e4e1adea3 fix more clang complaints
Fix some more of the complaints from clang's static analyzer.  The one
in options.c (manipulating warnings symbols) appears to be an actual bug.
All the rest are either because the analysis isn't quite sophicated
enough or outright bogus.

Two of them appear to be because a static routine is attempting to guard
against callers in the same file failing to pass in required output
pointers.  Stripping away the check for missing pointer should convince
the analyzer that those output parameters always receive a value.  We'll
see once the analysis is eventually re-run....
2015-11-21 00:25:50 -08:00
PatR
d3d332e606 valgrind trap complaint
I think this should fix one of the valgrind complaints.  Traps which
didn't use the trap->vl union field never initialized it, leaving a
bit of random garbage in the malloc'd trap structure.  (And traps
which overwrote existing ones that did use it didn't reinitialize it
so kept stale data around.)  Since those fields weren't in use by
the traps that don't care about them, this didn't provoke any actual
trouble.

Also reformatting....
2015-11-20 18:31:17 -08:00
PatR
3dfc3200dd more warning suppression
This should avoid two of the three bogus clang complaints about
retaining the address of a stack variable after it has gone out of
scope.

Plus a recreation of some formatting I did a while back and then
accidentally clobbered before committing.
2015-11-20 02:00:31 -08:00
PatR
a2a567737e warning suppression
Fix a couple of the clang static analyzer's warnings.

muse.c has some reformatting.  zap.c wasn't triggering any warning about
possible null pointer, but using MON_AT() to maybe avoid m_at() is not
a useful optimization since m_at() is a macro which starts out by using
MON_AT() itself.
2015-11-19 18:49:50 -08:00
PatR
b5a08bc729 built warning for STATUS_VIA_WINDOWPORT
This should fix one of the 64-bit warnings.  Make the conversion from
ptrdiff_t to int be explicit with a cast.
2015-11-19 16:18:12 -08:00
Pasi Kallinen
dc09a991fe Fix some warnings from clang's static code analyzer 2015-11-18 22:54:28 +02:00
PatR
3583587f1c fix for pre-ANSI compilers
Declare a function pointer without requiring support for prototypes.
Plus a couple of formatting tidbits.
2015-11-18 00:45:03 -08:00
Pasi Kallinen
acc883f122 Comment typofix 2015-11-16 11:46:45 +02:00
PatR
c40982eb23 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.)
2015-11-15 21:57:15 -08:00
Pasi Kallinen
8a07e2cdc5 Fix use of data from deleted vault teleport trap 2015-11-15 18:55:09 +02:00
PatR
d813c6f0ee 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).
2015-11-15 00:32:56 -08:00
Pasi Kallinen
9eb14f684c Extract guard gold before disposing it
If the gold is still in monster inventory, dealloc_obj will panic.
2015-11-14 17:41:31 +02:00
PatR
272d32b343 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?)
2015-11-14 00:46:19 -08:00
Pasi Kallinen
739b6708ee Fix enexto complaint when morguemon returned null 2015-11-14 09:59:35 +02:00
PatR
95772261dc 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.
2015-11-13 20:39:10 -08:00
Pasi Kallinen
4387bde968 Clear thrownobj when punished and swallowed
As per Pat's suggestion, this actually does work correctly;
I have no idea why I thought it didn't ...
2015-11-13 00:07:47 +02:00
Pasi Kallinen
489d56d4bb Fix hiding under nothing when corpse rotted away 2015-11-13 00:06:07 +02:00
Pasi Kallinen
ca02f00208 Prevent buffer overflow 2015-11-12 22:01:47 +02:00
Pasi Kallinen
c1e34f17f7 Prevent a rnd(0) call 2015-11-12 20:11:45 +02:00
Pasi Kallinen
8451f67dff Fix wallification and wallify catacombs mine end 2015-11-12 18:29:33 +02:00
Pasi Kallinen
0bcb713b4f Fix special level loader memory leaks 2015-11-12 18:00:55 +02:00
PatR
b9d5b35078 src/objects.c formatting
Fit the new comments within 80 (actually 78) columns.
2015-11-11 23:30:59 -08:00
nhmall
ce6670174c Merge branch 'master' of https://rodney.nethack.org:20040/git/NHsource 2015-11-12 00:52:35 -05:00
nhmall
39a1667677 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"
2015-11-12 00:42:52 -05:00
Pasi Kallinen
fad2eab749 Fix infinite looping when bound digging on solid map 2015-11-11 21:47:51 +02:00
PatR
cbeb562d20 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.
2015-11-11 01:28:04 -08:00
PatR
2e3ef24762 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'.
2015-11-09 19:20:19 -08:00
PatR
85b234e1fc tiny symset memory leak
Symbol set names weren't being freed upon exit.
2015-11-09 19:11:41 -08:00
PatR
010859bcca SYSCF tiny memory leak
Free sysopt.shellers and sysopt.explorers when releasing the memory used
for other sysopt fields.

Also some formatting stuff since sys.c was previously untouched.
2015-11-09 17:21:20 -08:00
Pasi Kallinen
2c0f24896f Unify blind feel_location or newsym info single func 2015-11-09 21:37:28 +02:00
Pasi Kallinen
7132f56901 Unwrap t-shirt and apron texts, and add one t-shirt msg 2015-11-09 13:24:40 +02:00
Pasi Kallinen
d195052796 Remove trailing whitespaces 2015-11-09 13:06:19 +02:00
PatR
dd633a9eaa 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.
2015-11-08 01:41:43 -08:00
PatR
62193be46a more formatting
Mostly tab replacement, plus the last of the cast spacing.
2015-11-08 01:37:55 -08:00
PatR
c09fe294dd formatting: more casts 2015-11-07 20:02:04 -08:00
PatR
eaec3fee75 formatting: more (typedef) (expression) 2015-11-07 02:35:22 -08:00
Pasi Kallinen
bf6a61ddf5 Make status hilites show none instead of empty in options 2015-11-07 11:55:12 +02:00
PatR
e5ff572891 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.
2015-11-07 01:12:30 -08:00
PatR
7ddcf113f2 rn2()/rnd() debugging
Finding bad calls to rn2(0) or rnd(0) should not be dependent upon
having DEBUGFILES=rnd.c, so switch from debugpline() to impossible().
2015-11-07 00:12:09 -08:00
Pasi Kallinen
464bb3a1f4 Rephrase version number in comment 2015-11-07 09:06:13 +02:00
PatR
e322623210 yet more src reformatting
Last of the suspicious block comments, plus the usual miscellaneous
stuff in files that hadn't been subjected to it before.
2015-11-06 18:03:13 -08:00
PatR
449084fa6c 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.
2015-11-06 15:57:23 -08:00
Pasi Kallinen
99925ff155 Update version numbers in source comments 2015-11-06 16:05:36 +02:00
Pasi Kallinen
a159226a9f Remove a leftover ifdef REINCARNATION 2015-11-06 15:49:29 +02:00
PatR
915dd89270 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.
2015-11-06 03:14:50 -08:00
PatR
102e427ca7 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.
2015-11-05 18:39:02 -08:00
Pasi Kallinen
8f3d91785d Free allocated temporary lregion 2015-11-05 21:03:57 +02:00
PatR
ea8afe7e24 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.
2015-11-05 00:54:13 -08:00
Pasi Kallinen
2ee06dda5a 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.
2015-11-04 21:13:39 +02:00
PatR
145ff80ec5 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.)
2015-11-04 02:57:40 -08:00