Commit Graph

3260 Commits

Author SHA1 Message Date
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
PatR
c48e1732d8 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.
2015-11-04 02:27:59 -08:00
PatR
2ddc361adf 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.
2015-11-03 18:28:53 -08:00
PatR
37771f779e 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).
2015-11-03 18:13:00 -08:00
PatR
69b13d574d 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.)
2015-11-02 18:14:57 -08:00
Pasi Kallinen
91369e7a76 Revert the created inventory nhwindow destruction
At least perm_invent (and other stuff?) causes problems with this.
2015-11-02 22:23:18 +02:00
PatR
80d4acdc81 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.
2015-11-02 01:53:38 -08:00
Pasi Kallinen
7a517dea36 Destroy created inventory nhwindow 2015-11-01 21:59:56 +02:00
Pasi Kallinen
9181f06dab Fix crystal ball use after being destroyed
Crystal ball can be destroyed when used, so pass the object parameter
back as null in that case.
2015-11-01 18:49:43 +02:00
PatR
a9eb5b2ca8 yet more formatting
Reformat some trailing &&, || operators followed by end-of-line comment,
missed by the earlier continuation formating.

An
  #if 0
    something {
  #else
    something_else {
  #endif
construct in rhack(cmd.c) confused the automated reformatter, resulting
in some code from inside a function ending up in column 1.
2015-11-01 01:17:54 -08:00