Commit Graph

18207 Commits

Author SHA1 Message Date
Alex Smith
77ac6e51d5 Remove stray "static"
This is a globally-visible function, so it shouldn't be marked as
static.
2025-11-30 14:25:10 +00:00
Alex Smith
656f58b099 A basic version of starting character rerolling
This adds a "reroll" option that lets players reroll their
character's attributes and starting inventory. Although I generally
think doing this makes the game worse, a) some players are going to
do it regardless and b) if a player is going for a challenge game,
rather than to win, it may be required. So in the absence of an
option like this, players repeatedly start and quit games instead,
creating a large number of junk logfile entries and generally
causing problems for other players on the same shared machine
(because repeatedly reloading the game is very CPU-intensive).

This should in theory be windowport-agnostic (although in practice
it may not be). Tested on tty, X11 and curses; on tty and X11 it
works fine (although X11 treats the change in attributes as
something that needs a status highlight), on curses it is slightly
jankier in terms of what other windows are drawn in the background
(but still plays correctly and I suspect this is a pre-existing
bug).

To form a complete implementation, we will need to consider the
following:

- Should there be a delay on a) starting the game and/or b)
  rerolling? If so, what should it be (maybe configurable via
  sysconf?)

- Should we take more steps to discourage players from rerolling?
  It would be bad if players see the option exists and turn it on
  just because it exists, or (worse) treat it as condoning the
  particular style of play.

- Should we take steps to detect that players are rerolling
  manually and a) tell them to use the option instead, b) tell them
  that this is not an intended way to play (and may make the game
  less enjoyable and/or prevent them getting the practice they need
  to eventually win)?

Breaks save and bones files.
2025-11-30 06:49:14 +00:00
Alex Smith
e428046ffa Restructure u_init to allow for inventory rerolling
This doesn't implement inventory rerolling, just adds the
infrastructure: it's now possible to call u_init_inventory_attrs
multiple times and the starting inventory/attributes replace those
from the previous call rather than compounding.
2025-11-30 04:52:13 +00:00
Alex Smith
d41cea8286 Make the inventory-initialisation arrays constants
This is helpful for if we ever allow playing multiple games in the
same session: because the arrays are not modified, they can now be
used more than once.
2025-11-30 02:59:23 +00:00
PatR
94e5f7b861 part of issue #1463: // vs lootabc
Issue reported by ashleyharvey in a comment to issue #1463:  with the
'lootabc' option set, using the '/' command wouldn't accept a second
slash to look at things on the map (nor a question mark to type in
text to look up).

Not a bug since '//' is not documented as the way to look at the map
and '/a' works for lootabc, but '//' is useful so add support for it.

The '/' menu already uses 'y' and 'n' as unshown synonyms for looking
at the map and for looking up words.  Those now only work for the
'!lootabc' setting since lootabc can't assign multiple group
accelerators to the relevant choices.  Many of the other !lootabc
choice letters now work as unshown synonyms for lootabc choices, but
not all.  Feeding 'i' and 'e' to the menu as group accelerators would
interfere with using them as ordinary abc choices (at least for tty).
2025-11-28 15:13:01 -08:00
Alex Smith
b08fbef739 Followup to erinyes changes / offering while impaired
The important part of the "don't offer while impaired" change was to
prevent offering while confused.  However, it was also extended to
other status conditions: stunning seems fine, but hallucination was
problematic (both because it makes a large number of messages
inaccessible, and because hallucination is more of a long-term status
effect than the other two and players may sometimes choose to play
with it for a large portion of the game).  So make the change trigger
only on stunning and confusion, not hallucination.

This also updates the changelog for the change, because while
connected to the erinys changes, it's technically separate and is
relevant even in games where erinyes are never summoned.
2025-11-27 23:14:17 +00:00
Alex Smith
4d55e1de79 Make saving grace also work against repeated damage sources
For example, being hit by the bounce of a wand of fire means that
the main character could take damage twice in a turn, which would
kill even through saving grace; and scrolls and potions could burn
up after that and finish off the last HP, even if the wand only hit
once. This commit changes it to track all damage done during the
turn, and prevent HP dropping below 1 from damage until the next
player action or the next turn boundary, whichever comes first.
2025-11-26 05:45:45 +00:00
Alex Smith
6eb2eb7df7 Accurate dknown when writing scrolls while blind
If you write the scroll by description, you obviously know what the
label is because you specified the label (even if you didn't know
what the scroll was). When writing an unidentified scroll by type,
though, and getting lucky, you don't necessarily know the label of
the resulting scroll.
2025-11-25 23:01:46 +00:00
Alex Smith
8c29b20010 Accurately track which items have been discovered, even if not #named
This fixes a couple of bugs: a long-standing bug in which writing a
scroll by label could fail even if you've already seen a scroll with
that label (due to the game not tracking whether or not you've seen a
scroll if it doesn't have a name); and a somewhat newer bug in which
spellbooks auto-identified by Wizard knowledge were marked as having
been encountered (rather than as known but not encountered).

Breaks save file compatibility, but not bones files.
2025-11-25 22:42:38 +00:00
Alex Smith
10a5e67478 Some types of shopkeeper start with a scroll of charging
This is partially for the pun, and partially because the "wish for
scrolls of charging to identify them" strategy has been nerfed in
previous commits and this offers an opportunity to discover what
scrolls of charging are without randomly encountering one.
2025-11-25 22:19:24 +00:00
nhmall
53247ec474 Makefile.nmake update 2025-11-24 19:27:59 -05:00
PatR
7b5d7d7ae6 fix issue #1462 - objects embedded in trees
Issue reported by chappg:  on arboreal levels, when an object was
located at a stone location treated as a tree location, examining
the object would report it as embedded in stone.

The Ranger quest has arboreal levels where STONE becomes TREE, and
items that would become embedded in stone will be in trees instead.
(Sometimes kicking a tree would drop fruit onto an adjacent tree,
effectively embedding it.  For testing, it's easier just to poly
into a xorn, walk onto the tree spot, and drop something.)  The item
description code for farlook and quicklook wasn't checking for that.

The fix also corrects another bug:  an item located at a normal tree
location would just be described as itself with no mention of the
tree at all.  Attempting to walk onto it would report the terrain
and not let you move there (assuming not in xorn form), like trying
to walk into a wall.

Fixes #1462
2025-11-24 12:37:08 -08:00
nhmall
88256d895a update CHKSUMS to add entry for current Lua 5.4.8 2025-11-24 08:54:32 -05:00
nhmall
9e08bf8159 submodules update for pdcurses 2025-11-24 08:45:45 -05:00
Alex Smith
fce66245ca Don't attempt to cache encumber_msg result
There was only one point in the code at which this caching was
being done, and it was incorrect: it's possible for the result of
near_capacity to change during a monster turn because monster
actions can change either inventory weight or carry capacity.

The bug was particularly relevant in cases where a character
polymorphed into a slow weak monster gets attacked by a monster
that moves at normal speed: due to the polyform being slow, the
normal-speed monster gets in a lot of attacks and causes a
rehumanization, but due to the polyform being weak, it was
burdened at the start of the monster turn, and so when that
penalty is (due to the bug) applied to the next turn it can
mean that the character misses the next turn too, and may end up
dying as a result.
2025-11-24 02:07:23 +00:00
nhmall
ae516ddc67 follow-up: reverse one warning-related change 2025-11-23 09:49:49 -05:00
nhmall
b3db46fd71 clear up some warnings in win/win32/NetHackW.c 2025-11-23 09:40:39 -05:00
nhmall
0faa3a70cc clear up some warnings in sys/windows/consoletty.c 2025-11-23 09:28:38 -05:00
nhmall
f78e0d0caf MSYS CLANGARM64 bit 2025-11-22 10:39:37 -05:00
nhmall
113607823d Windows warning bit in windsys.c
windows/windsys.c:263:15: warning: format string is not a string literal
      (potentially insecure) [-Wformat-security]
  263 |         msmsg(buf);
      |               ^~~
../sys/windows/windsys.c:263:15: note: treat the string as an argument to avoid this
  263 |         msmsg(buf);
      |               ^
      |               "%s",
../sys/windows/windsys.c:267:20: warning: format string is not a string literal
      (potentially insecure) [-Wformat-security]
  267 |         raw_printf(buf);
      |                    ^~~
2025-11-22 10:34:45 -05:00
PatR
93f8e5b3b3 fix #S14702 - travel to covered vibrating square
Targeting '~' when vibrating square has been discovered would report
"Can't find dungeon feature '~'" if it was covered by an object or a
monster.

That's normal behavior for a trap but the vibrating square is only
one of those for display purposes.
2025-11-20 15:02:54 -08:00
PatR
6466b47fc1 miscellaneous formatting of zap.c
Just to clear zap.c modifications out of my working directory.
2025-11-20 14:54:57 -08:00
nhmall
69886bd3d1 typo fix 2025-11-20 14:32:23 -05:00
nhmall
57ccb6208e another documentation update build-vs.txt 2025-11-20 14:28:59 -05:00
nhmall
edc04fbf77 documentation update build-vs.txt 2025-11-20 14:15:00 -05:00
nhmall
7e7f393aef update tested versions of Visual Studio 2025-11-20 2025-11-20 10:45:35 -05:00
nhmall
e3a00c2ce3 roll back changes to 2 files; issue in CI 2025-11-18 20:36:15 -05:00
nhmall
be10b30914 more Visual Studio vcxproj tweaking 2025-11-18 20:03:05 -05:00
nhmall
ec04123a71 lualib.vcxproj bit 2025-11-18 19:10:28 -05:00
nhmall
2b0c083894 nmake trailing slash fix 2025-11-18 19:04:07 -05:00
nhmall
df54c155b2 yet another Visual Studio follow-up
yet another path correction
2025-11-18 18:56:35 -05:00
nhmall
9221247e24 another Visual Studio follow-up
path fix
2025-11-18 18:54:14 -05:00
nhmall
6de1f39c38 follow-up Visual Studio package fix 2025-11-18 18:27:45 -05:00
nhw_cron
8f52d51bd2 This is cron-daily v1-Apr-1-2024. 000files updated: Files 2025-11-18 18:24:48 -05:00
nhmall
a9d11db853 visual studio project tweaks 2025-11-18 13:44:55 -05:00
nhmall
b1cffe11f9 Cross-compiling on Windows 11 with Visual Studio
Cross-compiling NetHack with Visual Studio from an x64 platform to an ARM64
target presents some new build challenges.

In the current nethack.sln solution, the build attempts to execute the
several just-built tools during the build of various subprojects.

For example, when cross-compiling on a typical Windows 11 x64 machine
to build a target ARM64 Windows 11 package, the build process tries to
run the following just-built target tools:

(under a Debug build)
    "$(ToolsDir)\Debug\ARM64\uudecode.exe"
    "$(ToolsDir)\Debug\ARM64\makedefs.exe"
    "$(ToolsDir)\Debug\ARM64\tilemap.exe"
    "$(ToolsDir)\Debug\ARM64\tile2bmp.exe"
    "$(ToolsDir)\Debug\ARM64\dlb.exe"

(under a Release build)
    "$(ToolsDir)\Release\ARM64\uudecode.exe"
    "$(ToolsDir)\Release\ARM64\makedefs.exe"
    "$(ToolsDir)\Release\ARM64\tilemap.exe"
    "$(ToolsDir)\Release\ARM64\tile2bmp.exe"
    "$(ToolsDir)\Release\ARM64\dlb.exe"

Those fail to execute successfully on Intel x64 (or x86) since they
are actually ARM64 executables, and the build attempts to execute
them on the host Intel x64 hardware.

The situation is a little different if the cross-compile is carried out
on a Windows 11 ARM64 machine (such as SnapDragon).

On an ARM64 machine, the cross-compile to build a target Intel x64
Windows 11 package, tries to execute the following:

(under a Debug build)
    "$(ToolsDir)\Debug\x64\uudecode.exe"
    "$(ToolsDir)\Debug\x64\makedefs.exe"
    "$(ToolsDir)\Debug\x64\tilemap.exe"
    "$(ToolsDir)\Debug\x64\tile2bmp.exe"
    "$(ToolsDir)\Debug\x64\dlb.exe"

(under a Release build)
    "$(ToolsDir)\Release\x64\uudecode.exe"
    "$(ToolsDir)\Release\x64\makedefs.exe"
    "$(ToolsDir)\Release\x64\tilemap.exe"
    "$(ToolsDir)\Release\x64\tile2bmp.exe"
    "$(ToolsDir)\Release\x64\dlb.exe"

Those actual do succeed in executing on ARM64, because of the
"prism emulation" that is available on Windows 11 ARM64 operating
systems to allow x64 and x86 executables to run.

The following change adds some detection to build environment, leading
to the definition of a "HostTools" macro that leads to the native host
tools for those steps.

There is a catch:

It means that the native build of the interim tools for Windows 11 must
be executed prior to attempting a cross-compile build to a non-native
target. That ensures that the native x64 interim uudecode, makedefs,
tilemap, tile2bmp and dlb tools are available on the disk for use by
a subsequent cross-compile.

This change consistently switches to the use of the host-native
interim tools for uudecode, makedefs, tilemap, tile2bmp and dlb tools.

Technically, this change would not be strictly necessary on an
ARM64-hosted build that was targeting x64 or x86, because of the
available prism-emulation that allows ARM64, x64, and x86 images to
execute, but this maintains consistency of the build process on
either platform. It is also likely that the native host versions execute
more quickly than versions requiring the prism emulation, although
that isn't really a concern for a NetHack build.

The use of native host uudecode, makedefs, tilemap, tile2bmp and
dlb tools is done with the Unix-hosted cross-compiles to other
target platforms as well (on Linux or macOS).
2025-11-18 10:10:32 -05:00
nhmall
a6801b004c use lowercase platform name in zip file name 2025-11-17 21:02:45 -05:00
nhmall
8f97b824d5 visual studio build update
address warning disparity between ARM64 and x64
2025-11-17 20:44:08 -05:00
nhmall
7dbc0ac6b8 visual studio Makefile variable 2025-11-16 15:48:05 -05:00
nhmall
043b867da7 yet-another follow-up for NetHackW.vcxproj 2025-11-16 15:31:41 -05:00
nhmall
f790458587 follow-up bit for NetHackW.vcxproj
Remove a resource compiler architecture conditional, since it does not vary between
the different architectures. This is simpler.
2025-11-16 15:26:49 -05:00
nhmall
4f59f24485 some vcxproj fixes 2025-11-16 15:16:10 -05:00
nhmall
3885638934 update suppressed warnings in NetHack vcxproj
Also be more consistent on preprocessor #define entries between
Visual Studio builds and command line nmake Makefile builds.
2025-11-16 14:12:14 -05:00
nhmall
d7e4f2e2b1 Windows build support for Windows 11 arm64 (snapdragon) 2025-11-14 21:24:24 -05:00
nhmall
eb4496c575 vcxproj updates
define HAS_INTTYPES_H alongside HAS_STDINT_H in the visual studio projects
2025-11-13 09:11:49 -05:00
nhw_cron
b5792107a1 This is cron-daily v1-Apr-1-2024. 000files updated: Files 2025-11-12 21:33:21 -05:00
nhmall
2b845066fa update naming for generated Files 2025-11-12 21:14:42 -05:00
nhmall
cd98047de4 update tested versions of Visual Studio 2025-11-12 2025-11-12 20:40:01 -05:00
nhmall
c12344cd48 build dos in CI but skip faltering Terminus font steps 2025-11-10 12:56:49 -05:00
nhmall
d4a04b2632 turn off msdos build in CI for now 2025-11-10 09:21:22 -05:00