nhmall [Sat, 16 Feb 2019 19:15:35 +0000 (14:15 -0500)]
NetHack Windows curses port build with Jan 2019 PDCurses update
Clear up some NetHack warnings with updated PDCurses by using
-DCHTYPE_32
..\win\curses\cursinvt.c(98): warning C4244: 'function': conversion from 'attr_t' to 'int', possible loss of data
..\win\curses\cursinvt.c(101): warning C4244: 'function': conversion from 'attr_t' to 'int', possible loss of data
..\win\curses\cursinvt.c(105): warning C4244: 'function': conversion from 'attr_t' to 'int', possible loss of data
PatR [Tue, 12 Feb 2019 23:40:05 +0000 (15:40 -0800)]
fix #H8183 - leather jacket doesn't show AC
Leather jacket doesn't take multiple turns to wear, so wearing it
wasn't calling Armor_on() and recently moved 'uarm->known = 1' didn't
get executed. Not reported yet but had the same issue: fedora and
dented pot wouldn't call Helmet_on().
PatR [Mon, 11 Feb 2019 21:39:34 +0000 (13:39 -0800)]
more #H8167 - late messages
Do late message suppression in a different fashion. Also, there are
more messages than shk taking hero's possessions and guard taking
hero's gold that need to be suppressed if regular message delivery
is no longer possible: "do not pass Go", "you arise from the grave
as a foo", "the corridor disappears", "you are encased in the rock".
Those last two are from vault handling but take place in a convoluted
manner: paygd -> mongone -> grddead -> clear_fcorr.
PatR [Mon, 11 Feb 2019 01:45:26 +0000 (17:45 -0800)]
fix #H8167 - shopkeeper message after ending game
Closing nethack's window sets 'program_state.stopprint' to inhibit
disclosure interaction, but shopkeeper claiming hero's stuff or vault
guard claiming hero's gold didn't honor that and just issued normal
pline messages. For win32, they got delivered in a popup even though
nethack's window had gone away.
Make those two end-of-game situations honor 'program_state.stopprint'.
[Fix not tested on win32...]
PatR [Sun, 10 Feb 2019 00:07:18 +0000 (16:07 -0800)]
fix #H8124 - interrupted donning gives player info
about the armor. Wearing armor sets obj->known, making its enchantment
be shown when it gets formatted, because the AC value on the status line
lets the player deduce what that is. It was being set at the beginning
of the wear operation. If the armor got stolen before it became fully
worn, the enchantment was still shown. Defer that until the end of the
operation. An attentive player can still deduce the enchantment if the
item is stolen (because its protection starts immediately) but the hero
won't learn that enchantment unless the donning completes.
This might be suboptimal but it isn't qualitatively different from
watching a pet walk/not-walk over items whose bless/curse state isn't
known or dropping unidentified items in a shop to check their price.
The player can deduce something that the hero doesn't know yet.
PatR [Fri, 8 Feb 2019 23:50:59 +0000 (15:50 -0800)]
curses: plug most memory leaks
This takes care of a lot of the leaked memory in the curses interface.
It still needs to free memory allocated for status fields when the
status window is destroyed at game end; likewise for message history
when the message window is destroyed.
PatR [Fri, 8 Feb 2019 22:54:40 +0000 (14:54 -0800)]
curses: getline vs DEL, ESC
Support <delete> (aka <rubout>) during getline(). It doesn't actually
honor the current erase_char value set up for the terminal, just
treats DEL the same as ^H. (The previous lack of support had nothing
to do with terminfo specifying ^H; the handling is hard-coded.)
tty treats escape while there's already some input as kill_char (erase
the input but get more from scratch) and returns ESC if there isn't.
curses was doing the first half but not the second, so not providing
any way to communicate "cancel" back to the core. Fix is simple.
Other getline() bug fixes:
1] there was a wprintw("%*something") which was passing the value from
strlen (type 'size_t') to the "%*" argument (type 'int'). That's
always wrong (size_t is guaranteed to be unsigned) and could be severe
(if size_t is different width than int--as on current OSX systems--
depending upon the internals of argument passing).
2] strncpy() only supplies a terminating '\0' if the input is shorter
than the number of characters specified.
A lot of reformatting is warranted but I only did the getline routine
(manually, so might have missed stuff).
PatR [Fri, 8 Feb 2019 01:10:55 +0000 (17:10 -0800)]
curses memory: 'anything identifier'
Three or four instances of one simple memory leak. Allocating a union
'anything' to pass to add_menu(), then not doing anything with it. The
value gets copied so there's no reason for the original to stick around.
PatR [Fri, 8 Feb 2019 00:48:37 +0000 (16:48 -0800)]
curses: change from malloc() to nethack's alloc()
There was no provision for malloc() potentially returning Null and it
wasn't integrated with nethack's MONITOR_HEAP. 'heaputil' shows that
the curses interface is leaking like a sieve. If some things are
actually being allocated separately and then freed from within curses,
those need to be thoroughly documented and maybe switched back to
malloc().
PatR [Fri, 8 Feb 2019 00:04:24 +0000 (16:04 -0800)]
custompline(SUPPRESS_HISTORY,...) for curses
The curses interface already has a hack to keep 'Count: 12', 'Count:
123' intermediate multi-digit counts out of its message recall history
for ^P, but it was flushing real messages when getpos()'s 'autodescribe'
reported what the cursor moved over. Overload the count hack to support
putstr(WIN_MESSAGE, ATR_NOHISTORY, text)
(which is what custompline(SUPPRESS_HISTORY, ...) eventually calls).
The conditional logic for when to create the 'count_window' was pretty
convoluted. This simplification has the same semantics but I don't
have PDCURSES to actually verify that.
PatR [Tue, 5 Feb 2019 02:40:55 +0000 (18:40 -0800)]
more message history
Noticed while investigating the issue with DECgraphics characters in
msg_window:full/combination/reverse output for tty which got fixed
by the previous commit. There was a discrepancy in DUMPLOG because
the pager code bypasses pline() in order to use putmixed(). tty
puts strings from the latter into ^P recall history (although they'll
only render correctly if nothing after the first character needs
special handling), but nothing was putting that same info into
DUMPLOG. This fix is pretty clumsy but eliminates the discrepancy.
PatR [Tue, 5 Feb 2019 02:24:17 +0000 (18:24 -0800)]
tty ^P recall for dolook/whatis feedback
Noticed while testing the history suppression: if you have DECgraphics
enabled and look at a graphics character on the map, the topline shows
x description of x
where 'x' is displayed as it appears on the map (line drawing char).
^P for msg_window:single knows about that and reproduces the effect if
you recall such a line. But msg_window:full/combination/reverse didn't
know about that and dumped it as-is into text output, ending up with a
strange 8-bit character for 'x' instead of the line drawing one.
I think other rendering schemes will be unaffected by this. It's just
duplicating what is done for msg_window:single.
PatR [Tue, 5 Feb 2019 00:46:04 +0000 (16:46 -0800)]
tty ^P message recall
Extend 'putstr(WIN_MESSAGE, attribute, string)'s attribute so that
'custompline(SUPPRESS_HISTORY, ...)' can work with ^P's message
history like DUMPLOG history, in order to keep autodescribe feedback
and intermediate prompts for multi-digit count ('Count: 12', 'Count:
123') prompts out of recall history. The old autodescribe behavior
could easily push all real messages out of the recall buffer when
moving the cursor around for getpos, and the count behavior looked
silly for a four or five digit gold count if you set the msg_window
option to 'full' or 'combination' and viewed them all at once.
Other interfaces may want to follow suit, but this doesn't force them
to make any changes. I added a hook for "urgent messages" that might
be rendered in bold or red or some such and/or override the use of
ESC at --More-- from suppressing further messages, but there aren't
any custompline(URGENT_MESSAGE, ...) calls (potentially "You die...",
for instance) to exercise it. Other people have implemented similar
feature it different ways and I'm not sure whether this one is really
the way to go since the core needs to categorize each message that it
deems to be urgent. MSG_TYPE:stop may be sufficent, although MSG_TYPE
matching can entail a lot of regexp execution overhead at run-time.
PatR [Sun, 3 Feb 2019 01:37:06 +0000 (17:37 -0800)]
fix #H7173 / github #101 - vault exit
Fixes #101
If you tell the vault guard your name, drop carried gold, wait one
turn, then pick up the gold again, the guard will move a step away
during the wait. If you teleport away, the guard will seal vault
walls and then park himself on the one-square (so far) temporary
corridor adjacent to the vault wall. Periodically he'll say "Move
along!" and the hero will hear it, regardless of location on the
level. Unless you dig a corridor to rescue him, or one or more of
the vault's walls get breached again, he will never move.
The report emphasized that you could use this to steal the vault's
gold, but it relies on being able to teleport beyond the gaurd's
reach and if you can do that, you might as well do so before the
guard comes. The stranded guard, and him saying "Move along!" when
no longer leading hero out of the vault, are more significant bugs.
Bonus fix: if the game ends and the guard seals up the vault while
the hero is in a spot that gets fixed up (vault wall or temporary
corridor) don't give the "You are encased in the rock" message if
game end was due to death rather than quit.
PatR [Sat, 2 Feb 2019 02:40:45 +0000 (18:40 -0800)]
object classes for wizard mode identify
When ^I was changed to allow picking more than one item to make
its temporary identification become persistent, group accelators got
left out. So to pick all potions, you needed to select them letter
by letter (or via '.' to select everything, then deselect non-potions
letter by letter). Now you can use '!' to select all potions.
PatR [Sat, 2 Feb 2019 02:24:23 +0000 (18:24 -0800)]
curing deafness
Make healing magic which cures blindness also cure deafness. So,
drinking non-cursed potion of healing or any extra healing or full
healing; breathing fumes from blessed potion of healing or non-cursed
potion of extra healing or any potion of full healing; prayer reward
to cure blindness as a minor trouble. (Doesn't affect unicorn horns
which already treat deafness and blindness as two distinct troubles
that are eligible to be cured.)
More of a missing feature than a bug fix, so I listed it in the new
features section of the fixes file.
Pasi Kallinen [Fri, 1 Feb 2019 16:19:00 +0000 (18:19 +0200)]
Fix making fake leash object with leashmon set
When farlooking at a leash glyph on a map, the fake object should never
have leashmon set. This happened when a mimic was on the same spot
and was mimicing a corpse or statue, due to leashmon and corpsenm
using the same field.
PatR [Thu, 31 Jan 2019 23:50:12 +0000 (15:50 -0800)]
stale lock picking context
Lock context wasn't being cleared if it was for a container and that
container got destroyed. Case discovered was forcelock() ->
breakchestlock() -> delobj() (sometimes the container is destroyed
rather than just breaking its lock) followed by #wizmakemap (replace
current level) and maybe_reset_pick() trying to check whether
xlock.box was being carried. But being interrupted, destroying the
container or dropping it down a hole to ship it to another level, then
attempting to resume picking the lock would also find a stale pointer.
PatR [Thu, 31 Jan 2019 12:22:04 +0000 (04:22 -0800)]
fix monstone() ... dealloc_obj() panic
Fuzzer feebdack. When turning a monster into a statue, monstone()
builds a linked list of mon->minvent items to put into that statue.
It doesn't use obj_extract_self() to take them off again, leaving
obj->nobj non-Null. Not noticed for the normal case where each item
gets linked into the container's contents, but triggers panic if an
item merges with something already put inside so gets removed.
nhmall [Wed, 30 Jan 2019 01:29:56 +0000 (20:29 -0500)]
fix build
../sys/unix/unixmain.c: In function ‘sys_random_seed’:
../sys/unix/unixmain.c:779:29: error: expected expression before ‘long’
fread(&seed, sizeof long, 1, fptr);
PatR [Tue, 29 Jan 2019 23:27:22 +0000 (15:27 -0800)]
last warning fix
Compiler gave four diagnostics about 'seed' being used uninitialized
if 'no_seed' were false, but two of those were alternate suggestions
for how to suppress them.
PatR [Tue, 29 Jan 2019 23:00:07 +0000 (15:00 -0800)]
warning fix
The new code provoked several warnings; this fixes one of them.
Moving the declaration of 'rolecount' would have been sufficient,
but I've gone another way.
nhmall [Tue, 29 Jan 2019 22:07:00 +0000 (17:07 -0500)]
try fix for Qt4 using a core macro
../win/Qt4/qt4inv.cpp:41:26: error: macro "obj_to_glyph" requires 2 arguments, but only 1 given
glyph=obj_to_glyph(nhobj);
^
../win/Qt4/qt4inv.cpp: In member function ‘void nethack_qt4::NetHackQtInvUsageWindow::drawWorn(QPainter&, obj*, int, int, bool)’:
../win/Qt4/qt4inv.cpp:41:8: error: ‘obj_to_glyph’ was not declared in this scope
glyph=obj_to_glyph(nhobj);
^
Alex Smith [Tue, 29 Jan 2019 03:37:08 +0000 (03:37 +0000)]
Consistently use rn2 in trap detection
It's a gameplay-affecting action (it updates the character's
memory of the map), and there's no way to spam it without using
resources, so rn2 is safe.
nhmall [Tue, 29 Jan 2019 00:43:55 +0000 (19:43 -0500)]
merge Alex's dual rng proposal with the isaac64 rng code and adjust
This is branched from Alex's hallu-rng-stability branch,
with two build corrections (detect.c, zap.c), and merged
with the isaac64 branch that we have ready to go.
Alex's dual rng is supported by setting up the array
of multiple isaac64 contexts.
I stuck with Alex's approach of passing the rng function
name around as the parameter (rng or rn2_on_display_rng)
for the new additional parameter needed for
set_random(), init_random(), reseed_random(),
and init_isaac64().
PatR [Mon, 28 Jan 2019 17:10:52 +0000 (09:10 -0800)]
fix #H8072 - failing wish segfaults
Having an artifact wish be refused uses zeroobj and code which
followed was attempting to update its weight, triggering a segfault
now that zeroobj is 'const'.
nhmall [Tue, 15 Jan 2019 01:36:50 +0000 (20:36 -0500)]
define Rand() in isaac4 config
Rand() was typically defined to random() or to rand().
gcc seems to provide a random() to link to on linux
when sys/share/random.c is linked in, but other platforms
such as Windows got an undefined refence to random()
when RANDOM wasn't defined.
The only direct use seems to be in get_rnd_txt() these
days, in rumors.c
Under the USE_ISAAC64 config, neither srandom()
nor srand() are being invoked to seed those routines,
and it really should be using isaac64 when USE_ISAAC64
is defined anyway.
Patric Mueller [Sat, 12 Jan 2019 20:36:08 +0000 (21:36 +0100)]
add file for the isaac64 random number generator
This is the version from the Comprehensive C Archive Network, licensed
under the CC0 "No Rights Reserved" Creative Common License.
http://ccodearchive.net/info/isaac.html
Patric Mueller [Fri, 11 Jan 2019 18:23:01 +0000 (19:23 +0100)]
reseed during level change to prevent deduction of rng state
For platforms that read from the system's random number generator,
reseed during level change, before the map of a new level is created and
after level creation has finished.
Alex Smith [Mon, 28 Jan 2019 04:45:26 +0000 (04:45 +0000)]
Don't advance the main RNG during hallucination
This is based on the multiple-RNGs code fron NetHack4, but using
only the parts relevant to the display RNG (and with substantial
changes, both because of post-3.4.3 changes, and because Nethack4's
display code is based on Slash'EM's rather than NetHack's).
PatR [Sun, 27 Jan 2019 23:28:31 +0000 (15:28 -0800)]
Wine Cellar tweak
User-contributed fix; bypassed the contact form so no #Hnnnn number.
On the Gnome King's Wine Cellar version of Mines' End, a couple of
wall stubs in the lower far right were diggable, unlike all other
walls on the level. One single-spot wall stub was leftmost of three
undiggable spots, wall+floor+stone. The floor spot wasn't noticeably
different from normal (not sure whether digging a pit was prohibited)
but the stone one was.
nhmall [Sun, 27 Jan 2019 16:55:23 +0000 (11:55 -0500)]
domove_core() out of domove(); assess domove_core() results
new domove_core() assessment results
potentially smudge engravings
Proceed to wipe engraving after domove_core() now, but only under
all of the following conditions:
- you can reach the floor
- preceding domove_core() move attempt was marked as
having succeeded in domove_core()
- there is actually an engraving there to impact at
your original spot, or your new spot, or both
PatR [Thu, 24 Jan 2019 23:25:50 +0000 (15:25 -0800)]
band-aid for #H4041 - build warning: has_colors()
Since no one has come up with a better fix for has_colors() being
implicitly declared, add a hack for suppressing a compiler complaint
about has_colors() on linux and/or sco unix that use sufficiently old
<curses.h>.
Report was right after release of 3.6.0 but my fix at the time broke
compile when using more recent <curses.h>.
PatR [Wed, 23 Jan 2019 02:15:49 +0000 (18:15 -0800)]
fix #H6422 - hmonas against shades
I did much of this quite some time ago, as prequisite for a different
bug report about monsters vs shades, then set it aside. It ended up
being more complicated than I anticipated.
When deciding whether various non-weapon attacks might hit a shade,
hmonas() was not checking for blessed or silver armor that should have
been applicable. It did check boots when kicking, but not gloves or
rings (when no gloves) when touching, or outermost of cloak/suit/shirt
when hugging, or helmet when head-butting. (The last one is actually
moot because nothing with a head-butt attack is able to wear a helm.)
The problem was more general than just whether attacks might hit and
hurt shades. Various undead and/or demons are also affected by blessed
and/or silver attack but weren't for non-weapon attacks by poly'd hero.
At least two unrelated bugs are fixed: a rope golem's AT_HUGS attack
gives feedback about choking but was fully effective against monsters
which fail the can_be_strangled() test. And it was possible to hug a
long worm's tail, rendering the entire worm immobile.
The report also suggested that all artifacts be able to hit shades for
full effect, but by the time shades are encountered everyone has an
artifact so that would nullify a shade's most interesting ability.
TODO: monster against hero and monster against other monster need to
have similar changes.
PatR [Tue, 22 Jan 2019 02:54:37 +0000 (18:54 -0800)]
shielding bashing
Extracted from a larger patch: the only way to get silver damage
bonus from attacking with a shield of reflection (polished silver
shield) is to throw it or to wield it. Give different feedback when
hitting something while wielding a shield (or an iron ball; it seemed
appropriate despite having nothing to due with wanting to dish out
silver damage).
PatR [Tue, 22 Jan 2019 02:49:44 +0000 (18:49 -0800)]
hmonas() simulated twoweap
Regular two-weapon requires that both weapons actually be weapons or
at least weapon-tools. Simulation of that while polymorphed allowed
any one-handed object as the primary weapon.