Commit Graph

15375 Commits

Author SHA1 Message Date
PatR
cd9f145dba fix leaving the tutorial levels
While running the tutorial, the Save command is disabled.  When the
tutorial was extended to two levels, stashing and restoring the
hero's equipment stopped working as intended if player entered the
second level.  The attempted fix for that broke re-enabling Save
even if the player left the tutorial without entering its second
level.

This seems to fix things, but I'm flailing around with barely a clue
here.  A couple of simpler attempts didn't work and I haven't figured
out why, so this is a bit more complex than what I wanted.

Reorganizing nhl_callback() isn't part of the fix, just avoids use
of some redundant code.
2023-06-23 15:19:36 -07:00
nhmall
47fc27d188 update for vmsbuild.com 2023-06-23 16:37:59 -04:00
PatR
ef534e053d basename() for util/*.c
Update dlb_main to use the revised vms_basename() for #if VMS in
case it issues a usage message.

Change recover to use similar setup, but the vms-specific bit is
commented out because I'm not sure whether the necessary routine
is being linked with it.
2023-06-23 12:10:38 -07:00
nhmall
0616a83ef8 updated build command file 2023-06-23 13:25:09 -04:00
nhmall
c891066bf1 cppregex.cpp: move NetHack includes below c++ includes
Avoid a conflict with c++ std header file on at least one platform.

Build log prior:
In file included from DKA100:[DEVEL.nethack-37.sys.share]cppregex.cpp;1:12:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/regex:768:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/stdexcept:5
1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/exception:8
7:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/cstdlib:91:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/stdlib.h:10
3:
/SYS$COMMON/VSICXX$LIB/INCLUDE/DECC$RTLDEF/stdlib.h:200:24: error: too many argu
ments provided to function-like macro invocation
    void     abort    (void);
                       ^
../INCLUDE/vmsconf.h:307:9: note: macro 'abort' defined here
#define abort() vms_abort()             /* vmsmisc.c */
        ^
2023-06-23 13:15:01 -04:00
PatR
16d0a9e4ef vms_basename fix
vms_basename() was recently changed to take a second argument to
control whether to include the suffix portion of the name but an
existing call to set up 'hname' still had only one.

More than just adding the extra argument was needed.  It returns
a static buffer so if it got called for DEBUGFILES, 'hname' would
have been clobbered.
2023-06-22 15:59:56 -07:00
PatR
643b78bc40 vms_basename fix
vms_basename() was recently changed to take a second argument to
control whether to include the suffix portion of the name (used for
DEBUGFILES) but an existing call still had only one.
2023-06-22 15:30:27 -07:00
PatR
c86595001c menustyle:full skip_inverted for u and x
Use of select-all, select-page, toggle-all, and toggle-page in the
object class selection menu for menustyle:full excluded A (auto-
select all), a (all classes), B, C, U, X (bless/curse states), and
P (recently picked up) but allowed u and x (unpaid and used-up shop
goods) to be set.  Treat u and x like the other pseudo-classes;
they have to be chosen explicitly rather than be set with . and ~.
2023-06-21 18:40:14 -07:00
PatR
1209b15bcf fix static analyzer vs alloc.c
gcc-13.1 static analyzer complains that alloc() returns long *
without guaranteeing to allocate an integral number of longs.  Fix
by rounding the requested amount up to the next long when dividing
the amount by 'sizeof (long)' yields a remainder.  Surprisingly--to
me, at least--the analyzer recognizes that this extra argument
manipulation will always produce a viable amount no matter what
alloc()'s caller passes in.

Also, the declarations for alloc() and re_alloc() in alloc.c didn't
match the ones in global.h for the MONITOR_HEAP config.  I guess
nobody has tested that since NONNULL got introduced.

A year ago the two FITSxxx routines were moved from hacklib.c to
alloc.c so that they could easily be linked into various programs
instead of being replicated in each, but the declarations for them
weren't moved from hacklib.c section in extern.h to alloc.c one.
2023-06-21 03:31:41 -07:00
PatR
e5055e5f60 unix veryold(), take II
Instead of adding extra complexity to deal with something that had
become too complicated, simplify.  Having veryold() conditionally
close the lock file made sense when the usage was just
'if (veryold()) goto gotlock;' but didn't after that became
'if (veryold() && clearoldlocks()) goto gotlock;'.  Have veryold()
always leave the file open and getlock() always close it.
2023-06-18 16:29:16 -07:00
PatR
90f9b0742e unix veryold() file handling
Fix another analyzer complaint, about potentially calling close(fd)
for a file descriptor number that has already been closed.  This time
it was right, although I think nothing bad would happen if that
occurred.

With the original code, veryold() might succeed and close the file,
then clearoldlocks() fail so skip 'goto gotlock'.  Then the already
closed file would passed to close() again.

Normal usage still works.  No testing using failure conditions has
been done.
2023-06-18 14:43:43 -07:00
PatR
97a1724f17 avoid drinksink() complaint from gcc13.1 -fanalyze
'Fix' fountain.c:598:18: warning: check of 'otmp' for NULL after
already dereferencing it [-Wanalyzer-deref-before-check]

The original code was ok.  Either the analyzer has a bug or NONNULL
in extern.h's 'extern struct obj *mkobj(int, boolean) NONNULL;' is
not expanding to the expected value.

This replacement code should be easier to comprehend and with any
luck be simpler to analyze.
2023-06-17 20:28:07 -07:00
PatR
8b9a93f797 stinking nemesis
Noticed when testing erodeproof Mitre of Holiness:  the cloud of
stinking gas released by Nalzok when he died ending up killing my pet
and my hero got blamed for that.  Don't blame--or credit--the hero for
monsters affected by the gas cloud when a dying nemesis produces such.
2023-06-17 14:15:49 -07:00
PatR
8fd8d1defa Mitre of Holiness
If the priest quest artifact Mitre of Holiness (a helm of brilliance,
so crystal helmet) is acquired via the quest (rather than by wishing)
make it start out tempered (aka crackproof|erodeproof).
2023-06-17 13:27:40 -07:00
PatR
bbba8b82d2 fix issue #1062 - monster hiding messages
Reported by Umbire:  if a statue of a hider-under was activated by
a statue trap, it would hide underneath its own statue.  Also, the
hero saw a snake hide under unseen submerged kelp.

Both of those things were exposed by new "you see <monster> hide"
message rather than caused by it.  It also led to the [re-]discovery
that an existing monster hiding under a statue that was a not-yet-
triggered trap prevented the trap from producing a monster.

This redoes yesterday's can't-hide-under-statue change:  hiders can
hide under statues again, but they can't hide under anything at trap
locations.  [Pits containing one or more objects are an exception,
although it seems silly that a hero is prevented from falling into
one by the presence of a tiny creepy-crawly hiding under a ring or
dart in there.]  So, hider-underers won't be able to interfere with
statue traps by being present at the trap location.  [Trappers and
lurkers-above probably need a similar restriction; I didn't look.
They avoid trap spots rather than get lured to such by objects.]

It also prevents newly created hider-underers from becoming hidden
as part of the their creation (except when that creation is part
of level creation) whether their creation uses up an object (statue
activation, egg hatching) or there are simply other items present.
That will prevent statue of a hider producing a monster that hides
under the activated statue (which was happening due to the sequence
create monster, transfer any statue contents to monster inventory,
destroy statue).

The can't-hide-under-statues code has been repurposed to prevent
hiding under gold pieces unless there are at least 10 (arbitrary
threshold) of those or they're in a pile with some other object(s).

Sea monsters hide in water regardless of the presence of objects.
Prevent other swimmers from hiding under objects at water locations.
Such creatures don't have gills and shouldn't be able to stay
submerged in hiding for an arbitrary length of time.  [No exception
is made for non-breathers.  The overlap between swimmers and hider-
underers is limited to small snakes, even though it is feasible for
a creature wearing an amulet of magical breathing to polymorph into
one.  Heros don't spend enough time underwater to worry about snakes
hiding under kelp or thrown junk.]

Lastly, alter the "suddenly, you notice a <monster>" message if
monster-vs-monster activity causes one you've just seen going into
hiding comes back out again without any intervening messages.  [I'm
not sure whether something similar is needed for the "Wait.  There's
something there" message in the you-vs-monster case.]

Fixes #1062
2023-06-16 21:19:43 -07:00
nhmall
5688754684 update tested versions of Visual Studio 2023-06-16 2023-06-16 07:13:55 -04:00
nhmall
fee66f2905 don't hide under statues, statue trap or not
Unlike ground clutter, statues are typically in pretty tight contact
with the ground; statue traps are sometimes proclaimed as "monsters
posing as statues".
2023-06-15 09:29:41 -04:00
PatR
1bd966f826 fix issue #1061 - dipping container into water
Issue reported by loggersviii:  dipping a container into an uncursed
potion of water mentions water getting into the container.  That
happens even when that type of potion hasn't been discovered yet.

Make POT_WATER become discovered if this occurs.  Doesn't apply when
hallucinating where a random liquid is mentioned instead of water.

Fixes #1061
2023-06-15 02:29:51 -07:00
PatR
7d052bafb0 crystal armor bit
Accidentally left out of the "breaking crystal armor" commit
e9c58c2fe4.
2023-06-14 16:14:18 -07:00
PatR
e9c58c2fe4 breaking crystal armor
Instead of a 5% chance for crystal plate mail or crystal helmet to
break each time it's subjected to breakage, switch to a 10% chance
but the damage is treated as erosion rather than break/don't-break.
'crystal foo' will need to go through four stages of damage before
breaking:  cracked crystal foo, very cracked crystal foo, thoroughly
cracked crystal foo, then gone.  Crackproof handling is included,
described as tempered crystal foo.

It mostly still applies to throwing and kicking the item.  Having
some hits trigger damage might be worthwhile but isn't implemented.

Object creation within lua code probably needs to be updated, and
when the Mitre of Holiness is created in the priest/priestess quest
it should start out as tempered (erodeproof).  Perhaps it ought to
be erodeproof regardless of where/how it's created.
2023-06-14 15:54:04 -07:00
PatR
450f060132 github issue #1060 - crystal helmet
Issue reported by vultur-cadens:  changing helm of brilliance to
crystal made it stop being classified as "hard helmet" so it gave
less protection against things falling onto the hero's head.

Change the is_metallic() tests used on helmets to new hard_helmet().
Unlike when thrown, crystal helmets don't break when objects fall
on them.

Fixes #1060
2023-06-14 06:13:11 -07:00
nhmall
0440eb5091 missing punctuation 2023-06-14 08:36:28 -04:00
PatR
fb0509a6b3 fix #3841 - steed and engulfer on same map spot
Reported five months ago, a save was performed while a mounted hero
was engulfed.  Restore issued a warning about the engulfer being
placed on top of the steed (who shouldn't have been on the map).

The report arrived at about the same time as engulfing a riding
hero was changed to force a dismount instead of engulfing both hero
and steed so nothing further was done about it.  This changes
restore to not put a steed on the map and then take it off again.
It also attempts to simplify usteed and ustuck handling during save
and restore.

Testing so far indicates that things are still working correctly.
Keep makeplural(body_part(FINGER)) crossed.

Existing save and bones files are invalidated.
2023-06-14 00:04:21 -07:00
PatR
bf47cc878e fountain and sink bookkeeping
This replaces most of commit 0ca2af4d8b
from a couple of days ago with something more robust.  That change
actually introduced redundant code that caused fountain and/or sink
count to be off instead of preventing it.

Revise set_levltyp() to update level.flags.nfountains and
level.flags.nsinks if setting the type to or from fountain or sink.
A bunch of places that were setting levl[x][y].typ directly needed
to be revised to use set_levltyp() instead.  set_levltyp() itself
hadn't been updated to handle LAVAWALL (to force such to be lit).
2023-06-12 15:07:34 -07:00
nhmall
299d49aebf another follow-up for curses_putmixed
We received a report from someone whose build was failing because
of the use of cchar_t and setcchar(). They were getting errors
even though they were using an up-to-date curses library.

Apparently, ncurses requires that _XOPEN_SOURCE_EXTENDED must be
defined before the curses header files in order for those features
to be available.

We had already updated our .370 series of hints and hints/include
files with
    -D_XOPEN_SOURCE_EXTENDED=1
but this person must have been building in some other way.

Instead of failing to build in that situation, allow the
fallback to the older, less-functional genl_putmixed() function,
but also try not to do so silently and display a message that
functionality is reduced.

The difference between the use of genl_putmixed() and
curses_putmixed() or tty_putmixed(), is that when doing
'/' farlook operations, curses_putmixed() and tty_putmixed() try to
display a character in the message window that looks exactly the same
as the one on the map, even if a symbol from a symset is being used
on the map, or when using ENHANCED_SYMBOLS.

Related note: curses_putmixed() matches the symbol and the color,
whereas tty_putmixed() (at present) does not attempt to match the
color.
2023-06-12 14:03:39 -04:00
nhmall
36ba2b9a0e fix curses build issue caused by "attr_t same as int" assumption
In file included from ../win/curses/cursmisc.c:6:
../win/curses/cursmisc.c: In function 'curses_convert_attr':
../lib/pdcursesmod/curses.h:562:32: warning: overflow in conversion from 'long long unsigned int' to 'int' changes value from '2147483648' to '-2147483648' [-Woverflow]
  562 | #define PDC_ATTRIBUTE_BIT( N)  ((chtype)1 << (N))
      |                                ^
../lib/pdcursesmod/curses.h:574:27: note: in expansion of macro 'PDC_ATTRIBUTE_BIT'
  574 |     # define A_DIM        PDC_ATTRIBUTE_BIT( PDC_CHARTEXT_BITS + 10)
      |                           ^~~~~~~~~~~~~~~~~
../win/curses/cursmisc.c:752:23: note: in expansion of macro 'A_DIM'
  752 |         curses_attr = A_DIM;
      |                       ^~~~~
2023-06-12 13:53:34 -04:00
nhmall
41c9c660e8 follow-up for curses_putmixed vs genl_putmixed 2023-06-11 09:58:36 -04:00
nhmall
37b21dd9fd bypass curses_putmixed if -DCURSES_GENL_PUTMIXED is defined 2023-06-11 09:23:07 -04:00
PatR
c4c31ae6a8 fix issue #1025 - stuck in Mines' End
Issue reported by AndrioCelos:  if you arrived at the Wine Cellar
variation of Mines' End by falling or by level teleportion instead
of via the stairs, you could end up in the treasure chamber.  If
you lacked a way to dig or to level teleport, you would be stuck.
Since most of that level is undiggable, it would likely fill up with
monsters before one that could dig would appear close enough to dig
to you and you'd eventually starve.

The initial report suggested including an escape item in the treasure
chamber.  This adds a teleport region to control hero's arrival spot
instead.  There was a suggestion fix things this way from copperwater
but I didn't notice that until I had already chosen this method....

Fixes #1025
2023-06-10 01:49:55 -07:00
PatR
0ca2af4d8b wizwish fountain and sink bookkeeping
Noticed while considering the pull request about loosening
restrictions on trap creation at furniture locations.  If you wish
for a terrain feature while on a fountain or sink, the counters
used to control whether sounds for those should be given will be
off by one.

It was incrementing the appropriate counter if you wished for a
fountain or sink, but it shouldn't do that if recreating the same
feature (perhaps to reset a magic fountain or looted sink) and it
needed to decrement when replacing either of those with some other
feature.  After the count became wrong, if all fountains or sinks
on the level were destroyed, those splashing, gurgling, &c sounds
would continue to be generated periodically.
2023-06-10 01:46:35 -07:00
PatR
9079250cfc testing for Vlad
Redo the check for whether a monster is Vlad when deciding whether to
keep it out of a bones file.  Use the new check in find_defensive()
where Vlad won't waste a turn attempting to use a wand of digging when
in his undiggable own tower.  (Failing to check for vampshifted Vlad
in the latter case wasn't actually a bug because if/when shifted,
he's unable to use items so couldn't attempt to use wand of digging.
Switch to the new check anyway.)
2023-06-09 16:09:26 -07:00
PatR
e475dca209 add 'montelecontrol' option (wizard-mode only)
Add a new debugging option, 'montelecontrol', that allows a wizard-
mode player to choose a teleporting monster's destination.  If player
picks a bad spot, confirmation will be requested.  If accepted, the
spot will be used even though the consequences could be bad; that's
on the player.  If rejected, the destination will be assigned as if
no control had been attempted rather than try again.

The fuzzer isn't allowed to override a bad spot if it tries to pick
one.  That would probably trigger a sanity_check warning; the fuzzer
causes impossible warnings to behave as if panic, so accepting a bad
spot would just be fuzzer suicide.  It is allowed to randomly set the
option and maybe--though extremely unlikely--randomly pick a valid
controlled destination.
2023-06-09 00:56:53 -07:00
PatR
62eacb11c4 bhit()'s use of bhitpos
bhit() updates the value of bhitpos as a zap or missile progresses
and it also maintains a copy in local x,y.  But it was using the
latter inconsistently and also used x,y to fetch drawbridge location,
which might retain the same value or might change one of the two
values by +1 or -1.  Use different local variables for drawbridege
handling and use x,y instead of bhitpos throughout bhit().

Also, zapping the spot in front of a closed bridge with striking or
force bolt would destroy the bridge even though the zap was just
passing over moat.  Don't destroy the bridge in that situation.
Zapping striking/force bolt across the span of an open bridege still
destroys the bridge.
2023-06-07 15:58:47 -07:00
nhmall
da08bb98e1 fix dos cross-compile attempt 2 2023-06-06 20:09:27 -04:00
nhmall
b21ef624eb fix dos cross-compile 2023-06-06 18:42:27 -04:00
nhmall
6ade366928 use pdcursesmod in CI 2023-06-06 18:22:31 -04:00
nhmall
4034ec915c curses_putmixed() initial attempt
The curses interface was using genl_putmixed() which doesn't
preserve the symbol actually used for a glyph on the display.
This is a first-attempt at implementing curses_putmixed().

On Linux you'll need to distribute the Makefiles again
    sh sys/unix/setup.sh sys/unix/hints/linux.370

On macOS, you'll need to distribute the Makefiles again
    sh sys/unix/setup.sh sys/unix/hints/macOS.370
2023-06-06 17:50:08 -04:00
PatR
a5a11c19c9 update data.base 'cat' entry
The first paragraph for cat/feline is obviously not from Lovecraft, so
insert an entry attribution line between it and the second paragraph.
2023-06-05 13:58:45 -07:00
nhmall
43951d3ad8 fixes entries for two pull requests
also update submodule/pdcursesmod again
2023-06-05 00:51:37 -04:00
nhmall
fc2104dfa2 Merge branch 'qt-tilewidth' of https://github.com/chasonr/NetHack into NetHack-3.7 2023-06-05 00:40:10 -04:00
nhmall
b41a182f05 Merge branch 'qt-utf16' of https://github.com/chasonr/NetHack into NetHack-3.7 2023-06-05 00:37:23 -04:00
Ray Chason
20fb008012 Fix memory errors in qt_tilewidth and qt_tileheight
* qt_tilewidth and qt_tileheight are allocated with alloc() and need
  to be freed with free().
* Don't use them after they're freed. Instead, retrieve the size from
  the glyphs object.
2023-06-04 22:17:00 -04:00
PatR
7e4be52a6c fix issue #1046 - unseen monster reading scroll
Reported by copperwater "on behalf of Maud":  when hero hears an
unseen monster read a not-yet-discovered scroll of create monster
and doesn't see any new monster appear, the player is given a chance
to call the scroll something.  When hearing an unseen monster read
a not-yet-discovered scroll of teleportation, the label is revealed
but no such 'call it' opportunity is offered, so the player could
deduce which of the two scroll types it was for either case.

Provide an opportunity to supply a 'called' name for scrolls of
teleportation when heard being read, same as with create monster.
Surprisingly complicated to achieve.

Eliminated a couple of goto's in the process.

Fixes #1046
2023-06-04 16:22:38 -07:00
Ray Chason
199a76eaaa Fix compile on Qt 4 2023-06-04 18:05:09 -04:00
Ray Chason
f78620efd7 Qt: Convert to UTF-16 2023-06-04 17:19:45 -04:00
nhmall
22d79e245d submodule update for pdcursesmod 2023-06-04 10:02:59 -04:00
PatR
ee27ec97d1 tutorial tweaks
Replace tests against tutorial_dnum with 'In_tutorial()' predicate.

Give a message when entering the tutorial (via level change mechanism).

Likewise, give a message when resuming regular play.

If player uses #quit or ^C in the tutorial, ask whether to cut the
tutorial short and resume regular play; skip "Really quit?" if the
answer is yes.  Behavior is a bit odd for ^C + yes; it just sits there
until player types something.
2023-06-04 00:22:14 -07:00
PatR
2bbfed2183 fix github issue #1046 - tutorial anomalies
Reported by Noisytoot:  going from level tut-1 to tut-2 returned the
hero's starting equipment too soon, and exiting the tutorial from
tut-2 let the hero keep any equipment acquired within the tutorial.

Entering and leaving the tutorial was being handled by lua code in
the level description of tut-1 and adding a second level messed that
up.  I didn't see any way of handing that with level-specific lua
code so I made it become the core's responsibility.  gotolevel()
knows when the hero is moving from one dungeon branch to another so
it can recognize entry to or exit from the tutorial easily.

While fixing this, prevent #invoke of the Eye of the Aethiopica from
offering the tutorial as a candidate destination (was feasible if it
had been entered at start of game).

Not fixed:  levels visited in the tutorial become part of #overview.

Show location as "Tutorial:1" instead of "Dlvl:1" on status lines.
Only tested with tty; some interfaces handle location themselves and
may need their own fixup for this.

Fixes #1046
2023-06-03 16:39:12 -07:00
PatR
4e32364313 fix #K3934 - curses menu bug when entering count
Entering a multi-digit count when selecting from a menu in the curses
interface causes the menu to disappear.  Report was about putting a
large subset of an object stack into a container but the bug affected
all menus that accepted counts.

curses_get_count() was changed to call core's get_count() quite a
while back.  get_count() calls mark_synch() when more that one digit
is typed or when backspace to remove the first digit occurs.
curses_mark_synch() had been a no-op but more recently it was changed
to try to make sure that the screen was up to date.  But it did that
by refreshing the persistent windows, making any temporary popup menu
or text window become hidden.  Also, the count-in-progress is being
sent to the message window with the no-history flag, so refreshing
the message window removed that too.

Switch curses_mark_synch() to use the basic screen refresh call that
doesn't do anything window-specific.  This also changes menu count
handling to have get_count() echo the number starting with the first
digit instead of waiting until the second.

If anything in the menu makes it be very wide it can cover up the
message window and any count being echoed there won't be visible.
I'm not going to try to figure out how to deal with that; it isn't
all that different from the old single-digit/unseen-count behavior.
2023-06-02 11:42:18 -07:00
nhmall
d74e84fb05 warning suppression
files.c: In function 'do_write_config_file':
files.c:2146:66: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
 2146 |             pline("An error occurred, wrote only partial data (%lu/%lu).",
      |                                                                ~~^
      |                                                                  |
      |                                                                  long unsigned int
      |                                                                %u
 2147 |                   wrote, len);
      |                   ~~~~~
      |                   |
      |                   size_t {aka unsigned int}
files.c:2146:70: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
 2146 |             pline("An error occurred, wrote only partial data (%lu/%lu).",
      |                                                                    ~~^
      |                                                                      |
      |                                                                      long unsigned int
      |                                                                    %u
 2147 |                   wrote, len);
      |                          ~~~
      |                          |
      |                          size_t {aka unsigned int}
2023-05-31 22:17:07 -04:00