Commit Graph

5312 Commits

Author SHA1 Message Date
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
PatR
61319ef1ca force NHSUBST for X11 icons 2015-11-02 01:51:58 -08:00
Pasi Kallinen
acd7396f46 Change version number of the help file 2015-11-02 11:23:10 +02:00
Pasi Kallinen
ab521ca574 Change Porting file version number to 3.6 2015-11-02 09:30:36 +02:00
Pasi Kallinen
7a517dea36 Destroy created inventory nhwindow 2015-11-01 21:59:56 +02:00
Pasi Kallinen
e022486cdc Actually destroy the character selection window 2015-11-01 20:49:32 +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
07e2d6175f X11 icon version numbering
One of the steps in the pre-release checklist:  make sure the version
number in the X11 icons is up to date.  nh32icon and nh56icon both have
the version number (major and minor values only, not patchlevel).
Update it from 3.4 to 3.6 for both.  (nh72icon doesn't have any version
info in its design, so doesn't need any update.)

The X11 'bitmap' program strips out the header comments, so I modified
the image, saved it, used 'git diff --patch' to capture the changes,
'git checkout' to revert to the existing file, and edited in the diff
bands pertaining to the changed data.  No doubt this could have been
done in some easier fashion, but it was victory just to find the bitmap
utility and achieve results using a one-button mouse--worse, a clumsy
touchpad substituting for one--when it's designed for a three-button one.
2015-11-01 03:59:55 -08: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
Pasi Kallinen
bdb5cb2b73 Free the compiled regex buffer 2015-11-01 10:23:11 +02:00
PatR
561ab1cb1e tribute: Monstrous Regiment 2015-10-31 18:37:16 -07:00
PatR
68cb45c9fd str_end_is()
Move this small utility routine to hacklib.c where other such things
live and where it's feasible to find them if you need the functionality
elsewhere.
2015-10-31 17:13:26 -07:00
Pasi Kallinen
b44486e7cc Prevent array underflow 2015-11-01 01:44:10 +02:00
Pasi Kallinen
6399347d9f Prevent string underflow in fruit name matching 2015-11-01 01:42:57 +02:00
Pasi Kallinen
0261bbf727 Add missing regex_frees 2015-11-01 01:38:12 +02:00
Pasi Kallinen
c6832a4d57 Free the venom object, even if it is not thrown 2015-11-01 01:36:18 +02:00
Pasi Kallinen
4f616a932c Prevent out of array access
As index() can match with the string terminator, that would make
the xdir etc array references out of bounds.
2015-11-01 01:32:24 +02:00
Pasi Kallinen
b0e4357c32 Fix lev_comp memory leaks 2015-11-01 00:28:28 +02:00
Pasi Kallinen
1a133be123 Fix makedefs memory leaks 2015-11-01 00:12:38 +02:00
Pasi Kallinen
3ff3f6d2de Use our dupstr instead 2015-10-30 23:27:19 +02:00
Pasi Kallinen
4aac554b66 Fix trying to look up curse state of deleted object 2015-10-30 20:54:45 +02:00
Pasi Kallinen
e6ed35b8f7 Free the allocated special level coder 2015-10-30 20:16:10 +02:00
keni
b5f266ee45 Add a Ben Aaronovitch quote as an engraving. 2015-10-30 09:33:43 -04:00
Pasi Kallinen
230cd0abed Fix syntax error in MacGraphics conditional part 2015-10-30 10:15:28 +02:00
PatR
8a5f340579 commit 84bec89d403a219ff75ae3fa97109de0cfb7941f
Author: PatR <rankin@nethack.org>
Date:   Fri Oct 30 00:50:52 2015 -0700

    more formatting

    Fix up the files containing '[?:] */' to get trailing trinary operator
    followed by end-of-line comment.  Tab replacement and removal of excess
    parentheses on return statements also done.
2015-10-30 00:58:06 -07:00
PatR
7b82fed49d '#turn' for non-priests/non-knights
Another code change while reformatting:  '#turn' by non-priest/non-knight
casts the "turn undead" spell if the hero has learned it, but it was
forcing the spell code to aim at self rather than ask for a direction.
Evidently nobody has ever used that while knowing the spell and able to
cast it....
2015-10-30 00:44:58 -07:00
PatR
1da6486e7b OSX vs apple core dump
Some reformatting mutated into a code change:  OSX gets code from two
conditional blocks
  '#if UNIX: eat apple or pear, give "core dump" message'
  '#if MAC || OSX: eat apple, give "It's a Macintosh" message'
but the second wouldn't be chosen due to the if-then-else logic having
already handled obj->otyp==APPLE before it was reached.  Reorder them
so that OSX gets the Macintosh message for apples and the core dump
message for pears.
2015-10-30 00:20:59 -07:00
PatR
41a40d41a0 monsters moving after player leaves level
Fix the problem reported by ais where it was possible for one monster
to knock the hero onto a level teleporter (or trapdoor or hole),
destination was selected and allowed-to-level-teleport checks were made,
then for another monster to knock or teleport the not-yet-relocated-hero
onto the Amulet and have auto-pickup move it into inventory.  At the end
of that turn's monster movement, hero would level teleport successfully
despite carrying the Amulet.

This short-circuits monster movement if the hero is scheduled to be
moved to a different level.  The monsters who haven't moved yet don't
lose their pending movement points; they'll catch up if/when the hero
returns to the level.
2015-10-29 18:18:12 -07:00
Pasi Kallinen
9008ba321b Fix uninitialized variable 2015-10-29 21:45:35 +02:00
Pasi Kallinen
2d83b83cc2 Fix uninitialized variable 2015-10-29 20:26:25 +02:00
PatR
a447534b2f formatting: src/t*.c - z*.c continuation lines
End of first pass, but '[&|?:][ \t]*$' doesn't catch trailing operater
followed by end-of-line comment so more needs to be done.  As with the
past couple of batches, I've removed redundant parentheses from 'return'
statements but only for files that had continuation fix-ups.

I've also removed tabs from comments in some of the files, but didn't
start until part way through this subset of the sources.
2015-10-28 17:33:38 -07:00
Pasi Kallinen
530ba8e3d3 Add sanity checking for light sources 2015-10-27 18:36:07 +02:00
Pasi Kallinen
ec58bfaa22 Pass LFLAGS from hints file to util Makefile 2015-10-27 18:13:35 +02:00
PatR
bb09cab067 formatting: src/r*.c - src/s*.c continuation lines 2015-10-26 17:49:40 -07:00
Pasi Kallinen
3fd92e3ef8 Fix mon weapon inconsistency when monster got disintegrated
This happened when the monster, who was wielding a weapon, got hit
by a disintegration blast, and then lifesaved by a worn amulet.
2015-10-24 09:30:38 +03:00
keni
c574b566be First bits of a hints file for 10.11. Still needs (at minimum) new packaging code. 2015-10-23 13:47:38 -04:00
PatR
e15f6cc965 tribute: The Wee Free Men 2015-10-23 01:37:31 -07:00
PatR
ea8a1beb0a formatting: src/m*.c - p*.c continuation lines
Somewhere along the line I started removing redundant parentheses from
return statements, but only in files that needed continuation fixups
so it's not comprehensive.
2015-10-22 16:35:01 -07:00
PatR
1e07a9637a tribute typo 2015-10-21 16:56:39 -07:00
PatR
ac27d2af43 trubute: Night Watch 2015-10-21 01:02:18 -07:00
PatR
b7b9d8faa9 formatting: src/e*.c - l*.c continuation lines
Relatively small number of continuation fixes needed for this subset.

Quite a bit of mangling to engrave.c unrelated to continuation lines,
with three or four coding changes.
2015-10-20 17:55:26 -07:00
Pasi Kallinen
581b1830ff Fix segfault when chameleon form fails on the Rogue level 2015-10-20 17:28:16 +03:00
PatR
3986546325 formatting: src/a*.c - d*.c continuation lines
Mostly && and || at end of the first half of a continued line rather
than at the start of the second half.  The automated reformat got
confused by comments in the midst of such lines.
  foo ||
  bar
was converted to
  foo
  || bar
but
  foo ||
  /* comment */
  bar
stayed as is.

Some excluded code [#if 0] was also manually reformatted, but this is
mainly stuff that can be found via regexp '[&|?:][ \t]*$' (with a lot
of false hits for labels whose colon ends their line).
2015-10-19 17:32:21 -07:00
PatR
2c20805b16 unsplitting split object stack
Replace the code that Dean objected to with something a little bit more
robust.  It doesn't rely on the two stacks being adjacent or having the
same inventory letter.  It is still vulnerable to having another
splitobj() occur between the offending split and its attempted unsplit,
or to either of the two halves of a split being extracted from their
object chain.  As before, failure to unsplit only results in the two
halves of the split remaining separate stacks, not anything more drastic
like the panic() that prompted all this.

Simplification of hallucinated currency names got mixed in with this
patch.  I haven't bothered separating it back out.

Whoever reset PATCHLEVEL to 0 jumped the gun.  This patch increments it
since change to the 'context' structure breaks save file compatibility,
so it will need to undergo another reset before release.
2015-10-18 17:37:15 -07:00