diff -Nru nethack-3.6.6/dat/hh nethack-3.6.7/dat/hh --- nethack-3.6.6/dat/hh 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/dat/hh 2023-02-15 21:52:57.000000000 +0000 @@ -9,9 +9,9 @@ case means the Control key, not a caret) > down m: move without picking up objects/fighting F: fight even if you don't sense a monster - If the number_pad option is set, the number keys move instead. - Depending on the platform, Shift number (on the numberpad), - Meta number, or Alt number will invoke the YUHJKLBN commands. + If the number_pad option is set, the digit keys move instead. + Depending on the platform, Shift digit (on the numberpad), + Meta digit, or Alt digit will invoke the YUHJKLBN commands. Control may or may not work when number_pad is enabled, depending on the platform's capabilities. Digit '5' acts as 'G' prefix, unless number_pad is set to 2 @@ -22,111 +22,135 @@ used but 'y' and 'z' are swapped. General commands: -? help display one of several informative texts -#quit quit end the game without saving current game -S save save the game (to be continued later) and exit - [to restore, play again and use the same character name] -! sh escape to some SHELL (if allowed; 'exit' to resume play) -^Z suspend suspend the game (independent of your current suspend char) +? help display one of several informative texts +#quit quit end the game without saving current game +S save save the game (to be continued later) and exit + [to restore, play again and use the same character name; + use #quit to quit without saving] +! sh escape to some SHELL (if allowed; 'exit' to resume play) +^Z suspend suspend the game (independent of your current suspend char) [on UNIX(tm)-based systems, use the 'fg' command to resume] -O options set options -/ what-is tell what a map symbol represents -\ known display list of what's been discovered -v version display version number -V history display game history -^A again redo the previous command (^A denotes the keystroke CTRL-A) -^R redraw redraw the screen -^P prevmsg repeat previous message (subsequent ^P's repeat earlier ones) +O options set options +/ what-is tell what a map symbol represents +\ known display list of what's been discovered +v version display version number +V history display game history +^A again redo the previous command +^R redraw redraw the screen +^P prevmsg repeat previous message (consecutive ^P's repeat earlier ones) # introduces an extended command (#? for a list of them) -& what-does describe the command a keystroke invokes +& what-does describe the command a keystroke invokes + +Control characters are depicted as '^' followed by a letter. Depress Ctrl +or Control like a shift key then type the letter. Control characters are +case-insensitive; ^D is the same as ^d, Ctrl+d is same as Ctrl+Shift+d. +There are a few non-letter control characters; nethack uses ^[ as a synonym +for Escape (or vice versa) but none of the others. Game commands: -^D kick kick (a door, or something else) -^T 'port teleport (if you can) -^X show show your attributes -a apply apply or use a tool (pick-axe, key, camera, etc.) -A armor take off all armor -c close close a door -C call name a monster, an individual object, or a type of object -d drop drop an object. d7a: drop seven items of object 'a' -D Drop drop selected types of objects -e eat eat something -E engrave write a message in the dust on the floor (E- use fingers) -f fire fire ammunition from quiver -F fight followed by direction, fight a monster -i invent list your inventory (all objects you are carrying) -I Invent list selected parts of your inventory - Iu: list unpaid objects - Ix: list unpaid but used up items - I$: count your money -o open open a door -p pay pay your bill (in a shop) -P puton put on an accessory (ring, amulet, etc) -q quaff drink something (potion, water, etc) -Q quiver select ammunition for quiver (use '#quit' to quit) -r read read a scroll or spellbook -R remove remove an accessory (ring, amulet, etc) -s search search for secret doors, hidden traps and monsters -t throw throw or shoot a weapon -T takeoff take off some armor -w wield wield a weapon (w- wield nothing) -W wear put on some armor -x xchange swap wielded and secondary weapons -X twoweapon toggle two-weapon combat (use '#explore' for explore mode) -z zap zap a wand (use y instead of z if number_pad is -1) -Z Zap cast a spell (use Y instead of Z if number_pad is -1) -< up go up the stairs -> down go down the stairs -^ trap_id identify a previously found trap -),[,=,",( ask for current items of specified symbol in use -* ask for combination of ),[,=,",( all at once -$ gold count your gold -+ spells list the spells you know; also rearrange them if desired -` classkn display known items for one class of objects -_ travel move via a shortest-path algorithm to a point on the map -. rest wait a moment -, pickup pick up all you can carry +^D kick kick (a door, or something else) +^T Tport teleport (if you can) +^X show show your attributes +a apply apply or use a tool (pick-axe, key, camera, etc.) +A takeoffall choose multiple items of armor, accessories, and weapons + to take off, remove, unwield (uses same amount of game time + as removing them individually with T,R,w- would take) +c close close a door +C call name a monster, an individual object, or a type of object +d drop drop an object. d7a: drop seven items of object 'a' +D Drop drop selected types of objects +e eat eat something +E engrave write a message in the dust on the floor (E- use fingers) +f fire fire ammunition from quiver +F fight followed by direction, fight a monster +i invent list your inventory (all objects you are carrying) +I Invent list selected parts of your inventory; for example + I( list all tools, or I" list all amulets + IB list all items known to be blessed + IU uncursed, or IC cursed, or IX unknown bless state + Iu when in a shop, list unpaid objects being carried + Ix in a shop, list any fees and used-up shop-owned items +o open open a door +p pay pay your bill (in a shop) +P puton put on an accessory (ring, amulet, etc; can be used to wear + armor too, but armor items aren't listed as likely candidates) +q quaff drink something (potion, water, etc) +Q quiver select ammunition for quiver (use '#quit' to quit) +r read read a scroll or spellbook +R remove remove an accessory (ring, amulet, etc; can be used to take + off armor too) +s search search for secret doors, hidden traps and monsters +t throw throw or shoot a weapon +T takeoff take off some armor; can be used to remove accessories too, + but those aren't listed as likely candidates) +w wield wield a weapon (w- wield nothing to unwield current weapon) +W wear wear an item of armor; can be used to put on accessories too, + but those aren't listed as likely candidates) +x xchange swap wielded and secondary weapons +X twoweapon toggle two-weapon combat if role allows that +z zap zap a wand (use y instead of z if number_pad is -1) +Z Zap cast a spell (use Y instead of Z if number_pad is -1) +< up go up the stairs +> down go down the stairs +^ trap_id identify a previously found trap +),[,=,",( show current items of specified symbol in use +* show combination of ),[,=,",( all at once +$ gold count your gold ++ spells list the spells you know; also rearrange them if desired +` classkn display known items for one class of objects +_ travel move via a shortest-path algorithm to a point on the map +. rest wait a moment +, pickup pick up all you can carry @ toggle "pickup" (auto pickup) option on and off -: look look at what is here -; farlook look at what is somewhere else by selecting a map symbol - -Keyboards that have a meta key can also use these extended commands -via the meta modifier instead of the # prefix: +: look look at what is here +; farlook look at what is somewhere else by selecting a map location + (for a monster on top of one or more objects, only describes + that monster; for a pile of objects, only describes top one) + +Keyboards that have a meta key (some use Alt for that, so typing Alt as a +shift plus 'e' would generate 'M-e') can also use these extended commands +via the meta modifier as an alternative to using the # prefix. Unlike +control characters, meta characters are case-sensitive so M-a is different +from M-A. Type the latter with two keys used as shifts, Meta+Shift+a. M-? display extended command help (if the platform allows this) -M-2 twoweapon toggle two-weapon combat (unless number_pad is enabled) -M-a adjust adjust inventory letters -M-A annotate add a one-line note to the current dungeon level (see M-O) -M-c chat talk to someone -M-C conduct view optional challenges -M-d dip dip an object into something -M-e enhance advance or check weapon and spell skills -M-f force force a lock -M-i invoke invoke an object's special powers -M-j jump jump to another location -M-l loot loot a box on the floor -M-m monster use a monster's special ability -M-n name name a monster, an individual object, or a type of object -M-N name synonym for M-n -M-o offer offer a sacrifice to the gods -M-O overview display information about visited levels and annotations -M-p pray pray to the gods for help -M-q quit stop playing -M-r rub rub a lamp or a stone -M-R ride mount or dismount saddled steed -M-s sit sit down -M-t turn turn undead -M-T tip upend a container to dump out its contents -M-u untrap untrap something -M-v version print compile time options for this version -M-w wipe wipe off your face +M-2 twoweapon toggle two-weapon combat (unless number_pad is enabled) +M-a adjust adjust inventory letters +M-A annotate add a one-line note to the current dungeon level (see M-O) +M-c chat talk to someone +M-C conduct view optional challenges +M-d dip dip an object into something +M-e enhance show weapon and spell skills, can improve them if eligible +M-f force force a lock +M-i invoke invoke an object's special powers +M-j jump jump to another location +M-l loot loot a box on the floor +M-m monster when polymorphed, use monster's special ability +M-n name name a monster, an individual object, or a type of object +M-N name synonym for M-n (both are the same as C) +M-o offer offer a sacrifice to the gods +M-O overview display information about visited levels and annotations +M-p pray pray to the gods for help +M-q quit stop playing without saving game (use S to save and exit) +M-r rub rub a lamp or a stone +M-R ride mount or dismount saddled steed +M-s sit sit down +M-t turn turn undead if role allows that +M-T tip upend a container to dump out its contents +M-u untrap untrap something +M-v version print compile time options for this version +M-w wipe wipe off your face +M-X explore switch from regular play to non-scoring explore mode -If the "number_pad" option is on, these additional variants are available: +If the 'number_pad' option is on, keys usually used for movement can be +used for various commands: n followed by number of times to repeat the next command -h help display one of several informative texts, like '?' -j jump jump to another location -k kick kick something (usually a door) -l loot loot a box on the floor -N name name an item or type of object -u untrap untrap something (usually a trapped object) +h help display one of several informative texts, like '?' +j jump jump to another location +k kick kick something (usually a door) +l loot loot a box on the floor +N name name an item or type of object +u untrap untrap something (usually a trapped object) + +Additional commands are available in debug mode (also known as wizard mode). diff -Nru nethack-3.6.6/dat/history nethack-3.6.7/dat/history --- nethack-3.6.6/dat/history 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/dat/history 2023-02-15 21:52:57.000000000 +0000 @@ -232,6 +232,9 @@ NetHack 3.6.6 was released on March 8, 2020 containing a security fix and some bug fixes. +NetHack 3.6.7 was released in February 2023 containing a security fix and +some bug fixes. + The official NetHack web site is maintained by Ken Lorber at http://www.nethack.org/. diff -Nru nethack-3.6.6/debian/changelog nethack-3.6.7/debian/changelog --- nethack-3.6.6/debian/changelog 2022-08-14 14:04:40.000000000 +0000 +++ nethack-3.6.7/debian/changelog 2023-06-18 15:59:30.000000000 +0000 @@ -1,3 +1,24 @@ +nethack (3.6.7-1) unstable; urgency=medium + + * Team upload. + + [ Reiner Herrmann ] + * New upstream release. + - Fixes buffer overflow that can crash the NetHack process + (CVE-2023-24809). (Closes: #1031869) + - Drop patches applied upstream. + * Enable dumplog support, which was enabled through thirdparty patch in an + older release (3.4.x), and is included upstream since 3.6.x, but had not + yet been re-enabled. (Closes: #1023578) + * Bump Standards-Version to 4.6.2. + * Replace obsolete build dependency: libncurses5-dev => libncurses-dev. + * Replace obsolete build dependency: bsdmainutils => bsdextrautils. + + [ Paulo Henrique de Lima Santana ] + * Update Brazilian Portuguese debconf templates translation (Closes: #1024192) + + -- Reiner Herrmann Sun, 18 Jun 2023 17:59:30 +0200 + nethack (3.6.6-3) unstable; urgency=medium * Team upload. diff -Nru nethack-3.6.6/debian/control nethack-3.6.7/debian/control --- nethack-3.6.6/debian/control 2022-08-14 14:04:40.000000000 +0000 +++ nethack-3.6.7/debian/control 2023-06-18 15:59:30.000000000 +0000 @@ -7,11 +7,11 @@ James Cowgill Build-Depends: bison, - bsdmainutils, + bsdextrautils, debhelper-compat (= 13), flex, groff-base, - libncurses5-dev | libncurses-dev, + libncurses-dev, libx11-dev, libxaw7-dev | libxaw-dev, libxext-dev, @@ -22,7 +22,7 @@ qtbase5-dev, qtmultimedia5-dev, xfonts-utils -Standards-Version: 4.6.1 +Standards-Version: 4.6.2 Homepage: https://www.nethack.org Vcs-Git: https://salsa.debian.org/games-team/nethack.git Vcs-Browser: https://salsa.debian.org/games-team/nethack diff -Nru nethack-3.6.6/debian/patches/0006-Common-config.h-for-all-binary-packages.patch nethack-3.6.7/debian/patches/0006-Common-config.h-for-all-binary-packages.patch --- nethack-3.6.6/debian/patches/0006-Common-config.h-for-all-binary-packages.patch 2022-08-14 14:04:40.000000000 +0000 +++ nethack-3.6.7/debian/patches/0006-Common-config.h-for-all-binary-packages.patch 2023-06-18 15:59:30.000000000 +0000 @@ -106,6 +106,15 @@ /* * If it is desirable to limit the number of people that can play Hack +@@ -543,7 +547,7 @@ + whole thing, then type a new end for the text. */ + /* #define EDIT_GETLIN */ + +-/* #define DUMPLOG */ /* End-of-game dump logs */ ++#define DUMPLOG /* End-of-game dump logs */ + #ifdef DUMPLOG + + #ifndef DUMPLOG_MSG_COUNT @@ -570,6 +574,9 @@ #define USE_ISAAC64 /* Use cross-plattform, bundled RNG */ diff -Nru nethack-3.6.6/debian/patches/0010-dumplog-path.patch nethack-3.6.7/debian/patches/0010-dumplog-path.patch --- nethack-3.6.6/debian/patches/0010-dumplog-path.patch 1970-01-01 00:00:00.000000000 +0000 +++ nethack-3.6.7/debian/patches/0010-dumplog-path.patch 2023-06-18 15:59:30.000000000 +0000 @@ -0,0 +1,15 @@ +Author: Reiner Herrmann +Description: set DUMPLOGFILE in sysconf +Forwarded: not-needed + +--- a/sys/unix/sysconf ++++ b/sys/unix/sysconf +@@ -103,7 +103,7 @@ + # %D current time, YYYYMMDDhhmmss format + # %n player name + # %N first character of player name +-#DUMPLOGFILE=/tmp/nethack.%n.%d.log ++DUMPLOGFILE=/var/games/nethack/dumps/nethack.%n.%d.log + + # Number of bones file pools. + # The pool you belong to is determined at game start. You will diff -Nru nethack-3.6.6/debian/patches/series nethack-3.6.7/debian/patches/series --- nethack-3.6.6/debian/patches/series 2022-08-14 14:04:40.000000000 +0000 +++ nethack-3.6.7/debian/patches/series 2023-06-18 15:59:30.000000000 +0000 @@ -5,6 +5,6 @@ 0007-Be-a-little-bit-more-useful-with-recover-s-error-mes.patch 0008-Use-usr-share-pixmaps-nethack-for-pretty-pictures.patch 0009-Better-way-to-do-it.patch +0010-dumplog-path.patch 0017-Debian-and-Linux-specifics-defined-in-unixconf.h.patch 0021-fix-kfreebsd-ftbfs.patch -warn_unused_result.patch diff -Nru nethack-3.6.6/debian/patches/warn_unused_result.patch nethack-3.6.7/debian/patches/warn_unused_result.patch --- nethack-3.6.6/debian/patches/warn_unused_result.patch 2022-08-14 14:04:40.000000000 +0000 +++ nethack-3.6.7/debian/patches/warn_unused_result.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -From 4a3d46635e823cefedc475892b69e1c35ba941e8 Mon Sep 17 00:00:00 2001 -From: nhmall -Date: Tue, 4 Jan 2022 08:24:08 -0500 -Bug-Debian: https://bugs.debian.org/1017326 -Subject: [PATCH] work around ubuntu 20.10 build issue - -NetHack was trying to suppress warn_unused_result -in include/tradstdc.h, by defining warn_unused_result -to an empty string. That began causing a build error -in a system-supplied header file cdefs.h -when using 20.10 ubuntu impish. - -Try skipping that in tradstdc.h for any linux, unless -the NetHack build defines GCC_URWARN to force it into -play. ---- - include/tradstdc.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/include/tradstdc.h b/include/tradstdc.h -index 12a0d4afe2..a70698be40 100644 ---- a/include/tradstdc.h -+++ b/include/tradstdc.h -@@ -429,12 +429,14 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ - #if __GNUC__ >= 3 - #define UNUSED __attribute__((unused)) - #define NORETURN __attribute__((noreturn)) -+#if !defined(__linux__) || defined(GCC_URWARN) - /* disable gcc's __attribute__((__warn_unused_result__)) since explicitly - discarding the result by casting to (void) is not accepted as a 'use' */ - #define __warn_unused_result__ /*empty*/ - #define warn_unused_result /*empty*/ - #endif - #endif -+#endif - - #ifndef PRINTF_F - #define PRINTF_F(f, v) diff -Nru nethack-3.6.6/debian/po/pt_BR.po nethack-3.6.7/debian/po/pt_BR.po --- nethack-3.6.6/debian/po/pt_BR.po 2022-08-14 14:04:40.000000000 +0000 +++ nethack-3.6.7/debian/po/pt_BR.po 2023-06-18 15:59:30.000000000 +0000 @@ -12,27 +12,28 @@ # Developers do not need to manually edit POT or PO files. # # Felipe Augusto van de Wiel (faw) , 2006. +# Paulo Henrique de Lima Santana (phls) , 2022. # Licensed under the same terms of the nethack package. # msgid "" msgstr "" -"Project-Id-Version: nethack (20061112)\n" +"Project-Id-Version: nethack_3.6.6-3\n" "Report-Msgid-Bugs-To: nethack@packages.debian.org\n" "POT-Creation-Date: 2009-03-17 07:46+0100\n" -"PO-Revision-Date: 2006-11-12 14:12-0200\n" -"Last-Translator: Felipe Augusto van de Wiel (faw) \n" +"PO-Revision-Date: 2022-11-15 18:54-0300\n" +"Last-Translator: Paulo Henrique de Lima Santana (phls) \n" "Language-Team: l10n portuguese \n" -"Language: \n" +"Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"pt_BR utf-8\n" +"X-Generator: Poedit 3.1.1\n" #. Type: boolean #. Description #: ../nethack-common.templates:2001 msgid "Use setgid bit with NetHack's recover utility?" -msgstr "" +msgstr "Usar setgid bit com o utilitário de recuperação do NetHack?" #. Type: boolean #. Description @@ -43,6 +44,11 @@ "recover their own save files after a crash (with \"games\" group " "privileges). This is a potential source of security problems." msgstr "" +"O programa \"recover\" no pacote nethack-common é tradicionalmente " +"instalado com o bit \"setgid\" definido, para que todos os usuários possam " +"usá-lo para recuperar seus próprios arquivos salvos após uma falha (com " +"privilégios de grupo \"games\"). Esta é uma fonte potencial de problemas " +"de segurança." #. Type: boolean #. Description @@ -53,84 +59,18 @@ "users will need to run it themselves, so the default is to install recover " "without the special permission bits required for that." msgstr "" +"Este pacote inclui um script que é executado durante a inicialização do " +"sistema, invocando a recuperação em qualquer arquivo salvo quebrado que " +"encontrar. Isso torna menos provável que os usuários precisem executá-lo " +"por conta própria, portanto, o padrão é instalar o recover sem os bits de " +"permissão especiais necessários para isso." #. Type: boolean #. Description #: ../nethack-common.templates:2001 msgid "" -"If you choose this option, unprivileged users will be able to run \"recover" -"\"." +"If you choose this option, unprivileged users will be able to run " +"\"recover\"." msgstr "" - -#~ msgid "abort, backup, purge, ignore" -#~ msgstr "abortar, backup, expurgar (\"purge\"), ignorar" - -#~ msgid "Should NetHack back up your old, incompatible save files?" -#~ msgstr "" -#~ "NetHack deveria fazer backup dos seus antigos e incompatíveis arquivos " -#~ "salvos?" - -#~ msgid "" -#~ "You are upgrading from a version of NetHack whose save files are not " -#~ "compatible with the version you are upgrading to. You may either have " -#~ "them backed up into /tmp, purge them, ignore this problem completely, or " -#~ "abort this installation and manually handle NetHack's save files. Your " -#~ "score files will be lost if you choose to purge." -#~ msgstr "" -#~ "Você está atualizando a partir de uma versão do NetHack cujos arquivos " -#~ "salvos não são compatíveis com a versão para a qual você está " -#~ "atualizando. Você pode fazer o backup deles no /tmp, expurgá-los, ignorar " -#~ "este problema completamente ou abortar esta instalação e manualmente " -#~ "manusear os arquivos salvos do NetHack. Seus arquivos de pontuação serão " -#~ "perdidos se você escolher expurgar." - -#~ msgid "" -#~ "If you choose to back up, the files will be backed up into a gzip-" -#~ "compressed tar archive in /tmp with a random name starting with 'nethk' " -#~ "and ending in '.tar.gz'." -#~ msgstr "" -#~ "Se você optar pelo backup, os arquivos serão salvos num arquivo tar " -#~ "compactado com gzip no /tmp com um nome aleatório começando com 'nethk' e " -#~ "terminando com '.tar.gz'." - -#~ msgid "" -#~ "Old NetHack save files can be found in /var/games/nethack (or /var/lib/" -#~ "games/nethack, for versions before 3.4.0)." -#~ msgstr "" -#~ "Antigos arquivos salvos NetHack podem ser encontrados em /var/games/" -#~ "nethack (ou /var/lib/games/nethack, para versões anteriores a 3.4.0)." - -#~ msgid "Would you like NetHack's recover utility to be setgid games?" -#~ msgstr "" -#~ "Você gostaria que o utilitário de recuperação do NetHack fosse " -#~ "configurado com setgid games?" - -#~ msgid "" -#~ "The 'recover' program is installed as part of the nethack-common package " -#~ "and exists to help the administrator recover broken save files, etc." -#~ msgstr "" -#~ "O programa 'recover' é instalado como parte do pacote nethack-common e " -#~ "existe para ajudar administradores a recuperar arquivos salvos quebrados, " -#~ "etc." - -#~ msgid "" -#~ "Recover is traditionally installed setgid games, although it does not " -#~ "need to be in the Debian NetHack installation, as it is automatically run " -#~ "at boot time as root. Its only usefulness as a setgid binary is to let " -#~ "players as normal users on the system recover their save files, should " -#~ "NetHack crash or their connection drop mid-game." -#~ msgstr "" -#~ "\"Recover\" é tradicionalmente instalado com setgid games, no entanto " -#~ "isto não é necessário na instalação do NetHack no Debian, pois ele é " -#~ "automaticamente executado na inicialização como root. Sua única utilidade " -#~ "como binário setgid é permitir que jogadores como usuários normais do " -#~ "sistema possam recuperar seus arquivos salvos, caso o NetHack falhe " -#~ "(\"crash\") ou suas conexões caiam no meio do jogo." - -#~ msgid "" -#~ "If you answer no, you will have to run recover as root or as someone in " -#~ "group games to recover save files after a crash or a connection drop." -#~ msgstr "" -#~ "Se você responder não, você terá que executar a recuperação como root ou " -#~ "como alguém que esteja no grupo games para recuperar os arquivos salvos " -#~ "após uma falha (\"crash\") ou uma queda de conexão." +"Se você escolher esta opção, usuários sem privilégios poderão executar " +"\"recover\"." diff -Nru nethack-3.6.6/doc/fixes36.6 nethack-3.6.7/doc/fixes36.6 --- nethack-3.6.6/doc/fixes36.6 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/doc/fixes36.6 2023-02-15 21:52:57.000000000 +0000 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6-Mar2020 $:$NHDT-Revision: 1.2 $ $NHDT-Date: 1583606861 2020/03/07 18:47:41 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.4 $ $NHDT-Date: 1587039894 2020/04/16 12:24:54 $ fixes36.6 contains a terse summary of changes made to 3.6.5 in order to produce 3.6.6 as well as any post-release fixes in binaries. @@ -24,4 +24,3 @@ General New Features -------------------- none - diff -Nru nethack-3.6.6/doc/fixes36.7 nethack-3.6.7/doc/fixes36.7 --- nethack-3.6.6/doc/fixes36.7 1970-01-01 00:00:00.000000000 +0000 +++ nethack-3.6.7/doc/fixes36.7 2023-02-15 21:52:57.000000000 +0000 @@ -0,0 +1,45 @@ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.4 $ $NHDT-Date: 1587039894 2020/04/16 12:24:54 $ + +fixes36.7 contains a summary of changes made to 3.6.6 in order to +produce 3.6.7 as well as any post-release fixes in binaries. + + +General Fixes and Modified Features +----------------------------------- +during engraving, spaces were counted instead of non-space (cherry-pick of + 4e0a1e04 from NetHack-3.7) +avoid potential buffer overflow in append_str() +resolve missing dependency in NetHack.sln +code in include/tradstdc.h was trying to suppress warn_unused result by + defining warn_unused_result to an empty string and that began causing + a build error within a system-supplied header file cdefs.h when using + ubuntu impish 21.10; disable that for any Linux unless GCC_URWARN is + defined to force it back into effect +update_inventory() after leash goes slack +player assigned name for monsters, specific objects, or object types could be + longer than what was intented to be allowed; for 'curses', much longer + +Platform- and/or Interface-Specific Fixes or Features +----------------------------------------------------- +windows: added winflexbison to travis-ci configuration to permit full build of + levcomp and dgncomp +windows: a bad chdir specified in win/win32/dgnstuff.mak caused full build to + abort +windows: the console.rc file had outdated information stating 3.6.3 when the + official 3.6.6 binary was built. +windows: switch from using keyhandling dll's to incorporating the three + variations (default, ray, 340) in sys/winnt/nttty.c +curses: cherry-picked selectsaved code from 3.7 for menu of save files +NetHackW: fix delay rendering of cursor when using farlook + + +General New Features +-------------------- +none + + +Fixes to 3.6.7 Post-release Problems and other Post-release changes +------------------------------------------------------------------- +none + + diff -Nru nethack-3.6.6/doc/Guidebook.mn nethack-3.6.7/doc/Guidebook.mn --- nethack-3.6.6/doc/Guidebook.mn 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/doc/Guidebook.mn 2023-02-15 21:52:57.000000000 +0000 @@ -24,7 +24,7 @@ .ds vr "NetHack 3.6 .ds f0 "\*(vr .ds f1 -.ds f2 "March 8, 2020 +.ds f2 "February 3, 2023 . .\" A note on some special characters: .\" \(lq = left double quote @@ -2460,7 +2460,7 @@ .pg Normally, if you have seen an object at a particular map location and move to another location where you can't directly see that object any -more, if will continue to be displayed on your map. +more, it will continue to be displayed on your map. That remains the case even if it is not actually there any more \(em perhaps a monster has picked it up or it has rotted away \(em until you can see or feel that location again. @@ -2636,12 +2636,12 @@ can be created with any text editor. .pg On Windows, it is \(lq.nethackrc\(rq in the folder -\(lq\\%USERPROFILE%\\NetHack\\3.6\(rq. The file may not exist, +\(lq\\%USERPROFILE%\\NetHack\\(rq. The file may not exist, but it is a normal ASCII text file can can be created with any text editor. After running NetHack for the first time, you should find a default template for the configuration file named \(lq.nethackrc.template\(rq -in \(lq\\%USERPROFILE%\\NetHack\\3.6\(rq. +in \(lq\\%USERPROFILE%\\NetHack\\(rq. If you had not created the configuration file, NetHack will create the configuration file for you using the default template file. .pg @@ -3787,11 +3787,10 @@ .pg Here are explanations of options that are used by specific platforms or ports to customize and change the port behavior. -.lp altkeyhandler -Select an alternate keystroke handler dll to load (Win32 tty NetHack only). -The name of the handler is specified without the .dll extension and without -any path information. -Cannot be set with the \(oqO\(cq command. +.lp altkeyhandling +Select an alternate way to handle keystrokes (Win32 tty NetHack only). +The name of the handling type is one of \(lqdefault\(rq, \(lqray\(rq, +\(lq340\(rq. .lp altmeta On Amiga, this option controls whether typing \(lqAlt\(rq plus another key functions as a meta-shift for that key (default on). @@ -5167,6 +5166,9 @@ NetHack 3.6.6 was released on March 8, 2020 containing a security fix and some bug fixes. .pg +NetHack 3.6.7 was released in February 2023 containing a security fix and +some bug fixes. +.pg The official NetHack web site is maintained by \fBKen Lorber\fP at .UR https://www.nethack.org/ . diff -Nru nethack-3.6.6/doc/Guidebook.tex nethack-3.6.7/doc/Guidebook.tex --- nethack-3.6.6/doc/Guidebook.tex 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/doc/Guidebook.tex 2023-02-15 21:52:57.000000000 +0000 @@ -45,7 +45,7 @@ %.au \author{Original version - Eric S. Raymond\\ (Edited and expanded for 3.6 by Mike Stephenson and others)} -\date{March 8, 2020} +\date{February 3, 2023} \maketitle @@ -2707,7 +2707,7 @@ %.pg Normally, if you have seen an object at a particular map location and move to another location where you can't directly see that object any -more, if will continue to be displayed on your map. +more, it will continue to be displayed on your map. That remains the case even if it is not actually there any more---perhaps a monster has picked it up or it has rotted away---until you can see or feel that location again. @@ -2883,12 +2883,12 @@ %.lp "" On Windows, it is \mbox{``.nethackrc''} in the folder -\mbox{{``\%USERPROFILE\%\textbackslash NetHack\textbackslash 3.6''}}. The +\mbox{{``\%USERPROFILE\%\textbackslash NetHack\textbackslash''}}. The file may not exist, but it is a normal ASCII text file and can be created with any text editor. After runing {\it NetHack\/} for the first time, you should find a default template for ths configuration file named \mbox{``.nethackrc.template''} in -\mbox{{``\%USERPROFILE\%\textbackslash NetHack\textbackslash 3.6''}}. +\mbox{{``\%USERPROFILE\%\textbackslash NetHack\textbackslash''}}. If you had not created the configuration file, {\it NetHack\/} will create the configuration file for you using the default template file. @@ -4211,11 +4211,9 @@ \blist{} %.lp -\item[\ib{altkeyhandler}] -Select an alternate keystroke handler dll to load ({\it Win32 tty\/ NetHack\/} only). -The name of the handler is specified without the .dll extension and without any -path information. -Cannot be set with the `{\tt O}' command. +\item[\ib{altkeyhandling}] +Select an alternate way to handle keystrokes ({\it Win32 tty\/ NetHack\/} only). +The name of the handling type is one of {\it default}, {\it ray}, {\it 340} %.lp \item[\ib{altmeta}] On Amiga, this option controls whether typing ``Alt'' plus another key @@ -5779,6 +5777,11 @@ some bug fixes. %.pg +\medskip +NetHack 3.6.7 was released in February 2023 containing a security fix and +some bug fixes. + +%.pg \medskip \nd The official {\it NetHack\/} web site is maintained by {\it Ken Lorber} at {\catcode`\#=11 diff -Nru nethack-3.6.6/doc/Guidebook.txt nethack-3.6.7/doc/Guidebook.txt --- nethack-3.6.6/doc/Guidebook.txt 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/doc/Guidebook.txt 2023-02-15 21:52:57.000000000 +0000 @@ -15,7 +15,7 @@ Original version - Eric S. Raymond (Edited and expanded for 3.6 by Mike Stephenson and others) - March 8, 2020 + February 3, 2023 @@ -126,7 +126,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -192,7 +192,7 @@ you have seen on the current dungeon level; as you explore more - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -258,7 +258,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -324,7 +324,7 @@ Intelligence affects your ability to cast spells and read - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -390,7 +390,7 @@ ical attacks. Many dungeons show only your experience level - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -456,7 +456,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -522,7 +522,7 @@ nasty and vicious. Sometimes, however, they can be helpful. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -588,7 +588,7 @@ symbol at the chosen location, conditionally check for "More - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -654,7 +654,7 @@ if you remember a monster there). - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -720,7 +720,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -786,7 +786,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -852,7 +852,7 @@ once you've closed this menu. The available options are - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -918,7 +918,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -984,7 +984,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1050,7 +1050,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1116,7 +1116,7 @@ (R)UNIX is a registered trademark of The Open Group. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1182,7 +1182,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1248,7 +1248,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1314,7 +1314,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1380,7 +1380,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1446,7 +1446,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1512,7 +1512,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1578,7 +1578,7 @@ When picking a target with cursor and the autodescribe - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1644,7 +1644,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1710,7 +1710,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1776,7 +1776,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1842,7 +1842,7 @@ the `^D' (kick) command. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1908,7 +1908,7 @@ on the corresponding staircase at your destination. However, - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -1974,7 +1974,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2040,7 +2040,7 @@ member a monster but want to try fighting anyway, you can use the - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2106,7 +2106,7 @@ ers (or even former incarnations of yourself!) and their personal - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2172,7 +2172,7 @@ ter. Many commands that operate on objects must ask you to find - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2238,7 +2238,7 @@ In some cases "uncursed" will be omitted as being redundant when - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2304,7 +2304,7 @@ to taking off other worn items. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2370,7 +2370,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2436,7 +2436,7 @@ ondary is just an item in your inventory that's been designated - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2502,7 +2502,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2568,7 +2568,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2634,7 +2634,7 @@ the wall, you might decide to go for broke and break your wand. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2700,7 +2700,7 @@ cation rather than just specify a particular direction. Other - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2766,7 +2766,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2817,7 +2817,7 @@ Normally, if you have seen an object at a particular map lo- cation and move to another location where you can't directly see - that object any more, if will continue to be displayed on your + that object any more, it will continue to be displayed on your map. That remains the case even if it is not actually there any more -- perhaps a monster has picked it up or it has rotted away -- until you can see or feel that location again. One notable @@ -2832,7 +2832,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2898,7 +2898,7 @@ brains while polymorphed into a mind flayer, is considered eating - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -2964,7 +2964,7 @@ type ("polypiling") or the form of your own body into another - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3010,11 +3010,11 @@ ASCII text file and can be created with any text editor. On Windows, it is ".nethackrc" in the folder "\%USERPRO- - FILE%\NetHack\3.6". The file may not exist, but it is a normal + FILE%\NetHack\(rq. The file may not exist, but it is a normal ASCII text file can can be created with any text editor. After running NetHack for the first time, you should find a default template for the configuration file named ".nethackrc.template" - in "\%USERPROFILE%\NetHack\3.6". If you had not created the con- + in "\%USERPROFILE%\NetHack\(rq. If you had not created the con- figuration file, NetHack will create the configuration file for you using the default template file. @@ -3030,7 +3030,7 @@ tion, and are ignored unless a CHOOSE statement was used to - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3096,7 +3096,7 @@ pletion has no effect for the X11 windowport. You can specify - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3162,7 +3162,7 @@ "Configuring User Sounds" section. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3228,7 +3228,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3294,7 +3294,7 @@ tion controls whether the description includes map coordinates. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3360,7 +3360,7 @@ was defined during compilation. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3426,7 +3426,7 @@ display for end-of-game disclosure follows a set sequence. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3492,7 +3492,7 @@ "no", you will exclude that gender from being picked randomly. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3558,7 +3558,7 @@ sistent. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3624,7 +3624,7 @@ fault `\'. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3690,7 +3690,7 @@ Prompt for new form whenever any monster changes shape (default - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3756,7 +3756,7 @@ Valid settings are: - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3822,7 +3822,7 @@ item. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3888,7 +3888,7 @@ (Default `S'). Persistent. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -3954,7 +3954,7 @@ be set with the `O' command. Persistent. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4020,7 +4020,7 @@ off). Persistent. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4086,7 +4086,7 @@ only; "X11" interface always uses a timer based delay. The - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4152,7 +4152,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4218,7 +4218,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4284,7 +4284,7 @@ If NetHack can, it should use this size font for text windows. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4350,7 +4350,7 @@ Number of lines for traditional below-the-map status display. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4416,7 +4416,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4449,11 +4449,10 @@ Here are explanations of options that are used by specific platforms or ports to customize and change the port behavior. - altkeyhandler - Select an alternate keystroke handler dll to load (Win32 tty - NetHack only). The name of the handler is specified without - the .dll extension and without any path information. Cannot be - set with the `O' command. + altkeyhandling + Select an alternate way to handle keystrokes (Win32 tty NetHack + only). The name of the handling type is one of "default", + "ray", "340". altmeta On Amiga, this option controls whether typing "Alt" plus anoth- @@ -4461,28 +4460,29 @@ altmeta On other (non-Amiga) systems where this option is available, it - can be set to tell NetHack to convert a two character sequence - beginning with ESC into a meta-shifted version of the second + can be set to tell NetHack to convert a two character sequence + beginning with ESC into a meta-shifted version of the second character (default off). - This conversion is only done for commands, not for other input + This conversion is only done for commands, not for other input prompts. Note that typing one or more digits as a count prefix prior to a command -- preceded by n if the number_pad option is - set -- is also subject to this conversion, so attempting to - abort the count by typing ESC will leave NetHack waiting for + set -- is also subject to this conversion, so attempting to + abort the count by typing ESC will leave NetHack waiting for another character to complete the two character sequence. Type - a second ESC to finish cancelling such a count. At other + a second ESC to finish cancelling such a count. At other prompts a single ESC suffices. BIOS Use BIOS calls to update the screen display quickly and to read - the keyboard (allowing the use of arrow keys to move) on ma- - chines with an IBM PC compatible BIOS ROM (default off, OS/2, + the keyboard (allowing the use of arrow keys to move) on ma- + chines with an IBM PC compatible BIOS ROM (default off, OS/2, PC, and ST NetHack only). - NetHack 3.6 March 8, 2020 + + NetHack 3.6 February 3, 2023 @@ -4502,10 +4502,10 @@ (default on, Mac NetHack only). rawio - Force raw (non-cbreak) mode for faster output and more bullet- - proof input (MS-DOS sometimes treats `^P' as a printer toggle - without it) (default off, OS/2, PC, and ST NetHack only). - Note: DEC Rainbows hang if this is turned on. Cannot be set + Force raw (non-cbreak) mode for faster output and more bullet- + proof input (MS-DOS sometimes treats `^P' as a printer toggle + without it) (default off, OS/2, PC, and ST NetHack only). + Note: DEC Rainbows hang if this is turned on. Cannot be set with the `O' command. soundcard @@ -4513,42 +4513,42 @@ mand. subkeyvalue - (Win32 tty NetHack only). May be used to alter the value of + (Win32 tty NetHack only). May be used to alter the value of keystrokes that the operating system returns to NetHack to help - compensate for international keyboard issues. OPTIONS=subkey- - value:171/92 will return 92 to NetHack, if 171 was originally - going to be returned. You can use multiple subkeyvalue state- - ments in the configuration file if needed. Cannot be set with + compensate for international keyboard issues. OPTIONS=subkey- + value:171/92 will return 92 to NetHack, if 171 was originally + going to be returned. You can use multiple subkeyvalue state- + ments in the configuration file if needed. Cannot be set with the `O' command. video Set the video mode used (PC NetHack only). Values are "autode- - tect", "default", or "vga". Setting "vga" (or "autodetect" - with vga hardware present) will cause the game to display + tect", "default", or "vga". Setting "vga" (or "autodetect" + with vga hardware present) will cause the game to display tiles. Cannot be set with the `O' command. videocolors - Set the color palette for PC systems using NO_TERMS (default - 4-2-6-1-5-3-15-12-10-14-9-13-11, (PC NetHack only). The order - of colors is red, green, brown, blue, magenta, cyan, - bright.white, bright.red, bright.green, yellow, bright.blue, - bright.magenta, and bright.cyan. Cannot be set with the `O' + Set the color palette for PC systems using NO_TERMS (default + 4-2-6-1-5-3-15-12-10-14-9-13-11, (PC NetHack only). The order + of colors is red, green, brown, blue, magenta, cyan, + bright.white, bright.red, bright.green, yellow, bright.blue, + bright.magenta, and bright.cyan. Cannot be set with the `O' command. videoshades Set the intensity level of the three gray scales available (de- fault dark normal light, PC NetHack only). If the game display - is difficult to read, try adjusting these scales; if this does - not correct the problem, try !color. Cannot be set with the + is difficult to read, try adjusting these scales; if this does + not correct the problem, try !color. Cannot be set with the `O' command. 9.7. Regular Expressions - Regular expressions are normally POSIX extended regular ex- - pressions. It is possible to compile NetHack without regular + Regular expressions are normally POSIX extended regular ex- + pressions. It is possible to compile NetHack without regular - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4558,10 +4558,10 @@ - expression support on a platform where there is no regular ex- - pression library. While this is not true of any modern platform, - if your NetHack was built this way, patterns are instead glob - patterns. This applies to Autopickup exceptions, Message types, + expression support on a platform where there is no regular ex- + pression library. While this is not true of any modern platform, + if your NetHack was built this way, patterns are instead glob + patterns. This applies to Autopickup exceptions, Message types, Menu colors, and User sounds. 9.8. Configuring Autopickup Exceptions @@ -4569,29 +4569,29 @@ You can further refine the behavior of the autopickup option beyond what is available through the pickup_types option. - By placing autopickup_exception lines in your configuration - file, you can define patterns to be checked when the game is + By placing autopickup_exception lines in your configuration + file, you can define patterns to be checked when the game is about to autopickup something. autopickup_exception - Sets an exception to the pickup_types option. The autopick- - up_exception option should be followed by a regular expression - to be used as a pattern to match against the singular form of + Sets an exception to the pickup_types option. The autopick- + up_exception option should be followed by a regular expression + to be used as a pattern to match against the singular form of the description of an object at your location. - In addition, some characters are treated specially if they oc- + In addition, some characters are treated specially if they oc- cur as the first character in the pattern, specifically: < - always pickup an object that matches rest of pattern; > - never pickup an object that matches rest of pattern. - The autopickup_exception rules are processed in the order in - which they appear in your configuration file, thus allowing a + The autopickup_exception rules are processed in the order in + which they appear in your configuration file, thus allowing a later rule to override an earlier rule. - Exceptions can be set with the `O' command, but because they - are not included in your configuration file, they won't be in - effect if you save and then restore your game. autopickup_ex- + Exceptions can be set with the `O' command, but because they + are not included in your configuration file, they won't be in + effect if you save and then restore your game. autopickup_ex- ception rules and not saved with the game. Here are some examples: @@ -4600,21 +4600,21 @@ autopickup_exception=">*corpse" autopickup_exception=">* cursed*" - The first example above will result in autopickup of any - type of arrow. The second example results in the exclusion of - any corpse from autopickup. The last example results in the ex- + The first example above will result in autopickup of any + type of arrow. The second example results in the exclusion of + any corpse from autopickup. The last example results in the ex- clusion of items known to be cursed from autopickup. 9.9. Changing Key Bindings - It is possible to change the default key bindings of some - special commands, menu accelerator keys, and extended commands, - by using BIND stanzas in the configuration file. Format is key, - followed by the command to bind to, separated by a colon. The + It is possible to change the default key bindings of some + special commands, menu accelerator keys, and extended commands, + by using BIND stanzas in the configuration file. Format is key, + followed by the command to bind to, separated by a colon. The key can be a single character ("x"), a control key ("^X", "C-x"), - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4633,25 +4633,25 @@ BIND=v:loot Extended command keys - You can bind multiple keys to the same extended command. Un- - bind a key by using "nothing" as the extended command to bind - to. You can also bind the "", "", and "" + You can bind multiple keys to the same extended command. Un- + bind a key by using "nothing" as the extended command to bind + to. You can also bind the "", "", and "" keys. Menu accelerator keys - The menu control or accelerator keys can also be rebound via - OPTIONS lines in the configuration file. You cannot bind ob- + The menu control or accelerator keys can also be rebound via + OPTIONS lines in the configuration file. You cannot bind ob- ject symbols into menu accelerators. Special command keys - Below are the special commands you can rebind. Some of them - can be bound to same keys with no problems, others are in the - same "context", and if bound to same keys, only one of those - commands will be available. Special command can only be bound + Below are the special commands you can rebind. Some of them + can be bound to same keys with no problems, others are in the + same "context", and if bound to same keys, only one of those + commands will be available. Special command can only be bound to a single key. count - Prefix key to start a count, to repeat a command this many + Prefix key to start a count, to repeat a command this many times. With number_pad only. Default is `n'. doinv @@ -4661,26 +4661,26 @@ Prefix key to force fight a direction. Default is `F'. fight.numpad - Prefix key to force fight a direction. With number_pad only. + Prefix key to force fight a direction. With number_pad only. Default is `-'. getdir.help - When asked for a direction, the key to show the help. Default + When asked for a direction, the key to show the help. Default is `?'. getdir.self - When asked for a direction, the key to target yourself. De- + When asked for a direction, the key to target yourself. De- fault is `.'. getdir.self2 - When asked for a direction, the key to target yourself. De- + When asked for a direction, the key to target yourself. De- fault is `s'. getpos.autodescribe - When asked for a location, the key to toggle autodescribe. + When asked for a location, the key to toggle autodescribe. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4697,56 +4697,56 @@ esting thing. Default is `a'. getpos.all.prev - When asked for a location, the key to go to previous closest + When asked for a location, the key to go to previous closest interesting thing. Default is `A'. getpos.door.next - When asked for a location, the key to go to next closest door + When asked for a location, the key to go to next closest door or doorway. Default is `d'. getpos.door.prev - When asked for a location, the key to go to previous closest + When asked for a location, the key to go to previous closest door or doorway. Default is `D'. getpos.help - When asked for a location, the key to show help. Default is + When asked for a location, the key to show help. Default is `?'. getpos.mon.next - When asked for a location, the key to go to next closest mon- + When asked for a location, the key to go to next closest mon- ster. Default is `m'. getpos.mon.prev - When asked for a location, the key to go to previous closest + When asked for a location, the key to go to previous closest monster. Default is `M'. getpos.obj.next - When asked for a location, the key to go to next closest ob- + When asked for a location, the key to go to next closest ob- ject. Default is `o'. getpos.obj.prev - When asked for a location, the key to go to previous closest + When asked for a location, the key to go to previous closest object. Default is `O'. getpos.menu - When asked for a location, and using one of the next or previ- - ous keys to cycle through targets, toggle showing a menu in- + When asked for a location, and using one of the next or previ- + ous keys to cycle through targets, toggle showing a menu in- stead. Default is `!'. getpos.moveskip - When asked for a location, and using the shifted movement keys - or meta-digit keys to fast-move around, move by skipping the + When asked for a location, and using the shifted movement keys + or meta-digit keys to fast-move around, move by skipping the same glyphs instead of by 8 units. Default is `*'. getpos.filter When asked for a location, change the filtering mode when using - one of the next or previous keys to cycle through targets. - Toggles between no filtering, in view only, and in the same + one of the next or previous keys to cycle through targets. + Toggles between no filtering, in view only, and in the same area only. Default is `"'. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4757,20 +4757,20 @@ getpos.pick - When asked for a location, the key to choose the location, and + When asked for a location, the key to choose the location, and possibly ask for more info. Default is `.'. getpos.pick.once - When asked for a location, the key to choose the location, and + When asked for a location, the key to choose the location, and skip asking for more info. Default is `,'. getpos.pick.quick When asked for a location, the key to choose the location, skip - asking for more info, and exit the location asking loop. De- + asking for more info, and exit the location asking loop. De- fault is `;'. getpos.pick.verbose - When asked for a location, the key to choose the location, and + When asked for a location, the key to choose the location, and show more info without asking. Default is `:'. getpos.self @@ -4778,23 +4778,23 @@ fault is `@'. getpos.unexplored.next - When asked for a location, the key to go to next closest unex- + When asked for a location, the key to go to next closest unex- plored location. Default is `x'. getpos.unexplored.prev - When asked for a location, the key to go to previous closest + When asked for a location, the key to go to previous closest unexplored location. Default is `X'. getpos.valid - When asked for a location, the key to go to show valid target + When asked for a location, the key to go to show valid target locations. Default is `$'. getpos.valid.next - When asked for a location, the key to go to next closest valid + When asked for a location, the key to go to next closest valid location. Default is `z'. getpos.valid.prev - When asked for a location, the key to go to previous closest + When asked for a location, the key to go to previous closest valid location. Default is `Z'. nopickup @@ -4804,7 +4804,7 @@ Key to redraw the screen. Default is `^R'. redraw.numpad - Key to redraw the screen. With number_pad only. Default is + Key to redraw the screen. With number_pad only. Default is `^L'. repeat @@ -4812,7 +4812,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4829,11 +4829,11 @@ Prefix key to run towards a direction. Default is `G'. run.nopickup - Prefix key to run towards a direction without picking up items + Prefix key to run towards a direction without picking up items on the way. Default is `M'. run.numpad - Prefix key to run towards a direction. With number_pad only. + Prefix key to run towards a direction. With number_pad only. Default is `5'. rush @@ -4844,7 +4844,7 @@ You can change the way the messages are shown in the message area, when the message matches a user-defined pattern. - In general, the configuration file entries to describe the + In general, the configuration file entries to describe the message types look like this: MSGTYPE=type "pattern" type - how the message should be shown; @@ -4857,28 +4857,28 @@ show - show message normally; hide - never show the message; stop - wait for user with more-prompt; - norep - show the message once, but not again if no other mes- + norep - show the message once, but not again if no other mes- sage is shown in between. - Here's an example of message types using NetHack's internal + Here's an example of message types using NetHack's internal pattern matching facility: MSGTYPE=stop "You feel hungry." MSGTYPE=hide "You displaced *." - specifies that whenever a message "You feel hungry" is shown, - the user is prompted with more-prompt, and a message matching + specifies that whenever a message "You feel hungry" is shown, + the user is prompted with more-prompt, and a message matching "You displaced ." is not shown at all. - The order of the defined MSGTYPE lines is important; the last - matching rule is used. Put the general case first, exceptions + The order of the defined MSGTYPE lines is important; the last + matching rule is used. Put the general case first, exceptions below them. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4891,52 +4891,52 @@ 9.11. Configuring Menu Colors Some platforms allow you to define colors used in menu lines - when the line matches a user-defined pattern. At this time the + when the line matches a user-defined pattern. At this time the tty, curses, win32tty and win32gui interfaces support this. - In general, the configuration file entries to describe the + In general, the configuration file entries to describe the menu color mappings look like this: MENUCOLOR="pattern"=color&attribute pattern - the pattern to match; - color - the color to use for lines matching the pat- + color - the color to use for lines matching the pat- tern; - attribute - the attribute to use for lines matching the - pattern. The attribute is optional, and if + attribute - the attribute to use for lines matching the + pattern. The attribute is optional, and if left out, you must also leave out the preced- - ing ampersand. If no attribute is defined, + ing ampersand. If no attribute is defined, no attribute is used. The pattern should be a regular expression. - Allowed colors are black, red, green, brown, blue, magenta, - cyan, gray, orange, light-green, yellow, light-blue, light-ma- - genta, light-cyan, and white. And no-color, the default fore- - ground color, which isn't necessarily the same as any of the + Allowed colors are black, red, green, brown, blue, magenta, + cyan, gray, orange, light-green, yellow, light-blue, light-ma- + genta, light-cyan, and white. And no-color, the default fore- + ground color, which isn't necessarily the same as any of the other colors. - Allowed attributes are none, bold, dim, underline, blink, and - inverse. "Normal" is a synonym for "none". Note that the + Allowed attributes are none, bold, dim, underline, blink, and + inverse. "Normal" is a synonym for "none". Note that the platform used may interpret the attributes any way it wants. - Here's an example of menu colors using NetHack's internal pat- + Here's an example of menu colors using NetHack's internal pat- tern matching facility: MENUCOLOR="* blessed *"=green MENUCOLOR="* cursed *"=red MENUCOLOR="* cursed *(being worn)"=red&underline - specifies that any menu line with " blessed " contained in it - will be shown in green color, lines with " cursed " will be - shown in red, and lines with " cursed " followed by "(being - worn)" on the same line will be shown in red color and under- + specifies that any menu line with " blessed " contained in it + will be shown in green color, lines with " cursed " will be + shown in red, and lines with " cursed " followed by "(being + worn)" on the same line will be shown in red color and under- lined. You can have multiple MENUCOLOR entries in your config- - uration file, and the last MENUCOLOR line that matches a menu + uration file, and the last MENUCOLOR line that matches a menu line will be used for the line. Note that if you intend to have one or more color specifica- - tions match " uncursed ", you will probably want to turn the im- + tions match " uncursed ", you will probably want to turn the im- plicit_uncursed option off so that all items known to be uncursed are actually displayed with the "uncursed" description. @@ -4944,7 +4944,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -4956,23 +4956,23 @@ 9.12. Configuring User Sounds - Some platforms allow you to define sound files to be played - when a message that matches a user-defined pattern is delivered + Some platforms allow you to define sound files to be played + when a message that matches a user-defined pattern is delivered to the message window. At this time the Qt port and the win32tty and win32gui ports support the use of user sounds. - The following configuration file entries are relevant to + The following configuration file entries are relevant to mapping user sounds to messages: SOUNDDIR The directory that houses the sound files to be played. SOUND - An entry that maps a sound file to a user-specified message - pattern. Each SOUND entry is broken down into the following + An entry that maps a sound file to a user-specified message + pattern. Each SOUND entry is broken down into the following parts: - MESG - message window mapping (the only one supported in + MESG - message window mapping (the only one supported in 3.6); pattern - the pattern to match; sound file - the sound file to play; @@ -4983,7 +4983,7 @@ 9.13. Configuring Status Hilites Your copy of NetHack may have been compiled with support for - "Status Hilites". If so, you can customize your game display by + "Status Hilites". If so, you can customize your game display by setting thresholds to change the color or appearance of fields in the status display. @@ -4991,8 +4991,8 @@ OPTION=hilite_status:field-name/behavior/color&attributes - For example, the following line in your configuration file - will cause the hitpoints field to display in the color red if + For example, the following line in your configuration file + will cause the hitpoints field to display in the color red if your hitpoints drop to or below a threshold of 30%: OPTION=hilite_status:hitpoints/<=30%/red/normal @@ -5000,17 +5000,17 @@ (That example is actually specifying red&normal for <=30% and no- color&normal for >30%.) - For another example, the following line in your configura- - tion file will cause wisdom to be displayed red if it drops and + For another example, the following line in your configura- + tion file will cause wisdom to be displayed red if it drops and green if it rises: OPTION=hilite_status:wisdom/down/red/up/green - Allowed colors are black, red, green, brown, blue, magenta, + Allowed colors are black, red, green, brown, blue, magenta, cyan, gray, orange, light-green, yellow, light-blue, light- - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5020,30 +5020,30 @@ - magenta, light-cyan, and white. And "no-color", the default - foreground color on the display, which is not necessarily the + magenta, light-cyan, and white. And "no-color", the default + foreground color on the display, which is not necessarily the same as black or white or any of the other colors. - Allowed attributes are none, bold, dim, underline, blink, - and inverse. "Normal" is a synonym for "none"; they should not + Allowed attributes are none, bold, dim, underline, blink, + and inverse. "Normal" is a synonym for "none"; they should not be used in combination with any of the other attributes. To specify both a color and an attribute, use `&' to combine - them. To specify multiple attributes, use `+' to combine those. + them. To specify multiple attributes, use `+' to combine those. For example: "magenta&inverse+dim". - Note that the display may substitute or ignore particular - attributes depending upon its capabilities, and in general may - interpret the attributes any way it wants. For example, on some + Note that the display may substitute or ignore particular + attributes depending upon its capabilities, and in general may + interpret the attributes any way it wants. For example, on some display systems a request for bold might yield blink or vice ver- sa. On others, issuing an attribute request while another is al- - ready set up will replace the earlier attribute rather than com- - bine with it. Since NetHack issues attribute requests sequen- + ready set up will replace the earlier attribute rather than com- + bine with it. Since NetHack issues attribute requests sequen- tially (at least with the tty interface) rather than all at once, the only way a situation like that can be controlled is to speci- fy just one attribute. - You can adjust the appearance of the following status + You can adjust the appearance of the following status fields: title dungeon-level experience-level strength gold experience @@ -5054,16 +5054,16 @@ charisma armor-class condition alignment score - The pseudo-field "characteristics" can be used to set all six - of Str, Dex, Con, Int, Wis, and Cha at once. "HD" is "hit - dice", an approximation of experience level displayed when - polymorphed. "experience", "time", and "score" are condition- + The pseudo-field "characteristics" can be used to set all six + of Str, Dex, Con, Int, Wis, and Cha at once. "HD" is "hit + dice", an approximation of experience level displayed when + polymorphed. "experience", "time", and "score" are condition- ally displayed depending upon your other option settings. - Instead of a behavior, "condition" takes the following condi- - tion flags: stone, slime, strngl, foodpois, termill, blind, - deaf, stun, conf, hallu, lev, fly, and ride. You can use "ma- - jor_troubles" as an alias for stone through termill, "mi- + Instead of a behavior, "condition" takes the following condi- + tion flags: stone, slime, strngl, foodpois, termill, blind, + deaf, stun, conf, hallu, lev, fly, and ride. You can use "ma- + jor_troubles" as an alias for stone through termill, "mi- nor_troubles" for blind through hallu, "movement" for lev, fly, and ride, and "all" for every condition. @@ -5072,11 +5072,11 @@ * "always" will set the default attributes for that field. - * "up", "down" set the field attributes for when the field - value changes upwards or downwards. This attribute times + * "up", "down" set the field attributes for when the field + value changes upwards or downwards. This attribute times - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5089,52 +5089,52 @@ out after statushilites turns. * "changed" sets the field attribute for when the field val- - ue changes. This attribute times out after statushilites - turns. (If a field has both a "changed" rule and an "up" - or "down" rule which matches a change in the field's val- + ue changes. This attribute times out after statushilites + turns. (If a field has both a "changed" rule and an "up" + or "down" rule which matches a change in the field's val- ue, the "up" or "down" one takes precedence.) - * percentage sets the field attribute when the field value - matches the percentage. It is specified as a number be- - tween 0 and 100, followed by `%' (percent sign). If the - percentage is prefixed with `<=' or `>=', it also matches - when value is below or above the percentage. Use prefix - `<' or `>' to match when strictly below or above. (The - numeric limit is relaxed slightly for those: >-1% and - <101% are allowed.) Only four fields support percentage - rules. Percentages for "hitpoints" and "power" are - straightforward; they're based on the corresponding maxi- - mum field. Percentage highlight rules are also allowed + * percentage sets the field attribute when the field value + matches the percentage. It is specified as a number be- + tween 0 and 100, followed by `%' (percent sign). If the + percentage is prefixed with `<=' or `>=', it also matches + when value is below or above the percentage. Use prefix + `<' or `>' to match when strictly below or above. (The + numeric limit is relaxed slightly for those: >-1% and + <101% are allowed.) Only four fields support percentage + rules. Percentages for "hitpoints" and "power" are + straightforward; they're based on the corresponding maxi- + mum field. Percentage highlight rules are also allowed for "experience level" and "experience points" (valid when the showexp option is enabled). For those, the percentage is based on the progress from the start of the current ex- perience level to the start of the next level. So if lev- - el 2 starts at 20 points and level 3 starts at 40 points, - having 30 points is 50% and 35 points is 75%. 100% is - unattainable for experience because you'll gain a level + el 2 starts at 20 points and level 3 starts at 40 points, + having 30 points is 50% and 35 points is 75%. 100% is + unattainable for experience because you'll gain a level and the calculations will be reset for that new level, but - a rule for =100% is allowed and matches the special case + a rule for =100% is allowed and matches the special case of being exactly 1 experience point short of the next lev- el. - * absolute value sets the attribute when the field value - matches that number. The number must be 0 or higher, ex- - cept for "armor-class' which allows negative values, and - may optionally be preceded by `='. If the number is pre- - ceded by `<=' or `>=' instead, it also matches when value - is below or above. If the prefix is `<' or `>', only + * absolute value sets the attribute when the field value + matches that number. The number must be 0 or higher, ex- + cept for "armor-class' which allows negative values, and + may optionally be preceded by `='. If the number is pre- + ceded by `<=' or `>=' instead, it also matches when value + is below or above. If the prefix is `<' or `>', only match when strictly above or below. * text match sets the attribute when the field value matches - the text. Text matches can only be used for "alignment", - "carrying-capacity", "hunger", "dungeon-level", and "ti- - tle". For title, only the role's rank title is tested; + the text. Text matches can only be used for "alignment", + "carrying-capacity", "hunger", "dungeon-level", and "ti- + tle". For title, only the role's rank title is tested; the character's name is ignored. - The in-game options menu can help you determine the correct + The in-game options menu can help you determine the correct syntax for a configuration file. - The whole feature can be disabled by setting option sta- + The whole feature can be disabled by setting option sta- tushilites to 0. Example hilites: @@ -5142,7 +5142,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5167,23 +5167,23 @@ NetHack can load entire symbol sets from the symbol file. - The options that are used to select a particular symbol set + The options that are used to select a particular symbol set from the symbol file are: symset Set the name of the symbol set that you want to load. roguesymset - Set the name of the symbol set that you want to load for dis- + Set the name of the symbol set that you want to load for dis- play on the rogue level. - You can also override one or more symbols using the SYMBOLS - and ROGUESYMBOLS configuration file options. Symbols are speci- + You can also override one or more symbols using the SYMBOLS + and ROGUESYMBOLS configuration file options. Symbols are speci- fied as name:value pairs. Note that NetHack escape-processes the - value string in conventional C fashion. This means that \ is a - prefix to take the following character literally. Thus \ needs - to be represented as \\. The special prefix form \m switches on - the meta bit in the symbol value, and the ^ prefix causes the + value string in conventional C fashion. This means that \ is a + prefix to take the following character literally. Thus \ needs + to be represented as \\. The special prefix form \m switches on + the meta bit in the symbol value, and the ^ prefix causes the following character to be treated as a control character. NetHack Symbols @@ -5208,7 +5208,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5274,7 +5274,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5340,7 +5340,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5406,7 +5406,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5422,57 +5422,57 @@ Notes: * Several symbols in this table appear to be blank. They are the - space character, except for S_pet_override and S_hero_override - which don't have any default value and can only be used if en- + space character, except for S_pet_override and S_hero_override + which don't have any default value and can only be used if en- abled in the "sysconf" file. - * S_rock is misleadingly named; rocks and stones use S_gem. - Statues and boulders are the rock being referred to, but since - version 3.6.0, statues are displayed as the monster they de- - pict. So S_rock is only used for boulders and not used at all + * S_rock is misleadingly named; rocks and stones use S_gem. + Statues and boulders are the rock being referred to, but since + version 3.6.0, statues are displayed as the monster they de- + pict. So S_rock is only used for boulders and not used at all if overridden by the more specific S_boulder. 9.15. Configuring NetHack for Play by the Blind - NetHack can be set up to use only standard ASCII characters - for making maps of the dungeons. This makes the MS-DOS versions - of NetHack completely accessible to the blind who use speech - and/or Braille access technologies. Players will require a good - working knowledge of their screen-reader's review features, and - will have to know how to navigate horizontally and vertically - character by character. They will also find the search capabili- - ties of their screen-readers to be quite valuable. Be certain to - examine this Guidebook before playing so you have an idea what - the screen layout is like. You'll also need to be able to locate - the PC cursor. It is always where your character is located. - Merely searching for an @-sign will not always find your charac- + NetHack can be set up to use only standard ASCII characters + for making maps of the dungeons. This makes the MS-DOS versions + of NetHack completely accessible to the blind who use speech + and/or Braille access technologies. Players will require a good + working knowledge of their screen-reader's review features, and + will have to know how to navigate horizontally and vertically + character by character. They will also find the search capabili- + ties of their screen-readers to be quite valuable. Be certain to + examine this Guidebook before playing so you have an idea what + the screen layout is like. You'll also need to be able to locate + the PC cursor. It is always where your character is located. + Merely searching for an @-sign will not always find your charac- ter since there are other humanoids represented by the same sign. - Your screen-reader should also have a function which gives you - the row and column of your review cursor and the PC cursor. - These co-ordinates are often useful in giving players a better + Your screen-reader should also have a function which gives you + the row and column of your review cursor and the PC cursor. + These co-ordinates are often useful in giving players a better sense of the overall location of items on the screen. - NetHack can also be compiled with support for sending the - game messages to an external program, such as a text-to-speech - synthesizer. If the "#version" extended command shows "external - program as a message handler", your NetHack has been compiled + NetHack can also be compiled with support for sending the + game messages to an external program, such as a text-to-speech + synthesizer. If the "#version" extended command shows "external + program as a message handler", your NetHack has been compiled with the capability. When compiling NetHack from source on Linux - and other POSIX systems, define MSGHANDLER to enable it. To use - the capability, set the environment variable NETHACK_MSGHANDLER + and other POSIX systems, define MSGHANDLER to enable it. To use + the capability, set the environment variable NETHACK_MSGHANDLER to an executable, which will be executed with the game message as the program's only parameter. - While it is not difficult for experienced users to edit the - defaults.nh file to accomplish this, novices may find this task + While it is not difficult for experienced users to edit the + defaults.nh file to accomplish this, novices may find this task somewhat daunting. Included within the "symbols" file of all of- ficial distributions of NetHack is a symset called NHAccess. Se- - lecting that symset in your configuration file will cause the - game to run in a manner accessible to the blind. After you have - gained some experience with the game and with editing files, you + lecting that symset in your configuration file will cause the + game to run in a manner accessible to the blind. After you have + gained some experience with the game and with editing files, you may want to alter settings via SYMBOLS= and ROGUESYMBOLS= in your - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5483,19 +5483,19 @@ configuration file to better suit your preferences. See the pre- - vious section for the special symbols S_pet_override to force a - consistent symbol for all pets and S_hero_override to force a - unique symbol for the player character if accessibility is en- + vious section for the special symbols S_pet_override to force a + consistent symbol for all pets and S_hero_override to force a + unique symbol for the player character if accessibility is en- abled in the sysconf file. - The most crucial settings to make the game more accessible + The most crucial settings to make the game more accessible are: symset:NHAccess Load a symbol set appropriate for use by blind players. roguesymset:NHAccess - Load a symbol set for the rogue level that is appropriate for + Load a symbol set for the rogue level that is appropriate for use by blind players. menustyle:traditional @@ -5505,40 +5505,40 @@ Show menus on a cleared screen and aligned to the left edge. number_pad - A lot of speech access programs use the number-pad to review + A lot of speech access programs use the number-pad to review the screen. If this is the case, disable the number_pad option and use the traditional Rogue-like commands. autodescribe - Automatically describe the terrain under the cursor when tar- + Automatically describe the terrain under the cursor when tar- geting. mention_walls - Give feedback messages when walking towards a wall or when + Give feedback messages when walking towards a wall or when travel command was interrupted. whatis_coord:compass - When targeting with cursor, describe the cursor position with + When targeting with cursor, describe the cursor position with coordinates relative to your character. whatis_filter:area - When targeting with cursor, filter possible locations so only - those in the same area (eg. same room, or same corridor) are + When targeting with cursor, filter possible locations so only + those in the same area (eg. same room, or same corridor) are considered. whatis_moveskip - When targeting with cursor and using fast-move, skip the same + When targeting with cursor and using fast-move, skip the same glyphs instead of moving 8 units at a time. nostatus_updates - Prevent updates to the status lines at the bottom of the - screen, if your screen-reader reads those lines. The same in- + Prevent updates to the status lines at the bottom of the + screen, if your screen-reader reads those lines. The same in- formation can be seen via the "#attributes" command. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5550,16 +5550,16 @@ 9.16. Global Configuration for System Administrators - If NetHack is compiled with the SYSCF option, a system ad- - ministrator should set up a global configuration; this is a file + If NetHack is compiled with the SYSCF option, a system ad- + ministrator should set up a global configuration; this is a file in the same format as the traditional per-user configuration file (see above). This file should be named sysconf and placed in the - same directory as the other NetHack support files. The options + same directory as the other NetHack support files. The options recognized in this file are listed below. Any option not set us- - es a compiled-in default (which may not be appropriate for your + es a compiled-in default (which may not be appropriate for your system). - WIZARDS = A space-separated list of user names who are allowed + WIZARDS = A space-separated list of user names who are allowed to play in debug mode (commonly referred to as wizard mode). A value of a single asterisk (*) allows anyone to start a game in debug mode. @@ -5567,28 +5567,28 @@ SHELLERS = A list of users who are allowed to use the shell es- cape command (!). The syntax is the same as WIZARDS. - EXPLORERS = A list of users who are allowed to use the explore + EXPLORERS = A list of users who are allowed to use the explore mode. The syntax is the same as WIZARDS. MAXPLAYERS = Limit the maximum number of games that can be run- ning at the same time. - SUPPORT = A string explaining how to get local support (no de- + SUPPORT = A string explaining how to get local support (no de- fault value). - RECOVER = A string explaining how to recover a game on this + RECOVER = A string explaining how to recover a game on this system (no default value). - SEDUCE = 0 or 1 to disable or enable, respectively, the SEDUCE + SEDUCE = 0 or 1 to disable or enable, respectively, the SEDUCE option. When disabled, incubi and succubi behave like nymphs. - CHECK_PLNAME = Setting this to 1 will make the EXPLORERS, WIZ- + CHECK_PLNAME = Setting this to 1 will make the EXPLORERS, WIZ- ARDS, and SHELLERS check for the player name instead of the us- er's login name. CHECK_SAVE_UID = 0 or 1 to disable or enable, respectively, the - UID (used identification number) checking for save files (to - verify that the user who is restoring is the same one who + UID (used identification number) checking for save files (to + verify that the user who is restoring is the same one who saved). The following options affect the score file: @@ -5597,14 +5597,14 @@ ENTRYMAX = Maximum number of entries in the score file. - POINTSMIN = Minimum number of points to get an entry in the + POINTSMIN = Minimum number of points to get an entry in the score file. - PERS_IS_UID = 0 or 1 to use user names or numeric userids, re- + PERS_IS_UID = 0 or 1 to use user names or numeric userids, re- spectively, to identify unique people for the score file. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5614,20 +5614,20 @@ - MAX_STATUENAME_RANK = Maximum number of score file entries to + MAX_STATUENAME_RANK = Maximum number of score file entries to use for random statue names (default is 10). - ACCESSIBILITY = 0 or 1 to disable or enable, respectively, the - ability for players to set S_pet_override and S_hero_override + ACCESSIBILITY = 0 or 1 to disable or enable, respectively, the + ability for players to set S_pet_override and S_hero_override symbols in their configuration file. - PORTABLE_DEVICE_PATHS = 0 or 1 Windows OS only, the game will - look for all of its external files, and write to all of its - output files in one place rather than at the standard loca- + PORTABLE_DEVICE_PATHS = 0 or 1 Windows OS only, the game will + look for all of its external files, and write to all of its + output files in one place rather than at the standard loca- tions. DUMPLOGFILE = A filename where the end-of-game dumplog is - saved. Not defining this will prevent dumplog from being cre- + saved. Not defining this will prevent dumplog from being cre- ated. Only available if your game is compiled with DUMPLOG. Al- lows the following placeholders: @@ -5643,26 +5643,26 @@ 10. Scoring - NetHack maintains a list of the top scores or scorers on + NetHack maintains a list of the top scores or scorers on your machine, depending on how it is set up. In the latter case, - each account on the machine can post only one non-winning score - on this list. If you score higher than someone else on this - list, or better your previous score, you will be inserted in the - proper place under your current name. How many scores are kept + each account on the machine can post only one non-winning score + on this list. If you score higher than someone else on this + list, or better your previous score, you will be inserted in the + proper place under your current name. How many scores are kept can also be set up when NetHack is compiled. - Your score is chiefly based upon how much experience you + Your score is chiefly based upon how much experience you gained, how much loot you accumulated, how deep you explored, and how the game ended. If you quit the game, you escape with all of - your gold intact. If, however, you get killed in the Mazes of + your gold intact. If, however, you get killed in the Mazes of Menace, the guild will only hear about 90% of your gold when your - corpse is discovered (adventurers have been known to collect - finder's fees). So, consider whether you want to take one last - hit at that monster and possibly live, or quit and stop with - whatever you have. If you quit, you keep all your gold, but if + corpse is discovered (adventurers have been known to collect + finder's fees). So, consider whether you want to take one last + hit at that monster and possibly live, or quit and stop with + whatever you have. If you quit, you keep all your gold, but if you swing and live, you might find more. - If you just want to see what the current top players/games + If you just want to see what the current top players/games list is, you can type nethack -s all on most versions. @@ -5670,7 +5670,7 @@ - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5682,61 +5682,61 @@ 11. Explore mode - NetHack is an intricate and difficult game. Novices might + NetHack is an intricate and difficult game. Novices might falter in fear, aware of their ignorance of the means to survive. Well, fear not. Your dungeon comes equipped with an "explore" or - "discovery" mode that enables you to keep old save files and - cheat death, at the paltry cost of not getting on the high score + "discovery" mode that enables you to keep old save files and + cheat death, at the paltry cost of not getting on the high score list. - There are two ways of enabling explore mode. One is to - start the game with the -X command-line switch or with the play- - mode:explore option. The other is to issue the "#exploremode" - extended command while already playing the game. Starting a new + There are two ways of enabling explore mode. One is to + start the game with the -X command-line switch or with the play- + mode:explore option. The other is to issue the "#exploremode" + extended command while already playing the game. Starting a new game in explore mode provides your character with a wand of wish- - ing in initial inventory; switching during play does not. The - other benefits of explore mode are left for the trepid reader to + ing in initial inventory; switching during play does not. The + other benefits of explore mode are left for the trepid reader to discover. 11.1. Debug mode Debug mode, also known as wizard mode, is undocumented aside - from this brief description and the various "debug mode only" - commands listed among the command descriptions. It is intended + from this brief description and the various "debug mode only" + commands listed among the command descriptions. It is intended for tracking down problems within the program rather than to pro- - vide god-like powers to your character, and players who attempt - debugging are expected to figure out how to use it themselves. - It is initiated by starting the game with the -D command-line + vide god-like powers to your character, and players who attempt + debugging are expected to figure out how to use it themselves. + It is initiated by starting the game with the -D command-line switch or with the playmode:debug option. - For some systems, the player must be logged in under a par- - ticular user name to be allowed to use debug mode; for others, - the hero must be given a particular character name (but may be - any role; there's no connection between "wizard mode" and the - Wizard role). Attempting to start a game in debug mode when not - allowed or not available will result in falling back to explore + For some systems, the player must be logged in under a par- + ticular user name to be allowed to use debug mode; for others, + the hero must be given a particular character name (but may be + any role; there's no connection between "wizard mode" and the + Wizard role). Attempting to start a game in debug mode when not + allowed or not available will result in falling back to explore mode instead. 12. Credits - The original hack game was modeled on the Berkeley UNIX - rogue game. Large portions of this paper were shamelessly - cribbed from A Guide to the Dungeons of Doom, by Michael C. Toy - and Kenneth C. R. C. Arnold. Small portions were adapted from + The original hack game was modeled on the Berkeley UNIX + rogue game. Large portions of this paper were shamelessly + cribbed from A Guide to the Dungeons of Doom, by Michael C. Toy + and Kenneth C. R. C. Arnold. Small portions were adapted from Further Exploration of the Dungeons of Doom, by Ken Arromdee. NetHack is the product of literally dozens of people's work. - Main events in the course of the game development are described + Main events in the course of the game development are described below: - Jay Fenlason wrote the original Hack, with help from Kenny + Jay Fenlason wrote the original Hack, with help from Kenny Woodland, Mike Thome and Jon Payne. Andries Brouwer did a major re-write, transforming Hack into - a very different game, and published (at least) three versions + a very different game, and published (at least) three versions - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5748,17 +5748,17 @@ (1.0.1, 1.0.2, and 1.0.3) for UNIX machines to the Usenet. - Don G. Kneller ported Hack 1.0.3 to Microsoft C and MS-DOS, - producing PC HACK 1.01e, added support for DEC Rainbow graphics - in version 1.03g, and went on to produce at least four more ver- + Don G. Kneller ported Hack 1.0.3 to Microsoft C and MS-DOS, + producing PC HACK 1.01e, added support for DEC Rainbow graphics + in version 1.03g, and went on to produce at least four more ver- sions (3.0, 3.2, 3.51, and 3.6). - R. Black ported PC HACK 3.51 to Lattice C and the Atari + R. Black ported PC HACK 3.51 to Lattice C and the Atari 520/1040ST, producing ST Hack 1.03. Mike Stephenson merged these various versions back together, - incorporating many of the added features, and produced NetHack - 1.4. He then coordinated a cast of thousands in enhancing and + incorporating many of the added features, and produced NetHack + 1.4. He then coordinated a cast of thousands in enhancing and debugging NetHack 1.4 and released NetHack versions 2.2 and 2.3. Later, Mike coordinated a major rewrite of the game, heading @@ -5766,43 +5766,43 @@ Creps, Eric Hendrickson, Izchak Miller, John Rupley, Mike Threep- oint, and Janet Walz, to produce NetHack 3.0c. - NetHack 3.0 was ported to the Atari by Eric R. Smith, to - OS/2 by Timo Hakulinen, and to VMS by David Gentzel. The three + NetHack 3.0 was ported to the Atari by Eric R. Smith, to + OS/2 by Timo Hakulinen, and to VMS by David Gentzel. The three of them and Kevin Darcy later joined the main NetHack Development Team to produce subsequent revisions of 3.0. - Olaf Seibert ported NetHack 2.3 and 3.0 to the Amiga. Norm - Meluch, Stephen Spackman and Pierre Martineau designed overlay - code for PC NetHack 3.0. Johnny Lee ported NetHack 3.0 to the - Macintosh. Along with various other Dungeoneers, they continued - to enhance the PC, Macintosh, and Amiga ports through the later + Olaf Seibert ported NetHack 2.3 and 3.0 to the Amiga. Norm + Meluch, Stephen Spackman and Pierre Martineau designed overlay + code for PC NetHack 3.0. Johnny Lee ported NetHack 3.0 to the + Macintosh. Along with various other Dungeoneers, they continued + to enhance the PC, Macintosh, and Amiga ports through the later revisions of 3.0. - Headed by Mike Stephenson and coordinated by Izchak Miller - and Janet Walz, the NetHack Development Team which now included - Ken Arromdee, David Cohrs, Jean-Christophe Collet, Kevin Darcy, - Matt Day, Timo Hakulinen, Steve Linhart, Dean Luick, Pat Rankin, + Headed by Mike Stephenson and coordinated by Izchak Miller + and Janet Walz, the NetHack Development Team which now included + Ken Arromdee, David Cohrs, Jean-Christophe Collet, Kevin Darcy, + Matt Day, Timo Hakulinen, Steve Linhart, Dean Luick, Pat Rankin, Eric Raymond, and Eric Smith undertook a radical revision of 3.0. They re-structured the game's design, and re-wrote major parts of - the code. They added multiple dungeons, a new display, special - individual character quests, a new endgame and many other new + the code. They added multiple dungeons, a new display, special + individual character quests, a new endgame and many other new features, and produced NetHack 3.1. - Ken Lorber, Gregg Wonderly and Greg Olson, with help from - Richard Addison, Mike Passaretti, and Olaf Seibert, developed + Ken Lorber, Gregg Wonderly and Greg Olson, with help from + Richard Addison, Mike Passaretti, and Olaf Seibert, developed NetHack 3.1 for the Amiga. - Norm Meluch and Kevin Smolkowski, with help from Carl Sche- + Norm Meluch and Kevin Smolkowski, with help from Carl Sche- lin, Stephen Spackman, Steve VanDevender, and Paul Winner, ported NetHack 3.1 to the PC. Jon W{tte and Hao-yang Wang, with help from Ross Brown, Mike - Engber, David Hairston, Michael Hamel, Jonathan Handler, Johnny - Lee, Tim Lennan, Rob Menke, and Andy Swanson, developed NetHack - 3.1 for the Macintosh, porting it for MPW. Building on their + Engber, David Hairston, Michael Hamel, Jonathan Handler, Johnny + Lee, Tim Lennan, Rob Menke, and Andy Swanson, developed NetHack + 3.1 for the Macintosh, porting it for MPW. Building on their - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5815,60 +5815,60 @@ development, Bart House added a Think C port. Timo Hakulinen ported NetHack 3.1 to OS/2. Eric Smith port- - ed NetHack 3.1 to the Atari. Pat Rankin, with help from Joshua - Delahunty, was responsible for the VMS version of NetHack 3.1. + ed NetHack 3.1 to the Atari. Pat Rankin, with help from Joshua + Delahunty, was responsible for the VMS version of NetHack 3.1. Michael Allison ported NetHack 3.1 to Windows NT. - Dean Luick, with help from David Cohrs, developed NetHack - 3.1 for X11. Warwick Allison wrote a tiled version of NetHack - for the Atari; he later contributed the tiles to the NetHack De- - velopment Team and tile support was then added to other plat- + Dean Luick, with help from David Cohrs, developed NetHack + 3.1 for X11. Warwick Allison wrote a tiled version of NetHack + for the Atari; he later contributed the tiles to the NetHack De- + velopment Team and tile support was then added to other plat- forms. The 3.2 NetHack Development Team, comprised of Michael Alli- son, Ken Arromdee, David Cohrs, Jessie Collet, Steve Creps, Kevin Darcy, Timo Hakulinen, Steve Linhart, Dean Luick, Pat Rankin, Er- - ic Smith, Mike Stephenson, Janet Walz, and Paul Winner, released + ic Smith, Mike Stephenson, Janet Walz, and Paul Winner, released version 3.2 in April of 1996. Version 3.2 marked the tenth anniversary of the formation of - the development team. In a testament to their dedication to the - game, all thirteen members of the original NetHack Development - Team remained on the team at the start of work on that release. - During the interval between the release of 3.1.3 and 3.2, one of - the founding members of the NetHack Development Team, Dr. Izchak - Miller, was diagnosed with cancer and passed away. That release - of the game was dedicated to him by the development and porting + the development team. In a testament to their dedication to the + game, all thirteen members of the original NetHack Development + Team remained on the team at the start of work on that release. + During the interval between the release of 3.1.3 and 3.2, one of + the founding members of the NetHack Development Team, Dr. Izchak + Miller, was diagnosed with cancer and passed away. That release + of the game was dedicated to him by the development and porting teams. During the lifespan of NetHack 3.1 and 3.2, several enthusi- - asts of the game added their own modifications to the game and + asts of the game added their own modifications to the game and made these "variants" publicly available: - Tom Proudfoot and Yuval Oren created NetHack++, which was - quickly renamed NetHack--. Working independently, Stephen White - wrote NetHack Plus. Tom Proudfoot later merged NetHack Plus and + Tom Proudfoot and Yuval Oren created NetHack++, which was + quickly renamed NetHack--. Working independently, Stephen White + wrote NetHack Plus. Tom Proudfoot later merged NetHack Plus and his own NetHack-- to produce SLASH. Larry Stewart-Zerba and War- - wick Allison improved the spell casting system with the Wizard - Patch. Warwick Allison also ported NetHack to use the Qt inter- + wick Allison improved the spell casting system with the Wizard + Patch. Warwick Allison also ported NetHack to use the Qt inter- face. - Warren Cheung combined SLASH with the Wizard Patch to pro- - duce Slash'EM, and with the help of Kevin Hugo, added more fea- - tures. Kevin later joined the NetHack Development Team and in- + Warren Cheung combined SLASH with the Wizard Patch to pro- + duce Slash'EM, and with the help of Kevin Hugo, added more fea- + tures. Kevin later joined the NetHack Development Team and in- corporated the best of these ideas in NetHack 3.3. The final update to 3.2 was the bug fix release 3.2.3, which - was released simultaneously with 3.3.0 in December 1999 just in + was released simultaneously with 3.3.0 in December 1999 just in time for the Year 2000. - The 3.3 NetHack Development Team, consisting of Michael Al- - lison, Ken Arromdee, David Cohrs, Jessie Collet, Steve Creps, - Kevin Darcy, Timo Hakulinen, Kevin Hugo, Steve Linhart, Ken Lor- - ber, Dean Luick, Pat Rankin, Eric Smith, Mike Stephenson, Janet + The 3.3 NetHack Development Team, consisting of Michael Al- + lison, Ken Arromdee, David Cohrs, Jessie Collet, Steve Creps, + Kevin Darcy, Timo Hakulinen, Kevin Hugo, Steve Linhart, Ken Lor- + ber, Dean Luick, Pat Rankin, Eric Smith, Mike Stephenson, Janet - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5878,53 +5878,53 @@ - Walz, and Paul Winner, released 3.3.0 in December 1999 and 3.3.1 + Walz, and Paul Winner, released 3.3.0 in December 1999 and 3.3.1 in August of 2000. Version 3.3 offered many firsts. It was the first version to - separate race and profession. The Elf class was removed in pref- + separate race and profession. The Elf class was removed in pref- erence to an elf race, and the races of dwarves, gnomes, and orcs - made their first appearance in the game alongside the familiar - human race. Monk and Ranger roles joined Archeologists, Barbar- - ians, Cavemen, Healers, Knights, Priests, Rogues, Samurai, - Tourists, Valkyries and of course, Wizards. It was also the - first version to allow you to ride a steed, and was the first - version to have a publicly available web-site listing all the - bugs that had been discovered. Despite that constantly growing - bug list, 3.3 proved stable enough to last for more than a year + made their first appearance in the game alongside the familiar + human race. Monk and Ranger roles joined Archeologists, Barbar- + ians, Cavemen, Healers, Knights, Priests, Rogues, Samurai, + Tourists, Valkyries and of course, Wizards. It was also the + first version to allow you to ride a steed, and was the first + version to have a publicly available web-site listing all the + bugs that had been discovered. Despite that constantly growing + bug list, 3.3 proved stable enough to last for more than a year and a half. - The 3.4 NetHack Development Team initially consisted of - Michael Allison, Ken Arromdee, David Cohrs, Jessie Collet, Kevin - Hugo, Ken Lorber, Dean Luick, Pat Rankin, Mike Stephenson, Janet - Walz, and Paul Winner, with Warwick Allison joining just before + The 3.4 NetHack Development Team initially consisted of + Michael Allison, Ken Arromdee, David Cohrs, Jessie Collet, Kevin + Hugo, Ken Lorber, Dean Luick, Pat Rankin, Mike Stephenson, Janet + Walz, and Paul Winner, with Warwick Allison joining just before the release of NetHack 3.4.0 in March 2002. - As with version 3.3, various people contributed to the game + As with version 3.3, various people contributed to the game as a whole as well as supporting ports on the different platforms that NetHack runs on: Pat Rankin maintained 3.4 for VMS. - Michael Allison maintained NetHack 3.4 for the MS-DOS plat- + Michael Allison maintained NetHack 3.4 for the MS-DOS plat- form. Paul Winner and Yitzhak Sapir provided encouragement. - Dean Luick, Mark Modrall, and Kevin Hugo maintained and en- + Dean Luick, Mark Modrall, and Kevin Hugo maintained and en- hanced the Macintosh port of 3.4. - Michael Allison, David Cohrs, Alex Kompel, Dion Nicolaas, - and Yitzhak Sapir maintained and enhanced 3.4 for the Microsoft + Michael Allison, David Cohrs, Alex Kompel, Dion Nicolaas, + and Yitzhak Sapir maintained and enhanced 3.4 for the Microsoft Windows platform. Alex Kompel contributed a new graphical inter- - face for the Windows port. Alex Kompel also contributed a Win- + face for the Windows port. Alex Kompel also contributed a Win- dows CE port for 3.4.1. Ron Van Iwaarden was the sole maintainer of NetHack for OS/2 - the past several releases. Unfortunately Ron's last OS/2 machine - stopped working in early 2006. A great many thanks to Ron for + the past several releases. Unfortunately Ron's last OS/2 machine + stopped working in early 2006. A great many thanks to Ron for keeping NetHack alive on OS/2 all these years. - Janne Salmijarvi and Teemu Suikki maintained and enhanced - the Amiga port of 3.4 after Janne Salmijarvi resurrected it for + Janne Salmijarvi and Teemu Suikki maintained and enhanced + the Amiga port of 3.4 after Janne Salmijarvi resurrected it for 3.3.1. Christian "Marvin" Bressler maintained 3.4 for the Atari af- @@ -5934,7 +5934,7 @@ ginning of a long release hiatus. 3.4.3 proved to be a remarkably - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -5945,62 +5945,62 @@ stable version that provided continued enjoyment by the community - for more than a decade. The NetHack Development Team slowly and - quietly continued to work on the game behind the scenes during - the tenure of 3.4.3. It was during that same period that several + for more than a decade. The NetHack Development Team slowly and + quietly continued to work on the game behind the scenes during + the tenure of 3.4.3. It was during that same period that several new variants emerged within the NetHack community. Notably sporkhack by Derek S. Ray, unnethack by Patric Mueller, nitrohack - and its successors originally by Daniel Thaler and then by Alex - Smith, and Dynahack by Tung Nguyen. Some of those variants con- - tinue to be developed, maintained, and enjoyed by the community + and its successors originally by Daniel Thaler and then by Alex + Smith, and Dynahack by Tung Nguyen. Some of those variants con- + tinue to be developed, maintained, and enjoyed by the community to this day. In September 2014, an interim snapshot of the code under de- velopment was released publicly by other parties. Since that code - was a work-in-progress and had not gone through the process of - debugging it as a suitable release, it was decided that the ver- - sion numbers present on that code snapshot would be retired and - never used in an official NetHack release. An announcement was - posted on the NetHack Development Team's official nethack.org - website to that effect, stating that there would never be a + was a work-in-progress and had not gone through the process of + debugging it as a suitable release, it was decided that the ver- + sion numbers present on that code snapshot would be retired and + never used in an official NetHack release. An announcement was + posted on the NetHack Development Team's official nethack.org + website to that effect, stating that there would never be a 3.4.4, 3.5, or 3.5.0 official release version. - In January 2015, preparation began for the release of + In January 2015, preparation began for the release of NetHack 3.6. - At the beginning of development for what would eventually - get released as 3.6.0, the NetHack Development Team consisted of - Warwick Allison, Michael Allison, Ken Arromdee, David Cohrs, - Jessie Collet, Ken Lorber, Dean Luick, Pat Rankin, Mike Stephen- - son, Janet Walz, and Paul Winner. In early 2015, ahead of the + At the beginning of development for what would eventually + get released as 3.6.0, the NetHack Development Team consisted of + Warwick Allison, Michael Allison, Ken Arromdee, David Cohrs, + Jessie Collet, Ken Lorber, Dean Luick, Pat Rankin, Mike Stephen- + son, Janet Walz, and Paul Winner. In early 2015, ahead of the release of 3.6.0, new members Sean Hunt, Pasi Kallinen, and Derek S. Ray joined the NetHack Development Team. Near the end of the development of 3.6.0, one of the signif- - icant inspirations for many of the humorous and fun features - found in the game, author Terry Pratchett, passed away. NetHack + icant inspirations for many of the humorous and fun features + found in the game, author Terry Pratchett, passed away. NetHack 3.6.0 introduced a tribute to him. 3.6.0 was released in December 2015, and merged work done by - the development team since the release of 3.4.3 with some of the + the development team since the release of 3.4.3 with some of the beloved community patches. Many bugs were fixed and some code was restructured. - The NetHack Development Team, as well as Steve VanDevender + The NetHack Development Team, as well as Steve VanDevender and Kevin Smolkowski, ensured that NetHack 3.6 continued to oper- ate on various UNIX flavors and maintained the X11 interface. - Ken Lorber, Haoyang Wang, Pat Rankin, and Dean Luick main- + Ken Lorber, Haoyang Wang, Pat Rankin, and Dean Luick main- tained the port of NetHack 3.6 for Mac OSX. - Michael Allison, David Cohrs, Bart House, Pasi Kallinen, - Alex Kompel, Dion Nicolaas, Derek S. Ray and Yitzhak Sapir main- + Michael Allison, David Cohrs, Bart House, Pasi Kallinen, + Alex Kompel, Dion Nicolaas, Derek S. Ray and Yitzhak Sapir main- tained the port of NetHack 3.6 for Microsoft Windows. - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -6010,43 +6010,46 @@ - Pat Rankin attempted to keep the VMS port running for + Pat Rankin attempted to keep the VMS port running for NetHack 3.6, hindered by limited access. Kevin Smolkowski has up- - dated and tested it for the most recent version of OpenVMS (V8.4 + dated and tested it for the most recent version of OpenVMS (V8.4 as of this writing) on Alpha and Integrity (aka Itanium aka IA64) but not VAX. - Ray Chason resurrected the msdos port for 3.6 and contrib- + Ray Chason resurrected the msdos port for 3.6 and contrib- uted the necessary updates to the community at large. - In late April 2018, several hundred bug fixes for 3.6.0 and - some new features were assembled and released as NetHack 3.6.1. + In late April 2018, several hundred bug fixes for 3.6.0 and + some new features were assembled and released as NetHack 3.6.1. The NetHack Development Team at the time of release of 3.6.1 con- - sisted of Warwick Allison, Michael Allison, Ken Arromdee, David - Cohrs, Jessie Collet, Pasi Kallinen, Ken Lorber, Dean Luick, - Patric Mueller, Pat Rankin, Derek S. Ray, Alex Smith, Mike + sisted of Warwick Allison, Michael Allison, Ken Arromdee, David + Cohrs, Jessie Collet, Pasi Kallinen, Ken Lorber, Dean Luick, + Patric Mueller, Pat Rankin, Derek S. Ray, Alex Smith, Mike Stephenson, Janet Walz, and Paul Winner. In early May 2019, another 320 bug fixes along with some en- - hancements and the adopted curses window port, were released as + hancements and the adopted curses window port, were released as 3.6.2. - Bart House, who had contributed to the game as a porting + Bart House, who had contributed to the game as a porting team participant for decades, joined the NetHack Development Team in late May 2019. - NetHack 3.6.3 was released on December 5, 2019 containing + NetHack 3.6.3 was released on December 5, 2019 containing over 190 bug fixes to NetHack 3.6.2. NetHack 3.6.4 was released on December 18, 2019 containing a security fix and a few bug fixes. - NetHack 3.6.5 was released on January 27, 2020 containing + NetHack 3.6.5 was released on January 27, 2020 containing some security fixes and a small number of bug fixes. NetHack 3.6.6 was released on March 8, 2020 containing a se- curity fix and some bug fixes. + NetHack 3.6.7 was released in February 2023 containing a se- + curity fix and some bug fixes. + The official NetHack web site is maintained by Ken Lorber at https://www.nethack.org/. @@ -6060,13 +6063,10 @@ tournaments such as Junethack, The November NetHack Tournament and in days past, devnull.net (gone for now, but not forgotten). - - - - - - - - - - - - From time to time, some depraved individual out there in - netland sends a particularly intriguing modification to help out - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 @@ -6076,6 +6076,10 @@ + - - - - - - - - - - + + From time to time, some depraved individual out there in + netland sends a particularly intriguing modification to help out with the game. The NetHack Development Team sometimes makes note of the names of the worst of these miscreants in this, the list of Dungeoneers: @@ -6128,11 +6132,7 @@ - - - - - NetHack 3.6 March 8, 2020 + NetHack 3.6 February 3, 2023 diff -Nru nethack-3.6.6/Files nethack-3.6.7/Files --- nethack-3.6.6/Files 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/Files 2023-02-15 21:52:57.000000000 +0000 @@ -7,7 +7,7 @@ .: (files in top directory) -.clang-format .travis.yml Files Porting README +.clang-format Files Porting README DEVEL: (files for people developing changes to NetHack) @@ -282,8 +282,7 @@ (files for Windows 7/8.x/10 version) .nethackrc.template Install.nt Makefile.gcc Makefile.msc console.rc nethack.def -nh340key.c nhdefkey.c nhico.uu -nhraykey.c nhsetup.bat ntsound.c +nhico.uu nhsetup.bat ntsound.c nttty.c porthelp stub-pdcscrn.c stubs.c sysconf.template win10.c win10.h win32api.h windmain.c @@ -403,9 +402,6 @@ dirs.props dlb.vcxproj dll.props files.props levcomp.vcxproj makedefs.vcxproj -nh340key.def nh340key.vcxproj -nhdefkey.def nhdefkey.vcxproj -nhraykey.def nhraykey.vcxproj recover.vcxproj tile2bmp.vcxproj tilemap.vcxproj tiles.vcxproj travisci.sh uudecode.vcxproj diff -Nru nethack-3.6.6/include/extern.h nethack-3.6.7/include/extern.h --- nethack-3.6.6/include/extern.h 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/include/extern.h 2023-02-15 21:52:57.000000000 +0000 @@ -1680,7 +1680,8 @@ E void NDECL(synch_cursor); E void NDECL(nethack_enter_nttty); E void NDECL(nttty_exit); -#endif +E int NDECL(set_keyhandling_via_option); +#endif /* WIN32 */ /* ### o_init.c ### */ diff -Nru nethack-3.6.6/include/flag.h nethack-3.6.7/include/flag.h --- nethack-3.6.6/include/flag.h 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/include/flag.h 2023-02-15 21:52:57.000000000 +0000 @@ -222,6 +222,15 @@ NUM_GFILTER }; +#ifdef WIN32 +enum windows_key_handling { + no_keyhandling, + default_keyhandling, + ray_keyhandling, + nh340_keyhandling +}; +#endif + struct debug_flags { boolean test; #ifdef TTY_GRAPHICS @@ -427,8 +436,9 @@ int wc2_windowborders; /* display borders on NetHack windows */ int wc2_petattr; /* text attributes for pet */ #ifdef WIN32 -#define MAX_ALTKEYHANDLER 25 - char altkeyhandler[MAX_ALTKEYHANDLER]; +#define MAX_ALTKEYHANDLING 25 + char altkeyhandling[MAX_ALTKEYHANDLING]; + enum windows_key_handling key_handling; #endif /* copies of values in struct u, used during detection when the originals are temporarily cleared; kept here rather than diff -Nru nethack-3.6.6/include/isaac64.h nethack-3.6.7/include/isaac64.h --- nethack-3.6.6/include/isaac64.h 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/include/isaac64.h 2023-02-15 21:52:57.000000000 +0000 @@ -1,7 +1,7 @@ /* CC0 (Public domain) - see http://creativecommons.org/publicdomain/zero/1.0/ for details */ #if !defined(_isaac64_H) # define _isaac64_H (1) -# include +# include "integer.h" diff -Nru nethack-3.6.6/include/ntconf.h nethack-3.6.7/include/ntconf.h --- nethack-3.6.6/include/ntconf.h 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/include/ntconf.h 2023-02-15 21:52:57.000000000 +0000 @@ -234,7 +234,7 @@ extern void NDECL(toggle_mouse_support); extern void FDECL(map_subkeyvalue, (char *)); #if defined(WIN32CON) -extern void FDECL(set_altkeyhandler, (const char *)); +extern void set_altkeyhandling(const char *); #endif extern void NDECL(raw_clear_screen); diff -Nru nethack-3.6.6/include/patchlevel.h nethack-3.6.7/include/patchlevel.h --- nethack-3.6.6/include/patchlevel.h 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/include/patchlevel.h 2023-02-15 21:52:57.000000000 +0000 @@ -1,4 +1,4 @@ -/* NetHack 3.6 patchlevel.h $NHDT-Date: 1583508697 2020/03/06 15:31:37 $ $NHDT-Branch: NetHack-3.6-Mar2020 $:$NHDT-Revision: 1.139 $ */ +/* NetHack 3.6 patchlevel.h $NHDT-Date: 1674867524 2023/01/28 00:58:44 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.141 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -9,14 +9,14 @@ /* * PATCHLEVEL is updated for each release. */ -#define PATCHLEVEL 6 +#define PATCHLEVEL 7 /* * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ #define EDITLEVEL 0 -#define COPYRIGHT_BANNER_A "NetHack, Copyright 1985-2020" +#define COPYRIGHT_BANNER_A "NetHack, Copyright 1985-2023" #define COPYRIGHT_BANNER_B \ " By Stichting Mathematisch Centrum and M. Stephenson." /* COPYRIGHT_BANNER_C is generated by makedefs into date.h */ @@ -36,7 +36,34 @@ /****************************************************************************/ /* Version 3.6.x */ +/* Patch 7, February 16, 2023 + * + * during engraving, spaces were counted instead of non-space (cherry-pick of + * 4e0a1e04 from NetHack-3.7) + * avoid potential buffer overflow in append_str() + * resolve missing dependency in NetHack.sln + * code in include/tradstdc.h was trying to suppress warn_unused result by + * defining warn_unused_result to an empty string and that began causing + * a build error within a system-supplied header file cdefs.h when using + * ubuntu impish 21.10; disable that for any Linux unless GCC_URWARN is + * defined to force it back into effect + * update_inventory() after leash goes slack + * player assigned name for monsters, specific objects, or object types could be + longer than what was intented to be allowed; for 'curses', much longer + * windows: added winflexbison to travis-ci configuration to permit full build of + * levcomp and dgncomp + * windows: a bad chdir specified in win/win32/dgnstuff.mak caused full build to + * abort + * windows: the console.rc file had outdated information stating 3.6.3 when the + * official 3.6.6 binary was built. + * windows: switch from using keyhandling dll's to incorporating the three + * variations (default, ray, 340) in sys/winnt/nttty.c + * curses: cherry-picked selectsaved code from 3.7 for menu of save files + * NetHackW: fix delayed rendering of cursor when using farlook + */ + /* Patch 6, March 8, 2020 + * * invalid status highlight color could be maliciously used to corrupt memory * formatting corpse names used internal buffers differently from formatting * other objects and could potentially clobber memory diff -Nru nethack-3.6.6/include/tradstdc.h nethack-3.6.7/include/tradstdc.h --- nethack-3.6.6/include/tradstdc.h 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/include/tradstdc.h 2023-02-15 21:52:57.000000000 +0000 @@ -429,12 +429,14 @@ #if __GNUC__ >= 3 #define UNUSED __attribute__((unused)) #define NORETURN __attribute__((noreturn)) +#if !defined(__linux__) || defined(GCC_URWARN) /* disable gcc's __attribute__((__warn_unused_result__)) since explicitly discarding the result by casting to (void) is not accepted as a 'use' */ #define __warn_unused_result__ /*empty*/ #define warn_unused_result /*empty*/ #endif #endif +#endif #ifndef PRINTF_F #define PRINTF_F(f, v) diff -Nru nethack-3.6.6/README nethack-3.6.7/README --- nethack-3.6.6/README 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/README 2023-02-15 21:52:57.000000000 +0000 @@ -1,14 +1,14 @@ - NetHack 3.6.6 -- General information March 2020 + NetHack 3.6.7 -- General information February 2023 NetHack 3.6 is an enhancement to the dungeon exploration game NetHack, which is a distant descendent of Rogue and Hack, and a direct descendent of NetHack 3.4 as there was no NetHack 3.5 release. -NetHack 3.6.6 is the official release of NetHack that follows NetHack 3.6.5 -and contains bug fixes since 3.6.5, including a security fix that affected -versions 3.6.1, 3.6.2, 3.6.3, 3.6.4 and 3.6.5. +NetHack 3.6.7 is the official release of NetHack that follows NetHack 3.6.6 +and contains bug fixes since 3.6.6, including a security fix which prompted +the release. -The file doc/fixes36.6 in the source distribution has a full list of fixes. +The file doc/fixes36.7 in the source distribution has a full list of fixes. The text in there was written for the development team's own use and is provided "as is", so please do not ask us to further explain the entries in that file. Some entries might be considered "spoilers", particularly in the @@ -17,12 +17,28 @@ Below you will find some other general notes that were not considered spoilers: - * invalid status highlight color could be maliciously used to corrupt memory - * formatting corpse names used internal buffers differently from formatting - * other objects and could potentially clobber memory - * avoid divide by 0 crash if 'bogusmon' (file of bogus monster types) is empty - * avoid #wizrumorcheck crash if either 'rumors.tru' or 'rumors.fal' or both - * were empty when makedefs built 'rumors' + * during engraving, spaces were counted instead of non-space (cherry-pick of + 4e0a1e04 from NetHack-3.7) + * avoid potential buffer overflow in append_str() + * resolve missing dependency in NetHack.sln + * code in include/tradstdc.h was trying to suppress warn_unused result by + defining warn_unused_result to an empty string and that began causing + a build error within a system-supplied header file cdefs.h when using + ubuntu impish 21.10; disable that for any Linux unless GCC_URWARN is + defined to force it back into effect + * update_inventory() after leash goes slack + * player assigned name for monsters, specific objects, or object types could be + longer than what was intented to be allowed; for 'curses', much longer + * windows: added winflexbison to travis-ci configuration to permit full build of + levcomp and dgncomp + * windows: a bad chdir specified in win/win32/dgnstuff.mak caused full build to + abort + * windows: the console.rc file had outdated information stating 3.6.3 when the + official 3.6.6 binary was built. + * windows: switch from using keyhandling dll's to incorporating the three + variations (default, ray, 340) in sys/winnt/nttty.c + * curses: cherry-picked selectsaved code from 3.7 for menu of save files + * NetHackW: fix delay rendering of cursor when using farlook - - - - - - - - - - - @@ -170,6 +186,6 @@ -- Good luck, and happy Hacking -- -# $NHDT-Date: 1583508658 2020/03/06 15:30:58 $ $NHDT-Branch: NetHack-3.6-Mar2020 $:$NHDT-Revision: 1.80 $ +# $NHDT-Date: 1672610729 2023/01/01 22:05:29 $ $NHDT-Branch: releasebits-3.6 $:$NHDT-Revision: 1.81 $ # Copyright (c) 2012 by Michael Allison # NetHack may be freely redistributed. See license for details. diff -Nru nethack-3.6.6/src/apply.c nethack-3.6.7/src/apply.c --- nethack-3.6.6/src/apply.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/apply.c 2023-02-15 21:52:57.000000000 +0000 @@ -572,8 +572,10 @@ Your("leash falls slack."); } for (otmp = invent; otmp; otmp = otmp->nobj) - if (otmp->otyp == LEASH && otmp->leashmon == (int) mtmp->m_id) + if (otmp->otyp == LEASH && otmp->leashmon == (int) mtmp->m_id) { otmp->leashmon = 0; + update_inventory(); + } mtmp->mleashed = 0; } diff -Nru nethack-3.6.6/src/do_name.c nethack-3.6.7/src/do_name.c --- nethack-3.6.6/src/do_name.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/do_name.c 2023-02-15 21:52:57.000000000 +0000 @@ -1,4 +1,4 @@ -/* NetHack 3.6 do_name.c $NHDT-Date: 1582364431 2020/02/22 09:40:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.174 $ */ +/* NetHack 3.6 do_name.c $NHDT-Date: 1674864731 2023/01/28 00:12:11 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.154 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -9,6 +9,7 @@ STATIC_DCL void FDECL(getpos_help, (BOOLEAN_P, const char *)); STATIC_DCL int FDECL(CFDECLSPEC cmp_coord_distu, (const void *, const void *)); STATIC_DCL boolean FDECL(gather_locs_interesting, (int, int, int)); +STATIC_DCL char *FDECL(name_from_player, (char *, const char *, const char *)); STATIC_DCL void FDECL(gather_locs, (coord **, int *, int)); STATIC_DCL int FDECL(gloc_filter_floodfill_matcharea, (int, int)); STATIC_DCL void FDECL(auto_describe, (int, int)); @@ -1061,6 +1062,34 @@ return ""; } +/* get a name for a monster or an object from player; + truncate if longer than PL_PSIZ, then return it */ +static char * +name_from_player(outbuf, prompt, defres) +char *outbuf; /* output buffer, assumed to be at least BUFSZ long; + * anything longer than PL_PSIZ will be truncated */ +const char *prompt; +const char *defres; /* only used if EDIT_GETLIN is enabled; only useful + * if windowport xxx's xxx_getlin() supports that */ +{ + outbuf[0] = '\0'; +#ifdef EDIT_GETLIN + if (defres && *defres) + Strcpy(outbuf, defres); /* default response from getlin() */ +#else + nhUse(defres); +#endif + getlin(prompt, outbuf); + if (!*outbuf || *outbuf == '\033') + return NULL; + + /* strip leading and trailing spaces, condense internal sequences */ + (void) mungspaces(outbuf); + if (strlen(outbuf) >= PL_PSIZ) + outbuf[PL_PSIZ - 1] = '\0'; + return outbuf; +} + /* historical note: this returns a monster pointer because it used to allocate a new bigger block of memory to hold the monster and its name */ struct monst * @@ -1158,17 +1187,9 @@ /* special case similar to the one in lookat() */ Sprintf(qbuf, "What do you want to call %s?", distant_monnam(mtmp, ARTICLE_THE, monnambuf)); - buf[0] = '\0'; -#ifdef EDIT_GETLIN - /* if there's an existing name, make it be the default answer */ - if (has_mname(mtmp)) - Strcpy(buf, MNAME(mtmp)); -#endif - getlin(qbuf, buf); - if (!*buf || *buf == '\033') + /* use getlin() to get a name string from the player */ + if (!name_from_player(buf, qbuf, has_mname(mtmp) ? MNAME(mtmp) : NULL)) return; - /* strip leading and trailing spaces; unnames monster if all spaces */ - (void) mungspaces(buf); /* Unique monsters have their own specific names or titles. * Shopkeepers, temple priests and other minions use alternate @@ -1220,17 +1241,9 @@ Sprintf(qbuf, "What do you want to name %s ", is_plural(obj) ? "these" : "this"); (void) safe_qbuf(qbuf, qbuf, "?", obj, xname, simpleonames, "item"); - buf[0] = '\0'; -#ifdef EDIT_GETLIN - /* if there's an existing name, make it be the default answer */ - if (has_oname(obj)) - Strcpy(buf, ONAME(obj)); -#endif - getlin(qbuf, buf); - if (!*buf || *buf == '\033') + /* use getlin() to get a name string from the player */ + if (!name_from_player(buf, qbuf, safe_oname(obj))) return; - /* strip leading and trailing spaces; unnames item if all spaces */ - (void) mungspaces(buf); /* * We don't violate illiteracy conduct here, although it is @@ -1484,14 +1497,8 @@ docall_xname, simpleonames, "thing"); /* pointer to old name */ str1 = &(objects[obj->otyp].oc_uname); - buf[0] = '\0'; -#ifdef EDIT_GETLIN - /* if there's an existing name, make it be the default answer */ - if (*str1) - Strcpy(buf, *str1); -#endif - getlin(qbuf, buf); - if (!*buf || *buf == '\033') + /* use getlin() to get a name string from the player */ + if (!name_from_player(buf, qbuf, *str1)) return; /* clear old name */ diff -Nru nethack-3.6.6/src/engrave.c nethack-3.6.7/src/engrave.c --- nethack-3.6.6/src/engrave.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/engrave.c 2023-02-15 21:52:57.000000000 +0000 @@ -1139,7 +1139,7 @@ /* Chop engraving down to size if necessary */ if (len > maxelen) { for (sp = ebuf; maxelen && *sp; sp++) - if (*sp == ' ') + if (!(*sp == ' ')) maxelen--; if (!maxelen && *sp) { *sp = '\0'; diff -Nru nethack-3.6.6/src/files.c nethack-3.6.7/src/files.c --- nethack-3.6.6/src/files.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/files.c 2023-02-15 21:52:57.000000000 +0000 @@ -4167,8 +4167,13 @@ if (sysopt.portable_device_paths) { const char *pd = get_portable_device(); - raw_printf("portable_device_paths (set in sysconf):"); - raw_printf(" \"%s\"", pd); + /* an empty value for pd indicates that portable_device_paths + got set TRUE in a sysconf file other than the one containing + the executable; disregard it */ + if (strlen(pd) > 0) { + raw_printf("portable_device_paths (set in sysconf):"); + raw_printf(" \"%s\"", pd); + } } #endif diff -Nru nethack-3.6.6/src/invent.c nethack-3.6.7/src/invent.c --- nethack-3.6.6/src/invent.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/invent.c 2023-02-15 21:52:57.000000000 +0000 @@ -1,4 +1,4 @@ -/* NetHack 3.6 invent.c $NHDT-Date: 1575245062 2019/12/02 00:04:22 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.267 $ */ +/* NetHack 3.6 invent.c $NHDT-Date: 1674864733 2023/01/28 00:12:13 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.268 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2462,9 +2462,12 @@ #else static char li[BUFSZ]; #endif + char suffix[80]; /* plenty of room for count and hallucinatory currency */ + int sfxlen, txtlen; /* signed int for %*s formatting */ + const char *fmt; boolean use_invlet = (flags.invlet_constant && let != CONTAINED_SYM && let != HANDS_SYM); - long savequan = 0; + long savequan = 0L; if (quan && obj) { savequan = obj->quan; @@ -2476,18 +2479,33 @@ * * Then obj == null and we are printing a total amount. * > Then the object is contained and doesn't have an inventory letter. */ - if (cost != 0 || let == '*') { + fmt = "%c - %.*s%s"; + if (!txt) + txt = doname(obj); + txtlen = (int) strlen(txt); + + if (cost != 0L || let == '*') { /* if dot is true, we're doing Iu, otherwise Ix */ - Sprintf(li, - iflags.menu_tab_sep ? "%c - %s\t%6ld %s" - : "%c - %-45s %6ld %s", - (dot && use_invlet ? obj->invlet : let), - (txt ? txt : doname(obj)), cost, currency(cost)); + if (dot && use_invlet) + let = obj->invlet; + Sprintf(suffix, "%c%6ld %.50s", iflags.menu_tab_sep ? '\t' : ' ', + cost, currency(cost)); + if (!iflags.menu_tab_sep) { + fmt = "%c - %-45.*s%s"; + if (txtlen < 45) + txtlen = 45; + } } else { /* ordinary inventory display or pickup message */ - Sprintf(li, "%c - %s%s", (use_invlet ? obj->invlet : let), - (txt ? txt : doname(obj)), (dot ? "." : "")); - } + if (use_invlet) + let = obj->invlet; + Strcpy(suffix, dot ? "." : ""); + } + sfxlen = (int) strlen(suffix); + if (txtlen > BUFSZ - 1 - (4 + sfxlen)) /* 4: "c - " prefix */ + txtlen = BUFSZ - 1 - (4 + sfxlen); + Sprintf(li, fmt, let, txtlen, txt, suffix); + if (savequan) obj->quan = savequan; diff -Nru nethack-3.6.6/src/isaac64.c nethack-3.6.7/src/isaac64.c --- nethack-3.6.6/src/isaac64.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/isaac64.c 2023-02-15 21:52:57.000000000 +0000 @@ -12,7 +12,6 @@ #include "config.h" #ifdef USE_ISAAC64 -#include #include #include "isaac64.h" diff -Nru nethack-3.6.6/src/objnam.c nethack-3.6.7/src/objnam.c --- nethack-3.6.6/src/objnam.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/objnam.c 2023-02-15 21:52:57.000000000 +0000 @@ -1,4 +1,4 @@ -/* NetHack 3.6 objnam.c $NHDT-Date: 1583315888 2020/03/04 09:58:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.293 $ */ +/* NetHack 3.6 objnam.c $NHDT-Date: 1674864732 2023/01/28 00:12:12 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.259 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -16,6 +16,7 @@ STATIC_DCL boolean FDECL(wishymatch, (const char *, const char *, BOOLEAN_P)); STATIC_DCL char *NDECL(nextobuf); STATIC_DCL void FDECL(releaseobuf, (char *)); +STATIC_DCL void FDECL(xcalled, (char *, int, const char *, const char *)); STATIC_DCL char *FDECL(minimal_xname, (struct obj *)); STATIC_DCL void FDECL(add_erosion_words, (struct obj *, char *)); STATIC_DCL char *FDECL(doname_base, (struct obj *obj, unsigned)); @@ -116,6 +117,7 @@ if (Role_if(PM_SAMURAI) && Japanese_item_name(otyp)) actualn = Japanese_item_name(otyp); + buf[0] = '\0'; switch (ocl->oc_class) { case COIN_CLASS: Strcpy(buf, "coin"); @@ -146,7 +148,7 @@ else Strcpy(buf, "amulet"); if (un) - Sprintf(eos(buf), " called %s", un); + xcalled(buf, BUFSZ - (dn ? (int) strlen(dn) + 3 : 0), "", un); if (dn) Sprintf(eos(buf), " (%s)", dn); return buf; @@ -155,8 +157,8 @@ Strcpy(buf, actualn); if (GemStone(otyp)) Strcat(buf, " stone"); - if (un) - Sprintf(eos(buf), " called %s", un); + if (un) /* 3: length of " (" + ")" which will enclose 'dn' */ + xcalled(buf, BUFSZ - (dn ? (int) strlen(dn) + 3 : 0), "", un); if (dn) Sprintf(eos(buf), " (%s)", dn); } else { @@ -165,7 +167,7 @@ Strcat(buf, (ocl->oc_material == MINERAL) ? " stone" : " gem"); if (un) - Sprintf(eos(buf), " called %s", un); + xcalled(buf, BUFSZ, "", un); } return buf; } @@ -176,8 +178,8 @@ else Sprintf(eos(buf), " of %s", actualn); } - if (un) - Sprintf(eos(buf), " called %s", un); + if (un) /* 3: length of " (" + ")" which will enclose 'dn' */ + xcalled(buf, BUFSZ - (dn ? (int) strlen(dn) + 3 : 0), "", un); if (dn) Sprintf(eos(buf), " (%s)", dn); return buf; @@ -410,6 +412,24 @@ } } +/* add " called " to end of buf, truncating if necessary */ +STATIC_OVL void +xcalled(buf, siz, pfx, sfx) +char *buf; /* eos(obuf) or eos(&obuf[PREFIX]) */ +int siz; /* BUFSZ or BUFSZ-PREFIX */ +const char *pfx; /* usually class string, sometimes more specific */ +const char *sfx; /* user assigned type name */ +{ + int bufsiz = siz - 1 - (int) strlen(buf), + pfxlen = (int) (strlen(pfx) + sizeof " called " - sizeof ""); + + if (pfxlen > bufsiz) + panic("xcalled: not enough room for prefix (%d > %d)", + pfxlen, bufsiz); + + Sprintf(eos(buf), "%s called %.*s", pfx, bufsiz - pfxlen, sfx); +} + char * xname(obj) struct obj *obj; @@ -435,7 +455,7 @@ buf = nextobuf() + PREFIX; /* leave room for "17 -3 " */ if (Role_if(PM_SAMURAI) && Japanese_item_name(typ)) actualn = Japanese_item_name(typ); - /* As of 3.6.2: this used to be part of 'dn's initialization, but it + /* 3.6.2: this used to be part of 'dn's initialization, but it needs to come after possibly overriding 'actualn' */ if (!dn) dn = actualn; @@ -478,7 +498,7 @@ else if (nn) Strcpy(buf, actualn); else if (un) - Sprintf(buf, "amulet called %s", un); + xcalled(buf, BUFSZ - PREFIX, "amulet", un); else Sprintf(buf, "%s amulet", dn); break; @@ -497,11 +517,9 @@ Strcat(buf, dn); else if (nn) Strcat(buf, actualn); - else if (un) { - Strcat(buf, dn); - Strcat(buf, " called "); - Strcat(buf, un); - } else + else if (un) + xcalled(buf, BUFSZ - PREFIX, dn, un); + else Strcat(buf, dn); if (typ == FIGURINE && omndx != NON_PM) { @@ -631,8 +649,7 @@ } Strcat(buf, actualn); } else { - Strcat(buf, " called "); - Strcat(buf, un); + xcalled(buf, BUFSZ - PREFIX, "", un); } } else { Strcat(buf, dn); @@ -647,8 +664,7 @@ Strcat(buf, " of "); Strcat(buf, actualn); } else if (un) { - Strcat(buf, " called "); - Strcat(buf, un); + xcalled(buf, BUFSZ - PREFIX, "", un); } else if (ocl->oc_magic) { Strcat(buf, " labeled "); Strcat(buf, dn); @@ -663,7 +679,7 @@ else if (nn) Sprintf(buf, "wand of %s", actualn); else if (un) - Sprintf(buf, "wand called %s", un); + xcalled(buf, BUFSZ - PREFIX, "wand", un); else Sprintf(buf, "%s wand", dn); break; @@ -674,7 +690,7 @@ else if (nn) Strcpy(buf, actualn); else if (un) - Sprintf(buf, "novel called %s", un); + xcalled(buf, BUFSZ - PREFIX, "novel", un); else Sprintf(buf, "%s book", dn); break; @@ -686,7 +702,7 @@ Strcpy(buf, "spellbook of "); Strcat(buf, actualn); } else if (un) { - Sprintf(buf, "spellbook called %s", un); + xcalled(buf, BUFSZ - PREFIX, "spellbook", un); } else Sprintf(buf, "%s spellbook", dn); break; @@ -696,7 +712,7 @@ else if (nn) Sprintf(buf, "ring of %s", actualn); else if (un) - Sprintf(buf, "ring called %s", un); + xcalled(buf, BUFSZ - PREFIX, "ring", un); else Sprintf(buf, "%s ring", dn); break; @@ -707,7 +723,7 @@ Strcpy(buf, rock); } else if (!nn) { if (un) - Sprintf(buf, "%s called %s", rock, un); + xcalled(buf, BUFSZ - PREFIX, rock, un); else Sprintf(buf, "%s %s", dn, rock); } else { @@ -732,7 +748,8 @@ if (has_oname(obj) && dknown) { Strcat(buf, " named "); nameit: - Strcat(buf, ONAME(obj)); + (void) strncat(buf, ONAME(obj), + BUFSZ - 1 - PREFIX - (unsigned) strlen(buf)); } if (!strncmpi(buf, "the ", 4)) @@ -1684,7 +1701,7 @@ return strcpy(buf, "an []"); } (void) just_an(buf, str); - return strcat(buf, str); + return strncat(buf, str, BUFSZ - 1 - (unsigned) strlen(buf)); } char * @@ -1752,9 +1769,7 @@ Strcpy(buf, "the "); else buf[0] = '\0'; - Strcat(buf, str); - - return buf; + return strncat(buf, str, BUFSZ - 1 - (unsigned) strlen(buf)); } char * @@ -3166,10 +3181,12 @@ */ if ((p = strstri(bp, " named ")) != 0) { *p = 0; + /* note: if 'name' is too long, oname() will truncate it */ name = p + 7; } if ((p = strstri(bp, " called ")) != 0) { *p = 0; + /* note: if 'un' is too long, obj lookup just won't match anything */ un = p + 8; /* "helmet called telepathy" is not "helmet" (a specific type) * "shield called reflection" is not "shield" (a general type) diff -Nru nethack-3.6.6/src/o_init.c nethack-3.6.7/src/o_init.c --- nethack-3.6.6/src/o_init.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/o_init.c 2023-02-15 21:52:57.000000000 +0000 @@ -1,4 +1,4 @@ -/* NetHack 3.6 o_init.c $NHDT-Date: 1545383615 2018/12/21 09:13:35 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.25 $ */ +/* NetHack 3.6 o_init.c $NHDT-Date: 1674864731 2023/01/28 00:12:11 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.27 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -10,6 +10,7 @@ STATIC_DCL void FDECL(shuffle, (int, int, BOOLEAN_P)); STATIC_DCL void NDECL(shuffle_all); STATIC_DCL boolean FDECL(interesting_to_discover, (int)); +STATIC_DCL void FDECL(disco_append_typename, (char *, int)); STATIC_DCL char *FDECL(oclass_to_name, (CHAR_P, char *)); static NEARDATA short disco[NUM_OBJECTS] = DUMMY; @@ -416,6 +417,32 @@ BELL_OF_OPENING, }; +/* append typename(dis) to buf[], possibly truncating in the process */ +STATIC_OVL void +disco_append_typename(buf, dis) +char *buf; +int dis; +{ + unsigned len = (unsigned) strlen(buf); + char *p, *typnm = obj_typename(dis); + + if (len + (unsigned) strlen(typnm) < BUFSZ) { + /* ordinary */ + Strcat(buf, typnm); + } else if ((p = rindex(typnm, '(')) != 0 + && p > typnm && p[-1] == ' ' && index(p, ')') != 0) { + /* typename() returned "really long user-applied name (actual type)" + and we want to truncate from "really long user-applied name" while + keeping " (actual type)" intact */ + --p; /* back up to space in front of open paren */ + (void) strncat(buf, typnm, BUFSZ - 1 - (len + (unsigned) strlen(p))); + Strcat(buf, p); + } else { + /* unexpected; just truncate from end of typename */ + (void) strncat(buf, typnm, BUFSZ - 1 - len); + } +} + /* the '\' command - show discovered object types */ int dodiscovered() /* free after Robert Viduya */ @@ -459,9 +486,8 @@ let_to_name(oclass, FALSE, FALSE)); prev_class = oclass; } - Sprintf(buf, "%s %s", - (objects[dis].oc_pre_discovered ? "*" : " "), - obj_typename(dis)); + Strcpy(buf, objects[dis].oc_pre_discovered ? "* " : " "); + disco_append_typename(buf, dis); putstr(tmpwin, 0, buf); } } @@ -641,9 +667,8 @@ for (i = bases[(int) oclass]; i < NUM_OBJECTS && objects[i].oc_class == oclass; ++i) { if ((dis = disco[i]) != 0 && interesting_to_discover(dis)) { - Sprintf(buf, "%s %s", - objects[dis].oc_pre_discovered ? "*" : " ", - obj_typename(dis)); + Strcpy(buf, objects[dis].oc_pre_discovered ? "* " : " "); + disco_append_typename(buf, dis); putstr(tmpwin, 0, buf); ++ct; } diff -Nru nethack-3.6.6/src/options.c nethack-3.6.7/src/options.c --- nethack-3.6.6/src/options.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/options.c 2023-02-15 21:52:57.000000000 +0000 @@ -2823,7 +2823,7 @@ return FALSE; } else if ((op = string_for_opt(opts, negated)) != empty_optstr) { #if defined(WIN32) && defined(TTY_GRAPHICS) - set_altkeyhandler(op); + set_altkeyhandling(op); #endif } else return FALSE; @@ -5580,7 +5580,11 @@ assign_graphics(PRIMARY); preference_update("symset"); need_redraw = TRUE; - +#ifdef WIN32 + } else if (!strcmp("altkeyhandler", optname) + || !strcmp("altkeyhandling", optname)) { + return set_keyhandling_via_option(); +#endif } else { /* didn't match any of the special options */ return FALSE; @@ -5620,7 +5624,11 @@ #ifdef WIN32 else if (!strcmp(optname, "altkeyhandler")) Sprintf(buf, "%s", - iflags.altkeyhandler[0] ? iflags.altkeyhandler : "default"); + (iflags.key_handling == ray_keyhandling) + ? "ray" + : (iflags.key_handling == nh340_keyhandling) + ? "340" + : "default"); #endif #ifdef BACKWARD_COMPAT else if (!strcmp(optname, "boulder")) diff -Nru nethack-3.6.6/src/pager.c nethack-3.6.7/src/pager.c --- nethack-3.6.6/src/pager.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/pager.c 2023-02-15 21:52:57.000000000 +0000 @@ -49,27 +49,34 @@ return FALSE; } -/* - * Append new_str to the end of buf if new_str doesn't already exist as - * a substring of buf. Return 1 if the string was appended, 0 otherwise. - * It is expected that buf is of size BUFSZ. - */ +/* Append " or "+new_str to the end of buf if new_str doesn't already exist + as a substring of buf. Return 1 if the string was appended, 0 otherwise. + It is expected that buf is of size BUFSZ. */ STATIC_OVL int append_str(buf, new_str) char *buf; const char *new_str; { - int space_left; /* space remaining in buf */ - + static const char sep[] = " or "; + size_t oldlen, space_left; + if (strstri(buf, new_str)) - return 0; + return 0; /* already present */ - space_left = BUFSZ - strlen(buf) - 1; - if (space_left < 1) - return 0; - (void) strncat(buf, " or ", space_left); - (void) strncat(buf, new_str, space_left - 4); - return 1; + oldlen = strlen(buf); + if (oldlen >= BUFSZ - 1) { + if (oldlen > BUFSZ - 1) + impossible("append_str: 'buf' contains %lu characters.", + (unsigned long) oldlen); + return 0; /* no space available */ + } + + /* some space available, but not necessarily enough for full append */ + space_left = BUFSZ - 1 - oldlen; /* space remaining in buf */ + (void) strncat(buf, sep, space_left); + if (space_left > sizeof sep - 1) + (void) strncat(buf, new_str, space_left - (sizeof sep - 1)); + return 1; /* something was appended, possibly just part of " or " */ } /* shared by monster probing (via query_objlist!) as well as lookat() */ diff -Nru nethack-3.6.6/src/priest.c nethack-3.6.7/src/priest.c --- nethack-3.6.6/src/priest.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/priest.c 2023-02-15 21:52:57.000000000 +0000 @@ -622,7 +622,7 @@ && (!(HProtection & INTRINSIC) || (u.ublessed < 20 && (u.ublessed < 9 || !rn2(u.ublessed))))) { - verbalize("Thy devotion has been rewarded."); + verbalize("Thou hast been rewarded for thy devotion."); if (!(HProtection & INTRINSIC)) { HProtection |= FROMOUTSIDE; if (!u.ublessed) diff -Nru nethack-3.6.6/src/weapon.c nethack-3.6.7/src/weapon.c --- nethack-3.6.6/src/weapon.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/src/weapon.c 2023-02-15 21:52:57.000000000 +0000 @@ -843,9 +843,13 @@ newly_welded = mwelded(obj); obj->owornmask &= ~W_WEP; if (newly_welded) { + const char *mon_hand = mbodypart(mon, HAND); + + if (bimanual(obj)) + mon_hand = makeplural(mon_hand); pline("%s %s to %s %s!", Tobjnam(obj, "weld"), is_plural(obj) ? "themselves" : "itself", - s_suffix(mon_nam(mon)), mbodypart(mon, HAND)); + s_suffix(mon_nam(mon)), mon_hand); obj->bknown = 1; } } diff -Nru nethack-3.6.6/sys/unix/Makefile.src nethack-3.6.7/sys/unix/Makefile.src --- nethack-3.6.6/sys/unix/Makefile.src 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/unix/Makefile.src 2023-02-15 21:52:57.000000000 +0000 @@ -991,7 +991,7 @@ detect.o: detect.c $(HACK_H) ../include/artifact.h dig.o: dig.c $(HACK_H) display.o: display.c $(HACK_H) -dlb.o: dlb.c $(CONFIG_H) ../include/dlb.h +dlb.o: dlb.c $(CONFIG_H) ../include/dlb.h ../include/patchlevel.h do.o: do.c $(HACK_H) ../include/lev.h do_name.o: do_name.c $(HACK_H) do_wear.o: do_wear.c $(HACK_H) @@ -1058,7 +1058,7 @@ region.o: region.c $(HACK_H) ../include/lev.h restore.o: restore.c $(HACK_H) ../include/lev.h ../include/tcap.h rip.o: rip.c $(HACK_H) -rnd.o: rnd.c $(HACK_H) +rnd.o: rnd.c $(HACK_H) ../include/isaac64.h ../include/integer.h role.o: role.c $(HACK_H) rumors.o: rumors.c $(HACK_H) ../include/lev.h ../include/dlb.h save.o: save.c $(HACK_H) ../include/lev.h diff -Nru nethack-3.6.6/sys/vms/Makefile.src nethack-3.6.7/sys/vms/Makefile.src --- nethack-3.6.6/sys/vms/Makefile.src 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/vms/Makefile.src 2023-02-15 21:52:57.000000000 +0000 @@ -133,7 +133,7 @@ # Other things that have to be reconfigured are in vmsconf.h, # and config.h -VERSION = 3.6.6 +VERSION = 3.6.7 MAKEDEFS = $(UTL)makedefs.exe; diff -Nru nethack-3.6.6/sys/vms/vmsbuild.com nethack-3.6.7/sys/vms/vmsbuild.com --- nethack-3.6.6/sys/vms/vmsbuild.com 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/vms/vmsbuild.com 2023-02-15 21:52:57.000000000 +0000 @@ -1,5 +1,5 @@ $ ! vms/vmsbuild.com -- compile and link NetHack 3.6.* [pr] -$ version_number = "3.6.6" +$ version_number = "3.6.7" $ ! $NHDT-Date: 1557701518 2019/05/12 22:51:58 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.23 $ $ ! Copyright (c) 2018 by Robert Patrick Rankin $ ! NetHack may be freely redistributed. See license for details. diff -Nru nethack-3.6.6/sys/winnt/console.rc nethack-3.6.7/sys/winnt/console.rc --- nethack-3.6.6/sys/winnt/console.rc 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/console.rc 2023-02-15 21:52:57.000000000 +0000 @@ -1,4 +1,4 @@ -/* NetHack 3.6 console.rc $NHDT-Date: 1575245149 2019/12/02 00:05:49 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.13 $ */ +/* NetHack 3.6 console.rc $NHDT-Date: 1601668518 2020/10/02 19:55:18 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.14 $ */ /* Copyright (c) Yitzhak Sapir, 2002. */ /* NetHack may be freely redistributed. See license for details. */ @@ -12,8 +12,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,6,3,0 - PRODUCTVERSION 3,6,3,0 + FILEVERSION 3,6,7,0 + PRODUCTVERSION 3,6,7,0 FILEFLAGSMASK 0x1fL #ifdef _DEBUG FILEFLAGS 0x9L @@ -29,13 +29,13 @@ BLOCK "040904b0" BEGIN VALUE "FileDescription", "NetHack for Windows - TTY Interface\0" - VALUE "FileVersion", "3.6.3\0" + VALUE "FileVersion", "3.6.7\0" VALUE "InternalName", "NetHack\0" - VALUE "LegalCopyright", "Copyright (C) 1985 - 2019. By Stichting Mathematisch Centrum and M. Stephenson. See license for details.\0" + VALUE "LegalCopyright", "Copyright (C) 1985 - 2023. By Stichting Mathematisch Centrum and M. Stephenson. See license for details.\0" VALUE "OriginalFilename", "NetHack.exe\0" VALUE "PrivateBuild", "050102\0" VALUE "ProductName", "NetHack\0" - VALUE "ProductVersion", "3.6.3\0" + VALUE "ProductVersion", "3.6.7\0" END END BLOCK "VarFileInfo" diff -Nru nethack-3.6.6/sys/winnt/Install.nt nethack-3.6.7/sys/winnt/Install.nt --- nethack-3.6.6/sys/winnt/Install.nt 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/Install.nt 2023-02-15 21:52:57.000000000 +0000 @@ -1,13 +1,13 @@ - Copyright (c) NetHack Development Team 1990-2020 + Copyright (c) NetHack Development Team 1990-2023 NetHack may be freely redistributed. See license for details. ============================================================== Instructions for compiling and installing NetHack 3.6 on a Windows system - (Windows 7/8.x/10 or later only) + (Windows 10/11 or later) ============================================================== Last revision: $NHDT-Date: 1575245156 2019/12/02 00:05:56 $ -Credit for the porting of NetHack to the Win32 Console Subsystem goes to +Credit for the porting of NetHack to the Win32 Console Subsystem goes to the NT Porting Team started by Michael Allison. Credit for the Win32 Graphical version of NetHack (aka "NetHack for @@ -16,9 +16,9 @@ Alex Kompel, Dion Nicolaas, Yitzhak Sapir, Derek S. Ray, Michael Allison, Pasi Kallinen, Bart House, and Janet Walz contributed to the maintainance -of the tty and graphical windows versions of NetHack 3.6.6. +of the tty and graphical windows versions of NetHack 3.6.7. -You can build a TTY version of NetHack and a Windows Graphical +You can build a TTY version of NetHack and a Windows Graphical version. You can use one of the following build environments: o A copy of Microsoft Visual Studio 2017 Community Edition or @@ -26,9 +26,9 @@ OR - o (Untested for 3.6) A copy of MinGW. MinGW is a collection of header - files and import libraries with which native Windows32 programs - can be built; the MinGW distribution contains the GNU Compiler + o (Untested for 3.6) A copy of MinGW. MinGW is a collection of header + files and import libraries with which native Windows32 programs + can be built; the MinGW distribution contains the GNU Compiler Collection. You can download MinGW at http://www.mingw.org/ Earlier versions of MinGW will not allow you to build the Windows @@ -38,22 +38,22 @@ | Directories for a Win32 NetHack build | \---------------------------------------------/ - + (NetHack-top) ----------------------(optional-pdcurses-top) | | ---------------------------------------------- -------------- | | | | | | | | | - util dat doc include src sys win pdcurses wincon + util dat doc include src sys win pdcurses wincon | | - ------ -------- + ------ -------- | | | | share winnt tty win32 | vs2017 - + /--------------------------------------------------------\ -| Building And Running Using Visual Studio 2017 | +| Building And Running Using Visual Studio | \--------------------------------------------------------/ If you are NOT using Visual Studio 2017 IDE, or you prefer to build @@ -67,12 +67,19 @@ win\win32\vs2017\NetHack.sln You can use that same win\win32\vs2017\NetHack.sln with Visual Studio 2019, -but you may have to retarget the projects: - Windows SDK Version: 10.0.17763.0 [ There have been some reports of - difficulties if you instead choose - "10.0 (latest installed version)" ] +but you likely have to retarget the projects. The same would apply if you are +trying to build using an even more recent version of Visual Studio as well. +Note: If you already built NetHack previously with an older version of +Visual Studio, manually delete the following subfolders of win\win32\vs2017: + obj + symbols + + Windows SDK Version: 10.0.22000.0 [ There have been some reports of + difficulties if you choose + "10.0 (latest installed version)" + instead ] Platform Toolset: Upgrade to v142 - + Before executing the steps to build listed in the next paragraph, decide if you want to include optional curses window-port. See @@ -94,18 +101,18 @@ * Optional curses window-port support * Since 3.6.2, the community patch for a window-port that uses curses has been -incorporated into the NetHack source code tree. That window-port, which +incorporated into the NetHack source code tree. That window-port, which evolved from work originally done by Karl Garrison, has been used in several NetHack variants and on nethack.alt.org and on www.hardfought.org/nethack/. If you want to include the curses window-port support in your Visual Studio build, you will have to first obtain the PDCurses sources from https://github.com/wmcbrine/PDCurses -and have them available prior to building NetHack. There are two ways to -enable curses window-port support during the VS build: Either set the -environment variable PDCURSES to a folder containing a PDCurses +and have them available prior to building NetHack. There are two ways to +enable curses window-port support during the VS build: Either set the +environment variable PDCURSES to a folder containing a PDCurses repository/source-tree - OR + OR Place the PDCurses folder alongside the NetHack source repository prior to proceeding with steps 1 through 5 above. @@ -117,8 +124,8 @@ -------------------------------------------------------------------------- -- Beginning of prerequisite step -- -The first step in building either version of NetHack via Makefile is to -execute sys\winnt\nhsetup.bat to move some files to their required locations. +The first step in building either version of NetHack via Makefile is to +execute sys\winnt\nhsetup.bat to move some files to their required locations. From the command prompt: cd sys\winnt @@ -141,25 +148,25 @@ NetHackW. The executable for Console NetHack will be named NetHack.exe. The -executable for Graphical NetHack will be named NetHackW.exe. The +executable for Graphical NetHack will be named NetHackW.exe. The Makefile configuration will build both; NetHackW.exe and NetHack.exe will be able to use the same datafiles, save files and bones files. -Since the last official release of NetHack, compilers and computer +Since the last official release of NetHack, compilers and computer architectures have evolved and you can now choose whether to build a 32-bit x86 version, or a 64-bit x64 version. The default Makefile -is set up for a 32-bit x86 version, but that's only because it will +is set up for a 32-bit x86 version, but that's only because it will run on the most number of existing Windows environments. -NetHack's save files and bones files in the 3.6.6 release have not yet -evolved enough to allow them to interchange between the 32-bit version +NetHack's save files and bones files in the 3.6.7 release have not yet +evolved enough to allow them to interchange between the 32-bit version and the 64-bit version (or between different platforms). Hopefully that will change in an upcoming release. I. Dispelling the Myths: Compiling NetHack for Windows is not as easy as it sounds, nor as hard - as it looks, however it will behoove you to read this entire section + as it looks, however it will behoove you to read this entire section through before beginning the task. We have provided a Makefile for each of the following compilers: @@ -168,10 +175,10 @@ The Community Editions are fine and available at no cost o MinGW 2.0 (with GCC 3.2) - The Microsoft Visual Studio makefile was created for use - with MS NMAKE which is provided with the Microsoft compiler. + The Microsoft Visual Studio makefile was created for use + with MS NMAKE which is provided with the Microsoft compiler. The supplied Makefile may work with earlier versions of the Microsoft - compiler, but that has not been tested. + compiler, but that has not been tested. The GCC Makefile was created for use with GNU Make version 3.79.1, which comes with the MinGW package. @@ -185,41 +192,41 @@ Setting Up -1. It almost goes without saying that you should make sure that your +1. It almost goes without saying that you should make sure that your tools are set up and running correctly. That includes ensuring that all the necessary environment variables for the compiler environment - are set correctly. + are set correctly. - Change your current directory to the src subfolder of the nethack + Change your current directory to the src subfolder of the nethack source tree. cd src - GCC + GCC - For the GCC Makefile, add \bin to your path, where + For the GCC Makefile, add \bin to your path, where is your MinGW root directory.). - Change your current directory to src subfolder of the nethack + Change your current directory to src subfolder of the nethack source tree. cd src 2. Since 3.6.2, the community patch for an optional curses window-port - has been incorporated into the NetHack source code tree. That + has been incorporated into the NetHack source code tree. That window-port, which evolved from work originally done by Karl Garrison, - has been used in several NetHack variants and on nethack.alt.org and - on www.hardfought.org/nethack/. The optional curses window-port is + has been used in several NetHack variants and on nethack.alt.org and + on www.hardfought.org/nethack/. The optional curses window-port is available for Windows, Mac OS X, and Unix (and also DOS). If you want to include the optional curses window-port support in your - command line Makefile build, you will have to first obtain the + command line Makefile build, you will have to first obtain the PDCurses sources from https://github.com/wmcbrine/PDCurses and have that source code tree available prior to building NetHack. - Edit your Makefile and in Question 4 of the four decisions you can + Edit your Makefile and in Question 4 of the four decisions you can make in there, uncomment these two lines: ADD_CURSES=Y PDCURSES_TOP=..\..\pdcurses - Adjust the PDCURSES_TOP macro so that it points to the correct + Adjust the PDCURSES_TOP macro so that it points to the correct location for the top of the PDCurses source tree if it differs from the path shown. @@ -228,8 +235,8 @@ subdirectories dat, doc, include, src, sys\share, sys\winnt, win\tty, util. - If you are including the optional Curses window port into your - build,then you will need the top of the PDCurses sources in a + If you are including the optional Curses window port into your + build,then you will need the top of the PDCurses sources in a folder parallel to the top of the NetHack folder (or you will need to change the value of the PDCURSES_TOP macro in the Makefile to specify the appropriate location. @@ -257,7 +264,7 @@ 5. Now that everything is set up... For the Visual Studio compiler, as mentioned above, you should now be - at the command prompt to carry out the build and your current + at the command prompt to carry out the build and your current directory should be the src subdirectory in the NetHack source tree. In the src subdirectory, issue this command: @@ -273,7 +280,7 @@ particular machine of course, but you should be able to go for lunch and return to find everything finished. The less memory, and slower your machine, the longer the lunch you may take. :-) - + In any case, it is likely that the command prompt window where you are doing the compiling will be occupied for a while. If all goes well, you will get an NetHack executable. @@ -284,7 +291,7 @@ your current directory to src and issue the appropriate command for your compiler: - For Microsoft compiler: + For Microsoft compiler: nmake For GCC: @@ -299,19 +306,19 @@ have to delete dgn_flex.c, dgn_yacc.c, lev_flex.c, and lev_yacc.c from the util directory to ensure that they are remade. -2. Depending on the build and compiler and tools used above, the +2. Depending on the build and compiler and tools used above, the executable produced by the TTY build is either: - - a 32-bit (x86), flat-address space, non-overlayed .exe file, + - a 32-bit (x86), flat-address space, non-overlayed .exe file, which should run on any recent Win32 environment. or - - a 64-bit (x64) .exe file, + - a 64-bit (x64) .exe file, which should run on any 64-bit Windows O/S. Note that saved games are NOT compatible between the 32-bit and the 64-bit versions at this time. NetHack.exe is the tty version. NetHackW.exe is the graphical version. -Play NetHack. +Play NetHack. PROBLEMS diff -Nru nethack-3.6.6/sys/winnt/Makefile.gcc nethack-3.6.7/sys/winnt/Makefile.gcc --- nethack-3.6.6/sys/winnt/Makefile.gcc 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/Makefile.gcc 2023-02-15 21:52:57.000000000 +0000 @@ -1483,10 +1483,10 @@ ifeq "$(WANT_WIN_QT4)" "Y" # Qt dependencies -$(GAMEDIR))/Qt5Core.dll : $(QT4_DIRECTORY)/bin/Qt5Core.dll +$(GAMEDIR)/Qt5Core.dll : $(QT4_DIRECTORY)/bin/Qt5Core.dll $(subst /,\,@copy $< $@ >nul) -$(GAMEDIR))/Qt5Gui.dll : $(QT4_DIRECTORY)/bin/Qt5Gui.dll +$(GAMEDIR)/Qt5Gui.dll : $(QT4_DIRECTORY)/bin/Qt5Gui.dll $(subst /,\,@copy $< $@ >nul) $(GAMEDIR)/Qt5Widgets.dll : $(QT4_DIRECTORY)/bin/Qt5Widgets.dll diff -Nru nethack-3.6.6/sys/winnt/Makefile.msc nethack-3.6.7/sys/winnt/Makefile.msc --- nethack-3.6.6/sys/winnt/Makefile.msc 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/Makefile.msc 2023-02-15 21:52:57.000000000 +0000 @@ -1,5 +1,5 @@ # NetHack 3.6 Makefile.msc $NHDT-Date: 1572748386 2019/11/03 02:33:06 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.167 $ */ -# Copyright (c) NetHack PC Development Team 1993-2019 +# Copyright (c) NetHack PC Development Team 1993-2023 # #============================================================================== # Build Tools Environment @@ -93,7 +93,7 @@ #============================================================================== # # The version of the game this Makefile was designed for -NETHACK_VERSION="3.6.6" +NETHACK_VERSION="3.6.7" # A brief version for use in macros NHV=$(NETHACK_VERSION:.=) @@ -274,8 +274,6 @@ COMCTRL = comctl32.lib -KEYDLLS = $(GAMEDIR)\nhdefkey.dll $(GAMEDIR)\nh340key.dll $(GAMEDIR)\nhraykey.dll - TILEUTIL16 = $(UTIL)\tile2bmp.exe TILEBMP16 = $(SRC)\tiles.bmp @@ -373,7 +371,27 @@ # Visual Studio we are using. We set VSVER to 0000 to flag any version that # is too old or untested. # -#NMAKE version 1421277022 is distributed with latest VS 2019 +#NMAKE version 1421277022 is distributed with latest VS 2019 at time of 3.6.6 +#NMAKE version 1434319370 is distributed with latest VS 2019 at time of 3.6.7 + +# Before we get started, this section is used to determine the version of +# Visual Studio we are using. We set VSVER to 0000 to flag any version that +# is too old or untested. +# +# Recently tested versions: +TESTEDVS2017 = 14.16.27048.0 +TESTEDVS2019 = 14.29.30147.0 +TESTEDVS2022 = 14.34.31937.0 + +VS2017CUR = $(TESTEDVS2017:.=) +VS2019CUR = $(TESTEDVS2019:.=) +VS2022CUR = $(TESTEDVS2022:.=) +VS2017UP1 = $(VS2017CUR) + 1 +VS2019UP1 = $(VS2019CUR) + 1 +VS2022UP1 = $(VS2022CUR) + 1 +VS20171ST = 1411000000 +VS20191ST = $(VS2017UP1) +VS20221ST = $(VS2019UP1) #!MESSAGE $(MAKEFLAGS) #!MESSAGE $(MAKEDIR) @@ -384,7 +402,8 @@ #!MESSAGE $(_NMAKE_VER) #!MESSAGE $(MAKEVERSION) -VSNEWEST=2019 +VSSPECIAL= +VSNEWEST=2022 !IF ($(MAKEVERSION) < 1000000000) VSVER=0000 #untested ancient version !ELSEIF ($(MAKEVERSION) > 1000000000) && ($(MAKEVERSION) < 1100000000) @@ -395,21 +414,26 @@ VSVER=2013 !ELSEIF ($(MAKEVERSION) > 1400000000) && ($(MAKEVERSION) < 1411000000) VSVER=2015 -!ELSEIF ($(MAKEVERSION) > 1411000000) && ($(MAKEVERSION) < 1416270312) +!ELSEIF ($(MAKEVERSION) > $(VS20171ST)) && ($(MAKEVERSION) < $(VS2017UP1)) VSVER=2017 -!ELSEIF ($(MAKEVERSION) > 1416270311) && ($(MAKEVERSION) < 1421277023) -VSVER=$(VSNEWEST) -!ELSEIF ($(MAKEVERSION) > 1421277022) +!ELSEIF ($(MAKEVERSION) > $(VS20191ST)) && ($(MAKEVERSION) < $(VS2019UP1)) +VSVER=2019 +!ELSEIF ($(MAKEVERSION) > $(VS20221ST)) && ($(MAKEVERSION) < $(VS2022UP1)) +VSVER=2022 +!ELSEIF ($(MAKEVERSION) > $(VS2022CUR)) VSVER=2999 #untested future version !ENDIF !IF ($(VSVER) >= 2012) -!MESSAGE Autodetected Visual Studio $(VSVER) -!ELSEIF ($(VSVER) == 2999 -!MESSAGE The version of Visual Studio is newer than the most recent at -!MESSAGE the time this Makefile was crafted (Visual Studio $(VSNEWEST)). -!MESSAGE Because it is newer we'll proceed expecting that the -!MESSAGE VS$(VSNEWEST) processing will still work. +!IF ($(VSVER) <= $(VSNEWEST)) +!MESSAGE Autodetected Visual Studio $(VSVER) $(VSSPECIAL) +!ENDIF +!ENDIF +!IF ($(VSVER) == 2999) +!MESSAGE The NMAKE version of this Visual Studio $(_NMAKE_VER) is newer than the +!MESSAGE most recent at the time this Makefile was crafted (Visual Studio $(VSNEWEST)). +!MESSAGE Because it is newer we'll proceed expecting that the VS$(VSNEWEST) processing +!MESSAGE will still work. !ELSEIF ($(VSVER) == 0000) !MESSAGE The version of Visual Studio appears to be quite old, older !MESSAGE than VS2010 which is the oldest supported version by this @@ -845,63 +869,6 @@ @if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR) @echo directory created > $@ -$(O)nhdefkey.def: - @echo LIBRARY $(@B) >$@ -! IF "$(TARGET_CPU)"=="x64" || "$(PROCESSOR_ARCHITECTURE)"=="x64" -! ELSE - @echo EXPORTS >>$@ - @echo ProcessKeystroke >>$@ - @echo NHkbhit >>$@ - @echo CheckInput >>$@ - @echo SourceWhere >>$@ - @echo SourceAuthor >>$@ - @echo KeyHandlerName >>$@ -! ENDIF - -$(GAMEDIR)\nhdefkey.dll : $(O)$(@B).o $(O)gamedir.tag $(O)$(@B).def - @echo Linking $(@:\=/) - @$(link) $(ldebug) /RELEASE /DLL user32.lib \ - /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).map" /DEF:$(O)$(@B).def \ - /IMPLIB:$(O)$(@B).lib -out:$@ $(O)$(@B).o - -$(O)nh340key.def: - @echo LIBRARY $(@B) >$@ -! IF "$(TARGET_CPU)"=="x64" || "$(PROCESSOR_ARCHITECTURE)"=="x64" -! ELSE - @echo EXPORTS >>$@ - @echo ProcessKeystroke >>$@ - @echo NHkbhit >>$@ - @echo CheckInput >>$@ - @echo SourceWhere >>$@ - @echo SourceAuthor >>$@ - @echo KeyHandlerName >>$@ -! ENDIF - -$(GAMEDIR)\nh340key.dll : $(O)$(@B).o $(O)gamedir.tag $(O)$(@B).def - @echo Linking $(@:\=/) - @$(link) $(ldebug) /RELEASE /NOLOGO /DLL user32.lib \ - /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).map" /DEF:$(O)$(@B).def \ - /IMPLIB:$(O)$(@B).lib -out:$@ $(O)$(@B).o - -$(O)nhraykey.def: - @echo LIBRARY $(@B) >$@ -! IF "$(TARGET_CPU)"=="x64" || "$(PROCESSOR_ARCHITECTURE)"=="x64" -! ELSE - @echo EXPORTS >>$@ - @echo ProcessKeystroke >>$@ - @echo NHkbhit >>$@ - @echo CheckInput >>$@ - @echo SourceWhere >>$@ - @echo SourceAuthor >>$@ - @echo KeyHandlerName >>$@ -! ENDIF - -$(GAMEDIR)\nhraykey.dll : $(O)$(@B).o $(O)gamedir.tag $(O)$(@B).def - @echo Linking $(@:\=/) - @$(link) $(ldebug) /RELEASE /NOLOGO /DLL user32.lib \ - /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).map" /DEF:$(O)$(@B).def \ - /IMPLIB:$(O)$(@B).lib -out:$@ $(O)$(@B).o - # # Secondary Targets. # @@ -1281,9 +1248,6 @@ spotless: clean ! IF ("$(OBJ)"!="") if exist $(OBJ)\* rmdir $(OBJ) /s /Q - if exist $(GAMEDIR)\nhdefkey.dll del $(GAMEDIR)\nhdefkey.dll - if exist $(GAMEDIR)\nh340key.dll del $(GAMEDIR)\nh340key.dll - if exist $(GAMEDIR)\nhraykey.dll del $(GAMEDIR)\nhraykey.dll if exist $(GAMEDIR)\NetHack.exe del $(GAMEDIR)\NetHack.exe if exist $(GAMEDIR)\NetHack.pdb del $(GAMEDIR)\NetHack.pdb if exist $(GAMEDIR)\nhdat$(NHV) del $(GAMEDIR)\nhdat$(NHV) @@ -1381,26 +1345,15 @@ if exist $(O)makedefs.MAP del $(O)makedefs.MAP if exist $(O)makedefs.PDB del $(O)makedefs.PDB if exist $(O)NetHack.MAP del $(O)NetHack.MAP - if exist $(O)nh340key.def del $(O)nh340key.def - if exist $(O)nh340key.exp del $(O)nh340key.exp - if exist $(O)nh340key.lib del $(O)nh340key.lib - if exist $(O)nh340key.map del $(O)nh340key.map - if exist $(O)nh340key.PDB del $(O)nh340key.PDB - if exist $(O)nhdefkey.def del $(O)nhdefkey.def - if exist $(O)nhdefkey.exp del $(O)nhdefkey.exp - if exist $(O)nhdefkey.lib del $(O)nhdefkey.lib - if exist $(O)nhdefkey.map del $(O)nhdefkey.map - if exist $(O)nhdefkey.PDB del $(O)nhdefkey.PDB - if exist $(O)nhraykey.def del $(O)nhraykey.def - if exist $(O)nhraykey.exp del $(O)nhraykey.exp - if exist $(O)nhraykey.lib del $(O)nhraykey.lib - if exist $(O)nhraykey.map del $(O)nhraykey.map - if exist $(O)nhraykey.PDB del $(O)nhraykey.PDB if exist $(O)envchk.tag del $(O)envchk.tag if exist $(O)obj.tag del $(O)obj.tag if exist $(O)sp_lev.tag del $(O)sp_lev.tag if exist $(O)uudecode.MAP del $(O)uudecode.MAP if exist $(O)uudecode.PDB del $(O)uudecode.PDB + if exist $(SRC)\tiles.bmp del $(SRC)\tiles.bmp + if exist $(O)console.res del $(O)console.res + if exist $(O)NetHack.res del $(O)NetHack.res + if exist $(O)NetHackW.res del $(O)NetHackW.res rem rem defer to the steps in ..\win\win32\levstuff.mak rem diff -Nru nethack-3.6.6/sys/winnt/.nethackrc.template nethack-3.6.7/sys/winnt/.nethackrc.template --- nethack-3.6.6/sys/winnt/.nethackrc.template 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/.nethackrc.template 2023-02-15 21:52:57.000000000 +0000 @@ -27,13 +27,11 @@ #OPTIONS=windowtype:curses # # Keyboard handling -# Different keyboard handlers can be loaded. -# Default is nhdefkey.dll but you can override that. -# Ray Chason's keyboard handler -# OPTIONS=altkeyhandler:nhraykey.dll +# Ray Chason's keyboard handling +# OPTIONS=altkeyhandling:ray # # NetHack 3.4.0 keyboard handling -# OPTIONS=altkeyhandler:nh340key.dll +# OPTIONS=altkeyhandling:340 # *** Personal Preferences *** # Some options to set personal preferences. Uncomment and change these to diff -Nru nethack-3.6.6/sys/winnt/nh340key.c nethack-3.6.7/sys/winnt/nh340key.c --- nethack-3.6.6/sys/winnt/nh340key.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/nh340key.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,356 +0,0 @@ -/* NetHack 3.6 nh340key.c $NHDT-Date: 1432512793 2015/05/25 00:13:13 $ $NHDT-Branch: master $:$NHDT-Revision: 1.12 $ */ -/* Copyright (c) NetHack PC Development Team 2003 */ -/* NetHack may be freely redistributed. See license for details. */ - -/* - * This is the NetHack keystroke processing from NetHack 3.4.0. - * It can be built as a run-time loadable dll (nh340key.dll), - * placed in the same directory as the nethack.exe executable, - * and loaded by specifying OPTIONS=altkeyhandler:nh340key - * in defaults.nh - */ - -static char where_to_get_source[] = "http://www.nethack.org/"; -static char author[] = "The NetHack Development Team"; - -#include "win32api.h" -#include "hack.h" -#include "wintty.h" - -extern HANDLE hConIn; -extern INPUT_RECORD ir; -char dllname[512]; -char *shortdllname; - -int FDECL(__declspec(dllexport) __stdcall ProcessKeystroke, - (HANDLE hConIn, INPUT_RECORD *ir, boolean *valid, - BOOLEAN_P numberpad, int portdebug)); - -int WINAPI -DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) -{ - char dlltmpname[512]; - char *tmp = dlltmpname, *tmp2; - *(tmp + GetModuleFileName(hInstance, tmp, 511)) = '\0'; - (void) strcpy(dllname, tmp); - tmp2 = strrchr(dllname, '\\'); - if (tmp2) { - tmp2++; - shortdllname = tmp2; - } - return TRUE; -} - -/* - * Keyboard translation tables. - * (Adopted from the MSDOS port) - */ - -#define KEYPADLO 0x47 -#define KEYPADHI 0x53 - -#define PADKEYS (KEYPADHI - KEYPADLO + 1) -#define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI) - -#ifdef QWERTZ_SUPPORT -/* when 'numberpad' is 0 and Cmd.swap_yz is True - (signaled by setting 0x10 on boolean numpad argument) - treat keypress of numpad 7 as 'z' rather than 'y' */ -static boolean qwertz = FALSE; -#endif - -/* - * Keypad keys are translated to the normal values below. - * Shifted keypad keys are translated to the - * shift values below. - */ - -static const struct pad { - uchar normal, shift, cntrl; -} keypad[PADKEYS] = - { - { 'y', 'Y', C('y') }, /* 7 */ - { 'k', 'K', C('k') }, /* 8 */ - { 'u', 'U', C('u') }, /* 9 */ - { 'm', C('p'), C('p') }, /* - */ - { 'h', 'H', C('h') }, /* 4 */ - { 'g', 'G', 'g' }, /* 5 */ - { 'l', 'L', C('l') }, /* 6 */ - { '+', 'P', C('p') }, /* + */ - { 'b', 'B', C('b') }, /* 1 */ - { 'j', 'J', C('j') }, /* 2 */ - { 'n', 'N', C('n') }, /* 3 */ - { 'i', 'I', C('i') }, /* Ins */ - { '.', ':', ':' } /* Del */ - }, - numpad[PADKEYS] = { - { '7', M('7'), '7' }, /* 7 */ - { '8', M('8'), '8' }, /* 8 */ - { '9', M('9'), '9' }, /* 9 */ - { 'm', C('p'), C('p') }, /* - */ - { '4', M('4'), '4' }, /* 4 */ - { 'g', 'G', 'g' }, /* 5 */ - { '6', M('6'), '6' }, /* 6 */ - { '+', 'P', C('p') }, /* + */ - { '1', M('1'), '1' }, /* 1 */ - { '2', M('2'), '2' }, /* 2 */ - { '3', M('3'), '3' }, /* 3 */ - { 'i', 'I', C('i') }, /* Ins */ - { '.', ':', ':' } /* Del */ - }; - -#define inmap(x, vk) (((x) > 'A' && (x) < 'Z') || (vk) == 0xBF || (x) == '2') - -int __declspec(dllexport) __stdcall ProcessKeystroke(hConIn, ir, valid, - numberpad, portdebug) -HANDLE hConIn; -INPUT_RECORD *ir; -boolean *valid; -boolean numberpad; -int portdebug; -{ - int metaflags = 0, k = 0; - int keycode, vk; - unsigned char ch, pre_ch, mk = 0; - unsigned short int scan; - unsigned long shiftstate; - int altseq = 0; - const struct pad *kpad; - -#ifdef QWERTZ_SUPPORT - if (numberpad & 0x10) { - numberpad &= ~0x10; - qwertz = TRUE; - } else { - qwertz = FALSE; - } -#endif - - shiftstate = 0L; - ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar; - scan = ir->Event.KeyEvent.wVirtualScanCode; - vk = ir->Event.KeyEvent.wVirtualKeyCode; - keycode = MapVirtualKey(vk, 2); - shiftstate = ir->Event.KeyEvent.dwControlKeyState; - - if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { - if (ch || inmap(keycode, vk)) - altseq = 1; - else - altseq = -1; /* invalid altseq */ - } - if (ch || (iskeypad(scan)) || (altseq > 0)) - *valid = TRUE; - /* if (!valid) return 0; */ - /* - * shiftstate can be checked to see if various special - * keys were pressed at the same time as the key. - * Currently we are using the ALT & SHIFT & CONTROLS. - * - * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED, - * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED, - * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON, - * CAPSLOCK_ON, ENHANCED_KEY - * - * are all valid bit masks to use on shiftstate. - * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the - * left control key was pressed with the keystroke. - */ - if (iskeypad(scan)) { - kpad = numberpad ? numpad : keypad; - if (shiftstate & SHIFT_PRESSED) { - ch = kpad[scan - KEYPADLO].shift; - } else if (shiftstate & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) { - ch = kpad[scan - KEYPADLO].cntrl; - } else { - ch = kpad[scan - KEYPADLO].normal; - } -#ifdef QWERTZ_SUPPORT - /* OPTIONS=number_pad:-1 is for qwertz keyboard; for that setting, - 'numberpad' will be 0; core swaps y to zap, z to move northwest; - we want numpad 7 to move northwest, so when qwertz is set, - tell core that user who types numpad 7 typed z rather than y */ - if (qwertz && kpad[scan - KEYPADLO].normal == 'y') - ch += 1; /* changes y to z, Y to Z, ^Y to ^Z */ -#endif /*QWERTZ_SUPPORT*/ - } else if (altseq > 0) { /* ALT sequence */ - if (vk == 0xBF) - ch = M('?'); - else - ch = M(tolower((uchar) keycode)); - } - if (ch == '\r') - ch = '\n'; -#ifdef PORT_DEBUG - if (portdebug) { - char buf[BUFSZ]; - Sprintf(buf, - "PORTDEBUG (%s): ch=%u, sc=%u, vk=%d, sh=0x%X (ESC to end)", - shortdllname, ch, scan, vk, shiftstate); - fprintf(stdout, "\n%s", buf); - } -#endif - return ch; -} - -int __declspec(dllexport) __stdcall NHkbhit(hConIn, ir) -HANDLE hConIn; -INPUT_RECORD *ir; -{ - int done = 0; /* true = "stop searching" */ - int retval; /* true = "we had a match" */ - DWORD count; - unsigned short int scan; - unsigned char ch; - unsigned long shiftstate; - int altseq = 0, keycode, vk; - done = 0; - retval = 0; - while (!done) { - count = 0; - PeekConsoleInput(hConIn, ir, 1, &count); - if (count > 0) { - if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { - ch = ir->Event.KeyEvent.uChar.AsciiChar; - scan = ir->Event.KeyEvent.wVirtualScanCode; - shiftstate = ir->Event.KeyEvent.dwControlKeyState; - vk = ir->Event.KeyEvent.wVirtualKeyCode; - keycode = MapVirtualKey(vk, 2); - if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { - if (ch || inmap(keycode, vk)) - altseq = 1; - else - altseq = -1; /* invalid altseq */ - } - if (ch || iskeypad(scan) || altseq) { - done = 1; /* Stop looking */ - retval = 1; /* Found what we sought */ - } else { - /* Strange Key event; let's purge it to avoid trouble */ - ReadConsoleInput(hConIn, ir, 1, &count); - } - - } else if ((ir->EventType == MOUSE_EVENT - && (ir->Event.MouseEvent.dwButtonState - & MOUSEMASK))) { - done = 1; - retval = 1; - } - - else /* Discard it, it's an insignificant event */ - ReadConsoleInput(hConIn, ir, 1, &count); - } else /* There are no events in console event queue */ { - done = 1; /* Stop looking */ - retval = 0; - } - } - return retval; -} - -int __declspec(dllexport) __stdcall CheckInput(hConIn, ir, count, numpad, - mode, mod, cc) -HANDLE hConIn; -INPUT_RECORD *ir; -DWORD *count; -boolean numpad; -int mode; -int *mod; -coord *cc; -{ -#if defined(SAFERHANGUP) - DWORD dwWait; -#endif - int ch; - boolean valid = 0, done = 0; - -#ifdef QWERTZ_SUPPORT - if (numpad & 0x10) { - numpad &= ~0x10; - qwertz = TRUE; - } else { - qwertz = FALSE; - } -#endif - while (!done) { -#if defined(SAFERHANGUP) - dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for - INFINITE, // waits indefinitely - TRUE); // alertable wait enabled - if (dwWait == WAIT_FAILED) - return '\033'; -#endif - ReadConsoleInput(hConIn, ir, 1, count); - if (mode == 0) { - if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { -#ifdef QWERTZ_SUPPORT - if (qwertz) - numpad |= 0x10; -#endif - ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0); -#ifdef QWERTZ_SUPPORT - numpad &= ~0x10; -#endif - done = valid; - } - } else { - if (count > 0) { - if (ir->EventType == KEY_EVENT - && ir->Event.KeyEvent.bKeyDown) { - ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0); - if (valid) - return ch; - } else if (ir->EventType == MOUSE_EVENT) { - if ((ir->Event.MouseEvent.dwEventFlags == 0) - && (ir->Event.MouseEvent.dwButtonState & MOUSEMASK)) { - cc->x = ir->Event.MouseEvent.dwMousePosition.X + 1; - cc->y = ir->Event.MouseEvent.dwMousePosition.Y - 1; - - if (ir->Event.MouseEvent.dwButtonState & LEFTBUTTON) - *mod = CLICK_1; - else if (ir->Event.MouseEvent.dwButtonState - & RIGHTBUTTON) - *mod = CLICK_2; -#if 0 /* middle button */ - else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON) - *mod = CLICK_3; -#endif - return 0; - } - } - } else - done = 1; - } - } - return mode ? 0 : ch; -} - -int __declspec(dllexport) __stdcall SourceWhere(buf) -char **buf; -{ - if (!buf) - return 0; - *buf = where_to_get_source; - return 1; -} - -int __declspec(dllexport) __stdcall SourceAuthor(buf) -char **buf; -{ - if (!buf) - return 0; - *buf = author; - return 1; -} - -int __declspec(dllexport) __stdcall KeyHandlerName(buf, full) -char **buf; -int full; -{ - if (!buf) - return 0; - if (full) - *buf = dllname; - else - *buf = shortdllname; - return 1; -} diff -Nru nethack-3.6.6/sys/winnt/nhdefkey.c nethack-3.6.7/sys/winnt/nhdefkey.c --- nethack-3.6.6/sys/winnt/nhdefkey.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/nhdefkey.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,388 +0,0 @@ -/* NetHack 3.6 nhdefkey.c $NHDT-Date: 1432512793 2015/05/25 00:13:13 $ $NHDT-Branch: master $:$NHDT-Revision: 1.14 $ */ -/* Copyright (c) NetHack PC Development Team 2003 */ -/* NetHack may be freely redistributed. See license for details. */ - -/* - * This is the default NetHack keystroke processing. - * It can be built as a run-time loadable dll (nhdefkey.dll). - * Alternative keystroke handlers can be built using the - * entry points in this file as a template. - * - * Use the defaults.nh "altkeyhandler" option to set a - * different dll name (without the ".DLL" extension) to - * get different processing. Ensure that the dll referenced - * in defaults.nh exists in the same directory as NetHack in - * order for it to load successfully. - * - */ - -static char where_to_get_source[] = "http://www.nethack.org/"; -static char author[] = "The NetHack Development Team"; - -#include "win32api.h" -#include "hack.h" -#include "wintty.h" - -extern HANDLE hConIn; -extern INPUT_RECORD ir; -extern struct sinfo program_state; - -char dllname[512]; -char *shortdllname; - -int FDECL(__declspec(dllexport) __stdcall ProcessKeystroke, - (HANDLE hConIn, INPUT_RECORD *ir, boolean *valid, - BOOLEAN_P numberpad, int portdebug)); - -int WINAPI -DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) -{ - char dlltmpname[512]; - char *tmp = dlltmpname, *tmp2; - *(tmp + GetModuleFileName(hInstance, tmp, 511)) = '\0'; - (void) strcpy(dllname, tmp); - tmp2 = strrchr(dllname, '\\'); - if (tmp2) { - tmp2++; - shortdllname = tmp2; - } - return TRUE; -} - -/* - * Keyboard translation tables. - * (Adopted from the MSDOS port) - */ - -#define KEYPADLO 0x47 -#define KEYPADHI 0x53 - -#define PADKEYS (KEYPADHI - KEYPADLO + 1) -#define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI) - -#ifdef QWERTZ_SUPPORT -/* when 'numberpad' is 0 and Cmd.swap_yz is True - (signaled by setting 0x10 on boolean numpad argument) - treat keypress of numpad 7 as 'z' rather than 'y' */ -static boolean qwertz = FALSE; -#endif - -/* - * Keypad keys are translated to the normal values below. - * Shifted keypad keys are translated to the - * shift values below. - */ - -static const struct pad { - uchar normal, shift, cntrl; -} keypad[PADKEYS] = - { - { 'y', 'Y', C('y') }, /* 7 */ - { 'k', 'K', C('k') }, /* 8 */ - { 'u', 'U', C('u') }, /* 9 */ - { 'm', C('p'), C('p') }, /* - */ - { 'h', 'H', C('h') }, /* 4 */ - { 'g', 'G', 'g' }, /* 5 */ - { 'l', 'L', C('l') }, /* 6 */ - { '+', 'P', C('p') }, /* + */ - { 'b', 'B', C('b') }, /* 1 */ - { 'j', 'J', C('j') }, /* 2 */ - { 'n', 'N', C('n') }, /* 3 */ - { 'i', 'I', C('i') }, /* Ins */ - { '.', ':', ':' } /* Del */ - }, - numpad[PADKEYS] = { - { '7', M('7'), '7' }, /* 7 */ - { '8', M('8'), '8' }, /* 8 */ - { '9', M('9'), '9' }, /* 9 */ - { 'm', C('p'), C('p') }, /* - */ - { '4', M('4'), '4' }, /* 4 */ - { '5', M('5'), '5' }, /* 5 */ - { '6', M('6'), '6' }, /* 6 */ - { '+', 'P', C('p') }, /* + */ - { '1', M('1'), '1' }, /* 1 */ - { '2', M('2'), '2' }, /* 2 */ - { '3', M('3'), '3' }, /* 3 */ - { '0', M('0'), '0' }, /* Ins */ - { '.', ':', ':' } /* Del */ - }; - -#define inmap(x, vk) (((x) > 'A' && (x) < 'Z') || (vk) == 0xBF || (x) == '2') - -static BYTE KeyState[256]; - -int __declspec(dllexport) __stdcall ProcessKeystroke(hConIn, ir, valid, - numberpad, portdebug) -HANDLE hConIn; -INPUT_RECORD *ir; -boolean *valid; -boolean numberpad; -int portdebug; -{ - int metaflags = 0, k = 0; - int keycode, vk; - unsigned char ch, pre_ch, mk = 0; - unsigned short int scan; - unsigned long shiftstate; - int altseq = 0; - const struct pad *kpad; - -#ifdef QWERTZ_SUPPORT - if (numberpad & 0x10) { - numberpad &= ~0x10; - qwertz = TRUE; - } else { - qwertz = FALSE; - } -#endif - shiftstate = 0L; - ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar; - scan = ir->Event.KeyEvent.wVirtualScanCode; - vk = ir->Event.KeyEvent.wVirtualKeyCode; - keycode = MapVirtualKey(vk, 2); - shiftstate = ir->Event.KeyEvent.dwControlKeyState; - KeyState[VK_SHIFT] = (shiftstate & SHIFT_PRESSED) ? 0x81 : 0; - KeyState[VK_CONTROL] = - (shiftstate & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) ? 0x81 : 0; - KeyState[VK_CAPITAL] = (shiftstate & CAPSLOCK_ON) ? 0x81 : 0; - - if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { - if (ch || inmap(keycode, vk)) - altseq = 1; - else - altseq = -1; /* invalid altseq */ - } - if (ch || (iskeypad(scan)) || (altseq > 0)) - *valid = TRUE; - /* if (!valid) return 0; */ - /* - * shiftstate can be checked to see if various special - * keys were pressed at the same time as the key. - * Currently we are using the ALT & SHIFT & CONTROLS. - * - * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED, - * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED, - * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON, - * CAPSLOCK_ON, ENHANCED_KEY - * - * are all valid bit masks to use on shiftstate. - * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the - * left control key was pressed with the keystroke. - */ - if (iskeypad(scan)) { - kpad = numberpad ? numpad : keypad; - if (shiftstate & SHIFT_PRESSED) { - ch = kpad[scan - KEYPADLO].shift; - } else if (shiftstate & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) { - ch = kpad[scan - KEYPADLO].cntrl; - } else { - ch = kpad[scan - KEYPADLO].normal; - } -#ifdef QWERTZ_SUPPORT - /* OPTIONS=number_pad:-1 is for qwertz keyboard; for that setting, - 'numberpad' will be 0; core swaps y to zap, z to move northwest; - we want numpad 7 to move northwest, so when qwertz is set, - tell core that user who types numpad 7 typed z rather than y */ - if (qwertz && kpad[scan - KEYPADLO].normal == 'y') - ch += 1; /* changes y to z, Y to Z, ^Y to ^Z */ -#endif /*QWERTZ_SUPPORT*/ - } else if (altseq > 0) { /* ALT sequence */ - if (vk == 0xBF) - ch = M('?'); - else - ch = M(tolower((uchar) keycode)); - } - /* Attempt to work better with international keyboards. */ - else { - WORD chr[2]; - k = ToAscii(vk, scan, KeyState, chr, 0); - if (k <= 2) - switch (k) { - case 2: /* two characters */ - ch = (unsigned char) chr[1]; - *valid = TRUE; - break; - case 1: /* one character */ - ch = (unsigned char) chr[0]; - *valid = TRUE; - break; - case 0: /* no translation */ - default: /* negative */ - *valid = FALSE; - } - } - if (ch == '\r') - ch = '\n'; -#ifdef PORT_DEBUG - if (portdebug) { - char buf[BUFSZ]; - Sprintf(buf, "PORTDEBUG (%s): ch=%u, sc=%u, vk=%d, pre=%d, sh=0x%X, " - "ta=%d (ESC to end)", - shortdllname, ch, scan, vk, pre_ch, shiftstate, k); - fprintf(stdout, "\n%s", buf); - } -#endif - return ch; -} - -int __declspec(dllexport) __stdcall NHkbhit(hConIn, ir) -HANDLE hConIn; -INPUT_RECORD *ir; -{ - int done = 0; /* true = "stop searching" */ - int retval; /* true = "we had a match" */ - DWORD count; - unsigned short int scan; - unsigned char ch; - unsigned long shiftstate; - int altseq = 0, keycode, vk; - done = 0; - retval = 0; - while (!done) { - count = 0; - PeekConsoleInput(hConIn, ir, 1, &count); - if (count > 0) { - if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { - ch = ir->Event.KeyEvent.uChar.AsciiChar; - scan = ir->Event.KeyEvent.wVirtualScanCode; - shiftstate = ir->Event.KeyEvent.dwControlKeyState; - vk = ir->Event.KeyEvent.wVirtualKeyCode; - keycode = MapVirtualKey(vk, 2); - if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { - if (ch || inmap(keycode, vk)) - altseq = 1; - else - altseq = -1; /* invalid altseq */ - } - if (ch || iskeypad(scan) || altseq) { - done = 1; /* Stop looking */ - retval = 1; /* Found what we sought */ - } else { - /* Strange Key event; let's purge it to avoid trouble */ - ReadConsoleInput(hConIn, ir, 1, &count); - } - - } else if ((ir->EventType == MOUSE_EVENT - && (ir->Event.MouseEvent.dwButtonState - & MOUSEMASK))) { - done = 1; - retval = 1; - } - - else /* Discard it, it's an insignificant event */ - ReadConsoleInput(hConIn, ir, 1, &count); - } else /* There are no events in console event queue */ { - done = 1; /* Stop looking */ - retval = 0; - } - } - return retval; -} - -int __declspec(dllexport) __stdcall CheckInput(hConIn, ir, count, numpad, - mode, mod, cc) -HANDLE hConIn; -INPUT_RECORD *ir; -DWORD *count; -boolean numpad; -int mode; -int *mod; -coord *cc; -{ -#if defined(SAFERHANGUP) - DWORD dwWait; -#endif - int ch; - boolean valid = 0, done = 0; - -#ifdef QWERTZ_SUPPORT - if (numpad & 0x10) { - numpad &= ~0x10; - qwertz = TRUE; - } else { - qwertz = FALSE; - } -#endif - while (!done) { -#if defined(SAFERHANGUP) - dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for - INFINITE, // waits indefinitely - TRUE); // alertable wait enabled - if (dwWait == WAIT_FAILED) - return '\033'; -#endif - ReadConsoleInput(hConIn, ir, 1, count); - if (mode == 0) { - if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { - ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0); - done = valid; - } - } else { - if (count > 0) { - if (ir->EventType == KEY_EVENT - && ir->Event.KeyEvent.bKeyDown) { -#ifdef QWERTZ_SUPPORT - if (qwertz) - numpad |= 0x10; -#endif - ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0); -#ifdef QWERTZ_SUPPORT - numpad &= ~0x10; -#endif - if (valid) - return ch; - } else if (ir->EventType == MOUSE_EVENT) { - if ((ir->Event.MouseEvent.dwEventFlags == 0) - && (ir->Event.MouseEvent.dwButtonState & MOUSEMASK)) { - cc->x = ir->Event.MouseEvent.dwMousePosition.X + 1; - cc->y = ir->Event.MouseEvent.dwMousePosition.Y - 1; - - if (ir->Event.MouseEvent.dwButtonState & LEFTBUTTON) - *mod = CLICK_1; - else if (ir->Event.MouseEvent.dwButtonState - & RIGHTBUTTON) - *mod = CLICK_2; -#if 0 /* middle button */ - else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON) - *mod = CLICK_3; -#endif - return 0; - } - } - } else - done = 1; - } - } - return mode ? 0 : ch; -} - -int __declspec(dllexport) __stdcall SourceWhere(buf) -char **buf; -{ - if (!buf) - return 0; - *buf = where_to_get_source; - return 1; -} - -int __declspec(dllexport) __stdcall SourceAuthor(buf) -char **buf; -{ - if (!buf) - return 0; - *buf = author; - return 1; -} - -int __declspec(dllexport) __stdcall KeyHandlerName(buf, full) -char **buf; -int full; -{ - if (!buf) - return 0; - if (full) - *buf = dllname; - else - *buf = shortdllname; - return 1; -} diff -Nru nethack-3.6.6/sys/winnt/nhraykey.c nethack-3.6.7/sys/winnt/nhraykey.c --- nethack-3.6.6/sys/winnt/nhraykey.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/nhraykey.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,669 +0,0 @@ -/* NetHack 3.6 nhraykey.c $NHDT-Date: 1457207047 2016/03/05 19:44:07 $ $NHDT-Branch: chasonr $:$NHDT-Revision: 1.16 $ */ -/* Copyright (c) NetHack PC Development Team 2003 */ -/* NetHack may be freely redistributed. See license for details. */ - -/* - * Keystroke handling contributed by Ray Chason. - * The following text was written by Ray Chason. - * - * The problem - * =========== - * - * The console-mode Nethack wants both keyboard and mouse input. The - * problem is that the Windows API provides no easy way to get mouse input - * and also keyboard input properly translated according to the user's - * chosen keyboard layout. - * - * The ReadConsoleInput function returns a stream of keyboard and mouse - * events. Nethack is interested in those events that represent a key - * pressed, or a click on a mouse button. The keyboard events from - * ReadConsoleInput are not translated according to the keyboard layout, - * and do not take into account the shift, control, or alt keys. - * - * The PeekConsoleInput function works similarly to ReadConsoleInput, - * except that it does not remove an event from the queue and it returns - * instead of blocking when the queue is empty. - * - * A program can also use ReadConsole to get a properly translated stream - * of characters. Unfortunately, ReadConsole does not return mouse events, - * does not distinguish the keypad from the main keyboard, does not return - * keys shifted with Alt, and does not even return the ESC key when - * pressed. - * - * We want both the functionality of ReadConsole and the functionality of - * ReadConsoleInput. But Microsoft didn't seem to think of that. - * - * - * The solution, in the original code - * ================================== - * - * The original 3.4.1 distribution tries to get proper keyboard translation - * by passing keyboard events to the ToAscii function. This works, to some - * extent -- it takes the shift key into account, and it processes dead - * keys properly. But it doesn't take non-US keyboards into account. It - * appears that ToAscii is meant for windowed applications, and does not - * have enough information to do its job properly in a console application. - * - * - * The Finnish keyboard patch - * ========================== - * - * This patch adds the "subkeyvalue" option to the defaults.nh file. The - * user can then add OPTIONS=sukeyvalue:171/92, for instance, to replace - * the 171 character with 92, which is \. This works, once properly - * configured, but places too much burden on the user. It also bars the - * use of the substituted characters in naming objects or monsters. - * - * - * The solution presented here - * =========================== - * - * The best way I could find to combine the functionality of ReadConsole - * with that of ReadConsoleInput is simple in concept. First, call - * PeekConsoleInput to get the first event. If it represents a key press, - * call ReadConsole to retrieve the key. Otherwise, pop it off the queue - * with ReadConsoleInput and, if it's a mouse click, return it as such. - * - * But the Devil, as they say, is in the details. The problem is in - * recognizing an event that ReadConsole will return as a key. We don't - * want to call ReadConsole unless we know that it will immediately return: - * if it blocks, the mouse and the Alt sequences will cease to function - * until it returns. - * - * Separating process_keystroke into two functions, one for commands and a - * new one, process_keystroke2, for answering prompts, makes the job a lot - * easier. process_keystroke2 doesn't have to worry about mouse events or - * Alt sequences, and so the consequences are minor if ReadConsole blocks. - * process_keystroke, OTOH, never needs to return a non-ASCII character - * that was read from ReadConsole; it returns bytes with the high bit set - * only in response to an Alt sequence. - * - * So in process_keystroke, before calling ReadConsole, a bogus key event - * is pushed on the queue. This event causes ReadConsole to return, even - * if there was no other character available. Because the bogus key has - * the eighth bit set, it is filtered out. This is not done in - * process_keystroke2, because that would render dead keys unusable. - * - * A separate process_keystroke2 can also process the numeric keypad in a - * way that makes sense for prompts: just return the corresponding symbol, - * and pay no mind to number_pad or the num lock key. - * - * The recognition of Alt sequences is modified, to support the use of - * characters generated with the AltGr key. A keystroke is an Alt sequence - * if an Alt key is seen that can't be an AltGr (since an AltGr sequence - * could be a character, and in some layouts it could even be an ASCII - * character). This recognition is different on NT-based and 95-based - * Windows: - * - * * On NT-based Windows, AltGr signals as right Alt and left Ctrl - * together. So an Alt sequence is recognized if either Alt key is - * pressed and if right Alt and left Ctrl are not both present. This - * is true even if the keyboard in use does not have an AltGr key, and - * uses right Alt for AltGr. - * - * * On 95-based Windows, with a keyboard that lacks the AltGr key, the - * right Alt key is used instead. But it still signals as right Alt, - * without left Ctrl. There is no way for the application to know - * whether right Alt is Alt or AltGr, and so it is always assumed - * to be AltGr. This means that Alt sequences must be formed with - * left Alt. - * - * So the patch processes keystrokes as follows: - * - * * If the scan and virtual key codes are both 0, it's the bogus key, - * and we ignore it. - * - * * Keys on the numeric keypad are processed for commands as in the - * unpatched Nethack, and for prompts by returning the ASCII - * character, even if the num lock is off. - * - * * Alt sequences are processed for commands as in the unpatched - * Nethack, and ignored for prompts. - * - * * Control codes are returned as received, because ReadConsole will - * not return the ESC key. - * - * * Other key-down events are passed to ReadConsole. The use of - * ReadConsole is different for commands than for prompts: - * - * o For commands, the bogus key is pushed onto the queue before - * ReadConsole is called. On return, non-ASCII characters are - * filtered, so they are not mistaken for Alt sequences; this also - * filters the bogus key. - * - * o For prompts, the bogus key is not used, because that would - * interfere with dead keys. Eight bit characters may be returned, - * and are coded in the configured code page. - * - * - * Possible improvements - * ===================== - * - * Some possible improvements remain: - * - * * Integrate the existing Finnish keyboard patch, for use with non- - * QWERTY layouts such as the German QWERTZ keyboard or Dvorak. - * - * * Fix the keyboard glitches in the graphical version. Namely, dead - * keys don't work, and input comes in as ISO-8859-1 but is displayed - * as code page 437 if IBMgraphics is set on startup. - * - * * Transform incoming text to ISO-8859-1, for full compatibility with - * the graphical version. - * - * * After pushing the bogus key and calling ReadConsole, check to see - * if we got the bogus key; if so, and an Alt is pressed, process the - * event as an Alt sequence. - * - */ - -static char where_to_get_source[] = "http://www.nethack.org/"; -static char author[] = "Ray Chason"; - -#include "win32api.h" -#include "hack.h" -#include "wintty.h" - -extern HANDLE hConIn; -extern INPUT_RECORD ir; -char dllname[512]; -char *shortdllname; - -int FDECL(__declspec(dllexport) __stdcall ProcessKeystroke, - (HANDLE hConIn, INPUT_RECORD *ir, boolean *valid, - BOOLEAN_P numberpad, int portdebug)); - -static INPUT_RECORD bogus_key; - -int WINAPI -DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) -{ - char dlltmpname[512]; - char *tmp = dlltmpname, *tmp2; - *(tmp + GetModuleFileName(hInstance, tmp, 511)) = '\0'; - (void) strcpy(dllname, tmp); - tmp2 = strrchr(dllname, '\\'); - if (tmp2) { - tmp2++; - shortdllname = tmp2; - } - /* A bogus key that will be filtered when received, to keep ReadConsole - * from blocking */ - bogus_key.EventType = KEY_EVENT; - bogus_key.Event.KeyEvent.bKeyDown = 1; - bogus_key.Event.KeyEvent.wRepeatCount = 1; - bogus_key.Event.KeyEvent.wVirtualKeyCode = 0; - bogus_key.Event.KeyEvent.wVirtualScanCode = 0; - bogus_key.Event.KeyEvent.uChar.AsciiChar = (uchar) 0x80; - bogus_key.Event.KeyEvent.dwControlKeyState = 0; - return TRUE; -} - -/* - * Keyboard translation tables. - * (Adopted from the MSDOS port) - */ - -#define KEYPADLO 0x47 -#define KEYPADHI 0x53 - -#define PADKEYS (KEYPADHI - KEYPADLO + 1) -#define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI) -#define isnumkeypad(x) \ - (KEYPADLO <= (x) && (x) <= 0x51 && (x) != 0x4A && (x) != 0x4E) - -#ifdef QWERTZ_SUPPORT -/* when 'numberpad' is 0 and Cmd.swap_yz is True - (signaled by setting 0x10 on boolean numpad argument) - treat keypress of numpad 7 as 'z' rather than 'y' */ -static boolean qwertz = FALSE; -#endif - -/* - * Keypad keys are translated to the normal values below. - * Shifted keypad keys are translated to the - * shift values below. - */ - -static const struct pad { - uchar normal, shift, cntrl; -} keypad[PADKEYS] = - { - { 'y', 'Y', C('y') }, /* 7 */ - { 'k', 'K', C('k') }, /* 8 */ - { 'u', 'U', C('u') }, /* 9 */ - { 'm', C('p'), C('p') }, /* - */ - { 'h', 'H', C('h') }, /* 4 */ - { 'g', 'G', 'g' }, /* 5 */ - { 'l', 'L', C('l') }, /* 6 */ - { '+', 'P', C('p') }, /* + */ - { 'b', 'B', C('b') }, /* 1 */ - { 'j', 'J', C('j') }, /* 2 */ - { 'n', 'N', C('n') }, /* 3 */ - { 'i', 'I', C('i') }, /* Ins */ - { '.', ':', ':' } /* Del */ - }, - numpad[PADKEYS] = { - { '7', M('7'), '7' }, /* 7 */ - { '8', M('8'), '8' }, /* 8 */ - { '9', M('9'), '9' }, /* 9 */ - { 'm', C('p'), C('p') }, /* - */ - { '4', M('4'), '4' }, /* 4 */ - { 'g', 'G', 'g' }, /* 5 */ - { '6', M('6'), '6' }, /* 6 */ - { '+', 'P', C('p') }, /* + */ - { '1', M('1'), '1' }, /* 1 */ - { '2', M('2'), '2' }, /* 2 */ - { '3', M('3'), '3' }, /* 3 */ - { 'i', 'I', C('i') }, /* Ins */ - { '.', ':', ':' } /* Del */ - }; - -#define inmap(x, vk) (((x) > 'A' && (x) < 'Z') || (vk) == 0xBF || (x) == '2') - -/* Use process_keystroke for key commands, process_keystroke2 for prompts */ -/* int FDECL(process_keystroke, (INPUT_RECORD *ir, boolean *valid, int - * portdebug)); */ -int FDECL(process_keystroke2, (HANDLE, INPUT_RECORD *ir, boolean *valid)); -static int FDECL(is_altseq, (unsigned long shiftstate)); - -static int -is_altseq(shiftstate) -unsigned long shiftstate; -{ - /* We need to distinguish the Alt keys from the AltGr key. - * On NT-based Windows, AltGr signals as right Alt and left Ctrl together; - * on 95-based Windows, AltGr signals as right Alt only. - * So on NT, we signal Alt if either Alt is pressed and left Ctrl is not, - * and on 95, we signal Alt for left Alt only. */ - switch (shiftstate - & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED)) { - case LEFT_ALT_PRESSED: - case LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED: - return 1; - - case RIGHT_ALT_PRESSED: - case RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED: - return (GetVersion() & 0x80000000) == 0; - - default: - return 0; - } -} - -int __declspec(dllexport) __stdcall ProcessKeystroke(hConIn, ir, valid, - numberpad, portdebug) -HANDLE hConIn; -INPUT_RECORD *ir; -boolean *valid; -boolean numberpad; -int portdebug; -{ - int metaflags = 0, k = 0; - int keycode, vk; - unsigned char ch, pre_ch, mk = 0; - unsigned short int scan; - unsigned long shiftstate; - int altseq = 0; - const struct pad *kpad; - DWORD count; - -#ifdef QWERTZ_SUPPORT - if (numberpad & 0x10) { - numberpad &= ~0x10; - qwertz = TRUE; - } else { - qwertz = FALSE; - } -#endif - shiftstate = 0L; - ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar; - scan = ir->Event.KeyEvent.wVirtualScanCode; - vk = ir->Event.KeyEvent.wVirtualKeyCode; - keycode = MapVirtualKey(vk, 2); - shiftstate = ir->Event.KeyEvent.dwControlKeyState; - if (scan == 0 && vk == 0) { - /* It's the bogus_key */ - ReadConsoleInput(hConIn, ir, 1, &count); - *valid = FALSE; - return 0; - } - - if (is_altseq(shiftstate)) { - if (ch || inmap(keycode, vk)) - altseq = 1; - else - altseq = -1; /* invalid altseq */ - } - if (ch || (iskeypad(scan)) || (altseq > 0)) - *valid = TRUE; - /* if (!valid) return 0; */ - /* - * shiftstate can be checked to see if various special - * keys were pressed at the same time as the key. - * Currently we are using the ALT & SHIFT & CONTROLS. - * - * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED, - * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED, - * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON, - * CAPSLOCK_ON, ENHANCED_KEY - * - * are all valid bit masks to use on shiftstate. - * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the - * left control key was pressed with the keystroke. - */ - if (iskeypad(scan)) { - ReadConsoleInput(hConIn, ir, 1, &count); - kpad = numberpad ? numpad : keypad; - if (shiftstate & SHIFT_PRESSED) { - ch = kpad[scan - KEYPADLO].shift; - } else if (shiftstate & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) { - ch = kpad[scan - KEYPADLO].cntrl; - } else { - ch = kpad[scan - KEYPADLO].normal; - } -#ifdef QWERTZ_SUPPORT - /* OPTIONS=number_pad:-1 is for qwertz keyboard; for that setting, - 'numberpad' will be 0; core swaps y to zap, z to move northwest; - we want numpad 7 to move northwest, so when qwertz is set, - tell core that user who types numpad 7 typed z rather than y */ - if (qwertz && kpad[scan - KEYPADLO].normal == 'y') - ch += 1; /* changes y to z, Y to Z, ^Y to ^Z */ -#endif /*QWERTZ_SUPPORT*/ - } else if (altseq > 0) { /* ALT sequence */ - ReadConsoleInput(hConIn, ir, 1, &count); - if (vk == 0xBF) - ch = M('?'); - else - ch = M(tolower((uchar) keycode)); - } else if (ch < 32 && !isnumkeypad(scan)) { - /* Control code; ReadConsole seems to filter some of these, - * including ESC */ - ReadConsoleInput(hConIn, ir, 1, &count); - } - /* Attempt to work better with international keyboards. */ - else { - CHAR ch2; - DWORD written; - /* The bogus_key guarantees that ReadConsole will return, - * and does not itself do anything */ - WriteConsoleInput(hConIn, &bogus_key, 1, &written); - ReadConsole(hConIn, &ch2, 1, &count, NULL); - /* Prevent high characters from being interpreted as alt - * sequences; also filter the bogus_key */ - if (ch2 & 0x80) - *valid = FALSE; - else - ch = ch2; - if (ch == 0) - *valid = FALSE; - } - if (ch == '\r') - ch = '\n'; -#ifdef PORT_DEBUG - if (portdebug) { - char buf[BUFSZ]; - Sprintf(buf, "PORTDEBUG: ch=%u, scan=%u, vk=%d, pre=%d, " - "shiftstate=0x%X (ESC to end)\n", - ch, scan, vk, pre_ch, shiftstate); - fprintf(stdout, "\n%s", buf); - } -#endif - return ch; -} - -int -process_keystroke2(hConIn, ir, valid) -HANDLE hConIn; -INPUT_RECORD *ir; -boolean *valid; -{ - /* Use these values for the numeric keypad */ - static const char keypad_nums[] = "789-456+1230."; - - unsigned char ch; - int vk; - unsigned short int scan; - unsigned long shiftstate; - int altseq; - DWORD count; - - ch = ir->Event.KeyEvent.uChar.AsciiChar; - vk = ir->Event.KeyEvent.wVirtualKeyCode; - scan = ir->Event.KeyEvent.wVirtualScanCode; - shiftstate = ir->Event.KeyEvent.dwControlKeyState; - - if (scan == 0 && vk == 0) { - /* It's the bogus_key */ - ReadConsoleInput(hConIn, ir, 1, &count); - *valid = FALSE; - return 0; - } - - altseq = is_altseq(shiftstate); - if (ch || (iskeypad(scan)) || altseq) - *valid = TRUE; - /* if (!valid) return 0; */ - /* - * shiftstate can be checked to see if various special - * keys were pressed at the same time as the key. - * Currently we are using the ALT & SHIFT & CONTROLS. - * - * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED, - * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED, - * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON, - * CAPSLOCK_ON, ENHANCED_KEY - * - * are all valid bit masks to use on shiftstate. - * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the - * left control key was pressed with the keystroke. - */ - if (iskeypad(scan) && !altseq) { - ReadConsoleInput(hConIn, ir, 1, &count); - ch = keypad_nums[scan - KEYPADLO]; - } else if (ch < 32 && !isnumkeypad(scan)) { - /* Control code; ReadConsole seems to filter some of these, - * including ESC */ - ReadConsoleInput(hConIn, ir, 1, &count); - } - /* Attempt to work better with international keyboards. */ - else { - CHAR ch2; - ReadConsole(hConIn, &ch2, 1, &count, NULL); - ch = ch2 & 0xFF; - if (ch == 0) - *valid = FALSE; - } - if (ch == '\r') - ch = '\n'; - return ch; -} - -int __declspec(dllexport) __stdcall CheckInput(hConIn, ir, count, numpad, - mode, mod, cc) -HANDLE hConIn; -INPUT_RECORD *ir; -DWORD *count; -int mode; -int *mod; -boolean numpad; -coord *cc; -{ -#if defined(SAFERHANGUP) - DWORD dwWait; -#endif - int ch; - boolean valid = 0, done = 0; - -#ifdef QWERTZ_SUPPORT - if (numpad & 0x10) { - numpad &= ~0x10; - qwertz = TRUE; - } else { - qwertz = FALSE; - } -#endif - while (!done) { - *count = 0; - dwWait = WaitForSingleObject(hConIn, INFINITE); -#if defined(SAFERHANGUP) - if (dwWait == WAIT_FAILED) - return '\033'; -#endif - PeekConsoleInput(hConIn, ir, 1, count); - if (mode == 0) { - if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { - ch = process_keystroke2(hConIn, ir, &valid); - done = valid; - } else - ReadConsoleInput(hConIn, ir, 1, count); - } else { - ch = 0; - if (count > 0) { - if (ir->EventType == KEY_EVENT - && ir->Event.KeyEvent.bKeyDown) { -#ifdef QWERTZ_SUPPORT - if (qwertz) - numpad |= 0x10; -#endif - ch = ProcessKeystroke(hConIn, ir, &valid, numpad, -#ifdef PORTDEBUG - 1); -#else - 0); -#endif -#ifdef QWERTZ_SUPPORT - numpad &= ~0x10; -#endif - if (valid) - return ch; - } else { - ReadConsoleInput(hConIn, ir, 1, count); - if (ir->EventType == MOUSE_EVENT) { - if ((ir->Event.MouseEvent.dwEventFlags == 0) - && (ir->Event.MouseEvent.dwButtonState - & MOUSEMASK)) { - cc->x = - ir->Event.MouseEvent.dwMousePosition.X + 1; - cc->y = - ir->Event.MouseEvent.dwMousePosition.Y - 1; - - if (ir->Event.MouseEvent.dwButtonState - & LEFTBUTTON) - *mod = CLICK_1; - else if (ir->Event.MouseEvent.dwButtonState - & RIGHTBUTTON) - *mod = CLICK_2; -#if 0 /* middle button */ - else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON) - *mod = CLICK_3; -#endif - return 0; - } - } -#if 0 - /* We ignore these types of console events */ - else if (ir->EventType == FOCUS_EVENT) { - } - else if (ir->EventType == MENU_EVENT) { - } -#endif - } - } else - done = 1; - } - } - *mod = 0; - return ch; -} - -int __declspec(dllexport) __stdcall NHkbhit(hConIn, ir) -HANDLE hConIn; -INPUT_RECORD *ir; -{ - int done = 0; /* true = "stop searching" */ - int retval; /* true = "we had a match" */ - DWORD count; - unsigned short int scan; - unsigned char ch; - unsigned long shiftstate; - int altseq = 0, keycode, vk; - - done = 0; - retval = 0; - while (!done) { - count = 0; - PeekConsoleInput(hConIn, ir, 1, &count); - if (count > 0) { - if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { - ch = ir->Event.KeyEvent.uChar.AsciiChar; - scan = ir->Event.KeyEvent.wVirtualScanCode; - shiftstate = ir->Event.KeyEvent.dwControlKeyState; - vk = ir->Event.KeyEvent.wVirtualKeyCode; - if (scan == 0 && vk == 0) { - /* It's the bogus_key. Discard it */ - ReadConsoleInput(hConIn,ir,1,&count); - } else { - keycode = MapVirtualKey(vk, 2); - if (is_altseq(shiftstate)) { - if (ch || inmap(keycode, vk)) - altseq = 1; - else - altseq = -1; /* invalid altseq */ - } - if (ch || iskeypad(scan) || altseq) { - done = 1; /* Stop looking */ - retval = 1; /* Found what we sought */ - } else { - /* Strange Key event; let's purge it to avoid trouble */ - ReadConsoleInput(hConIn, ir, 1, &count); - } - } - - } else if ((ir->EventType == MOUSE_EVENT - && (ir->Event.MouseEvent.dwButtonState - & MOUSEMASK))) { - done = 1; - retval = 1; - } - - else /* Discard it, it's an insignificant event */ - ReadConsoleInput(hConIn, ir, 1, &count); - } else /* There are no events in console event queue */ { - done = 1; /* Stop looking */ - retval = 0; - } - } - return retval; -} - -int __declspec(dllexport) __stdcall SourceWhere(buf) -char **buf; -{ - if (!buf) - return 0; - *buf = where_to_get_source; - return 1; -} - -int __declspec(dllexport) __stdcall SourceAuthor(buf) -char **buf; -{ - if (!buf) - return 0; - *buf = author; - return 1; -} - -int __declspec(dllexport) __stdcall KeyHandlerName(buf, full) -char **buf; -int full; -{ - if (!buf) - return 0; - if (full) - *buf = dllname; - else - *buf = shortdllname; - return 1; -} diff -Nru nethack-3.6.6/sys/winnt/nttty.c nethack-3.6.7/sys/winnt/nttty.c --- nethack-3.6.6/sys/winnt/nttty.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/nttty.c 2023-02-15 21:52:57.000000000 +0000 @@ -8,8 +8,8 @@ * Initial Creation M. Allison 1993/01/31 * Switch to low level console output routines M. Allison 2003/10/01 * Restrict cursor movement until input pending M. Lehotay 2003/10/02 - * Call Unicode version of output API on NT R. Chason 2005/10/28 - * Use of back buffer to improve performance B. House 2018/05/06 + * Call Unicode version of output API on NT R. Chason 2005/10/28 + * Use of back buffer to improve performance B. House 2018/05/06 * */ @@ -179,33 +179,36 @@ char erase_char, kill_char; #define DEFTEXTCOLOR ttycolors[7] -/* dynamic keystroke handling .DLL support */ -typedef int(__stdcall *PROCESS_KEYSTROKE)(HANDLE, INPUT_RECORD *, boolean *, - BOOLEAN_P, int); - -typedef int(__stdcall *NHKBHIT)(HANDLE, INPUT_RECORD *); - -typedef int(__stdcall *CHECKINPUT)(HANDLE, INPUT_RECORD *, DWORD *, BOOLEAN_P, +int default_processkeystroke(HANDLE, INPUT_RECORD *, boolean *, boolean, int); +int default_kbhit(HANDLE, INPUT_RECORD *); +int default_checkinput(HANDLE, INPUT_RECORD *, DWORD *, boolean, + int, int *, coord *); + +int ray_processkeystroke(HANDLE, INPUT_RECORD *, boolean *, boolean, int); +int ray_kbhit(HANDLE, INPUT_RECORD *); +int ray_checkinput(HANDLE, INPUT_RECORD *, DWORD *, boolean, + int, int *, coord *); + +int nh340_processkeystroke(HANDLE, INPUT_RECORD *, boolean *, boolean, int); +int nh340_kbhit(HANDLE, INPUT_RECORD *); +int nh340_checkinput(HANDLE, INPUT_RECORD *, DWORD *, boolean, + int, int *, coord *); + +struct keyboard_handling_t { + char *pKeyHandlingName; + int (*pProcessKeystroke)(HANDLE, INPUT_RECORD *, boolean *, + boolean, int); + int (*pNHkbhit)(HANDLE, INPUT_RECORD *); + int (*pCheckInput)(HANDLE, INPUT_RECORD *, DWORD *, boolean, int, int *, coord *); +} keyboard_handling = { + (char *) no_keyhandling, + default_processkeystroke, + default_kbhit, + default_checkinput +}; -typedef int(__stdcall *SOURCEWHERE)(char **); - -typedef int(__stdcall *SOURCEAUTHOR)(char **); - -typedef int(__stdcall *KEYHANDLERNAME)(char **, int); - -typedef struct { - char * name; // name without DLL extension - HANDLE hLibrary; - PROCESS_KEYSTROKE pProcessKeystroke; - NHKBHIT pNHkbhit; - CHECKINPUT pCheckInput; - SOURCEWHERE pSourceWhere; - SOURCEAUTHOR pSourceAuthor; - KEYHANDLERNAME pKeyHandlerName; -} keyboard_handler_t; - -keyboard_handler_t keyboard_handler; +static INPUT_RECORD bogus_key; /* Console buffer flipping support */ @@ -244,7 +247,7 @@ void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y) { nhassert(x >= 0 && x < console.width); - nhassert(y >= 0 && ((y < console.height) || (y == console.height && + nhassert(y >= 0 && ((y < console.height) || (y == console.height && x == 0))); cell_t * dst = buffer + console.width * y + x; @@ -259,7 +262,7 @@ static void buffer_clear_to_end_of_line(cell_t * buffer, int x, int y) { nhassert(x >= 0 && x < console.width); - nhassert(y >= 0 && ((y < console.height) || (y == console.height && + nhassert(y >= 0 && ((y < console.height) || (y == console.height && x == 0))); cell_t * dst = buffer + console.width * y + x; cell_t *sentinel = buffer + console.width * (y + 1); @@ -433,7 +436,7 @@ if (Cmd.swap_yz) numberpad |= 0x10; #endif - ch = keyboard_handler.pProcessKeystroke( + ch = keyboard_handling.pProcessKeystroke( console.hConIn, ir, valid, numberpad, portdebug); #ifdef QWERTZ_SUPPORT numberpad &= ~0x10; @@ -447,7 +450,7 @@ int nttty_kbhit() { - return keyboard_handler.pNHkbhit(console.hConIn, &ir); + return keyboard_handling.pNHkbhit(console.hConIn, &ir); } int @@ -468,7 +471,7 @@ return (program_state.done_hup) ? '\033' - : keyboard_handler.pCheckInput( + : keyboard_handling.pCheckInput( console.hConIn, &ir, &count, numpad, 0, &mod, &cc); } @@ -490,7 +493,7 @@ #endif ch = (program_state.done_hup) ? '\033' - : keyboard_handler.pCheckInput( + : keyboard_handling.pCheckInput( console.hConIn, &ir, &count, numpad, 1, mod, &cc); #ifdef QWERTZ_SUPPORT numpad &= ~0x10; @@ -710,7 +713,7 @@ void clear_screen() { - buffer_fill_to_end(console.back_buffer, &clear_cell, 0, 0); + buffer_fill_to_end(console.back_buffer, &clear_cell, 0, 0); home(); } @@ -995,38 +998,6 @@ (void) doredraw(); } void -win32con_handler_info() -{ - char *buf; - int ci; - if (!keyboard_handler.pSourceAuthor && !keyboard_handler.pSourceWhere) - pline("Keyboard handler source info and author unavailable."); - else { - if (keyboard_handler.pKeyHandlerName && - keyboard_handler.pKeyHandlerName(&buf, 1)) { - xputs("\n"); - xputs("Keystroke handler loaded: \n "); - xputs(buf); - } - if (keyboard_handler.pSourceAuthor && - keyboard_handler.pSourceAuthor(&buf)) { - xputs("\n"); - xputs("Keystroke handler Author: \n "); - xputs(buf); - } - if (keyboard_handler.pSourceWhere && - keyboard_handler.pSourceWhere(&buf)) { - xputs("\n"); - xputs("Keystroke handler source code available at:\n "); - xputs(buf); - } - xputs("\nPress any key to resume."); - ci = nhgetch(); - (void) doredraw(); - } -} - -void win32con_toggle_cursor_info() { display_cursor_info = !display_cursor_info; @@ -1067,81 +1038,6 @@ key_overrides[idx] = val; } -void unload_keyboard_handler() -{ - nhassert(keyboard_handler.hLibrary != NULL); - - FreeLibrary(keyboard_handler.hLibrary); - memset(&keyboard_handler, 0, sizeof(keyboard_handler_t)); -} - -boolean -load_keyboard_handler(const char * inName) -{ - char path[MAX_ALTKEYHANDLER + 4]; - strcpy(path, inName); - strcat(path, ".dll"); - - HANDLE hLibrary = LoadLibrary(path); - - if (hLibrary == NULL) - return FALSE; - - PROCESS_KEYSTROKE pProcessKeystroke = (PROCESS_KEYSTROKE) GetProcAddress( - hLibrary, TEXT("ProcessKeystroke")); - NHKBHIT pNHkbhit = (NHKBHIT) GetProcAddress( - hLibrary, TEXT("NHkbhit")); - CHECKINPUT pCheckInput = - (CHECKINPUT) GetProcAddress(hLibrary, TEXT("CheckInput")); - - if (!pProcessKeystroke || !pNHkbhit || !pCheckInput) - { - return FALSE; - } else { - if (keyboard_handler.hLibrary != NULL) - unload_keyboard_handler(); - - keyboard_handler.hLibrary = hLibrary; - - keyboard_handler.pProcessKeystroke = pProcessKeystroke; - keyboard_handler.pNHkbhit = pNHkbhit; - keyboard_handler.pCheckInput = pCheckInput; - - keyboard_handler.pSourceWhere = - (SOURCEWHERE) GetProcAddress(hLibrary, TEXT("SourceWhere")); - keyboard_handler.pSourceAuthor = - (SOURCEAUTHOR) GetProcAddress(hLibrary, TEXT("SourceAuthor")); - keyboard_handler.pKeyHandlerName = (KEYHANDLERNAME) GetProcAddress( - hLibrary, TEXT("KeyHandlerName")); - } - - return TRUE; -} - -void set_altkeyhandler(const char * inName) -{ - if (strlen(inName) >= MAX_ALTKEYHANDLER) { - config_error_add("altkeyhandler name '%s' is too long", inName); - return; - } - - char name[MAX_ALTKEYHANDLER]; - strcpy(name, inName); - - /* We support caller mistakenly giving name with '.dll' extension */ - char * ext = strchr(name, '.'); - if (ext != NULL) *ext = '\0'; - - if (load_keyboard_handler(name)) - strcpy(iflags.altkeyhandler, name); - else { - config_error_add("unable to load altkeyhandler '%s'", name); - return; - } - - return; -} - /* fatal error */ /*VARARGS1*/ @@ -1759,7 +1655,7 @@ // code page 437 mappings. if (console.cpMap[i] < 32) console.cpMap[i] = cp437[console.cpMap[i]]; - } + } } } @@ -1952,13 +1848,11 @@ /* This was overriding the handler that had already been loaded during options parsing. Needs to check first */ - if (!iflags.altkeyhandler[0]) { + if (iflags.key_handling == no_keyhandling) { if (primary_language == LANG_ENGLISH) { - if (!load_keyboard_handler("nhdefkey")) - error("Unable to load nhdefkey.dll"); + set_altkeyhandling("default"); } else { - if (!load_keyboard_handler("nhraykey")) - error("Unable to load nhraykey.dll"); + set_altkeyhandling("ray"); } } } @@ -2001,4 +1895,1271 @@ return; } + +/* + * Keyboard translation tables. + * (Adopted from the MSDOS port) + */ + +#define KEYPADLO 0x47 +#define KEYPADHI 0x53 + +#define PADKEYS (KEYPADHI - KEYPADLO + 1) +#define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI) +#define isnumkeypad(x) \ + (KEYPADLO <= (x) && (x) <= 0x51 && (x) != 0x4A && (x) != 0x4E) + +#ifdef QWERTZ_SUPPORT +/* when 'numberpad' is 0 and Cmd.swap_yz is True + (signaled by setting 0x10 on boolean numpad argument) + treat keypress of numpad 7 as 'z' rather than 'y' */ +static boolean qwertz = FALSE; +#endif +#define inmap(x, vk) (((x) > 'A' && (x) < 'Z') || (vk) == 0xBF || (x) == '2') + +const struct pad { + uchar normal, shift, cntrl; +}; + +/* + * default key handling + * + * This is the default NetHack keystroke processing. + * Use the .nethackrc "altkeyhandling" option to set a + * different handling type. + * + */ +/* + * Keypad keys are translated to the normal values below. + * Shifted keypad keys are translated to the + * shift values below. + */ + +static const struct pad default_keypad[PADKEYS] = { + { 'y', 'Y', C('y') }, /* 7 */ + { 'k', 'K', C('k') }, /* 8 */ + { 'u', 'U', C('u') }, /* 9 */ + { 'm', C('p'), C('p') }, /* - */ + { 'h', 'H', C('h') }, /* 4 */ + { 'g', 'G', 'g' }, /* 5 */ + { 'l', 'L', C('l') }, /* 6 */ + { '+', 'P', C('p') }, /* + */ + { 'b', 'B', C('b') }, /* 1 */ + { 'j', 'J', C('j') }, /* 2 */ + { 'n', 'N', C('n') }, /* 3 */ + { 'i', 'I', C('i') }, /* Ins */ + { '.', ':', ':' } /* Del */ +}, default_numpad[PADKEYS] = { + { '7', M('7'), '7' }, /* 7 */ + { '8', M('8'), '8' }, /* 8 */ + { '9', M('9'), '9' }, /* 9 */ + { 'm', C('p'), C('p') }, /* - */ + { '4', M('4'), '4' }, /* 4 */ + { '5', M('5'), '5' }, /* 5 */ + { '6', M('6'), '6' }, /* 6 */ + { '+', 'P', C('p') }, /* + */ + { '1', M('1'), '1' }, /* 1 */ + { '2', M('2'), '2' }, /* 2 */ + { '3', M('3'), '3' }, /* 3 */ + { '0', M('0'), '0' }, /* Ins */ + { '.', ':', ':' } /* Del */ +}; + +/* + * Keypad keys are translated to the normal values below. + * Shifted keypad keys are translated to the + * shift values below. + */ + +static const struct pad +ray_keypad[PADKEYS] = { + { 'y', 'Y', C('y') }, /* 7 */ + { 'k', 'K', C('k') }, /* 8 */ + { 'u', 'U', C('u') }, /* 9 */ + { 'm', C('p'), C('p') }, /* - */ + { 'h', 'H', C('h') }, /* 4 */ + { 'g', 'G', 'g' }, /* 5 */ + { 'l', 'L', C('l') }, /* 6 */ + { '+', 'P', C('p') }, /* + */ + { 'b', 'B', C('b') }, /* 1 */ + { 'j', 'J', C('j') }, /* 2 */ + { 'n', 'N', C('n') }, /* 3 */ + { 'i', 'I', C('i') }, /* Ins */ + { '.', ':', ':' } /* Del */ +}, +ray_numpad[PADKEYS] = { + { '7', M('7'), '7' }, /* 7 */ + { '8', M('8'), '8' }, /* 8 */ + { '9', M('9'), '9' }, /* 9 */ + { 'm', C('p'), C('p') }, /* - */ + { '4', M('4'), '4' }, /* 4 */ + { 'g', 'G', 'g' }, /* 5 */ + { '6', M('6'), '6' }, /* 6 */ + { '+', 'P', C('p') }, /* + */ + { '1', M('1'), '1' }, /* 1 */ + { '2', M('2'), '2' }, /* 2 */ + { '3', M('3'), '3' }, /* 3 */ + { 'i', 'I', C('i') }, /* Ins */ + { '.', ':', ':' } /* Del */ +}; + +static const struct pad +nh340_keypad[PADKEYS] = { + { 'y', 'Y', C('y') }, /* 7 */ + { 'k', 'K', C('k') }, /* 8 */ + { 'u', 'U', C('u') }, /* 9 */ + { 'm', C('p'), C('p') }, /* - */ + { 'h', 'H', C('h') }, /* 4 */ + { 'g', 'G', 'g' }, /* 5 */ + { 'l', 'L', C('l') }, /* 6 */ + { '+', 'P', C('p') }, /* + */ + { 'b', 'B', C('b') }, /* 1 */ + { 'j', 'J', C('j') }, /* 2 */ + { 'n', 'N', C('n') }, /* 3 */ + { 'i', 'I', C('i') }, /* Ins */ + { '.', ':', ':' } /* Del */ +}, +nh340_numpad[PADKEYS] = { + { '7', M('7'), '7' }, /* 7 */ + { '8', M('8'), '8' }, /* 8 */ + { '9', M('9'), '9' }, /* 9 */ + { 'm', C('p'), C('p') }, /* - */ + { '4', M('4'), '4' }, /* 4 */ + { 'g', 'G', 'g' }, /* 5 */ + { '6', M('6'), '6' }, /* 6 */ + { '+', 'P', C('p') }, /* + */ + { '1', M('1'), '1' }, /* 1 */ + { '2', M('2'), '2' }, /* 2 */ + { '3', M('3'), '3' }, /* 3 */ + { 'i', 'I', C('i') }, /* Ins */ + { '.', ':', ':' } /* Del */ +}; + +static struct pad keypad[PADKEYS], numpad[PADKEYS]; +static BYTE KeyState[256]; +static const char default_name[] = "default"; +const char *const legal_key_handling[] = { + "none", + "default", + "ray", + "340", +}; +enum windows_key_handling keyh[] = { no_keyhandling, default_keyhandling, ray_keyhandling, + nh340_keyhandling }; + +void set_altkeyhandling(const char *inName) +{ + int i, k; + /*backward compatibility - so people's existing config files + may work as is */ + if (!strcmpi(inName, "nhraykey.dll")) + inName = legal_key_handling[ray_keyhandling]; + else if (!strcmpi(inName, "nh340key.dll")) + inName = legal_key_handling[nh340_keyhandling]; + else if (!strcmpi(inName, "nhdefkey.dll")) + inName = legal_key_handling[default_keyhandling]; + + for (i = default_keyhandling; i < SIZE(legal_key_handling); i++) { + if (!strcmpi(inName, legal_key_handling[i])) { + iflags.key_handling = keyh[i]; + if (keyboard_handling.pKeyHandlingName) { + free((genericptr_t) keyboard_handling.pKeyHandlingName); + keyboard_handling.pKeyHandlingName = (char *) 0; + } + switch(iflags.key_handling) { + case ray_keyhandling: + keyboard_handling.pKeyHandlingName = strdup("ray"); + keyboard_handling.pProcessKeystroke = ray_processkeystroke; + keyboard_handling.pNHkbhit = ray_kbhit; + keyboard_handling.pCheckInput = ray_checkinput; + /* A bogus key that will be filtered when received, to keep ReadConsole + * from blocking */ + bogus_key.EventType = KEY_EVENT; + bogus_key.Event.KeyEvent.bKeyDown = 1; + bogus_key.Event.KeyEvent.wRepeatCount = 1; + bogus_key.Event.KeyEvent.wVirtualKeyCode = 0; + bogus_key.Event.KeyEvent.wVirtualScanCode = 0; + bogus_key.Event.KeyEvent.uChar.AsciiChar = (uchar) 0x80; + bogus_key.Event.KeyEvent.dwControlKeyState = 0; + for (k = 0; k < SIZE(keypad); ++k) { + keypad[k] = ray_keypad[k]; + numpad[k] = ray_numpad[k]; + } + break; + case nh340_keyhandling: + keyboard_handling.pKeyHandlingName = strdup("340"); + keyboard_handling.pProcessKeystroke = nh340_processkeystroke; + keyboard_handling.pNHkbhit = nh340_kbhit; + keyboard_handling.pCheckInput = nh340_checkinput; + for (k = 0; k < SIZE(keypad); ++k) { + keypad[k] = nh340_keypad[k]; + numpad[k] = nh340_numpad[k]; + } + break; + case default_keyhandling: + default: + keyboard_handling.pKeyHandlingName = strdup("default"); + keyboard_handling.pProcessKeystroke + = default_processkeystroke; + keyboard_handling.pNHkbhit = default_kbhit; + keyboard_handling.pCheckInput = default_checkinput; + for (k = 0; k < SIZE(keypad); ++k) { + keypad[k] = default_keypad[k]; + numpad[k] = default_numpad[k]; + } + break; + } + return; + } + } + config_error_add("invalid altkeyhandling '%s'", inName); + return; +} + +int +set_keyhandling_via_option(void) +{ + winid tmpwin; + anything any; + int i; + menu_item *console_key_handling_pick = (menu_item *) 0; + + tmpwin = create_nhwindow(NHW_MENU); + start_menu(tmpwin); + any = zeroany; + for (i = default_keyhandling; i < SIZE(legal_key_handling); i++) { + any.a_int = i + 1; + add_menu(tmpwin, 0, &any, 'a' + i, + 0, ATR_NONE, + legal_key_handling[i], 0); + } + end_menu(tmpwin, "Select windows console key handling:"); + if (select_menu(tmpwin, PICK_ONE, &console_key_handling_pick) > 0) { + iflags.key_handling = keyh[console_key_handling_pick->item.a_int - 1]; + free((genericptr_t) console_key_handling_pick); + } + destroy_nhwindow(tmpwin); + set_altkeyhandling(legal_key_handling[iflags.key_handling]); + return 1; /* optn_ok */ +} + +int +default_processkeystroke( + HANDLE hConIn, + INPUT_RECORD* ir, + boolean* valid, + boolean numberpad, + int portdebug) +{ + int k = 0; + int keycode, vk; + unsigned char ch, pre_ch; + unsigned short int scan; + unsigned long shiftstate; + int altseq = 0; + const struct pad *kpad; + +#ifdef QWERTZ_SUPPORT + if (numberpad & 0x10) { + numberpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif + shiftstate = 0L; + ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar; + scan = ir->Event.KeyEvent.wVirtualScanCode; + vk = ir->Event.KeyEvent.wVirtualKeyCode; + keycode = MapVirtualKey(vk, 2); + shiftstate = ir->Event.KeyEvent.dwControlKeyState; + KeyState[VK_SHIFT] = (shiftstate & SHIFT_PRESSED) ? 0x81 : 0; + KeyState[VK_CONTROL] = + (shiftstate & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) ? 0x81 : 0; + KeyState[VK_CAPITAL] = (shiftstate & CAPSLOCK_ON) ? 0x81 : 0; + + if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { + if (ch || inmap(keycode, vk)) + altseq = 1; + else + altseq = -1; /* invalid altseq */ + } + if (ch || (iskeypad(scan)) || (altseq > 0)) + *valid = TRUE; + /* if (!valid) return 0; */ + /* + * shiftstate can be checked to see if various special + * keys were pressed at the same time as the key. + * Currently we are using the ALT & SHIFT & CONTROLS. + * + * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED, + * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED, + * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON, + * CAPSLOCK_ON, ENHANCED_KEY + * + * are all valid bit masks to use on shiftstate. + * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the + * left control key was pressed with the keystroke. + */ + if (iskeypad(scan)) { + kpad = numberpad ? numpad : keypad; + if (shiftstate & SHIFT_PRESSED) { + ch = kpad[scan - KEYPADLO].shift; + } else if (shiftstate & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) { + ch = kpad[scan - KEYPADLO].cntrl; + } else { + ch = kpad[scan - KEYPADLO].normal; + } +#ifdef QWERTZ_SUPPORT + /* OPTIONS=number_pad:-1 is for qwertz keyboard; for that setting, + 'numberpad' will be 0; core swaps y to zap, z to move northwest; + we want numpad 7 to move northwest, so when qwertz is set, + tell core that user who types numpad 7 typed z rather than y */ + if (qwertz && kpad[scan - KEYPADLO].normal == 'y') + ch += 1; /* changes y to z, Y to Z, ^Y to ^Z */ +#endif /*QWERTZ_SUPPORT*/ + } else if (altseq > 0) { /* ALT sequence */ + if (vk == 0xBF) + ch = M('?'); + else + ch = M(tolower((uchar) keycode)); + } + /* Attempt to work better with international keyboards. */ + else { + WORD chr[2]; + k = ToAscii(vk, scan, KeyState, chr, 0); + if (k <= 2) + switch (k) { + case 2: /* two characters */ + ch = (unsigned char) chr[1]; + *valid = TRUE; + break; + case 1: /* one character */ + ch = (unsigned char) chr[0]; + *valid = TRUE; + break; + case 0: /* no translation */ + default: /* negative */ + *valid = FALSE; + } + } + if (ch == '\r') + ch = '\n'; +#ifdef PORT_DEBUG + if (portdebug) { + char buf[BUFSZ]; + Sprintf(buf, "PORTDEBUG (%s): ch=%u, sc=%u, vk=%d, pre=%d, sh=0x%lX, " + "ta=%d (ESC to end)", + "default", ch, scan, vk, pre_ch, shiftstate, k); + fprintf(stdout, "\n%s", buf); + } +#endif + return ch; +} + +int +default_kbhit(HANDLE hConIn, INPUT_RECORD *ir) +{ + int done = 0; /* true = "stop searching" */ + int retval; /* true = "we had a match" */ + DWORD count; + unsigned short int scan; + unsigned char ch; + unsigned long shiftstate; + int altseq = 0, keycode, vk; + done = 0; + retval = 0; + while (!done) { + count = 0; + PeekConsoleInput(hConIn, ir, 1, &count); + if (count > 0) { + if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { + ch = ir->Event.KeyEvent.uChar.AsciiChar; + scan = ir->Event.KeyEvent.wVirtualScanCode; + shiftstate = ir->Event.KeyEvent.dwControlKeyState; + vk = ir->Event.KeyEvent.wVirtualKeyCode; + keycode = MapVirtualKey(vk, 2); + if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { + if (ch || inmap(keycode, vk)) + altseq = 1; + else + altseq = -1; /* invalid altseq */ + } + if (ch || iskeypad(scan) || altseq) { + done = 1; /* Stop looking */ + retval = 1; /* Found what we sought */ + } else { + /* Strange Key event; let's purge it to avoid trouble */ + ReadConsoleInput(hConIn, ir, 1, &count); + } + + } else if ((ir->EventType == MOUSE_EVENT + && (ir->Event.MouseEvent.dwButtonState + & MOUSEMASK))) { + done = 1; + retval = 1; + } + + else /* Discard it, it's an insignificant event */ + ReadConsoleInput(hConIn, ir, 1, &count); + } else /* There are no events in console event queue */ { + done = 1; /* Stop looking */ + retval = 0; + } + } + return retval; +} + +int +default_checkinput( + HANDLE hConIn, + INPUT_RECORD *ir, + DWORD* count, + boolean numpad, + int mode, + int *mod, + coord *cc) +{ +#if defined(SAFERHANGUP) + DWORD dwWait; +#endif + int ch = 0; + boolean valid = 0, done = 0; + +#ifdef QWERTZ_SUPPORT + if (numpad & 0x10) { + numpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif + while (!done) { +#if defined(SAFERHANGUP) + dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for + INFINITE, // waits indefinitely + TRUE); // alertable wait enabled + if (dwWait == WAIT_FAILED) + return '\033'; +#endif + ReadConsoleInput(hConIn, ir, 1, count); + if (mode == 0) { + if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { + ch = default_processkeystroke(hConIn, ir, &valid, numpad, 0); + done = valid; + } + } else { + if (count > 0) { + if (ir->EventType == KEY_EVENT + && ir->Event.KeyEvent.bKeyDown) { +#ifdef QWERTZ_SUPPORT + if (qwertz) + numpad |= 0x10; +#endif + ch = default_processkeystroke(hConIn, ir, &valid, numpad, 0); +#ifdef QWERTZ_SUPPORT + numpad &= ~0x10; +#endif + if (valid) + return ch; + } else if (ir->EventType == MOUSE_EVENT) { + if ((ir->Event.MouseEvent.dwEventFlags == 0) + && (ir->Event.MouseEvent.dwButtonState & MOUSEMASK)) { + cc->x = ir->Event.MouseEvent.dwMousePosition.X + 1; + cc->y = ir->Event.MouseEvent.dwMousePosition.Y - 1; + + if (ir->Event.MouseEvent.dwButtonState & LEFTBUTTON) + *mod = CLICK_1; + else if (ir->Event.MouseEvent.dwButtonState + & RIGHTBUTTON) + *mod = CLICK_2; +#if 0 /* middle button */ + else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON) + *mod = CLICK_3; +#endif + return 0; + } + } + } else + done = 1; + } + } + return mode ? 0 : ch; +} + +/* + * Keystroke handling contributed by Ray Chason. + * The following text was written by Ray Chason. + * + * The problem + * =========== + * + * The console-mode Nethack wants both keyboard and mouse input. The + * problem is that the Windows API provides no easy way to get mouse input + * and also keyboard input properly translated according to the user's + * chosen keyboard layout. + * + * The ReadConsoleInput function returns a stream of keyboard and mouse + * events. Nethack is interested in those events that represent a key + * pressed, or a click on a mouse button. The keyboard events from + * ReadConsoleInput are not translated according to the keyboard layout, + * and do not take into account the shift, control, or alt keys. + * + * The PeekConsoleInput function works similarly to ReadConsoleInput, + * except that it does not remove an event from the queue and it returns + * instead of blocking when the queue is empty. + * + * A program can also use ReadConsole to get a properly translated stream + * of characters. Unfortunately, ReadConsole does not return mouse events, + * does not distinguish the keypad from the main keyboard, does not return + * keys shifted with Alt, and does not even return the ESC key when + * pressed. + * + * We want both the functionality of ReadConsole and the functionality of + * ReadConsoleInput. But Microsoft didn't seem to think of that. + * + * + * The solution, in the original code + * ================================== + * + * The original 3.4.1 distribution tries to get proper keyboard translation + * by passing keyboard events to the ToAscii function. This works, to some + * extent -- it takes the shift key into account, and it processes dead + * keys properly. But it doesn't take non-US keyboards into account. It + * appears that ToAscii is meant for windowed applications, and does not + * have enough information to do its job properly in a console application. + * + * + * The Finnish keyboard patch + * ========================== + * + * This patch adds the "subkeyvalue" option to the defaults.nh file. The + * user can then add OPTIONS=sukeyvalue:171/92, for instance, to replace + * the 171 character with 92, which is \. This works, once properly + * configured, but places too much burden on the user. It also bars the + * use of the substituted characters in naming objects or monsters. + * + * + * The solution presented here + * =========================== + * + * The best way I could find to combine the functionality of ReadConsole + * with that of ReadConsoleInput is simple in concept. First, call + * PeekConsoleInput to get the first event. If it represents a key press, + * call ReadConsole to retrieve the key. Otherwise, pop it off the queue + * with ReadConsoleInput and, if it's a mouse click, return it as such. + * + * But the Devil, as they say, is in the details. The problem is in + * recognizing an event that ReadConsole will return as a key. We don't + * want to call ReadConsole unless we know that it will immediately return: + * if it blocks, the mouse and the Alt sequences will cease to function + * until it returns. + * + * Separating process_keystroke into two functions, one for commands and a + * new one, process_keystroke2, for answering prompts, makes the job a lot + * easier. process_keystroke2 doesn't have to worry about mouse events or + * Alt sequences, and so the consequences are minor if ReadConsole blocks. + * process_keystroke, OTOH, never needs to return a non-ASCII character + * that was read from ReadConsole; it returns bytes with the high bit set + * only in response to an Alt sequence. + * + * So in process_keystroke, before calling ReadConsole, a bogus key event + * is pushed on the queue. This event causes ReadConsole to return, even + * if there was no other character available. Because the bogus key has + * the eighth bit set, it is filtered out. This is not done in + * process_keystroke2, because that would render dead keys unusable. + * + * A separate process_keystroke2 can also process the numeric keypad in a + * way that makes sense for prompts: just return the corresponding symbol, + * and pay no mind to number_pad or the num lock key. + * + * The recognition of Alt sequences is modified, to support the use of + * characters generated with the AltGr key. A keystroke is an Alt sequence + * if an Alt key is seen that can't be an AltGr (since an AltGr sequence + * could be a character, and in some layouts it could even be an ASCII + * character). This recognition is different on NT-based and 95-based + * Windows: + * + * * On NT-based Windows, AltGr signals as right Alt and left Ctrl + * together. So an Alt sequence is recognized if either Alt key is + * pressed and if right Alt and left Ctrl are not both present. This + * is true even if the keyboard in use does not have an AltGr key, and + * uses right Alt for AltGr. + * + * * On 95-based Windows, with a keyboard that lacks the AltGr key, the + * right Alt key is used instead. But it still signals as right Alt, + * without left Ctrl. There is no way for the application to know + * whether right Alt is Alt or AltGr, and so it is always assumed + * to be AltGr. This means that Alt sequences must be formed with + * left Alt. + * + * So the patch processes keystrokes as follows: + * + * * If the scan and virtual key codes are both 0, it's the bogus key, + * and we ignore it. + * + * * Keys on the numeric keypad are processed for commands as in the + * unpatched Nethack, and for prompts by returning the ASCII + * character, even if the num lock is off. + * + * * Alt sequences are processed for commands as in the unpatched + * Nethack, and ignored for prompts. + * + * * Control codes are returned as received, because ReadConsole will + * not return the ESC key. + * + * * Other key-down events are passed to ReadConsole. The use of + * ReadConsole is different for commands than for prompts: + * + * o For commands, the bogus key is pushed onto the queue before + * ReadConsole is called. On return, non-ASCII characters are + * filtered, so they are not mistaken for Alt sequences; this also + * filters the bogus key. + * + * o For prompts, the bogus key is not used, because that would + * interfere with dead keys. Eight bit characters may be returned, + * and are coded in the configured code page. + * + * + * Possible improvements + * ===================== + * + * Some possible improvements remain: + * + * * Integrate the existing Finnish keyboard patch, for use with non- + * QWERTY layouts such as the German QWERTZ keyboard or Dvorak. + * + * * Fix the keyboard glitches in the graphical version. Namely, dead + * keys don't work, and input comes in as ISO-8859-1 but is displayed + * as code page 437 if IBMgraphics is set on startup. + * + * * Transform incoming text to ISO-8859-1, for full compatibility with + * the graphical version. + * + * * After pushing the bogus key and calling ReadConsole, check to see + * if we got the bogus key; if so, and an Alt is pressed, process the + * event as an Alt sequence. + * + */ + +#if 0 +static char where_to_get_source[] = "http://www.nethack.org/"; +static char author[] = "Ray Chason"; +#endif + +int process_keystroke2(HANDLE hConIn, INPUT_RECORD *ir, boolean *valid); + +/* Use ray_processkeystroke for key commands, process_keystroke2 for prompts */ +/* int ray_processkeystroke(INPUT_RECORD *ir, boolean *valid, int + * portdebug); + */ + +int process_keystroke2(HANDLE, INPUT_RECORD *ir, boolean *valid); +static int is_altseq(unsigned long shiftstate); + +static int +is_altseq(unsigned long shiftstate) +{ + /* We need to distinguish the Alt keys from the AltGr key. + * On NT-based Windows, AltGr signals as right Alt and left Ctrl together; + * on 95-based Windows, AltGr signals as right Alt only. + * So on NT, we signal Alt if either Alt is pressed and left Ctrl is not, + * and on 95, we signal Alt for left Alt only. */ + switch (shiftstate + & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED)) { + case LEFT_ALT_PRESSED: + case LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED: + return 1; + + case RIGHT_ALT_PRESSED: + case RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED: + return (GetVersion() & 0x80000000) == 0; + + default: + return 0; + } +} + +int ray_processkeystroke( + HANDLE hConIn, + INPUT_RECORD *ir, + boolean *valid, + boolean numberpad, + int portdebug) +{ + int keycode, vk; + unsigned char ch, pre_ch; + unsigned short int scan; + unsigned long shiftstate; + int altseq = 0; + const struct pad *kpad; + DWORD count; + +#ifdef QWERTZ_SUPPORT + if (numberpad & 0x10) { + numberpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif + shiftstate = 0L; + ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar; + scan = ir->Event.KeyEvent.wVirtualScanCode; + vk = ir->Event.KeyEvent.wVirtualKeyCode; + keycode = MapVirtualKey(vk, 2); + shiftstate = ir->Event.KeyEvent.dwControlKeyState; + if (scan == 0 && vk == 0) { + /* It's the bogus_key */ + ReadConsoleInput(hConIn, ir, 1, &count); + *valid = FALSE; + return 0; + } + + if (is_altseq(shiftstate)) { + if (ch || inmap(keycode, vk)) + altseq = 1; + else + altseq = -1; /* invalid altseq */ + } + if (ch || (iskeypad(scan)) || (altseq > 0)) + *valid = TRUE; + /* if (!valid) return 0; */ + /* + * shiftstate can be checked to see if various special + * keys were pressed at the same time as the key. + * Currently we are using the ALT & SHIFT & CONTROLS. + * + * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED, + * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED, + * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON, + * CAPSLOCK_ON, ENHANCED_KEY + * + * are all valid bit masks to use on shiftstate. + * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the + * left control key was pressed with the keystroke. + */ + if (iskeypad(scan)) { + ReadConsoleInput(hConIn, ir, 1, &count); + kpad = numberpad ? numpad : keypad; + if (shiftstate & SHIFT_PRESSED) { + ch = kpad[scan - KEYPADLO].shift; + } else if (shiftstate & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) { + ch = kpad[scan - KEYPADLO].cntrl; + } else { + ch = kpad[scan - KEYPADLO].normal; + } +#ifdef QWERTZ_SUPPORT + /* OPTIONS=number_pad:-1 is for qwertz keyboard; for that setting, + 'numberpad' will be 0; core swaps y to zap, z to move northwest; + we want numpad 7 to move northwest, so when qwertz is set, + tell core that user who types numpad 7 typed z rather than y */ + if (qwertz && kpad[scan - KEYPADLO].normal == 'y') + ch += 1; /* changes y to z, Y to Z, ^Y to ^Z */ +#endif /*QWERTZ_SUPPORT*/ + } else if (altseq > 0) { /* ALT sequence */ + ReadConsoleInput(hConIn, ir, 1, &count); + if (vk == 0xBF) + ch = M('?'); + else + ch = M(tolower((uchar) keycode)); + } else if (ch < 32 && !isnumkeypad(scan)) { + /* Control code; ReadConsole seems to filter some of these, + * including ESC */ + ReadConsoleInput(hConIn, ir, 1, &count); + } + /* Attempt to work better with international keyboards. */ + else { + CHAR ch2; + DWORD written; + /* The bogus_key guarantees that ReadConsole will return, + * and does not itself do anything */ + WriteConsoleInput(hConIn, &bogus_key, 1, &written); + ReadConsole(hConIn, &ch2, 1, &count, NULL); + /* Prevent high characters from being interpreted as alt + * sequences; also filter the bogus_key */ + if (ch2 & 0x80) + *valid = FALSE; + else + ch = ch2; + if (ch == 0) + *valid = FALSE; + } + if (ch == '\r') + ch = '\n'; +#ifdef PORT_DEBUG + if (portdebug) { + char buf[BUFSZ]; + Sprintf(buf, "PORTDEBUG: ch=%u, scan=%u, vk=%d, pre=%d, " + "shiftstate=0x%lX (ESC to end)\n", + ch, scan, vk, pre_ch, shiftstate); + fprintf(stdout, "\n%s", buf); + } +#endif + return ch; +} + +int +process_keystroke2( + HANDLE hConIn, + INPUT_RECORD *ir, + boolean *valid) +{ + /* Use these values for the numeric keypad */ + static const char keypad_nums[] = "789-456+1230."; + + unsigned char ch; + int vk; + unsigned short int scan; + unsigned long shiftstate; + int altseq; + DWORD count; + + ch = ir->Event.KeyEvent.uChar.AsciiChar; + vk = ir->Event.KeyEvent.wVirtualKeyCode; + scan = ir->Event.KeyEvent.wVirtualScanCode; + shiftstate = ir->Event.KeyEvent.dwControlKeyState; + + if (scan == 0 && vk == 0) { + /* It's the bogus_key */ + ReadConsoleInput(hConIn, ir, 1, &count); + *valid = FALSE; + return 0; + } + + altseq = is_altseq(shiftstate); + if (ch || (iskeypad(scan)) || altseq) + *valid = TRUE; + /* if (!valid) return 0; */ + /* + * shiftstate can be checked to see if various special + * keys were pressed at the same time as the key. + * Currently we are using the ALT & SHIFT & CONTROLS. + * + * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED, + * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED, + * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON, + * CAPSLOCK_ON, ENHANCED_KEY + * + * are all valid bit masks to use on shiftstate. + * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the + * left control key was pressed with the keystroke. + */ + if (iskeypad(scan) && !altseq) { + ReadConsoleInput(hConIn, ir, 1, &count); + ch = keypad_nums[scan - KEYPADLO]; + } else if (ch < 32 && !isnumkeypad(scan)) { + /* Control code; ReadConsole seems to filter some of these, + * including ESC */ + ReadConsoleInput(hConIn, ir, 1, &count); + } + /* Attempt to work better with international keyboards. */ + else { + CHAR ch2; + ReadConsole(hConIn, &ch2, 1, &count, NULL); + ch = ch2 & 0xFF; + if (ch == 0) + *valid = FALSE; + } + if (ch == '\r') + ch = '\n'; + return ch; +} + +int +ray_checkinput( + HANDLE hConIn, + INPUT_RECORD *ir, + DWORD *count, + boolean numpad, + int mode, + int *mod, + coord *cc) +{ +#if defined(SAFERHANGUP) + DWORD dwWait; +#endif + int ch = 0; + boolean valid = 0, done = 0; + +#ifdef QWERTZ_SUPPORT + if (numpad & 0x10) { + numpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif + while (!done) { + *count = 0; + dwWait = WaitForSingleObject(hConIn, INFINITE); +#if defined(SAFERHANGUP) + if (dwWait == WAIT_FAILED) + return '\033'; +#endif + PeekConsoleInput(hConIn, ir, 1, count); + if (mode == 0) { + if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { + ch = process_keystroke2(hConIn, ir, &valid); + done = valid; + } else + ReadConsoleInput(hConIn, ir, 1, count); + } else { + ch = 0; + if (count > 0) { + if (ir->EventType == KEY_EVENT + && ir->Event.KeyEvent.bKeyDown) { +#ifdef QWERTZ_SUPPORT + if (qwertz) + numpad |= 0x10; +#endif + ch = ray_processkeystroke(hConIn, ir, &valid, numpad, +#ifdef PORTDEBUG + 1); +#else + 0); +#endif +#ifdef QWERTZ_SUPPORT + numpad &= ~0x10; +#endif + if (valid) + return ch; + } else { + ReadConsoleInput(hConIn, ir, 1, count); + if (ir->EventType == MOUSE_EVENT) { + if ((ir->Event.MouseEvent.dwEventFlags == 0) + && (ir->Event.MouseEvent.dwButtonState + & MOUSEMASK)) { + cc->x = + ir->Event.MouseEvent.dwMousePosition.X + 1; + cc->y = + ir->Event.MouseEvent.dwMousePosition.Y - 1; + + if (ir->Event.MouseEvent.dwButtonState + & LEFTBUTTON) + *mod = CLICK_1; + else if (ir->Event.MouseEvent.dwButtonState + & RIGHTBUTTON) + *mod = CLICK_2; +#if 0 /* middle button */ + else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON) + *mod = CLICK_3; +#endif + return 0; + } + } +#if 0 + /* We ignore these types of console events */ + else if (ir->EventType == FOCUS_EVENT) { + } + else if (ir->EventType == MENU_EVENT) { + } +#endif + } + } else + done = 1; + } + } + *mod = 0; + return ch; +} + +int +ray_kbhit( + HANDLE hConIn, + INPUT_RECORD *ir) +{ + int done = 0; /* true = "stop searching" */ + int retval; /* true = "we had a match" */ + DWORD count; + unsigned short int scan; + unsigned char ch; + unsigned long shiftstate; + int altseq = 0, keycode, vk; + + done = 0; + retval = 0; + while (!done) { + count = 0; + PeekConsoleInput(hConIn, ir, 1, &count); + if (count > 0) { + if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { + ch = ir->Event.KeyEvent.uChar.AsciiChar; + scan = ir->Event.KeyEvent.wVirtualScanCode; + shiftstate = ir->Event.KeyEvent.dwControlKeyState; + vk = ir->Event.KeyEvent.wVirtualKeyCode; + if (scan == 0 && vk == 0) { + /* It's the bogus_key. Discard it */ + ReadConsoleInput(hConIn,ir,1,&count); + } else { + keycode = MapVirtualKey(vk, 2); + if (is_altseq(shiftstate)) { + if (ch || inmap(keycode, vk)) + altseq = 1; + else + altseq = -1; /* invalid altseq */ + } + if (ch || iskeypad(scan) || altseq) { + done = 1; /* Stop looking */ + retval = 1; /* Found what we sought */ + } else { + /* Strange Key event; let's purge it to avoid trouble */ + ReadConsoleInput(hConIn, ir, 1, &count); + } + } + + } else if ((ir->EventType == MOUSE_EVENT + && (ir->Event.MouseEvent.dwButtonState + & MOUSEMASK))) { + done = 1; + retval = 1; + } + + else /* Discard it, it's an insignificant event */ + ReadConsoleInput(hConIn, ir, 1, &count); + } else /* There are no events in console event queue */ { + done = 1; /* Stop looking */ + retval = 0; + } + } + return retval; +} + +/* + * nh340 key handling + * + * This is the NetHack keystroke processing from NetHack 3.4.0. + * It can be built as a run-time loadable dll (nh340key.dll), + * placed in the same directory as the nethack.exe executable, + * and loaded by specifying OPTIONS=altkeyhandler:nh340key + * in defaults.nh + * + * Keypad keys are translated to the normal values below. + * Shifted keypad keys are translated to the + * shift values below. + */ + +int +nh340_processkeystroke( + HANDLE hConIn, + INPUT_RECORD *ir, + boolean *valid, + boolean numberpad, + int portdebug) +{ + int keycode, vk; + unsigned char ch, pre_ch; + unsigned short int scan; + unsigned long shiftstate; + int altseq = 0; + const struct pad *kpad; + +#ifdef QWERTZ_SUPPORT + if (numberpad & 0x10) { + numberpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif + + shiftstate = 0L; + ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar; + scan = ir->Event.KeyEvent.wVirtualScanCode; + vk = ir->Event.KeyEvent.wVirtualKeyCode; + keycode = MapVirtualKey(vk, 2); + shiftstate = ir->Event.KeyEvent.dwControlKeyState; + + if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { + if (ch || inmap(keycode, vk)) + altseq = 1; + else + altseq = -1; /* invalid altseq */ + } + if (ch || (iskeypad(scan)) || (altseq > 0)) + *valid = TRUE; + /* if (!valid) return 0; */ + /* + * shiftstate can be checked to see if various special + * keys were pressed at the same time as the key. + * Currently we are using the ALT & SHIFT & CONTROLS. + * + * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED, + * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED, + * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON, + * CAPSLOCK_ON, ENHANCED_KEY + * + * are all valid bit masks to use on shiftstate. + * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the + * left control key was pressed with the keystroke. + */ + if (iskeypad(scan)) { + kpad = numberpad ? numpad : keypad; + if (shiftstate & SHIFT_PRESSED) { + ch = kpad[scan - KEYPADLO].shift; + } else if (shiftstate & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) { + ch = kpad[scan - KEYPADLO].cntrl; + } else { + ch = kpad[scan - KEYPADLO].normal; + } +#ifdef QWERTZ_SUPPORT + /* OPTIONS=number_pad:-1 is for qwertz keyboard; for that setting, + 'numberpad' will be 0; core swaps y to zap, z to move northwest; + we want numpad 7 to move northwest, so when qwertz is set, + tell core that user who types numpad 7 typed z rather than y */ + if (qwertz && kpad[scan - KEYPADLO].normal == 'y') + ch += 1; /* changes y to z, Y to Z, ^Y to ^Z */ +#endif /*QWERTZ_SUPPORT*/ + } else if (altseq > 0) { /* ALT sequence */ + if (vk == 0xBF) + ch = M('?'); + else + ch = M(tolower((uchar) keycode)); + } + if (ch == '\r') + ch = '\n'; +#ifdef PORT_DEBUG + if (portdebug) { + char buf[BUFSZ]; + Sprintf(buf, + "PORTDEBUG (%s): ch=%u, sc=%u, vk=%d, sh=0x%lX (ESC to end)", + "nh340", ch, scan, vk, shiftstate); + fprintf(stdout, "\n%s", buf); + } +#endif + return ch; +} + +int +nh340_kbhit( + HANDLE hConIn, + INPUT_RECORD *ir) +{ + int done = 0; /* true = "stop searching" */ + int retval; /* true = "we had a match" */ + DWORD count; + unsigned short int scan; + unsigned char ch; + unsigned long shiftstate; + int altseq = 0, keycode, vk; + done = 0; + retval = 0; + while (!done) { + count = 0; + PeekConsoleInput(hConIn, ir, 1, &count); + if (count > 0) { + if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { + ch = ir->Event.KeyEvent.uChar.AsciiChar; + scan = ir->Event.KeyEvent.wVirtualScanCode; + shiftstate = ir->Event.KeyEvent.dwControlKeyState; + vk = ir->Event.KeyEvent.wVirtualKeyCode; + keycode = MapVirtualKey(vk, 2); + if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { + if (ch || inmap(keycode, vk)) + altseq = 1; + else + altseq = -1; /* invalid altseq */ + } + if (ch || iskeypad(scan) || altseq) { + done = 1; /* Stop looking */ + retval = 1; /* Found what we sought */ + } else { + /* Strange Key event; let's purge it to avoid trouble */ + ReadConsoleInput(hConIn, ir, 1, &count); + } + + } else if ((ir->EventType == MOUSE_EVENT + && (ir->Event.MouseEvent.dwButtonState + & MOUSEMASK))) { + done = 1; + retval = 1; + } + + else /* Discard it, it's an insignificant event */ + ReadConsoleInput(hConIn, ir, 1, &count); + } else /* There are no events in console event queue */ { + done = 1; /* Stop looking */ + retval = 0; + } + } + return retval; +} + +int +nh340_checkinput( + HANDLE hConIn, + INPUT_RECORD *ir, + DWORD *count, + boolean numpad, + int mode, + int *mod, + coord *cc) +{ +#if defined(SAFERHANGUP) + DWORD dwWait; +#endif + int ch = 0; + boolean valid = 0, done = 0; + +#ifdef QWERTZ_SUPPORT + if (numpad & 0x10) { + numpad &= ~0x10; + qwertz = TRUE; + } else { + qwertz = FALSE; + } +#endif + while (!done) { +#if defined(SAFERHANGUP) + dwWait = WaitForSingleObjectEx(hConIn, // event object to wait for + INFINITE, // waits indefinitely + TRUE); // alertable wait enabled + if (dwWait == WAIT_FAILED) + return '\033'; +#endif + ReadConsoleInput(hConIn, ir, 1, count); + if (mode == 0) { + if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) { +#ifdef QWERTZ_SUPPORT + if (qwertz) + numpad |= 0x10; +#endif + ch = nh340_processkeystroke(hConIn, ir, &valid, numpad, 0); +#ifdef QWERTZ_SUPPORT + numpad &= ~0x10; +#endif + done = valid; + } + } else { + if (count > 0) { + if (ir->EventType == KEY_EVENT + && ir->Event.KeyEvent.bKeyDown) { + ch = nh340_processkeystroke(hConIn, ir, &valid, numpad, 0); + if (valid) + return ch; + } else if (ir->EventType == MOUSE_EVENT) { + if ((ir->Event.MouseEvent.dwEventFlags == 0) + && (ir->Event.MouseEvent.dwButtonState & MOUSEMASK)) { + cc->x = ir->Event.MouseEvent.dwMousePosition.X + 1; + cc->y = ir->Event.MouseEvent.dwMousePosition.Y - 1; + + if (ir->Event.MouseEvent.dwButtonState & LEFTBUTTON) + *mod = CLICK_1; + else if (ir->Event.MouseEvent.dwButtonState + & RIGHTBUTTON) + *mod = CLICK_2; +#if 0 /* middle button */ + else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON) + *mod = CLICK_3; +#endif + return 0; + } + } + } else + done = 1; + } + } + return mode ? 0 : ch; +} + #endif /* WIN32 */ diff -Nru nethack-3.6.6/sys/winnt/stubs.c nethack-3.6.7/sys/winnt/stubs.c --- nethack-3.6.6/sys/winnt/stubs.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/sys/winnt/stubs.c 2023-02-15 21:52:57.000000000 +0000 @@ -189,4 +189,14 @@ { return; } +void +set_altkeyhandling(const char *inName) +{ +} + +int +set_keyhandling_via_option(void) +{ + return 1; +} #endif /* TTYSTUBS */ diff -Nru nethack-3.6.6/.travis.yml nethack-3.6.7/.travis.yml --- nethack-3.6.6/.travis.yml 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/.travis.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ -language: c -matrix: - include: - - os: linux - env: DESCR=linux-xenial-gcc HINTS=linux - compiler: gcc - script: "cd sys/unix/ && sh setup.sh hints/$HINTS && cd ../../ && make install" - - os: linux - env: DESCR=linux-xenial-clang HINTS=linux - compiler: clang - script: "cd sys/unix/ && sh setup.sh hints/$HINTS && cd ../../ && make install" - - os: linux - env: DESCR=linux-xenial-gcc-x11 HINTS=linux-x11 - compiler: gcc - addons: - apt: - packages: - - libx11-dev - - libxaw7-dev - - xfonts-utils - script: "cd sys/unix/ && sh setup.sh hints/$HINTS && cd ../../ && make install" - - os: linux - env: DESCR=linux-xenial-gcc-qt5 HINTS=linux-qt5 - compiler: gcc - addons: - apt: - packages: - - libx11-dev - - libxaw7-dev - - xfonts-utils - - qtbase5-dev - - qtmultimedia5-dev - - qtbase5-dev-tools - script: "cd sys/unix/ && sh setup.sh hints/$HINTS && cd ../../ && QT_SELECT=5 make MOC=moc install" - - os: linux - env: DESCR=linux-bionic-gcc-x11 HINTS=linux-x11 - dist: bionic - compiler: gcc - addons: - apt: - packages: - - libx11-dev - - libxaw7-dev - - xfonts-utils - script: "cd sys/unix/ && sh setup.sh hints/$HINTS && cd ../../ && make install" - - os: linux - env: DESCR=linux-xenial-gcc-minimal HINTS=linux-minimal - compiler: gcc - script: | - cd sys/unix/ && sh setup.sh hints/$HINTS && cd ../../ - sed -i '/^#define CLIPPING/d' include/config.h - sed -i '/^#define COMPRESS/d' include/config.h - #sed -i '/^#define DOAGAIN/d' include/config.h - sed -i '/^#define DUMPLOG/d' include/config.h - #sed -i '/^#define GDBPATH/d' include/config.h - #sed -i '/^#define GREPPATH/d' include/config.h - sed -i '/^#define INSURANCE/d' include/config.h - sed -i '/^#define LOGFILE/d' include/config.h - sed -i '/^#define NEWS/d' include/config.h - sed -i '/^#define PANICLOG/d' include/config.h - #sed -i '/^#define STATUS_HILITES/d' include/config.h - sed -i '/^#define SYSCF/d' include/config.h - sed -i '/^#define USER_SOUNDS/d' include/config.h - sed -i '/^#define XLOGFILE/d' include/config.h - - sed -i '/^#define MAIL/d' include/unixconf.h - sed -i '/^#define SHELL/d' include/unixconf.h - sed -i '/^#define SUSPEND/d' include/unixconf.h - sed -i 's/^#define TEXTCOLOR//' include/unixconf.h - make install - cat dat/options - - os: windows - env: DESCR=windows-visualstudio - language: shell - script: - - ./win/win32/vs2017/travisci.sh - - os: windows -# install: choco install mingw - env: DESCR=windows-mingw - script: - - git clone --depth 1 https://github.com/wmcbrine/PDCurses.git ../pdcurses - - export ADD_CURSES=Y - - export PDCURSES_TOP=../../pdcurses - - cd src - - cp ../sys/winnt/Makefile.gcc ./Makefile - - mingw32-make install - exclude: -# - os: osx -# osx_image: xcode10.3 -# env: DESCR=osx-xcode10.3-x11 HINTS=macosx10.14 WANT_WIN_CURSES=1 WANT_WIN_X11=1 USE_XPM=1 -# compiler: clang -# script: "cd sys/unix/ && sh setup.sh hints/$HINTS && cd ../../ && make install" - - os: osx - osx_image: xcode10.2 - env: HINTS=macosx10.14 - compiler: clang - script: "cd sys/unix/ && sh setup.sh hints/$HINTS && cd ../../ && make install" -# -sudo: false -notifications: - email: - recipients: - - devteam@nethack.org -# -deploy: - provider: releases - api_key: - secure: "U0Dt2CXrcG8Yi4taUCT/6AnM+0IJtdCv6IVG/2rGooUY3pZjNWE9XDM6X9ZeAmbI79aN6FPTppjUf3KbB/upYeJt+8mrjnxEk/ZTO1xXDDW8iL/DiqnczoFsMGmPsTM+Fkeak8bu0SifI7Qkx9i1N+zOyl2VdlaxGjchPfl/OJw2jcQs7rOGRfr23/rapZKTcFq+BFlxMiIHa0dXbCJ9vagdlyAeclOCtPjw1VoH/Cb/+0/Xlx2MFPncw4/1P+bO/fPantHyehh3/WCDVCnI4M7ftONpsTVRrQ+Hml89teUH9/1xXUOpbCeVghWr1rumLcQzMqLKNj2lP/gm9co2/DKpxiUPUzBfO/9Jvl1CNoEwPYQBRNb38kggDvAT4vKX38Oi5sZvumFEO4L0y7o4cW6SA4/CYIykfxOdkrryt8ltfWwopdy3I/DothYw31vJ9GsZOCAShFRAy3hJxYUbHhT+7SDUBadVSEkb4UqxQ+7zntAVT+Lp4DXLAfvsWxZGrQoP/IrWAgNOLRKILubpzh+YpadMH3Ygha2JRAeJAEZ3DnXf3vOOAucWnk4mNXDbW35GTDTAJDWMvddZCfsrUI/uHxgaRjFs9fLX1X5tqhGnsr27sKLWyX+zrIPVV0TPl3AzYPAf6Bc8Okeu+JEGQERvvgSasCuYcmhgYznBVJI=" - file_glob: true - file: - - "$TRAVIS_TAG.x86.zip" - skip_cleanup: true - on: - tags: true - prerelease: false - name: "Release build of NetHack 3.6.6" - body: "This is an auto generated Release build of NetHack 3.6.6" diff -Nru nethack-3.6.6/win/curses/cursmain.c nethack-3.6.7/win/curses/cursmain.c --- nethack-3.6.6/win/curses/cursmain.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/curses/cursmain.c 2023-02-15 21:52:57.000000000 +0000 @@ -45,13 +45,16 @@ #endif | WC_PERM_INVENT | WC_POPUP_DIALOG | WC_SPLASH_SCREEN), (WC2_DARKGRAY | WC2_HITPOINTBAR +#ifdef SELECTSAVED + | WC2_SELECTSAVED +#endif #if defined(STATUS_HILITES) | WC2_HILITE_STATUS #endif | WC2_FLUSH_STATUS | WC2_TERM_SIZE | WC2_STATUSLINES | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR | WC2_SUPPRESS_HIST), - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */ + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */ curses_init_nhwindows, curses_player_selection, curses_askname, @@ -242,6 +245,19 @@ void curses_askname() { +#ifdef SELECTSAVED + if (iflags.wc2_selectsaved && !iflags.renameinprogress) + switch (restore_menu(MAP_WIN)) { + case -1: + curses_bail("Until next time then..."); /* quit */ + /*NOTREACHED*/ + case 0: + break; /* no game chosen; start new game */ + case 1: + return; /* plname[] has been set */ + } +#endif /* SELECTSAVED */ + plname[0] = '\0'; curses_line_input_dialog("Who are you?", plname, PL_NSIZ); } diff -Nru nethack-3.6.6/win/Qt4/qt4bind.cpp nethack-3.6.7/win/Qt4/qt4bind.cpp --- nethack-3.6.6/win/Qt4/qt4bind.cpp 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/Qt4/qt4bind.cpp 2023-02-15 21:52:57.000000000 +0000 @@ -455,7 +455,22 @@ // Process events until a key arrives. // while (keybuffer.Empty()) { - qApp->exec(); + int exc = qApp->exec(); + /* + * On OSX (possibly elsewhere), this prevents an infinite + * loop repeatedly issuing the complaint: +QCoreApplication::exec: The event loop is already running + * to stderr if you syncronously start nethack from a terminal + * then switch focus back to that terminal and type ^C. + * SIGINT -> done1() -> done2() -> yn_function("Really quit?") + * in the core asks for another keystroke. + * + * However, it still issues one such complaint, and whatever + * prompt wanted a response ("Really quit?") is shown in the + * message window but is auto-answered with ESC. + */ + if (exc == -1) + keybuffer.Put('\033'); } return keybuffer.GetAscii(); @@ -469,7 +484,10 @@ // Process events until a key or map-click arrives. // while (keybuffer.Empty() && clickbuffer.Empty()) { - qApp->exec(); + int exc = qApp->exec(); + // [see comment above in qt_nhgetch()] + if (exc == -1) + keybuffer.Put('\033'); } if (!keybuffer.Empty()) { return keybuffer.GetAscii(); diff -Nru nethack-3.6.6/win/win32/dgnstuff.mak nethack-3.6.7/win/win32/dgnstuff.mak --- nethack-3.6.6/win/win32/dgnstuff.mak 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/dgnstuff.mak 2023-02-15 21:52:57.000000000 +0000 @@ -57,7 +57,7 @@ copy $(YTABH) ..\include\dgn_comp.h @del $(YTABC) @del $(YTABH) - chdir ..\build + chdir ..\src !ENDIF ..\util\dgn_yacc.c : ..\util\dgn_comp.y @@ -74,7 +74,7 @@ copy $(YTABH) ..\include\dgn_comp.h @del $(YTABC) @del $(YTABH) - chdir ..\build + chdir ..\src !ENDIF ..\util\dgn_lex.c: ..\util\dgn_comp.l @@ -89,5 +89,5 @@ $(LEX) dgn_comp.l copy $(LEXYYC) $@ @del $(LEXYYC) - chdir ..\build + chdir ..\src !ENDIF diff -Nru nethack-3.6.6/win/win32/mhmap.c nethack-3.6.7/win/win32/mhmap.c --- nethack-3.6.6/win/win32/mhmap.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/mhmap.c 2023-02-15 21:52:57.000000000 +0000 @@ -35,8 +35,8 @@ int map[COLNO][ROWNO]; /* glyph map */ int bkmap[COLNO][ROWNO]; /* backround glyph map */ - boolean mapDirty[COLNO][ROWNO]; /* dirty flag for map */ - + boolean locDirty[COLNO][ROWNO]; /* dirty flag for map location */ + boolean mapDirty; /* one or more map locations are dirty */ int mapMode; /* current map mode */ boolean bAsciiMode; /* switch ASCII/tiled mode */ boolean bFitToScreenMode; /* switch Fit map to screen mode on/off */ @@ -141,7 +141,7 @@ } void -mswin_map_stretch(HWND hWnd, LPSIZE map_size, BOOL redraw) +mswin_map_layout(HWND hWnd, LPSIZE map_size) { /* check arguments */ if (!IsWindow(hWnd) || !map_size || map_size->cx <= 0 @@ -364,10 +364,11 @@ mswin_cliparound(data->xCur, data->yCur); - if (redraw) { - dirtyAll(data); - InvalidateRect(hWnd, NULL, TRUE); - } + // redraw all map locations + dirtyAll(data); + + // invalidate entire map window + InvalidateRect(hWnd, NULL, TRUE); } /* set map mode */ @@ -475,13 +476,38 @@ mapSize.cx = data->tileWidth * COLNO; mapSize.cy = data->tileHeight * ROWNO; - mswin_map_stretch(hWnd, &mapSize, TRUE); + mswin_map_layout(hWnd, &mapSize); mswin_update_inventory(); /* for perm_invent to hide/show tiles */ return oldMode; } +void mswin_map_update(HWND hWnd) +{ + PNHMapWindow data = (PNHMapWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA); + + if (data->mapDirty) + { + /* update back buffer */ + HBITMAP savedBitmap = SelectObject(data->tileDC, GetNHApp()->bmpMapTiles); + + for (int i = 0; i < COLNO; i++) + for (int j = 0; j < ROWNO; j++) + if (data->locDirty[i][j]) + { + paint(data, i, j); + RECT rect; + nhcoord2display(data, i, j, &rect); + InvalidateRect(data->hWnd, &rect, FALSE); + } + + SelectObject(data->tileDC, savedBitmap); + data->mapDirty = FALSE; + } + +} + /* register window class for map window */ void register_map_window_class() @@ -553,7 +579,7 @@ size.cx = data->xFrontTile * COLNO; size.cy = data->yFrontTile * ROWNO; } - mswin_map_stretch(hWnd, &size, TRUE); + mswin_map_layout(hWnd, &size); /* update window placement */ GetWindowRect(hWnd, &rt); @@ -971,11 +997,8 @@ if ((data->map[i][j] != fg) || (data->bkmap[i][j] != bg)) { data->map[i][j] = fg; data->bkmap[i][j] = bg; - data->mapDirty[i][j] = TRUE; - - RECT rect; - nhcoord2display(data, i, j, &rect); - InvalidateRect(data->hWnd, &rect, FALSE); + data->locDirty[i][j] = TRUE; + data->mapDirty = TRUE; } } @@ -985,28 +1008,23 @@ for (int y = 0; y < ROWNO; y++) { data->map[x][y] = NO_GLYPH; data->bkmap[x][y] = NO_GLYPH; - data->mapDirty[x][y] = TRUE; + data->locDirty[x][y] = TRUE; } - InvalidateRect(data->hWnd, NULL, FALSE); + data->mapDirty = TRUE; } static void dirtyAll(PNHMapWindow data) { for (int i = 0; i < COLNO; i++) for (int j = 0; j < ROWNO; j++) - data->mapDirty[i][j] = TRUE; - - InvalidateRect(data->hWnd, NULL, FALSE); + data->locDirty[i][j] = TRUE; + data->mapDirty = TRUE; } static void dirty(PNHMapWindow data, int x, int y) { - data->mapDirty[x][y] = TRUE; - - RECT rt; - nhcoord2display(data, data->xCur, data->yCur, &rt); - - InvalidateRect(data->hWnd, &rt, FALSE); + data->locDirty[x][y] = TRUE; + data->mapDirty = TRUE; } static void @@ -1025,7 +1043,7 @@ paintTile(data, i, j, &rect); } - data->mapDirty[i][j] = FALSE; + data->locDirty[i][j] = FALSE; } @@ -1035,16 +1053,6 @@ { PNHMapWindow data = (PNHMapWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA); - /* update back buffer */ - HBITMAP savedBitmap = SelectObject(data->tileDC, GetNHApp()->bmpMapTiles); - - for (int i = 0; i < COLNO; i++) - for (int j = 0; j < ROWNO; j++) - if (data->mapDirty[i][j]) - paint(data, i, j); - - SelectObject(data->tileDC, savedBitmap); - PAINTSTRUCT ps; HDC hFrontBufferDC = BeginPaint(hWnd, &ps); diff -Nru nethack-3.6.6/win/win32/mhmap.h nethack-3.6.7/win/win32/mhmap.h --- nethack-3.6.6/win/win32/mhmap.h 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/mhmap.h 2023-02-15 21:52:57.000000000 +0000 @@ -11,8 +11,9 @@ COLORREF nhcolor_to_RGB(int c); HWND mswin_init_map_window(void); -void mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw); +void mswin_map_layout(HWND hWnd, LPSIZE lpsz); int mswin_map_mode(HWND hWnd, int mode); +void mswin_map_update(HWND hWnd); #define ROGUE_LEVEL_MAP_MODE MAP_MODE_ASCII12x16 #define ROGUE_LEVEL_MAP_MODE_FIT_TO_SCREEN MAP_MODE_ASCII_FIT_TO_SCREEN diff -Nru nethack-3.6.6/win/win32/mswproc.c nethack-3.6.7/win/win32/mswproc.c --- nethack-3.6.6/win/win32/mswproc.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/mswproc.c 2023-02-15 21:52:57.000000000 +0000 @@ -1835,6 +1835,7 @@ mswin_delay_output() { logDebug("mswin_delay_output()\n"); + mswin_map_update(mswin_hwnd_from_winid(WIN_MAP)); Sleep(50); } @@ -2103,9 +2104,11 @@ void mswin_main_loop() { - MSG msg; - while (!mswin_have_input()) { + MSG msg; + + mswin_map_update(mswin_hwnd_from_winid(WIN_MAP)); + if (!iflags.debug_fuzzer || PeekMessage(&msg, NULL, 0, 0, FALSE)) { if(GetMessage(&msg, NULL, 0, 0) != 0) { if (GetNHApp()->regNetHackMode @@ -2197,7 +2200,7 @@ map_size.cx = GetNHApp()->mapTile_X * COLNO; map_size.cy = GetNHApp()->mapTile_Y * ROWNO; - mswin_map_stretch(mswin_hwnd_from_winid(WIN_MAP), &map_size, TRUE); + mswin_map_layout(mswin_hwnd_from_winid(WIN_MAP), &map_size); return TRUE; } diff -Nru nethack-3.6.6/win/win32/nethack.rc nethack-3.6.7/win/win32/nethack.rc --- nethack-3.6.6/win/win32/nethack.rc 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/nethack.rc 2023-02-15 21:52:57.000000000 +0000 @@ -60,8 +60,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,6,6,0 - PRODUCTVERSION 3,6,6,0 + FILEVERSION 3,6,7,0 + PRODUCTVERSION 3,6,7,0 FILEFLAGSMASK 0x1fL #ifdef _DEBUG FILEFLAGS 0x9L @@ -77,12 +77,12 @@ BLOCK "040904b0" BEGIN VALUE "FileDescription", "NetHack for Windows - TTY Interface" - VALUE "FileVersion", "3.6.6" + VALUE "FileVersion", "3.6.7" VALUE "InternalName", "NetHack" - VALUE "LegalCopyright", "Copyright (C) 1985 - 2020. By Stichting Mathematisch Centrum and M. Stephenson. See license for details." + VALUE "LegalCopyright", "Copyright (C) 1985 - 2023. By Stichting Mathematisch Centrum and M. Stephenson. See license for details." VALUE "OriginalFilename", "NetHack.exe" VALUE "ProductName", "NetHack" - VALUE "ProductVersion", "3.6.6" + VALUE "ProductVersion", "3.6.7" END END BLOCK "VarFileInfo" diff -Nru nethack-3.6.6/win/win32/NetHackW.rc nethack-3.6.7/win/win32/NetHackW.rc --- nethack-3.6.6/win/win32/NetHackW.rc 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/NetHackW.rc 2023-02-15 21:52:57.000000000 +0000 @@ -320,8 +320,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,6,6,0 - PRODUCTVERSION 3,6,6,0 + FILEVERSION 3,6,7,0 + PRODUCTVERSION 3,6,7,0 FILEFLAGSMASK 0x1fL #ifdef _DEBUG FILEFLAGS 0x9L @@ -337,13 +337,13 @@ BLOCK "040904b0" BEGIN VALUE "FileDescription", "NetHack for Windows - Graphical Interface" - VALUE "FileVersion", "3.6.6" + VALUE "FileVersion", "3.6.7" VALUE "InternalName", "NetHackW" - VALUE "LegalCopyright", "Copyright (C) 1985 - 2020. By Stichting Mathematisch Centrum and M. Stephenson. See license for details." + VALUE "LegalCopyright", "Copyright (C) 1985 - 2023. By Stichting Mathematisch Centrum and M. Stephenson. See license for details." VALUE "OriginalFilename", "NetHackW.exe" VALUE "PrivateBuild", "140606" VALUE "ProductName", "NetHack" - VALUE "ProductVersion", "3.6.6" + VALUE "ProductVersion", "3.6.7" END END BLOCK "VarFileInfo" diff -Nru nethack-3.6.6/win/win32/vs2017/NetHackPackage.appxmanifest nethack-3.6.7/win/win32/vs2017/NetHackPackage.appxmanifest --- nethack-3.6.6/win/win32/vs2017/NetHackPackage.appxmanifest 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/NetHackPackage.appxmanifest 2023-02-15 21:52:57.000000000 +0000 @@ -1,6 +1,6 @@  - + NetHack 3.6 NetHack DevTeam diff -Nru nethack-3.6.6/win/win32/vs2017/NetHackProperties.props nethack-3.6.7/win/win32/vs2017/NetHackProperties.props --- nethack-3.6.6/win/win32/vs2017/NetHackProperties.props 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/NetHackProperties.props 2023-02-15 21:52:57.000000000 +0000 @@ -4,7 +4,7 @@ 3 6 - 6 + 7 diff -Nru nethack-3.6.6/win/win32/vs2017/NetHack.sln nethack-3.6.7/win/win32/vs2017/NetHack.sln --- nethack-3.6.6/win/win32/vs2017/NetHack.sln 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/NetHack.sln 2023-02-15 21:52:57.000000000 +0000 @@ -54,29 +54,14 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetHack", "NetHack.vcxproj", "{609BC774-C6F8-4B2B-AA7D-5B3D0EA95751}" ProjectSection(ProjectDependencies) = postProject + {93F10526-209E-41D7-BBEA-775787876895} = {93F10526-209E-41D7-BBEA-775787876895} {63F9B82B-F589-4082-ABE5-D4F0682050AB} = {63F9B82B-F589-4082-ABE5-D4F0682050AB} {9DD9C52E-E8C9-4533-BD22-83C055C0AABA} = {9DD9C52E-E8C9-4533-BD22-83C055C0AABA} {BA3DD34C-04B7-40D0-B373-9329AA9E8945} = {BA3DD34C-04B7-40D0-B373-9329AA9E8945} - {6813477F-64B6-4B97-B230-438D0D233385} = {6813477F-64B6-4B97-B230-438D0D233385} {0303A585-3F83-4BB7-AF6B-1E12C8FB54AC} = {0303A585-3F83-4BB7-AF6B-1E12C8FB54AC} {8A3F81C7-2968-49A8-86BF-2669412AD7DE} = {8A3F81C7-2968-49A8-86BF-2669412AD7DE} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nhdefkey", "nhdefkey.vcxproj", "{6813477F-64B6-4B97-B230-438D0D233385}" - ProjectSection(ProjectDependencies) = postProject - {BA3DD34C-04B7-40D0-B373-9329AA9E8945} = {BA3DD34C-04B7-40D0-B373-9329AA9E8945} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nh340key", "nh340key.vcxproj", "{BE04E242-A1E9-4593-B95B-057F37330B76}" - ProjectSection(ProjectDependencies) = postProject - {BA3DD34C-04B7-40D0-B373-9329AA9E8945} = {BA3DD34C-04B7-40D0-B373-9329AA9E8945} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nhraykey", "nhraykey.vcxproj", "{2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2}" - ProjectSection(ProjectDependencies) = postProject - {BA3DD34C-04B7-40D0-B373-9329AA9E8945} = {BA3DD34C-04B7-40D0-B373-9329AA9E8945} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PDCurses", "PDCurses.vcxproj", "{BAA70D0F-3EC7-4D10-91F0-974F1F49308B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{477BF231-48E0-4312-AA12-9D8576215489}" @@ -174,30 +159,6 @@ {609BC774-C6F8-4B2B-AA7D-5B3D0EA95751}.Release|Win32.Build.0 = Release|Win32 {609BC774-C6F8-4B2B-AA7D-5B3D0EA95751}.Release|x64.ActiveCfg = Release|x64 {609BC774-C6F8-4B2B-AA7D-5B3D0EA95751}.Release|x64.Build.0 = Release|x64 - {6813477F-64B6-4B97-B230-438D0D233385}.Debug|Win32.ActiveCfg = Debug|Win32 - {6813477F-64B6-4B97-B230-438D0D233385}.Debug|Win32.Build.0 = Debug|Win32 - {6813477F-64B6-4B97-B230-438D0D233385}.Debug|x64.ActiveCfg = Debug|x64 - {6813477F-64B6-4B97-B230-438D0D233385}.Debug|x64.Build.0 = Debug|x64 - {6813477F-64B6-4B97-B230-438D0D233385}.Release|Win32.ActiveCfg = Release|Win32 - {6813477F-64B6-4B97-B230-438D0D233385}.Release|Win32.Build.0 = Release|Win32 - {6813477F-64B6-4B97-B230-438D0D233385}.Release|x64.ActiveCfg = Release|x64 - {6813477F-64B6-4B97-B230-438D0D233385}.Release|x64.Build.0 = Release|x64 - {BE04E242-A1E9-4593-B95B-057F37330B76}.Debug|Win32.ActiveCfg = Debug|Win32 - {BE04E242-A1E9-4593-B95B-057F37330B76}.Debug|Win32.Build.0 = Debug|Win32 - {BE04E242-A1E9-4593-B95B-057F37330B76}.Debug|x64.ActiveCfg = Debug|x64 - {BE04E242-A1E9-4593-B95B-057F37330B76}.Debug|x64.Build.0 = Debug|x64 - {BE04E242-A1E9-4593-B95B-057F37330B76}.Release|Win32.ActiveCfg = Release|Win32 - {BE04E242-A1E9-4593-B95B-057F37330B76}.Release|Win32.Build.0 = Release|Win32 - {BE04E242-A1E9-4593-B95B-057F37330B76}.Release|x64.ActiveCfg = Release|x64 - {BE04E242-A1E9-4593-B95B-057F37330B76}.Release|x64.Build.0 = Release|x64 - {2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2}.Debug|Win32.ActiveCfg = Debug|Win32 - {2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2}.Debug|Win32.Build.0 = Debug|Win32 - {2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2}.Debug|x64.ActiveCfg = Debug|x64 - {2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2}.Debug|x64.Build.0 = Debug|x64 - {2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2}.Release|Win32.ActiveCfg = Release|Win32 - {2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2}.Release|Win32.Build.0 = Release|Win32 - {2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2}.Release|x64.ActiveCfg = Release|x64 - {2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2}.Release|x64.Build.0 = Release|x64 {BAA70D0F-3EC7-4D10-91F0-974F1F49308B}.Debug|Win32.ActiveCfg = Debug|Win32 {BAA70D0F-3EC7-4D10-91F0-974F1F49308B}.Debug|Win32.Build.0 = Debug|Win32 {BAA70D0F-3EC7-4D10-91F0-974F1F49308B}.Debug|x64.ActiveCfg = Debug|x64 diff -Nru nethack-3.6.6/win/win32/vs2017/nh340key.def nethack-3.6.7/win/win32/vs2017/nh340key.def --- nethack-3.6.6/win/win32/vs2017/nh340key.def 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/nh340key.def 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -LIBRARY nh340key -EXPORTS -ProcessKeystroke -NHkbhit -CheckInput -SourceWhere -SourceAuthor -KeyHandlerName diff -Nru nethack-3.6.6/win/win32/vs2017/nh340key.vcxproj nethack-3.6.7/win/win32/vs2017/nh340key.vcxproj --- nethack-3.6.6/win/win32/vs2017/nh340key.vcxproj 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/nh340key.vcxproj 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ - - - - - {BE04E242-A1E9-4593-B95B-057F37330B76} - Win32Proj - nh340key - - - - - - - - - - - - - - - - - - - - - - $(BinDir) - - - - $(IncDir);$(SysWinntDir);%(AdditionalIncludeDirectories) - - - $(ToolsDir)$(TargetName).lib - - - - - nh340key.def - - - - - - - - - - - - - \ No newline at end of file diff -Nru nethack-3.6.6/win/win32/vs2017/nhdefkey.def nethack-3.6.7/win/win32/vs2017/nhdefkey.def --- nethack-3.6.6/win/win32/vs2017/nhdefkey.def 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/nhdefkey.def 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -LIBRARY nhdefkey -EXPORTS -ProcessKeystroke -NHkbhit -CheckInput -SourceWhere -SourceAuthor -KeyHandlerName diff -Nru nethack-3.6.6/win/win32/vs2017/nhdefkey.vcxproj nethack-3.6.7/win/win32/vs2017/nhdefkey.vcxproj --- nethack-3.6.6/win/win32/vs2017/nhdefkey.vcxproj 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/nhdefkey.vcxproj 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ - - - - - {6813477F-64B6-4B97-B230-438D0D233385} - Win32Proj - nhdefkey - - - - - - - - - - - - - - - - - - - - - - $(BinDir) - - - - $(IncDir);$(SysWinntDir);%(AdditionalIncludeDirectories) - - - $(ToolsDir)$(TargetName).lib - - - - - nhdefkey.def - - - - - - - - - - - - - \ No newline at end of file diff -Nru nethack-3.6.6/win/win32/vs2017/nhraykey.def nethack-3.6.7/win/win32/vs2017/nhraykey.def --- nethack-3.6.6/win/win32/vs2017/nhraykey.def 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/nhraykey.def 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -LIBRARY nhraykey -EXPORTS -ProcessKeystroke -NHkbhit -CheckInput -SourceWhere -SourceAuthor -KeyHandlerName diff -Nru nethack-3.6.6/win/win32/vs2017/nhraykey.vcxproj nethack-3.6.7/win/win32/vs2017/nhraykey.vcxproj --- nethack-3.6.6/win/win32/vs2017/nhraykey.vcxproj 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/nhraykey.vcxproj 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ - - - - - {2E1F4BB3-3BD7-43AD-8E64-D3B8A2F5D7B2} - Win32Proj - nhraykey - - - - - - - - - - - - - - - - - - - - - - $(BinDir) - - - - $(IncDir);$(SysWinntDir);%(AdditionalIncludeDirectories) - - - $(ToolsDir)$(TargetName).lib - - - - - nhraykey.def - - - - - - - - - - - - - \ No newline at end of file diff -Nru nethack-3.6.6/win/win32/vs2017/travisci.sh nethack-3.6.7/win/win32/vs2017/travisci.sh --- nethack-3.6.6/win/win32/vs2017/travisci.sh 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/win32/vs2017/travisci.sh 2023-02-15 21:52:57.000000000 +0000 @@ -13,6 +13,7 @@ export PATH=/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/$VSVER/$TOOLSVER/VC/Tools/MSVC/$MSVER/bin/HostX64/x86:$PATH export PATH=$PATH:/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/$VSVER/$TOOLSVER/Common7/IDE/CommonExtensions/Microsoft/TestWindow export PATH=$PATH:/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/$VSVER/$TOOLSVER/MSBuild/Current/bin/Roslyn +export PATH=$PATH:/c/ProgramData/chocolatey/lib/winflexbison/tools export INCLUDE=/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/$TOOLSVER/VC/Tools/MSVC/$MSVER/include export INCLUDE=$INCLUDE:/c/Program\ Files\ \(x86\)/Windows\ Kits/10/Include/$WKITVER/ucrt export INCLUDE=$INCLUDE:/c/Program\ Files\ \(x86\)/Windows\ Kits/10/include/$WKITVER/ucrt @@ -27,8 +28,13 @@ git clone --depth 1 https://github.com/wmcbrine/PDCurses.git ../pdcurses export ADD_CURSES=Y export PDCURSES_TOP=../../pdcurses -export +export YACC="win_bison -y" +export LEX=win_flex.exe +export YTABC=y.tab.c +export YTABH=y.tab.h +export LEXYYC=lex.yy.cexport cd src +mkdir ../binary cp ../sys/winnt/Makefile.msc ./Makefile nmake install cd .. diff -Nru nethack-3.6.6/win/X11/winX.c nethack-3.6.7/win/X11/winX.c --- nethack-3.6.6/win/X11/winX.c 2020-03-08 17:29:31.000000000 +0000 +++ nethack-3.6.7/win/X11/winX.c 2023-02-15 21:52:57.000000000 +0000 @@ -82,11 +82,14 @@ struct xwindow window_list[MAX_WINDOWS]; AppResources appResources; void FDECL((*input_func), (Widget, XEvent *, String *, Cardinal *)); -int click_x, click_y, click_button; /* Click position on a map window */ - /* (filled by set_button_values()). */ +int click_x, click_y, click_button; /* Click position on a map window + * (filled by set_button_values()). */ int updated_inventory; -static int (*old_error_handler) (Display *, XErrorEvent *); +static void FDECL(X11_error_handler, (String)) NORETURN; +static int FDECL(X11_io_error_handler, (Display *)); + +static int FDECL((*old_error_handler), (Display *, XErrorEvent *)); #if !defined(NO_SIGNAL) && defined(SAFERHANGUP) #if XtSpecificationRelease >= 6 @@ -1477,6 +1480,33 @@ return 0; } +static void +X11_error_handler(str) +String str; +{ + nhUse(str); + hangup(1); +#ifdef SAFERHANGUP /* keeps going after hangup() for '#if SAFERHANGUP' */ + end_of_input(); +#endif + /*NOTREACHED*/ + nh_terminate(EXIT_FAILURE); +} + +static int +X11_io_error_handler(display) +Display *display; +{ + nhUse(display); + hangup(1); +#ifdef SAFERHANGUP /* keeps going after hangup() for '#if SAFERHANGUP' */ + end_of_input(); +#endif + /*NOREACHED*/ /* but not declared NORETURN */ + return 0; +} + + void X11_init_nhwindows(argcp, argv) int *argcp; @@ -1491,6 +1521,12 @@ for (i = 0; i < MAX_WINDOWS; i++) window_list[i].type = NHW_NONE; + /* force high scores display to be shown in a window, and don't allow + that to be toggled off via 'O' (note: 'nethack -s' won't reach here; + its output goes to stdout and could be redirected into a file) */ + iflags.toptenwin = TRUE; + set_option_mod_status("toptenwin", SET_IN_FILE); + /* add another option that can be set */ set_wc_option_mod_status(WC_TILED_MAP, SET_IN_GAME); set_option_mod_status("mouse_support", SET_IN_GAME); @@ -1507,7 +1543,7 @@ savuid = geteuid(); (void) seteuid(getuid()); - XSetIOErrorHandler((XIOErrorHandler) hangup); + XSetIOErrorHandler(X11_io_error_handler); num_args = 0; XtSetArg(args[num_args], XtNallowShellResize, True); num_args++; @@ -2572,7 +2608,7 @@ set_message_slider(&window_list[message_win]); /* attempt to catch fatal X11 errors before the program quits */ - (void) XtAppSetErrorHandler(app_context, (XtErrorHandler) hangup); + (void) XtAppSetErrorHandler(app_context, X11_error_handler); highlight_yn(TRUE); /* switch foreground and background */