Commit Graph

12377 Commits

Author SHA1 Message Date
nhmall
ba64bb8ce2 out-of-bounds access in farlook pr592
https://github.com/NetHack/NetHack/pull/592 comment states:
"In commit db68395, most of the instances of xdir and ydir here were
changed to u.dx and u.dy, but not all of them. The remaining ones are
out-of-bounds on xdir and ydir, because i is always set to 12 from an
earlier loop and is no longer involved in handling user input. They
should be u.dx and u.dy like the rest."
2021-10-16 10:16:13 -04:00
nhmall
bb67bec0fd Merge branch 'fix-asan-issues' of https://github.com/copperwater/NetHack into pr592 2021-10-16 10:14:42 -04:00
PatR
d9bbad8e6e fix github issue #606 - shop wall repair
triggering an impossible warning about "wall_angle: unknown" due
to the known conflict between door state and wall info which both
overlay the flags field for map locations.

Reported and diagnosed by vultur-cadens:  if a shop's wall was dug
open, followed by use of locking magic to plug the gap with a door,
and then unlocking that door, the D_CLOSED door flag was left as
invalid wall_info when shop damage was repaired.  Map re-display
complained.  Leaving the door locked or opening it after unlocking
did not result in any complaint because the values for those door
states do not conflict with wall angle values.

The problem was reproducible and is now fixed by adding an extra
field to the shop damage structure.  A similar change has been
made to the vault guard's 'fake corridor' structure but I have no
test case for that so don't know whether it makes any difference.
At least it doesn't seem to have broken anything.

Existing save and bones files are invalidated by the fixes.

Fixes #606
2021-10-15 15:43:23 -07:00
nhmall
53bb04d9ad fixes entry for consoletty.c fix
Closes #604
2021-10-12 21:23:29 -04:00
nhmall
92f54e600d consoletty.c preprocessor directives
The preprocessing was a little messed up if VIRTUAL_TERMINAL_SEQUENCES was not
defined.
2021-10-12 21:15:54 -04:00
PatR
5350f049b2 remove unused globals: save_cm, was_waterlevel
From entrez.  Since restoring was removed separately it was easier
to edit the files manually than to use his diff.
2021-10-12 11:41:56 -07:00
nhw_cron
9c667501b6 This is cron-daily v1-Jan-20-2020. guidebook updated: doc/Guidebook.txt 2021-10-11 20:08:57 -04:00
nhmall
1e78c296f3 remove a warning with gcc on Windows
"braces around scalar initializer"
2021-10-11 18:14:09 -04:00
PatR
8ec322b87e last? boulder change - Guidebook update
Describe the new feature of m<dir> making it feasible to move to a
boulder'd spot without pushing.  Giving specific information among
vague descriptions is awkward....

While in there, move a handful of sentences to separate lines as per
the 'roff guidelines.  I did the same for Guidebook.tex even though
it's not needed there, to try to keep things parallel.
2021-10-11 14:50:29 -07:00
nhmall
16c2df511d attempt to fix mingw build
This was detected by one of the CI builds.
2021-10-11 15:08:05 -04:00
nhmall
013f84f692 trailing blanks 2021-10-11 13:53:55 -04:00
nhmall
7405d1fa05 fix misaligned potion colors
Misaligned potion colors due to lack of reset_glyphmap() following obj shuffle.

This issue only impacted a new game
2021-10-11 13:36:10 -04:00
nhmall
e5f7ba9fe5 Windows virtual terminal sequences
Microsoft has been making a recommendation that programs should switch
from using the classic low-level console API calls to virtual terminal
sequences for a couple of years.

References:
"Our recommendation is to replace the classic Windows Console API with virtual
terminal sequences. This article will outline the difference between the two
and discuss the reasons for our recommendation."
From:
Classic Console APIs versus Virtual Terminal Sequences
https://docs.microsoft.com/en-us/windows/console/classic-vs-vt

The online documentation for WriteConsoleOutputCharacter() and
WriteConsoleOutputAttribute() have this disclaimer on them:
"This document describes console platform functionality that is no longer a
part of our ecosystem roadmap. We do not recommend using this content in new
products, but we will continue to support existing usages for the indefinite
future. Our preferred modern solution focuses on virtual terminal sequences
for maximum compatibility in cross-platform scenarios. You can find more
information about this design decision in our classic console vs. virtual
terminal document."

Since NetHack started out as a terminal program, before there was a
Windows "classic" console API introduced with Windows NT, it seemed only
fitting that the Windows console port should evolve in the virtual terminal
direction.

This is a first stab at it. The performance won't be as instantaneous as
the low-level console API's. That's likely partly because of this consoletty.c
initial implementation, but it may also partly be because under the hood in
the OS, there's recognitions/translations/conversions going on. Microsoft
states it will continue to evolve the Windows Terminal and console, and
hopefully it will improve. Hopefully it isn't too slow to play. It still
attempts to take advantage of the back buffer stuff that Barton House
introduced to minimize screen updates. At this point, it can still be
recompiled without the virtual terminal support by defining NO_VT when
compiling consoletty.c, or by commenting out the definition of
VIRTUAL_TERMINAL_SEQUENCES at the top of sys/windows/consoletty.c

That's the informational news, and the negative news out of the way.

There's some good news too. Because the virtual terminal sequences
support include 24-bit color support, the Windows console under virtual
terminal sequence can provide a more pleasant set of colors to the NetHack
console interface. To that end, some color changes have been implemented
in consoletty.c now.

It makes the console port ready to accept and display 24-bit color from
the NetHack core, if that should ever happen, as well.

As usual with a first implementation, there may be some bugs. Reports
are welcome.
2021-10-11 09:48:48 -04:00
PatR
e42488ca10 and even more boulders...
Revise the m<dir>-toward-boulder handling to let a hero who would be
able to squeese into the boulder's spot if it was blocked from being
pushed to do the squeeze without any pushing.

Unlike the previous changes, this might have an impact on play.  It
allows squeezing under then stepping past an unblocked boulder that's
in a corridor in order to be able to push it back the other direction
where maybe there's more room to maneuver it out of the way.
2021-10-10 18:05:11 -07:00
PatR
fc00ced6f4 yet more boulders: allow m<dir> to not push them
Allow a hero polymorphed into a giant to move to a boulder's spot
via m<dir> no-pickup move, instead of having to push it until the
way is blocked by something and then having push failure move hero
to the spot.

Also change m<dir> when not a giant to no longer push the boulder.
No time will elapse when not moving unless hero who didn't know
that there was a boulder there learns that one is.  Since no actual
push attempt gets performed, player doesn't learn whether there is
anything beyond the boulder that inhibits it from being pushed.
2021-10-10 15:02:21 -07:00
PatR
b29168aa43 fix the new boulder->next_boulder sanity check 2021-10-10 13:14:01 -07:00
PatR
708c2a4346 boulder sanity checking
Three new checks:
 1) boulders are expected to be at the top of their piles, or when
    not on top, only other boulders are above them;
 2) boulders shouldn't be located at water or lava spots;
 3) verify that boulders don't have their 'next_boulder' flag still
    set at times when sanity checks take place; that's only valid
    during moverock() [plus its calls to boulder_hits_pool()].
2021-10-10 12:59:17 -07:00
PatR
b700e3abf9 "new boulder" fix
The default value for obj->corpsenm is NON_PM which is -1, so the
default value of boulder->next_boulder was non-zero instead of 0
as expected.  Because of that, boulder object formatting by xname()
was yielding "next boulder" when plain "boulder" was intended.
Until the boulder or one in a pile above it got pushed, then it
was explicitly reset.
2021-10-10 12:39:27 -07:00
PatR
0e5b6ed519 better boulder pushing feedback
When you push a pile of boulders, describe the second and remainder
as "the next boulder" rather than just "the boulder".  Matters most
when pushing into water or lava and you keep on pushing when the
first one or more sink into the pool or plug it, but also matters
for an ordinary push where the top-most one moves successfully and
then blocks the continuation attempt to push the second one.  It was
somewhat confusing when all the messages said "the boulder" whether
they were referring to the same boulder or different ones.

Multiple pushes on the same move has always been a bit odd, but this
doesn't change that, just the feedback it generates.
2021-10-09 10:54:47 -07:00
nhmall
6eecfbc28b fix an expanded-glyphs regression
Restore behavior that was unintentionally overlooked during
the expansion of glyphs earlier this year.
2021-10-09 11:34:37 -04:00
PatR
51b8ded681 simpleonames() fix
Some code from about a month back changed xname() and doname() to
only use a single 'obuf[]'.  That was to make sure that perm_invent
update also used at most one obuf.  They use some slightly convoluted
code when they called other routines which returned an obuf because
only the most recently allocated one can be explicitly released for
re-use.  That works, so I did the same for simpleonames() and
thesimpleoname() and for some reason neglected the convolution for
simpleonames().

For the case where plural was needed, it needs two obufs and tried
to release the first, which is a no-op.  So if it was used in a loop
like display_pickinv() uses doname(), it could have cycled through
all the obufs and clobbered one a caller was expecting to remember.
I'm not aware of any instances of this being an actual problem, just
happened to notice that simpleonames() was different from other
similar routines.
2021-10-08 13:53:21 -07:00
PatR
536a5acd20 fixes37.0 entry typo 2021-10-08 13:24:54 -07:00
PatR
8c6bb81929 more DEF_PAGER
For Unix, add internal vs external pager choice to #version.
Others always use internal pagination so don't need to see that.

Also remove obsolete "command completion" option.  I don't know
when it became unconditional but that was long enough ago to be
absent from the git log and from second cvs log included in that.

And streamline the RNG seed stuff a bit.
2021-10-07 10:09:44 -07:00
PatR
a0e58fe323 fix confused remove curse bug
Reported directly to devteam, player observed that objects on the
floor had their bless/curse state change when reading a blessed
scroll of remove curse while confused.  Message feedback mentioned
a silver saber being dropped.  I didn't attempt to view the ttyrec
playbacks; what I'm sure happened was that the saber was secondary
weapon for dual wielding and had been uncursed; the confused remove
curse effect cursed it, which in turn caused it to be dropped.  The
saber's 'next object' pointer became the [previous] top of the pile
at that spot and further object traversal intended to process the
rest of hero's inventory ended up processing floor objects there
instead.

This bug has been present for over 20 years (since 3.3.0 came out
in late 1999, when dual wielding was introduced and cursing of the
secondary weapon forced it to be dropped since making it become
welded was deemed to be too complicated) and never been reported.
Most likely players keep secondary weapons blessed so the scroll
effect doesn't touch them and simple object traversal sticks with
inventory.  Or items at the spot have unknown BUC state so having
them be affected wouldn't be particularly noticeable.
2021-10-06 13:46:27 -07:00
PatR
01cb9d312f unused variable: g.restoring
Get rid of the last reference to 'g.restoring' (which managed to
unintentionally survive the change to 'g.program_state.restoring').

Also have suppress_map_output() check 'g.program_state.saving' and
switch the couple of checks against that flag to use the function.
2021-10-05 01:57:27 -07:00
PatR
ccfddd47de fix Unix build with DEF_PAGER defined
Eliminate a couple of compile warnings produced when DEF_PAGER is
defined:  unixmain.c: g.catmore=DEF_PAGER; wintty.c: fd=open(...).

Override its use when DLB is also defined since an external pager
could access 'license' but not 'history', 'opthelp', &c when those
are in the dlb container file.

In the commented out value for DEF_PAGER, show a viable value for
the default configuration these days.
2021-10-05 01:11:24 -07:00
PatR
013f3770d1 hints/macOS.2020 - remote duplicate -DDLB 2021-10-04 19:43:04 -07:00
PatR
c3e5aaf8ba displacer monster vs long worm
Reported directly to devteam:  monster vs monster location swapping
didn't handle single-segment long worms properly.  Multi-segment
worms are disallowed but a worm with no visible segments (which
actually has 1 segment at the head's location) are allowed and the
segment wasn't being moved with the core monster and could trigger
warnings if sanity checking is enabled.  The next time that the
worm moved, it got itself back in synch.

I couldn't reproduce the warning but mdisplacem() clearly assumed
that a long worm reporting 0 segments didn't have any so wasn't
attempting to handle the hidden one.
2021-10-03 14:15:02 -07:00
nhmall
5a652b0478 comment bit needed updating for a while 2021-10-03 09:43:21 -04:00
PatR
b1d76a772f fix github issue #596 - wishing exploit
for helm of opposite alignment.

Discovered and described by vultur-cadens.

The #adjust command can be used to split an object stack and if the
shop price of the two halves are different, the new stack will have
its obj->o_id modified to make the prices the same.  That could be
used to tip off the player as to what the low bits of the next o_id
will be.  Since no time passes, no intervening activity such as
random creation of a new monster can take place, so the player could
wish for something that depends on o_id with some degree of control.
Matters mainly for helms of opposite alignment intended to be used
by neutral characters since the player isn't supposed to be able to
control that.  (Other items like T-shirt slogan text and candy bar
wrapper text had a similar issue but controlling those wouldn't have
had any tangible difference on play.)

The issue writeup suggested allowing the player to specify a helm's
alignment during a wish.  That would defeat the purpose of having
o_id affect the helm's behavior in an arbitrary but repeatable way
so is rejected.

I implemented this fix before seeing a followup comment that suggests
using a more sophisticated decision than 'obj->o_id % N' for the
arbitrary effect.  This just increments context.ident for the next
obj->o_id or mon->m_id by 1 or 2 instead of always by 1 and should
be adequate.  It also has the side-effect that two consecutive wishes
for helm of opposite alignment won't necessary give one for each of
the two possible 'polarities', even with no intervening activity by
monsters, reinforcing the lack of player control.

Minor bonus fix:  it moves the incrementing check for wrap-to-0 into
a single place instead of replicating that half a dozen times.  Ones
that should have been there for shop billing and for objects loaded
from bones files were missing.

Fixes #596
2021-09-30 13:08:27 -07:00
nhmall
6073f5a553 more fixes entry tinkering for consistency 2021-09-30 14:37:37 -04:00
nhmall
6e9b1a2f06 correct a fixes37.0 entry 2021-09-30 14:26:10 -04:00
PatR
017a8687e0 fix github issue #594 - special attacks
by the Riders that only damage the hero, not other monsters.

Noticed and diagnosed by vultur-cadens.  Attacks dishing out the
damage type AD_DETH (Death), AD_FAMN (Famine), AD_PEST (Pestilence),
and also AD_DISE (Demogorgon, Juiblex, Scorpius) did 0 damage if
inflicted against monsters.  That made Death harmless to other
monsters.  The others have additional attacks (in the two Rider's
cases, only if both instances of their special attack hit on the
same move so that the second one is converted into a stun attack)
and could manage to kill other monsters.

The uhitm case can't happen.  I suspect that the mhitm case was
originally intentionally omitted as something which won't happen,
but that's just a guess.

Fixes #594
2021-09-30 05:26:04 -07:00
nhmall
036169a3b1 bmp file Y dimension 2021-09-28 12:21:49 -04:00
PatR
e52f38b3a3 Guidebook make sequencing
Be able to run 'make Guidebook{|.txt|.ps}' in the doc subdirectory
without requring a full install first.

makedefs is no longer one of the first things built when building
nethack, and even if it was, nobody should have to rebuild all of
nethack after 'make spotless' when they just want to create one
or more of the formatted Guidebooks.  The 'roff versions (.ps and
also .txt) use makedefs as a filter by default, so wouldn't build
if it wasn't there.

Have Makefile.doc build makedefs when needed.

Clean up some dependencies in Makefile.utl.

Add a couple of comments to Makefile.src.
2021-09-27 01:30:53 -07:00
nhmall
bdfd41d203 missed a couple 2021-09-26 16:12:50 -04:00
nhmall
9919bd2ed9 other.txt updates
altar tile differentiation
- contributed by Michael Meyer
2021-09-26 15:59:26 -04:00
nhmall
94ddf4329c update fixes37.0 and doc/Guidebook.txt
make format of pull request entries consistent
2021-09-26 15:48:59 -04:00
nhw_cron
756d38776d This is cron-daily v1-Jan-20-2020. guidebook updated: doc/Guidebook.txt 2021-09-26 15:47:15 -04:00
nhmall
feed225e37 Merge branch 'several-pr' into NetHack-3.7 2021-09-26 08:59:41 -04:00
nhmall
b1da4dea70 Merge branch 'supply-missing-changes' of https://github.com/argrath/NetHack into several-pr 2021-09-26 08:56:30 -04:00
nhmall
b2920ab728 Merge branch 'delete-extra-lines' of https://github.com/argrath/NetHack into several-pr 2021-09-26 08:56:08 -04:00
nhmall
d3acd8aa07 Merge branch 'ice-running' of https://github.com/copperwater/NetHack into several-pr 2021-09-26 08:54:47 -04:00
nhmall
026aec1086 Merge branch 'fix-travel' of https://github.com/entrez/NetHack into several-pr 2021-09-26 08:54:10 -04:00
copperwater
f20e99ac0a Fix out-of-bounds access of xdir and ydir in farlook
In commit db68395, most of the instances of xdir and ydir here were
changed to u.dx and u.dy, but not all of them. The remaining ones are
out-of-bounds on xdir and ydir, because i is always set to 12 from an
earlier loop and is no longer involved in handling user input. They
should be u.dx and u.dy like the rest.
2021-09-25 19:03:51 -04:00
Patric Mueller
92bff67a5d Fix compilation with TTY_TILES_ESCCODES for expanded-glyphs 2021-09-26 00:02:58 +02:00
SHIRAKATA Kentaro
96679152ef Supply missing changes
Some changes applied to Guidebook.mn were not applied to Guidebook.tex.
This commit supplies them.
2021-09-25 23:28:16 +09:00
PatR
eaaeb81a9f recalc_mapseen vs rooms
Reported and diagnosed by entrez:
recalc_mapseen() has been looking at all slots in u.urooms[] rather
than stopping at the first \0.  Since the whole array doesn't get
zeroed out when the value changes, stale room indices might follow
that first \0 and any rooms those referred to would erroneously get
flagged as having been visited by overview updates.  Wouldn't matter
for the level where the stale indices got set, since you'd have to
have been in those rooms for it to happen, but would matter once you
moved on to other levels.
2021-09-24 12:01:54 -07:00
nhmall
c760911f2e move enums in display.h ahead of macro definitions
move up the enums in display.h so that the enum values can be used
in place of mysterious magic numbers in some of the macro
definitions.
2021-09-22 21:46:30 -04:00
nhmall
47df95d8b8 remove unneeded per level flag
this is now taken care of in back_to_glyph (via altar_to_glyph)
2021-09-22 21:17:21 -04:00