Commit Graph

144 Commits

Author SHA1 Message Date
PatR
747ebf0ead fix #H7487 - dead with non-zero HP
Report was for being fried by angry deity.  There are lots of deaths
that don't involve subtracting HP until it hits 0 or less; I haven't
bothered tracking down which ones don't set u.uhp to 0 before they
call done().

No effect on life-saving or declining to die except for HP:0 being
visible on the status line during their messages.
2018-10-27 19:55:18 -07:00
keni
f222023bd8 Deprecate "makedefs -m".
mons[].difficulty takes over for monstr[]
Invoking "makedefs -m" gives a deprecation message; it is also included
in the (now mostly empty) monstr.c.
Ports should now remove "makedefs -m" from their build procedures but this
commit does not include that change.
2018-10-20 23:14:33 -04:00
PatR
3e19858edd fix #H6925 - being trapped vs Levitation/Flying
Make being trapped in/on/over floor block Levitation and Flying, the
way that being inside solid rock already does, and the way levitating
blocks flight.

Blocked levitation still provides enhanced carrying capacity since
magic is attempting to make the hero's body be bouyant.  I think that
that is appropriate but am not completely convinced.

One thing that almost certainly needs fixing is digging a hole when
trapped in the floor or tethered to a buried iron ball, where the
first part of digactualhole() releases the hero from being trapped.
If being released re-enables blocked levitation, the further stages
of digging might not make sense in some circumstances.

I recently realized that being held by a grabbing monster is similar
to being trapped so should also interfere with levitation and flying.
Nothing here attempts to address that.

Save files change, but in a compatible fashion unless trapped at the
time of saving.  If someone saves while trapped prior to this patch,
then applies it and restores, the game will behave as if the patch
wasn't in place--until escape from trap is achieved.  (Not verified.)
2018-09-30 01:06:59 -07:00
PatR
3eded06669 fix #H7156 - perm_invent
Bug report #H7156 listed three items, all relating to perm_invent:
1) it shouldn't persist across save/restore since restore might be
   on a system which doesn't have enough room to display it (report
   actually complained that config file setting was ignored when
   restoring old games, which is an expected side-effect for options
   that persist across save/restore);
2) permanent inventory wasn't updated when using scroll of charging;
3) attempts to update permanent inventory during restore could lead
   to crash if it tries to access shop cost for unpaid items.
Items (2) and (3) have already been fixed.  This fixes (1).

Replace 'flags.perm_invent' with a dummy flag, preserving save files
while removing it from flags.  Add 'iflags.perm_invent' to hold the
value of the perm_invent option.

The win32 files that are updated here haven't been tested.  Whichever
branch contains the curses interface needs to be updated; ditto for
any other pending/potential interfaces which support perm_invent.
2018-09-14 17:34:33 -07:00
PatR
f1d0636ba0 fix wiz identify bugs
Fixes #124

Fix github pull request #124 which was also reported directly (but not
through the contact form so #Hxxx number).  Using ^I or #wizidentify
displays inventory with everything ID'd for that command only and adds
a menu entry "_ - use '^I' to identify" that can be chosen to make
those ID's persistent.  Picking underscore would work but picking the
alternate '^I' wouldn't work if the platform had unsigned characters
for plain 'char'.  Switch the return value from magic number -1 to
magic number ^I which isn't a valid inventory letter and isn't subject
to sign conversion.  Casting -1 to '(char) -1' would have worked too
despite some confusion expressed in discussion of the pull request.

If ^I has been bound to some other command and #wizidentify hasn't
been bound to any keystroke, temporary ID didn't disclose any extra
information (ie, acted like ordinary inventory display) and the extra
menu entry to make temporary ID become persistent wasn't available.
This fixes that too.
2018-08-29 19:19:49 -07:00
PatR
77d478c939 fix #H7205, #H7120, #H5216 - sortloot
H7205 - full-pack identify might skip items if perm_invent is on
        because updating the inventory window might reorder 'invent'
        while the identify code is in the midst of traversing it;
H7120 - pickup that doesn't pick anything up can change the glyph
        shown on the map because the pile might be reordered such
        that a different item is on top;
H5216 - performing a sortloot operation on a pile and then switching
        back to sortloot:none doesn't restore pile's original order.

The 'revamp' that changed the contributed sortloot feature to switch
to simpler usage (object list itself was sorted rather than having a
parallel array that needed to be constructed, sorted, traversed, and
discarded) turns out to have too many problems.  This reverts to a
hybrid solution that constructs an array for traversal, leaving the
linked list in its original order, but hides most of the details of
that from sortloot() callers.  The 'revamp' benefit of being able to
use normal list traversal is lost, as is the potential to skip
sorting when the list turns out to already be in the desired order.

This could stand to have a lot more testing than it's had so far.
2018-06-11 16:31:58 -04:00
PatR
7951557057 makeknown()
Noticed while investigating the report about sortloot interacting
with persistent inventory window when identifying all of invent and
possibly skipping some items.  [This doesn't fix that.]

End of game disclosure was using makeknown() on inventory.  It is a
jacket around discover_object() which passes the flag to exercise
Wisdom.  That's useless at end of game [now; conceivably wrong if
disclosure of characteristics exercise ever got added], so call
discover_object() directly to suppress exercise of Wisdom.

discover_object() was also calling update_inventory() for every item
being discovered.  That's not useful when looping through inventory
at end of game.
2018-06-11 16:31:36 -04:00
keni
d8c49ec9d1 Add updated copyright lines, part 1. 2018-04-25 15:00:13 -04:00
Pasi Kallinen
ebde14a6f9 Still more enums 2018-03-31 11:43:38 +03:00
Pasi Kallinen
2ee6412a2f Fix X11 segfault when quitting without dumplogfile defined
Guard dumplog-specific output by checking we actually are putting
the output into the dumplog.

This is a post-3.6.0 bug.
2018-03-20 17:37:56 +02:00
PatR
99f5bbc59e fix #H5590 - pets not shown on dumplog map
When ascending or escaping from the dungeon, adjacent pets are moved
onto the 'mydogs' list so that they can be included in the score and
mentioned as being with hero in the final messages.  But keepdogs()
was caled to do that before the known portion of the map was drawn
in the dumplog file, so adjacent pets were missing.  Defer that until
after the map has been dumped so that pets will still be present.
2017-12-08 23:06:25 -08:00
PatR
72978d69fa fix #6284 - empty perm_invent
Report was for tty, but X11 exhibited the same behavior.  With the
perm_invent option enabled, when the permanent inventory window is
displayed, it would be empty if not carrying anything.  For tty, that
meant a naked "(end) " selection prompt.  Put a separator line of "Not
carrying anything" into the menu so that it won't be completely empty.
The selection prompt is still present but it is attached to something.
(The behavior is different from !perm_invent, where you get that same
text via pline without any menu at all.)
2017-10-28 14:12:50 -07:00
PatR
7f019d8115 suppress 'unused arg' warning for !DUMPLOG 2017-10-13 16:35:39 -07:00
Pasi Kallinen
69f7a78dba Hilite Status: Improved
Allow defining multiple stops per field. Add hitpointbar.
2017-09-26 10:04:25 +03:00
Pasi Kallinen
189809a55c Rename terminate to nh_terminate so VS2015 can compile 2017-08-19 14:10:29 +03:00
Pasi Kallinen
9eae5a8c4b Fix thinko on preprocessor conditional 2017-08-19 13:47:41 +03:00
PatR
365464d9a4 dumplog revisions
I saw dumplog text in a newsgroup posting and the only way I could
recognize what version generated it was that "You entered the dungeon
N turns ago" included the missing-until-recently final period.  So,
put nethack's one-line version information as the very first dumplog
text and follow it with the dumped game's start and end date+time.
(That information is useful to know in its own right, but also should
prevent the build date+time shown with the version from confusing
anybody about when the dump was written.)

Along the way, I noticed that the 'counting' phase for artifact_score
was being repeated for '#if DUMPLOG' even though it doesn't generate
output.  That had a side-effect of adding points for artifacts twice
(applicable when final score was for an ascension or dungeon escape).
2017-05-19 15:19:39 -07:00
PatR
9623154bbc vanquished monsters tidbit
Use the same terminology ("creatures" rather than "monsters") for
the two "no <foo> {have been, were} vanquished" messages as for the
"disclose vanquished <foo>" prompt and its "M <foo> vanquished"
summary.
2017-03-10 16:35:49 -08:00
PatR
ed300e5fa8 dumplog fixes: genocide list, survivor's tombstone
The dumplog data was including a final tombstone unconditionally,
which looked awfully strange for characters who didn't die.  Make
it conditional, like actual end-of-game tombstone.  (One difference
though:  dumplog has a tombstone for hero who died from genocide,
end-of-game does not.  I think the latter should display one even
though no grave gets generated.)  [Potential for future enhancement:
add some alternate ascii art in place of tombstone for survivors.]

The list of genocided and/or extincted species was never shown
since caller passed 'a' to list_genocided() and it expected 'y'.
Also, once shown, the list entries were lacking indentation that
other sections of the dump generally have.

Both vanquished monsters and genocided/extinct monsters included
a blank line separator even when there was no feedback, making a
noticeable gap in the dumplog text.  Have them report "no creatures
vanquished" and "no species genocided", when applicable, so that
their separator lines always have something to separate.

When dumping, omit a couple of blank lines each from vanquished
creatures list, genocided species list, and tombstone so the
relevant sections of the dump are more compact.
2017-03-06 00:22:00 -08:00
PatR
f55da584f4 dumplog's saved_plines[]
Use a simple ring buffer instead of a flat array that needed to have
49 pointers shifted down a slot every time a pline message was issued.

'saved_plines[saved_pline_index]' is the oldest message in the buffer
and the next slot to use when adding a new one.
2017-02-27 02:54:14 -08:00
PatR
fd2cfba544 dumplog lint and formatting 2017-02-25 18:27:21 -08:00
Pasi Kallinen
7d8b4d4f97 Add end-of-game dumplogs
This is based on the "new" dumplog patch for 3.6.0, by Maxime Bacoux.

Define DUMPLOG to enable. By default only enabled for the TTY linux.
2017-02-19 15:33:27 +02:00
Pasi Kallinen
79870d33be Silence Yet Another Valgrind complaint 2016-12-29 19:19:00 +02:00
PatR
9b725218bb fix #H4706 - non-zero hit points for poison death
For "the poison was deadly" against hero, hit points were set to -1
(which gets displayed as 0 when shown) but the status lines weren't
being updated, so stale positive HP value was visible during final
disclosure.
2016-12-08 16:39:55 -08:00
PatR
8c0810f687 multishot by monsters, plus reformatting
Some reformatting of the recently added pet ranged attack code.

The redundant--but different--multishot volley code has been replaced
so that there are only two versions (hero and monster) instead of
three (hero and monster vs hero and pet vs other monster).  The monst
version was out of date relative to post-3.4.3 changes to the hero one.
The pet version was way out of date and had some bugs:  wielding an
elven bow gave a +1 multishot increment to volley count for fast weapon
even when throwing something rather than shooting arrows, wielding any
weapon which had at least +2 enchantment gave 1/3 enchantment bonus to
volley count when throwing instead of shooting shoot ammo, and a pet
which got killed in the midst of a multishot volley--perhaps by a gas
spore explosion or some other passive counterattack--would keep on
shooting/throwing until the volley count was exhausted.

Pet use of ranged weapons is not ready for prime-time.  Pets don't
hang on to missiles or launchers+ammo, they just drop them if there is
no target immediately available.
2016-06-06 17:42:58 -07:00
PatR
a102ee9a1a ctype tweaks
None of these explains the Windows assertion failure.
 end.c - post-3.6.0
 options.c - in #else block of #if win32
 winmenu.c - X11
2016-05-28 17:18:51 -07:00
PatR
26226a1cdb misc core formatting
Some of these are post-3.6.0, some just got overlooked before the
3.6.0 release.
2016-05-14 18:26:48 -07:00
PatR
e0537a76d4 disclosing genocided/extinct monsters
Make the handling of unique monsters consistent between vanquished
monsters and genocided/extinct monsters.  No visible difference to
players.

This also prevents Nazgul and erinys from being polymorphed into
some other form to reduce the chance that their kill count fails
to match the expected number when they're reported to be extinct.
[My long test game (with 3451 total dead critters as of the last
save file) used for exercising the sorting of vanquished monsters
included
 120 soldiers
 111 wolves
   9 Nazgul
   2 erinyes
and the genocided/extinct list had none genocided, those four
extinct.  No doubt the missing third erinys was alive somewhere
rather than counted as something else after getting polymorphed,
so this band-aid wouldn't have helped this particular game.]
2016-05-04 17:42:58 -07:00
PatR
67cd22573e tweak #vanquished - ESC when choosing sort order
Skip displaying vanquished monsters if player responds with ESC
in the sort order menu instead of treating it like RET and using
default order.
2016-05-03 16:23:27 -07:00
PatR
b98427955c complicate #vanquished monsters processing...
...to make it more interesting.  Using #vanquished in wizard mode
or answering 'a' to the "disclose vanquished monsters?" prompt will
put up a menu to choose how the list of vanquished monsters should
be ordered.  Right now there are 6 choices:

  Traditional: by monster level, by internal index within level;
  by monster toughness, by internal index within monstr[] rating;
  alphabetically, first unique monsters, then others;
  by monster class, low to high level within class;
  by count, high to low, by internal index within tied count;
  by count, low to high, by internal index within tied count.

Two other orderings are implemented but suppressed from the menu
since they seemed uninteresting (alphabetical with uniques
intermixed with other monsters, and by-class high to low within
class).  The first two are very similar to each other and one of
them should probably be discarded too.  The by-class order(s) have
class-name separator lines between classes.

Options parsing for end of game disclosure has extended current
  +v (always show vanquished monsters)
  -v (never show vanquished monsters)
  yv (prompt about them, with default response 'y')
  nv (prompt about them, with default response 'n')
to include
  #v (always show vanquished monsters and choose the ordering)
  ?v (prompt about them, with default response 'a' to choose ordering)

The 'a' response was picked because it's easy to use ynaq()
instead of ynq(), but it can be considered to mean "ask about sort
order".  (Neither of the two new option values could be "av"; 'a'
for disclosing attributes would become ambiguous.)

+v or answering 'y' for any of yv, nv, or ?v uses the most recent
sort ordering (if #vanquished has been used in wizard mode) or the
traditional one (normal mode, or #vanquished not used).  Players
will probably want to specify a default order and then use +v
rather than choose the final order from a menu.  That hasn't been
implemented here.  Count high to low might be a better default than
level high to low.

While looking through Guidebook.tex to try to determine whether
the new text needed special handling, I spotted multiple mistakes
in the existing text.  Probably all from earlier updates of mine;
this attempts to fix them.  As usual of late, Guidebook.mn has been
tested and Guidebook.tex hasn't.
2016-05-03 01:12:32 -07:00
PatR
a952162a7b simplify #vanquished monsters processing...
...prior to making it more complicated.  Most of the diff is just
reducing the block nesting level of the kill-count formatting by
a couple of tab stops.
2016-05-01 13:54:08 -07:00
PatR
ff6e62b361 cleanup up #vanquished output
Tidy the output from disclosure of vanquished monsters at end of game
or from #vanquished wizard-mode command.  Instead of

Juiblex
The Wizard of Yendor (twice)
a mastodon
3 purple worms
an erinys
120 gnomes
42 grid bugs

it will line up the monster type names, yielding

    Juiblex
the Wizard of Yendor (twice)
  a mastodon
  3 purple worms
 an erinys
120 gnomes
 42 grid bugs

For short lists, the original looked ok (maybe even better...), but
for long lists at the end of a long game, aligning the names looks
better and is easier to read than left justifying everything.
2016-04-29 01:48:52 -07:00
PatR
b3b4953020 'sortloot' revamp
Change the sortloot option to use qsort() instead of naive insertion
sort.  After sorting, it reorders the linked list into the sorted
order, so might have some subtle change(s) in behavior since that
wasn't done before.

pickup.c includes some formatting cleanup.

modified:
  include/extern.h, hack.h, obj.h
  src/do.c, do_wear.c, end.c, invent.c, pickup.c
2016-03-13 16:23:38 -07:00
PatR
ca3ccdd5ab lint cleanup to pacify gcc
I upgraded from OSX 10.5.8 via 10.6.3 to 10.6.8, plus Xcode to whatever
version was on the 10.6 dvd, and ended up with a more recent version of
gcc that is configured to use 64 bit longs and 64 bit pointers (by
default; presumably that can be changed if necessary).  It triggered
several warnings about converting int to pointer of different size or
vice versa even when explicit casts were in use, and a couple of other
things.
2016-02-03 23:39:24 -08:00
PatR
68b7693d98 crash fix
After the recent shopkeeper fix, I wanted to find out what happens if
you turn to stone in the spot inside the shop door.  It didn't go too
well--a change of mine from three weeks ago caused a crash due to
passing a null pointer to strcmp().  Death from being turned to stone
or from starvation when there was no while-helpless reason (probably
not possible for starving) triggered it.  This fixes that.

As far as the test goes, the shopkeeper takes your inventory and moves
it all the way into the shop, and a statue of the petrified hero is
left without contents in the spot in front of the door.  That shk was
awfully quick....

Post-3.6.0 bug, so no fixes entry.
2016-01-29 17:14:42 -08:00
PatR
9fae621778 fix #H4181 - strange death messages
"Petrified by <foo>, while getting stoned." -- multi_reason "while
getting stoned" explains why no last-second recovery could be made,
but doesn't explain how the petrification happened, so suppress it.

"Died of starvation, while fainted from lack of food." -- nethack
does not display this; presumeably the IRC death notices for NAO are
generated from xlogfile entries.  Change 'while fainted from lack of
food' to 'while fainted' at time of death if reason for death is
starvation.  The longer version is accurate but sounds fairly silly.

When starvation is set in motion, set it up before checking whether
the initial faint triggers falling on a wielded cockatrice corpse, so
that fainting isn't applied after recovery in case of life-saving.
2016-01-07 01:53:06 -08:00
PatR
4604777c16 suppression of while-helpless for tombstone
Avoid the possibility of a user-supplied name interfering with killer
reason truncation.  A monster named ", while" that killed the hero
would result in "killed by <mon-type> called " being displayed on the
tombstone after stripping while-helpless reason to shorten the text.
2015-12-18 01:59:36 -08:00
PatR
8f96d4b9ef fix bz157, #H4075 - 'realtime' had strange units
A couple of reports asked what weird unit of measure was used for the
'realtime' value in xlogfile.  It was just seconds, but was accumulating
incorrectly whenever game-state got saved for the checkpoint option.
Now it really is seconds, or rather whatever unit you get for the delta
of two time_t values; usually seconds but not guaranteed to be that.
2015-12-15 17:59:42 -08:00
Pasi Kallinen
943cc6057c More tiny formatting fixes, move function names to start of line 2015-11-25 10:15:41 +02:00
PatR
3edfcffccc SYSCF WIZARDS
Preformat SYSCF entry 'WIZARDS' so that it can be displayed during panic
feedback without allocating memory for the formatted list at that time.
It also gets displayed for help's "support information" ('?k').

For panic(), push "it may be possible to rebuild" to a second line since
the formatted usernames might make the line long.
2015-11-22 17:23:11 -08:00
PatR
b30fce4f88 flag panic() and terminate() as "no return"
Mark panic() as never returning so that code analysis might be able
to do a smarter job.  It required splitting done() into two routines
since the first part really can return (but not if PANICKED was the
reason it got called).  done() is now much shorter and ends with a
call to new really_done(), and panic() skips done()'s might-return
part by calling really_done() directly.

Noticed in passing:  the "report error to <list of SYSCF WIZARDS>"
code calls a routine which uses alloc(), which won't work very well
if the reason for panic was because malloc() ran out of memory.
2015-11-22 08:33:42 -08:00
Pasi Kallinen
7063488621 Pacify some clang compile warnings 2015-11-21 23:40:06 +02:00
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
Pasi Kallinen
dc09a991fe Fix some warnings from clang's static code analyzer 2015-11-18 22:54:28 +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
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
866b5caee0 Text tombstone overflow and helpless
Betatesters noticed the death message could overflow the text tombstone,
because the helpless reason was also shown there.

So don't show the helpless at all in the tombstone.  The helpless is
still put in the record, logfile, and as a separate while-field in xlogfile.
2015-06-21 17:57:17 +03:00
PatR
710a8fb0e2 rising from the dead during panic
Prevent rising from the dead as a giant ant if the game panics during
initialization.
2015-06-15 15:47:47 -07:00
nhmall
f2daf4f7f8 punctuation in failed messages 2015-06-11 21:11:41 -04:00
Sean Hunt
1c081b1647 Remove stale version control lines. 2015-05-25 09:21:31 +09:00