From c969f79903dc8dc8585c86d04707056ded1fc90f Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Sat, 18 Feb 2023 13:27:22 +0900 Subject: [PATCH] upgrade to 3.6.7 --- .travis.yml | 29 - Files | 8 +- README | 40 +- dat/hh | 202 +-- doc/Guidebook.mn | 20 +- doc/Guidebook.tex | 21 +- doc/Guidebook.txt | 1030 +++++++------- doc/fixes36.6 | 3 +- include/extern.h | 3 +- include/flag.h | 14 +- include/isaac64.h | 2 +- include/ntconf.h | 2 +- include/patchlevel.h | 33 +- src/apply.c | 4 +- src/do_name.c | 65 +- src/engrave.c | 2 +- src/files.c | 9 +- src/invent.c | 47 +- src/isaac64.c | 1 - src/o_init.c | 39 +- src/objnam.c | 120 +- src/options.c | 17 +- src/pager.c | 45 +- src/priest.c | 2 +- src/weapon.c | 8 +- sys/unix/Makefile.src | 4 +- .../xcshareddata/WorkspaceSettings.xcsettings | 5 - sys/vms/Makefile.src | 2 +- sys/vms/vmsbuild.com | 2 +- sys/winnt/.nethackrc.template | 8 +- sys/winnt/Install.nt | 117 +- sys/winnt/Makefile.gcc | 4 +- sys/winnt/Makefile.msc | 135 +- sys/winnt/console.rc | 12 +- sys/winnt/nh340key.c | 356 ----- sys/winnt/nhdefkey.c | 416 ------ sys/winnt/nhraykey.c | 669 --------- sys/winnt/nttty.c | 1464 ++++++++++++++++++-- sys/winnt/stubs.c | 10 + win/Qt4/qt4bind.cpp | 22 +- win/X11/winX.c | 46 +- win/curses/cursmain.c | 18 +- win/win32/NetHackW.rc | 10 +- win/win32/dgnstuff.mak | 6 +- win/win32/mhmap.c | 80 +- win/win32/mhmap.h | 3 +- win/win32/mswproc.c | 9 +- win/win32/nethack.rc | 10 +- win/win32/vs2017/NetHack.sln | 41 +- win/win32/vs2017/NetHackPackage.appxmanifest | 2 +- win/win32/vs2017/NetHackProperties.props | 2 +- win/win32/vs2017/nhdefkey.def | 8 - win/win32/vs2017/nhdefkey.vcxproj | 54 - win/win32/vs2017/nhraykey.def | 8 - win/win32/vs2017/nhraykey.vcxproj | 54 - win/win32/vs2017/travisci.sh | 8 +- 56 files changed, 2551 insertions(+), 2800 deletions(-) delete mode 100644 .travis.yml delete mode 100644 sys/unix/NetHack.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings delete mode 100644 sys/winnt/nh340key.c delete mode 100644 sys/winnt/nhdefkey.c delete mode 100644 sys/winnt/nhraykey.c delete mode 100644 win/win32/vs2017/nhdefkey.def delete mode 100644 win/win32/vs2017/nhdefkey.vcxproj delete mode 100644 win/win32/vs2017/nhraykey.def delete mode 100644 win/win32/vs2017/nhraykey.vcxproj diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7c3dc0a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: c - -branches: - only: - - develop - -os: - - linux - - osx - -compiler: - - gcc - -osx_image: xcode13.2 - -addons: - apt: - packages: - - nkf - homebrew: - packages: - - nkf - - gcc@9 - -before_script: - - sh configure - -script: - - make install diff --git a/Files b/Files index d81ad0c..e315d58 100644 --- a/Files +++ b/Files @@ -7,7 +7,7 @@ from or not transferred to your system if you wish. .: (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 @@ sys/winnt: (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 @@ default_lib.props dgncomp.vcxproj 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 --git a/README b/README index 3b4ebac..87044cf 100644 --- a/README +++ b/README @@ -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 @@ that file. Some entries might be considered "spoilers", particularly in the 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 @@ In our own patches, we will assume that your code is synchronized with ours. -- 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 --git a/dat/hh b/dat/hh index 6d6967a..365846f 100644 --- a/dat/hh +++ b/dat/hh @@ -22,106 +22,128 @@ b j n 1 2 3 g: 'z' ‚ª“ü‚ê‘Ö‚í‚éD ˆê”Ê: -? help ƒwƒ‹ƒv•¶Í‚Ì•\Ž¦ -#quit quit Œ»Ý‚̃Q[ƒ€‚ð•Û‘¶‚¹‚¸‚ɃQ[ƒ€‚ð‚â‚ß‚é -S save ƒQ[ƒ€‚ð(Œã‚Å‘±‚¯‚邽‚ß‚É)•Û‘¶‚µ‚ďI—¹‚·‚é - [•œŒ³‚·‚é‚ɂ́CÄ‚уvƒŒƒC‚µ‚Ä“¯‚¶ƒLƒƒƒ‰ƒNƒ^[–¼‚ðŽg‚¤] -! sh (‚à‚µ‚Å‚«‚é‚È‚ç)ƒVƒFƒ‹‚ðŽÀs‚·‚éD(ÄŠJ‚·‚é‚É‚Í'exit') -^Z suspend ƒQ[ƒ€‚ð’†’f‚·‚éD(Œ»Ý‚Ì’†’f•¶Žš‚Ɉˑ¶‚µ‚È‚¢) +? help ƒwƒ‹ƒv•¶Í‚Ì•\Ž¦ +#quit quit Œ»Ý‚̃Q[ƒ€‚ð•Û‘¶‚¹‚¸‚ɃQ[ƒ€‚ð‚â‚ß‚é +S save ƒQ[ƒ€‚ð(Œã‚Å‘±‚¯‚邽‚ß‚É)•Û‘¶‚µ‚ďI—¹‚·‚é + [•œŒ³‚·‚é‚ɂ́CÄ‚уvƒŒƒC‚µ‚Ä“¯‚¶ƒLƒƒƒ‰ƒNƒ^[–¼‚ðŽg‚¤; + •Û‘¶‚¹‚¸‚É”²‚¯‚é‚É‚Í #quit ‚ðŽg‚¤] +! sh (‚à‚µ‚Å‚«‚é‚È‚ç)ƒVƒFƒ‹‚ðŽÀs‚·‚éD(ÄŠJ‚·‚é‚É‚Í'exit') +^Z suspend ƒQ[ƒ€‚ð’†’f‚·‚éD(Œ»Ý‚Ì’†’f•¶Žš‚Ɉˑ¶‚µ‚È‚¢) [UNIX(tm) ƒx[ƒX‚̃VƒXƒeƒ€‚ł́AÄŠJ‚·‚é‚É‚Í'fg'] -O options ƒIƒvƒVƒ‡ƒ“‚ðÝ’è‚·‚éD -/ what-is ‰æ–Ê‚Ì‹L†‚ª‰½‚©‚ð’m‚éD -\ known ¡‚Ü‚Å‚É”­Œ©‚µ‚½“¹‹ï‚̈ꗗ‚ð•\Ž¦‚·‚éD -v version ƒo[ƒWƒ‡ƒ“‚ð•\Ž¦‚·‚éD -V history ƒQ[ƒ€‚Ì—ðŽj‚ð•\Ž¦‚·‚éD -^A again 1‚‘O‚̃Rƒ}ƒ“ƒh‚ðÄŽÀs‚·‚éD(^A‚̓Rƒ“ƒgƒ[ƒ‹-A) -^R redraw ‰æ–Ê‚ð‘‚«‚È‚¨‚·D -^P prevmsg ‘O‚̃ƒbƒZ[ƒW‚ðŒ©‚éD(^P‚ÍŒJ‚è•Ô‚µŽg‚¦‚é) +O options ƒIƒvƒVƒ‡ƒ“‚ðÝ’è‚·‚éD +/ what-is ‰æ–Ê‚Ì‹L†‚ª‰½‚©‚ð’m‚éD +\ known ¡‚Ü‚Å‚É”­Œ©‚µ‚½“¹‹ï‚̈ꗗ‚ð•\Ž¦‚·‚éD +v version ƒo[ƒWƒ‡ƒ“‚ð•\Ž¦‚·‚éD +V history ƒQ[ƒ€‚Ì—ðŽj‚ð•\Ž¦‚·‚éD +^A again 1‚‘O‚̃Rƒ}ƒ“ƒh‚ðÄŽÀs‚·‚éD +^R redraw ‰æ–Ê‚ð‘‚«‚È‚¨‚·D +^P prevmsg ‘O‚̃ƒbƒZ[ƒW‚ðŒ©‚éD(^P‚ðŒJ‚è•Ô‚·‚Æ‚³‚ç‚É‘O‚̃ƒbƒZ[ƒW) # Šg’£ƒRƒ}ƒ“ƒh(#?‚Ńwƒ‹ƒv) -& what-does ƒL[‚ð‰Ÿ‚µ‚Ä‹N“®‚·‚éƒRƒ}ƒ“ƒh‚ðà–¾‚·‚éD +& what-does ƒL[‚ð‰Ÿ‚µ‚Ä‹N“®‚·‚éƒRƒ}ƒ“ƒh‚ðà–¾‚·‚éD + +§Œä•¶Žš‚́C'^' ‚Ɉø‚«‘±‚­ˆê•¶Žš‚Å•\‚³‚ê‚éD Ctrl ‚Ü‚½‚Í Control ƒL[‚ð +ƒVƒtƒgƒL[‚̂悤‚ɉŸ‚µ‰º‚°‚āA•¶Žš‚ð‘łD§Œä•¶Žš‚͑啶Žš¬•¶Žš‚Ì‹æ•Ê‚ª‚È‚¢; +^D ‚Í ^d ‚Æ“¯‚¶‚ŁACtrl+d ‚Í Ctrl+Shift+d ‚Æ“¯‚¶D +‰pŽš‚Å‚È‚¢§Œä•¶Žš‚à‚¢‚­‚‚©‚ ‚é; nethack ‚Í ^[ ‚ð Escape ‚Ì•Ê–¼‚Æ‚µ‚ÄŽg‚¤ +(‚Ü‚½‚Í‚»‚Ì‹t) ‚ªA‘¼‚Ì‚à‚Ì‚Í‚È‚¢D ƒQ[ƒ€: -^D kick R‚éD(”à“™) -^T 'port uŠÔˆÚ“®D(‰Â”\‚È‚ç) -^X show ‘®«‚ð•\Ž¦‚·‚é -a apply “¹‹ï‚ðŽg‚¤D(‚‚é‚Í‚µCŒ®CƒJƒƒ‰“™) -A armor ‘S‚Ä‚ÌŠZ‚ð’E‚®D -c close ”à‚ð•Â‚ß‚éD -C call “Á’è‚̉ö•¨CŒÂX‚̃AƒCƒeƒ€CƒAƒCƒeƒ€‚ÌŽí—Þ‚É–¼‘O‚ð‚‚¯‚éD -d drop •¨‚ð’u‚­D d7aFa‚È‚é‚à‚Ì‚ð7ŒÂ’u‚­D -D Drop Ží—Þ‚ð‘I‚ñ‚Å•¨‚ð’u‚­D -e eat ‰½‚©‚ðH‚ׂéD -E engrave °‚Ì‚Ù‚±‚è‚É•¶Žš‚ð‘‚­D(E- Žw‚ðŽg‚Á‚Ä) -f fire ‘•“U‚³‚ê‚Ä‚¢‚é‚à‚Ì‚ðŽË‚éD -F fight •ûŒü‚ðŽw’肵í‚¤D -i invent ‚ ‚È‚½‚ÌŽ‚¿•¨ˆê——D(‚ ‚È‚½‚ªŽ‚Á‚Ä‚¢‚é‚à‚Ì‘S‚Ä) -I Invent Ží—Þ‚ð‘I‘ð‚µ‚ÄŽ‚¿•¨ˆê——D - Iu: –¢•¥‚Ì“¹‹ïˆê——D - Ix: –¢•¥‚¾‚ªŽg‚¢‚Í‚½‚µ‚½“¹‹ïˆê——D - I$: ‚¨‹à‚𐔂¦‚éD -o open ”à‚ðŠJ‚¯‚éD -p pay Š¨’è‚𕥂¤D(“X‚Ì’†‚Å) -P puton ƒAƒNƒZƒTƒŠ‚ðg‚ɂ‚¯‚éD(Žw—ցC–‚œ‚¯‚È‚Ç) -q quaff ‰½‚©‚ðˆù‚Þ(…–ò, …, ‚È‚Ç) -Q quiver ‘•“U‚·‚é‚à‚Ì‚ð‘I‘ð‚·‚éD(I—¹‚Í'#quit') -r read Šª•¨‚â–‚–@‚Ì–{‚ð“ǂށD -R remove ƒAƒNƒZƒTƒŠ‚ð‚Í‚¸‚·D(Žw—ցC–‚œ‚¯‚È‚Ç) -s search ”é–§‚Ì”àC‰B‚ꂽ㩁C‰ö•¨‚ð’T‚·D -t throw •Ší‚ð“Š‚°‚éCŒ‚‚CŽË‚éD -T takeoff ŠZ‚ð’E‚®D -w wield •Ší‚ð‘•”õ‚·‚éD(w- ‰½‚à‘•”õ‚µ‚È‚¢) -W wear ŠZ‚ð’…‚éD -x xchange ¶‰E‚Ì•Ší‚ðŒðŠ·‚·‚éD -X twoweapon “ñ“—¬‚ðØ‚è‘Ö‚¦‚éD(’Tõƒ‚[ƒh‚Í'#explore') -z zap ñ‚ðU‚è‚©‚´‚·D(number_pad ‚ª -1 ‚È‚ç z ‚Å‚Í‚È‚­ y) -Z Zap Žô•¶‚ð¥‚¦‚éD(number_pad ‚ª -1 ‚È‚ç Z ‚Å‚Í‚È‚­ Y) -< up ŠK’i‚ð¸‚éD -> down ŠK’i‚ð~‚è‚éD -^ trap_id 㩂𒲂ׂéD +^D kick R‚éD(”à“™) +^T 'port uŠÔˆÚ“®D(‰Â”\‚È‚ç) +^X show ‘®«‚ð•\Ž¦‚·‚é +a apply “¹‹ï‚ðŽg‚¤D(‚‚é‚Í‚µCŒ®CƒJƒƒ‰“™) +A takeoffall –h‹ïCƒAƒNƒZƒTƒŠC•Ší‚𕡐”‘I‚ñ‚ŁA‚Ü‚Æ‚ß‚ÄŠO‚· + (T,R,w- ‚ŌX‚ÉŠO‚·‚Ì‚Æ“¯‚¶‚¾‚¯‚Ì + ƒQ[ƒ€“àŽžŠÔ‚ðŽg‚¤) +c close ”à‚ð•Â‚ß‚éD +C call “Á’è‚̉ö•¨CŒÂX‚̃AƒCƒeƒ€CƒAƒCƒeƒ€‚ÌŽí—Þ‚É–¼‘O‚ð‚‚¯‚éD +d drop •¨‚ð’u‚­D d7aFa‚È‚é‚à‚Ì‚ð7ŒÂ’u‚­D +D Drop Ží—Þ‚ð‘I‚ñ‚Å•¨‚ð’u‚­D +e eat ‰½‚©‚ðH‚ׂéD +E engrave °‚Ì‚Ù‚±‚è‚É•¶Žš‚ð‘‚­D(E- Žw‚ðŽg‚Á‚Ä) +f fire ‘•“U‚³‚ê‚Ä‚¢‚é‚à‚Ì‚ðŽË‚éD +F fight •ûŒü‚ðŽw’肵í‚¤D +i invent ‚ ‚È‚½‚ÌŽ‚¿•¨ˆê——D(‚ ‚È‚½‚ªŽ‚Á‚Ä‚¢‚é‚à‚Ì‘S‚Ä) +I Invent Ží—Þ‚ð‘I‘ð‚µ‚ÄŽ‚¿•¨ˆê——D; —Ⴆ‚Î + I( ‘S‚Ä‚Ì“¹‹ïˆê——C I" ‘S‚Ä‚Ì–‚œ‚¯ˆê—— + IB j•Ÿ‚³‚ê‚Ä‚¢‚é‚Æ•ª‚©‚Á‚Ä‚¢‚镨‚̈ꗗ + IU Žô‚í‚ê‚Ä‚¢‚È‚¢•¨C IC Žô‚í‚ê‚Ä‚¢‚镨C IX ó‘Ô•s–¾‚Ì•¨ + Iu: –¢•¥‚¢‚Ì•¨ˆê——D + Ix: –¢•¥‚¢‚¾‚ªŽg‚¢‚Í‚½‚µ‚½•¨ˆê——D +o open ”à‚ðŠJ‚¯‚éD +p pay Š¨’è‚𕥂¤D(“X‚Ì’†‚Å) +P puton ƒAƒNƒZƒTƒŠ‚ðg‚ɂ‚¯‚éD(Žw—ցC–‚œ‚¯‚È‚Ç; –h‹ï‚É‚àŽg‚¦‚邪C + –h‹ï‚ÍŒó•â‚ɂ͏o‚È‚¢) +q quaff ‰½‚©‚ðˆù‚Þ(…–ò, …, ‚È‚Ç) +Q quiver ‘•“U‚·‚é‚à‚Ì‚ð‘I‘ð‚·‚éD(I—¹‚Í'#quit') +r read Šª•¨‚â–‚–@‚Ì–{‚ð“ǂށD +R remove ƒAƒNƒZƒTƒŠ‚ð‚Í‚¸‚·D(Žw—ցC–‚œ‚¯‚È‚Ç; –h‹ï‚à + ŠO‚¹‚é) +s search ”é–§‚Ì”àC‰B‚ꂽ㩁C‰ö•¨‚ð’T‚·D +t throw •Ší‚ð“Š‚°‚éCŒ‚‚CŽË‚éD +T takeoff –h‹ï‚ð’E‚®; ƒAƒNƒZƒTƒŠ‚É‚àŽg‚¦‚邪C + ƒAƒNƒZƒTƒŠ‚ÍŒó•â‚ɂ͏o‚È‚¢) +w wield •Ší‚ð‘•”õ‚·‚éD(w- Œ»Ý‚Ì•Ší‚ðŠO‚·‚½‚߂ɉ½‚à‘•”õ‚µ‚È‚¢) +W wear ŠZ‚ð’…‚é; ƒAƒNƒZƒTƒŠ‚É‚àŽg‚¦‚邪C + ƒAƒNƒZƒTƒŠ‚ÍŒó•â‚ɂ͏o‚È‚¢) +x xchange ¶‰E‚Ì•Ší‚ðŒðŠ·‚·‚éD +X twoweapon E‹Æ‚ª‹–‚¹‚Γñ“—¬‚ðØ‚è‘Ö‚¦‚éD +z zap ñ‚ðU‚è‚©‚´‚·D(number_pad ‚ª -1 ‚È‚ç z ‚Å‚Í‚È‚­ y) +Z Zap Žô•¶‚ð¥‚¦‚éD(number_pad ‚ª -1 ‚È‚ç Z ‚Å‚Í‚È‚­ Y) +< up ŠK’i‚ð¸‚éD +> down ŠK’i‚ð~‚è‚éD +^ trap_id 㩂𒲂ׂéD ),[,=,",( Œ»Ý‘•”õ‚µ‚Ä‚¢‚é‹L†‚ɑΉž‚µ‚½‚à‚Ì‚ð•\Ž¦ * ‘•”õ‚µ‚Ä‚¢‚é‚à‚Ì‚ð•\Ž¦ -$ gold ‚¨‹à‚𐔂¦‚éD -+ spells ¥‚¦‚邱‚Æ‚Ì‚Å‚«‚é–‚–@‚̈ꗗD -` classkn ˆê‚‚̎í—Þ‚Ì’†‚Å”­Œ©‚µ‚½•¨‚ð•\Ž¦‚·‚é -_ travel ƒ}ƒbƒv‚ÅŽ¦‚³‚ꂽ“_‚ɍŏ¬Œo˜HƒAƒ‹ƒSƒŠƒYƒ€‚ňړ®‚·‚éD -. rest ‹x‚ށD -, pickup •¨‚ðE‚¤D +$ gold ‚¨‹à‚𐔂¦‚éD ++ spells ¥‚¦‚邱‚Æ‚Ì‚Å‚«‚é–‚–@‚̈ꗗD +` classkn ˆê‚‚̎í—Þ‚Ì’†‚Å”­Œ©‚µ‚½•¨‚ð•\Ž¦‚·‚é +_ travel ƒ}ƒbƒv‚ÅŽ¦‚³‚ꂽ“_‚ɍŏ¬Œo˜HƒAƒ‹ƒSƒŠƒYƒ€‚ňړ®‚·‚éD +. rest ‹x‚ށD +, pickup •¨‚ðE‚¤D @ `pickup'(Ž©“®pickup)‚̃IƒvƒVƒ‡ƒ“‚ðØ‚è‘Ö‚¦‚éD -: look ‰½‚ª‚ ‚é‚©‚ðŒ©‚éD -; farlook ‘¼‚ɉ½‚ª‚ ‚é‚©’²‚ׂéD(’n}ã‚Ì‹L†‚ð‘I‘ð‚·‚é) +: look ‰½‚ª‚ ‚é‚©‚ðŒ©‚éD +; farlook ’n}ã‚̈ʒu‚ð‘I‘ð‚µ‚Ä‘¼‚ɉ½‚ª‚ ‚é‚©’²‚ׂéD + (•¨‚̏ã‚ɉö•¨‚ª‚¢‚éê‡A‰ö•¨‚¾‚¯‚ª•\Ž¦‚³‚ê‚é; + •¡”‚Ì•¨‚ª‚ ‚éê‡Aˆê”ԏã‚Ì•¨‚¾‚¯‚ª•\Ž¦‚³‚ê‚é) -ƒƒ^ƒL[‚Ì‚ ‚éƒL[ƒ{[ƒh‚ł͈ȉº‚ÌŠg’£ƒRƒ}ƒ“ƒh‚ð # ‚Ì‚©‚í‚è‚Ƀƒ^ƒL[ -‚ð‰Ÿ‚µ‚È‚ª‚çŽÀs‚Å‚«‚éD +ƒƒ^ƒL[‚Ì‚ ‚éƒL[ƒ{[ƒh‚Å‚Í (Alt ƒL[‚ª‚ ‚éê‡‚́AAlt ‚ð‰Ÿ‚µ‚È‚ª‚ç +'e' ‚ð‰Ÿ‚·‚Æ 'M-e' ‚É‚È‚é) ˆÈ‰º‚ÌŠg’£ƒRƒ}ƒ“ƒh‚ð # ‚Ì‚©‚í‚è‚Ƀƒ^ƒL[ +‚ð‰Ÿ‚µ‚È‚ª‚çŽÀs‚Å‚«‚éD §Œä•¶Žš‚ƈقȂèAƒƒ^•¶Žš‚͑啶Žš¬•¶Žš‚Ì +‹æ•Ê‚ª‚ ‚é‚̂ŁAM-a ‚Í M-A ‚Æ‚±‚Æ‚È‚éB +‚±‚̏ꍇ Meta+Shift+a ‚Æ“ü—Í‚·‚éB M-? Šg’£ƒRƒ}ƒ“ƒhƒwƒ‹ƒv‚Ì•\Ž¦ (ƒvƒ‰ƒbƒgƒtƒH[ƒ€‚ª‹–‚¹‚Î) -M-2 twoweapon “ñ“—¬‚̐؂è‘Ö‚¦ (number_pad ‚ª–³Œø‚È‚ç) -M-a adjust Ž‚¿•¨ˆê——‚Ì’²® -M-A annotate Œ»Ý‚ÌŠK‚É1sƒƒ‚‚ð’ljÁ‚·‚é(M-OŽQÆ) -M-c chat ’N‚©‚Ƙb‚· -M-C conduct Ž©”­“I’§í‚ð•\Ž¦‚·‚é -M-d dip ‰½‚©‚É•¨‚ðZ‚·D -M-e enhance •Ší‚Ì‹Z—Ê‚ð‚‚ß‚é‚Ü‚½‚ÍŒ©‚é -M-f force Œ®‚ð‚±‚¶‚ ‚¯‚éD -M-i invoke •¨‚Ì“Á•Ê‚È—Í‚ðŽg‚¤D -M-j jump ‘¼‚̈ʒu‚É”ò‚Ñ‚¤‚‚éD -M-l loot °‚̏ã‚Ì” ‚Ì’†g‚ð—ª’D‚·‚éD -M-m monster ‰ö•¨‚Ì“Á•Ê”\—Í‚ðŽg‚¤D -M-n name “Á’è‚̉ö•¨CŒÂX‚̃AƒCƒeƒ€CƒAƒCƒeƒ€‚ÌŽí—Þ‚É–¼‘O‚ð‚‚¯‚éD -M-N name M-n‚Ì•Ê–¼ -M-o offer _‚É‹Ÿ•¨‚ð•ù‚°‚éD -M-O overview –K‚ꂽŠK‚ÉŠÖ‚·‚éî•ñ‚ƃƒ‚‚ð•\Ž¦‚·‚é -M-p pray _‚É‹F‚éD -M-q quit ƒQ[ƒ€‚ð‚â‚ß‚é -M-r rub ƒ‰ƒ“ƒv‚ð‚±‚·‚éD -M-R ride ‹Ræ‚·‚é‚Ü‚½‚Í‹Ræ‚ð‚â‚ß‚é -M-s sit À‚éD -M-t turn ƒAƒ“ƒfƒbƒg‚ð“y‚É•Ô‚·D -M-T tip “ü‚ꕨ‚ð‚ЂÁ‚­‚è•Ô‚· -M-u untrap 㩂ð‚Í‚¸‚·D -M-v version ƒRƒ“ƒpƒCƒ‹Žž‚̃IƒvƒVƒ‡ƒ“‚ð•\Ž¦‚·‚éD -M-w wipe Šç‚ð@‚¤D +M-2 twoweapon “ñ“—¬‚̐؂è‘Ö‚¦ (number_pad ‚ª–³Œø‚È‚ç) +M-a adjust Ž‚¿•¨ˆê——‚Ì’²® +M-A annotate Œ»Ý‚ÌŠK‚É1sƒƒ‚‚ð’ljÁ‚·‚é(M-OŽQÆ) +M-c chat ’N‚©‚Ƙb‚· +M-C conduct Ž©”­“I’§í‚ð•\Ž¦‚·‚é +M-d dip ‰½‚©‚É•¨‚ðZ‚·D +M-e enhance •Ší‚Ì‹Z—Ê‚ð‚‚ß‚é‚Ü‚½‚ÍŒ©‚éC€”õ‚ª‚Å‚«‚Ä‚¢‚ê‚ÎŒüã‚Å‚«‚éD +M-f force Œ®‚ð‚±‚¶‚ ‚¯‚éD +M-i invoke •¨‚Ì“Á•Ê‚È—Í‚ðŽg‚¤D +M-j jump ‘¼‚̈ʒu‚É”ò‚Ñ‚¤‚‚éD +M-l loot °‚̏ã‚Ì” ‚Ì’†g‚ð—ª’D‚·‚éD +M-m monster •Ï‰»’†C‰ö•¨‚Ì“Á•Ê”\—Í‚ðŽg‚¤D +M-n name “Á’è‚̉ö•¨CŒÂX‚̃AƒCƒeƒ€CƒAƒCƒeƒ€‚ÌŽí—Þ‚É–¼‘O‚ð‚‚¯‚éD +M-N name M-n‚Ì•Ê–¼ (‚Ç‚¿‚ç‚à C ‚Æ“¯‚¶) +M-o offer _‚É‹Ÿ•¨‚ð•ù‚°‚éD +M-O overview –K‚ꂽŠK‚ÉŠÖ‚·‚éî•ñ‚ƃƒ‚‚ð•\Ž¦‚·‚é +M-p pray _‚É‹F‚éD +M-q quit ƒQ[ƒ€‚ð•Û‘¶‚¹‚¸‚ɃQ[ƒ€‚ð‚â‚ß‚é (•Û‘¶‚µ‚ďI—¹‚·‚é‚É‚Í S) +M-r rub ƒ‰ƒ“ƒv‚ð‚±‚·‚éD +M-R ride ‹Ræ‚·‚é‚Ü‚½‚Í‹Ræ‚ð‚â‚ß‚é +M-s sit À‚éD +M-t turn E‹Æ‚ª‹–‚¹‚΁C•sŽ€‚̉ö•¨‚ð“y‚É•Ô‚·D +M-T tip “ü‚ꕨ‚ð‚ЂÁ‚­‚è•Ô‚· +M-u untrap 㩂ð‚Í‚¸‚·D +M-v version ƒRƒ“ƒpƒCƒ‹Žž‚̃IƒvƒVƒ‡ƒ“‚ð•\Ž¦‚·‚éD +M-w wipe Šç‚ð@‚¤D +M-X explore ƒXƒRƒA‚ª‹L˜^‚³‚ê‚È‚¢’Tõƒ‚[ƒh‚ɐ؂è‘Ö‚¦‚é -`number_pad'‚̃IƒvƒVƒ‡ƒ“‚ªƒIƒ“‚È‚çCŽŸ‚̃Rƒ}ƒ“ƒh‚ª‰Â”\‚É‚È‚éD +'number_pad'‚̃IƒvƒVƒ‡ƒ“‚ªƒIƒ“‚È‚çC’ʏí‚͈ړ®‚ÉŽg‚í‚ê‚Ä‚¢‚éƒL[‚ð +—lX‚ȃRƒ}ƒ“ƒh‚ÉŽg‚¦‚é: n ‚±‚ê‚É‘±‚­”Žš‚¾‚¯ŽŸ‚̃Rƒ}ƒ“ƒh‚ðŽÀs‚·‚éD h help '?' ‚Æ“¯—lƒwƒ‹ƒv•¶Í‚̈ê‚‚ð•\Ž¦ @@ -130,3 +152,5 @@ k kick l loot °‚̏ã‚Ì” ‚Ì’†g‚ð—ª’D‚·‚éD N name ƒAƒCƒeƒ€‚╨‚É–¼‘O‚ð‚‚¯‚éD u untrap 㩂ð‚Í‚¸‚·D(’ʏí‚Í‚µ‚©‚¯‚ç‚ꂽ•¨) + +ƒfƒoƒbƒOƒ‚[ƒh(‚Ü‚½‚Ì–¼‚ðƒEƒBƒU[ƒhƒ‚[ƒh)‚ł͒ljÁ‚̃Rƒ}ƒ“ƒh‚ªŽg‚¦‚éD diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index bad63a8..c302200 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -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 @@ Persistence of Objects .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 @@ The file may not exist, but it is a normal ASCII text file and 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 @@ Platform-specific Customization options .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 @@ and a small number of bug fixes. 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 --git a/doc/Guidebook.tex b/doc/Guidebook.tex index c34f6fa..7d9e320 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -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 @@ you are carrying (shopkeepers aside). %.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 @@ can be created with any text editor.\\ %.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 @@ or ports to customize and change the port behavior. \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 @@ -5780,6 +5778,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 \special{html:}} diff --git a/doc/Guidebook.txt b/doc/Guidebook.txt index 8464626..d9c5287 100644 --- a/doc/Guidebook.txt +++ b/doc/Guidebook.txt @@ -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 --git a/doc/fixes36.6 b/doc/fixes36.6 index 7eb7e85..aaa2b87 100644 --- a/doc/fixes36.6 +++ b/doc/fixes36.6 @@ -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 @@ teach unix/Makefile.doc how to make Guidebook.dat, an unpaginated copy of General New Features -------------------- none - diff --git a/include/extern.h b/include/extern.h index e7f1440..87062db 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1683,7 +1683,8 @@ E void FDECL(set_output_mode, (int)); 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 --git a/include/flag.h b/include/flag.h index 3b429e0..f10dc9c 100644 --- a/include/flag.h +++ b/include/flag.h @@ -222,6 +222,15 @@ enum getloc_filters { 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 @@ struct instance_flags { 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 --git a/include/isaac64.h b/include/isaac64.h index 6c9b45b..da9d5a0 100644 --- a/include/isaac64.h +++ b/include/isaac64.h @@ -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 --git a/include/ntconf.h b/include/ntconf.h index 32c5fc1..3da7e9c 100644 --- a/include/ntconf.h +++ b/include/ntconf.h @@ -239,7 +239,7 @@ extern void FDECL(nttty_preference_update, (const char *)); 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 --git a/include/patchlevel.h b/include/patchlevel.h index 36bc437..a52c715 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -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 --git a/src/apply.c b/src/apply.c index e57caec..27eb693 100644 --- a/src/apply.c +++ b/src/apply.c @@ -786,8 +786,10 @@ boolean feedback; Your("•R‚ª‚½‚é‚ñ‚Å—Ž‚¿‚½D"); } 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 --git a/src/do_name.c b/src/do_name.c index 1710840..485ad00 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -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. */ @@ -14,6 +14,7 @@ STATIC_DCL char *NDECL(nextmbuf); 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)); @@ -1296,6 +1297,34 @@ struct obj *obj; 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 * @@ -1419,17 +1448,9 @@ do_mname() */ Sprintf(qbuf, "%s‚ð‰½‚ÆŒÄ‚Ñ‚Ü‚·‚©H", 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 @@ -1498,17 +1519,9 @@ register struct obj *obj; (void) safe_qbuf(qbuf, "", "‚ð‰½‚Æ–¼‚¯‚Ü‚·‚©H", obj, xname, simpleonames, "‚»‚ê"); #endif - 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 @@ -1810,14 +1823,8 @@ struct obj *obj; #endif /* 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 --git a/src/engrave.c b/src/engrave.c index bc2f454..e44b8ed 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -1517,7 +1517,7 @@ doengrave() /* Chop engraving down to size if necessary */ if (len > maxelen) { for (sp = ebuf; maxelen && *sp; sp++) - if (*sp == ' ') + if (!(*sp == ' ')) maxelen--; if (!maxelen && *sp) { #if 1 /*JP*//*Š¿Žš‚Ì1ƒoƒCƒg–Ú‚¾‚¯‚ªŽc‚ç‚È‚¢‚悤‚É*/ diff --git a/src/files.c b/src/files.c index d660932..b650e91 100644 --- a/src/files.c +++ b/src/files.c @@ -4202,8 +4202,13 @@ reveal_paths(VOID_ARGS) 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 --git a/src/invent.c b/src/invent.c index 2127315..cd7f49b 100644 --- a/src/invent.c +++ b/src/invent.c @@ -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. */ @@ -2663,9 +2663,12 @@ long quan; /* if non-0, print this quantity, not obj->quan */ #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; @@ -2677,29 +2680,41 @@ long quan; /* if non-0, print this quantity, not obj->quan */ * * 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 */ + if (dot && use_invlet) + let = obj->invlet; #if 0 /*JP:T*/ - 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)); + Sprintf(suffix, "%c%6ld %.50s", iflags.menu_tab_sep ? '\t' : ' ', + cost, currency(cost)); #else - 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)); + Sprintf(suffix, "%c%6ld%.50s", iflags.menu_tab_sep ? '\t' : ' ', + cost, currency(cost)); #endif + 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), + if (use_invlet) + let = obj->invlet; /*JP - (txt ? txt : doname(obj)), (dot ? "." : "")); + Strcpy(suffix, dot ? "." : ""); */ - (txt ? txt : doname(obj)), (dot ? "D" : "")); + Strcpy(suffix, dot ? "D" : ""); } + 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 --git a/src/isaac64.c b/src/isaac64.c index 4d19335..8d09092 100644 --- a/src/isaac64.c +++ b/src/isaac64.c @@ -12,7 +12,6 @@ #include "config.h" #ifdef USE_ISAAC64 -#include #include #include "isaac64.h" diff --git a/src/o_init.c b/src/o_init.c index b29f914..7f51aeb 100644 --- a/src/o_init.c +++ b/src/o_init.c @@ -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. */ @@ -15,6 +15,7 @@ STATIC_DCL void FDECL(setgemprobs, (d_level *)); 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; @@ -424,6 +425,32 @@ static short uniq_objs[] = { 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 */ @@ -473,9 +500,8 @@ dodiscovered() /* free after Robert Viduya */ 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); } } @@ -680,9 +706,8 @@ doclassdisco() 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 --git a/src/objnam.c b/src/objnam.c index 491e89c..a5498cb 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -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. */ @@ -28,6 +28,7 @@ STATIC_DCL short FDECL(rnd_otyp_by_namedesc, (const char *, CHAR_P, int)); 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)); @@ -151,9 +152,14 @@ register int otyp; if (Role_if(PM_SAMURAI) && Japanese_item_name(otyp)) actualn = Japanese_item_name(otyp); + buf[0] = '\0'; #if 1 /*JP*/ - if(un) - Sprintf(buf, "%s‚ƌĂ΂ê‚é", un); + if (un) { + /* ‰pŒê‚Å‚ÍŒµ–§‚ɃTƒCƒY‚ðŽZo‚µ‚Ä‚¢‚邪“ú–{Œê‚͌ꏇ‚Ì“s‡‚Å + ³Šm‚ÉŽZo‚·‚é‚Ì‚ª‘å•Ï‚È‚Ì‚Å—]—T‚ðŽ‚Á‚½’l‚É‚·‚é */ + xcalled(buf, + BUFSZ - PREFIX - (dn ? (int) strlen(dn) + 3 : 0), "", un); + } #endif switch (ocl->oc_class) { case COIN_CLASS: @@ -207,7 +213,7 @@ register int otyp; 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; @@ -232,8 +238,8 @@ register int otyp; 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 @@ -246,7 +252,7 @@ register int otyp; Strcat(buf, (ocl->oc_material == MINERAL) ? " stone" : " gem"); if (un) - Sprintf(eos(buf), " called %s", un); + xcalled(buf, BUFSZ, "", un); #else Strcat(buf, dn ? dn : actualn); #endif @@ -269,8 +275,8 @@ register int otyp; #endif } #if 0 /*JP*/ - 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); #endif if (dn) #if 0 /*JP*/ @@ -515,6 +521,37 @@ boolean forward; } } +/* 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), +/*JP + pfxlen = (int) (strlen(pfx) + sizeof " called " - sizeof ""); +*/ + pfxlen = (int) (strlen(pfx) + sizeof "‚ƌĂ΂ê‚é" - sizeof ""); + + if (pfxlen > bufsiz) + panic("xcalled: not enough room for prefix (%d > %d)", + pfxlen, bufsiz); + +#if 0 /*JP*/ + Sprintf(eos(buf), "%s called %.*s", pfx, bufsiz - pfxlen, sfx); +#else + { + int sfxlen = bufsiz - pfxlen; + /* ‘SŠp‚Ì“r’†‚Ő؂ꂻ‚¤‚È‚Æ‚«‚É‚Í‚»‚ÌŽš‚̐擪‚Ü‚Å–ß‚é */ + sfxlen = sfxlen - offset_in_kanji(sfx, sfxlen); + /* •Ï”–¼‚ð•Ï‚¦‚邱‚Æ‚Í‚µ‚È‚¢‚ªAsfx‚ª‘OApfx‚ªŒã‚ë‚É‚È‚é */ + Sprintf(eos(buf), "%.*s‚ƌĂ΂ê‚é%s", sfxlen, sfx, pfx); + } +#endif +} + char * xname(obj) struct obj *obj; @@ -540,7 +577,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ 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; @@ -600,9 +637,9 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ Strcpy(buf, actualn); else if (un) /*JP - Sprintf(buf, "amulet called %s", un); + xcalled(buf, BUFSZ - PREFIX, "amulet", un); */ - Sprintf(eos(buf), "%s‚ƌĂ΂ê‚é–‚œ‚¯", un); + xcalled(buf, BUFSZ - PREFIX, "–‚œ‚¯", un); else /*JP Sprintf(buf, "%s amulet", dn); @@ -637,17 +674,9 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ Strcat(buf, dn); else if (nn) Strcat(buf, actualn); - else if (un) { -#if 0 /*JP*/ - Strcat(buf, dn); - Strcat(buf, " called "); - Strcat(buf, un); -#else - Strcat(buf, un); - Strcat(buf, "‚ƌĂ΂ê‚é"); - Strcat(buf, dn); -#endif - } else + else if (un) + xcalled(buf, BUFSZ - PREFIX, dn, un); + else Strcat(buf, dn); #if 0 /*JP*/ /*‚±‚ê‚͌ꏇ‚ÌŠÖŒW‚©‚çã‚Ì•û‚Å’è‹`*/ @@ -863,11 +892,9 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ Strcat(buf, actualn); } else { #if 0 /*JP*/ - Strcat(buf, " called "); - Strcat(buf, un); + xcalled(buf, BUFSZ - PREFIX, "", un); #else - Strcat(buf, un); - Strcat(buf, "‚ƌĂ΂ê‚é–ò"); + xcalled(buf, BUFSZ - PREFIX, "–ò", un); #endif } } else { @@ -895,11 +922,9 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ Strcat(buf, actualn); } else if (un) { #if 0 /*JP*/ - Strcat(buf, " called "); - Strcat(buf, un); + xcalled(buf, BUFSZ - PREFIX, "", un); #else - Strcat(buf, un); - Strcat(buf, "‚ƌĂ΂ê‚銪•¨"); + xcalled(buf, BUFSZ - PREFIX, "Šª•¨", un); #endif } else if (ocl->oc_magic) { #if 0 /*JP*/ @@ -928,9 +953,9 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ Strcat(buf, actualn); else if (un) /*JP - Sprintf(buf, "wand called %s", un); + xcalled(buf, BUFSZ - PREFIX, "wand", un); */ - Sprintf(eos(buf), "%s‚ƌĂ΂ê‚éñ", un); + xcalled(buf, BUFSZ - PREFIX, "ñ", un); else /*JP Sprintf(buf, "%s wand", dn); @@ -948,9 +973,9 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ Strcpy(buf, actualn); else if (un) /*JP - Sprintf(buf, "novel called %s", un); + xcalled(buf, BUFSZ - PREFIX, "novel", un); */ - Sprintf(buf, "%s‚Æ‚¢‚¤¬à", un); + xcalled(buf, BUFSZ - PREFIX, "¬à", un); else /*JP Sprintf(buf, "%s book", dn); @@ -971,9 +996,9 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ Strcat(buf, actualn); } else if (un) { /*JP - Sprintf(buf, "spellbook called %s", un); + xcalled(buf, BUFSZ - PREFIX, "spellbook", un); */ - Sprintf(eos(buf), "%s‚ƌĂ΂ê‚é–‚–@‘", un); + xcalled(buf, BUFSZ - PREFIX, "–‚–@‘", un); } else /*JP Sprintf(buf, "%s spellbook", dn); @@ -993,9 +1018,9 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ Strcat(buf, actualn); else if (un) /*JP - Sprintf(buf, "ring called %s", un); + xcalled(buf, BUFSZ - PREFIX, "ring", un); */ - Sprintf(eos(buf), "%s‚ƌĂ΂ê‚éŽw—Ö", un); + xcalled(buf, BUFSZ - PREFIX, "Žw—Ö", un); else /*JP Sprintf(buf, "%s ring", dn); @@ -1016,10 +1041,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ #endif } else if (!nn) { if (un) -/*JP - Sprintf(buf, "%s called %s", rock, un); -*/ - Sprintf(eos(buf), "%s‚ƌĂ΂ê‚é%s", un, rock); + xcalled(buf, BUFSZ - PREFIX, rock, un); else /*JP Sprintf(buf, "%s %s", dn, rock); @@ -1055,7 +1077,8 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */ 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)) @@ -2295,7 +2318,7 @@ const char *str; return strcpy(buf, "an []"); } (void) just_an(buf, str); - return strcat(buf, str); + return strncat(buf, str, BUFSZ - 1 - (unsigned) strlen(buf)); } char * @@ -2366,12 +2389,11 @@ const char *str; Strcpy(buf, "the "); else buf[0] = '\0'; - Strcat(buf, str); - + return strncat(buf, str, BUFSZ - 1 - (unsigned) strlen(buf)); #else /*’P‚ɃRƒs[*/ Strcpy(buf, str); -#endif /*JP*/ return buf; +#endif /*JP*/ } char * @@ -3981,10 +4003,12 @@ struct obj *no_wish; */ 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; #if 0 /*JP*//*ƒ^ƒCƒv•Ê‚Í‚Æ‚è‚ ‚¦‚¸‚µ‚È‚¢*/ /* "helmet called telepathy" is not "helmet" (a specific type) diff --git a/src/options.c b/src/options.c index ac25861..c40b615 100644 --- a/src/options.c +++ b/src/options.c @@ -3246,7 +3246,7 @@ boolean tinitial, tfrom_file; 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; @@ -6227,7 +6227,11 @@ boolean setinitial, setfromfile; 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; @@ -6286,10 +6290,11 @@ char *buf; #ifdef WIN32 else if (!strcmp(optname, "altkeyhandler")) Sprintf(buf, "%s", -/*JP - iflags.altkeyhandler[0] ? iflags.altkeyhandler : "default"); -*/ - iflags.altkeyhandler[0] ? iflags.altkeyhandler : defopt); + (iflags.key_handling == ray_keyhandling) + ? "ray" + : (iflags.key_handling == nh340_keyhandling) + ? "340" + : "default"); #endif #ifdef BACKWARD_COMPAT else if (!strcmp(optname, "boulder")) diff --git a/src/pager.c b/src/pager.c index 6bfd8f6..d2086f6 100644 --- a/src/pager.c +++ b/src/pager.c @@ -54,32 +54,37 @@ int c; 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 */ - +/*JP + static const char sep[] = " or "; +*/ + static const char sep[] = "‚Ü‚½‚Í"; + size_t oldlen, space_left; + if (strstri(buf, new_str)) - return 0; - - space_left = BUFSZ - strlen(buf) - 1; - if (space_left < 1) - return 0; -#if 0 /*JP:T*/ - (void) strncat(buf, " or ", space_left); - (void) strncat(buf, new_str, space_left - 4); -#else - (void) strncat(buf, "‚Ü‚½‚Í", space_left); - (void) strncat(buf, new_str, space_left - 6); -#endif - return 1; + return 0; /* already present */ + + 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 --git a/src/priest.c b/src/priest.c index 880fe0f..5442d20 100644 --- a/src/priest.c +++ b/src/priest.c @@ -784,7 +784,7 @@ register struct monst *priest; || (u.ublessed < 20 && (u.ublessed < 9 || !rn2(u.ublessed))))) { /*JP - verbalize("Thy devotion has been rewarded."); + verbalize("Thou hast been rewarded for thy devotion."); */ verbalize("“ð‚ªŒ£g‚É•ñ‚í‚ñD"); if (!(HProtection & INTRINSIC)) { diff --git a/src/weapon.c b/src/weapon.c index dd2a057..bcf4de3 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -925,14 +925,18 @@ register struct monst *mon; 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); #if 0 /*JP:T*/ 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); #else pline("%s‚͏ŸŽè‚É%s‚Ì%s‚É‘•”õ‚³‚ꂽI", xname(obj), - mon_nam(mon), mbodypart(mon, HAND)); + mon_nam(mon), mon_hand); #endif obj->bknown = 1; } diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index adc5d01..3d7b62a 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -994,7 +994,7 @@ decl.o: decl.c $(HACK_H) 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) @@ -1063,7 +1063,7 @@ rect.o: rect.c $(HACK_H) 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 --git a/sys/unix/NetHack.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/sys/unix/NetHack.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 0c67376..0000000 --- a/sys/unix/NetHack.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/sys/vms/Makefile.src b/sys/vms/Makefile.src index 745b21a..c15d10f 100644 --- a/sys/vms/Makefile.src +++ b/sys/vms/Makefile.src @@ -133,7 +133,7 @@ RANDOBJ = isaac64.obj,random.obj # 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 --git a/sys/vms/vmsbuild.com b/sys/vms/vmsbuild.com index c48364b..44735d1 100644 --- a/sys/vms/vmsbuild.com +++ b/sys/vms/vmsbuild.com @@ -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 --git a/sys/winnt/.nethackrc.template b/sys/winnt/.nethackrc.template index 8baf779..16ab416 100644 --- a/sys/winnt/.nethackrc.template +++ b/sys/winnt/.nethackrc.template @@ -28,13 +28,11 @@ OPTIONS=symset:default,roguesymset:default #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 --git a/sys/winnt/Install.nt b/sys/winnt/Install.nt index 9e3741d..c9ce99e 100644 --- a/sys/winnt/Install.nt +++ b/sys/winnt/Install.nt @@ -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 @@ contributed the port. 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 @@ version. You can use one of the following build environments: 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 @@ version. You can use one of the following build environments: | 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 @@ The Visual Studio 2017 NetHack solution file can be found here: 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 @@ using. Change to the directory win\win32\vs2017 and run "build.bat". * 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 @@ to proceeding with steps 1 through 5 above. -------------------------------------------------------------------------- -- 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 @@ command line using the Makefile approach: 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 @@ I. Dispelling the Myths: 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 @@ II. To compile your copy of NetHack on a Windows machine: 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 @@ Setting Up 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 @@ Compiling 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 @@ Compiling 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 @@ Notes: 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 @@ Notes: 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 --git a/sys/winnt/Makefile.gcc b/sys/winnt/Makefile.gcc index f955075..5932b2a 100644 --- a/sys/winnt/Makefile.gcc +++ b/sys/winnt/Makefile.gcc @@ -1483,10 +1483,10 @@ endif 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 --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index e7a5f03..6a117f6 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -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 @@ DEBUGINFO = Y #============================================================================== # # 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:.=) @@ -276,8 +276,6 @@ GUIHDR = $(MSWIN)\mhaskyn.h $(MSWIN)\mhdlg.h $(MSWIN)\mhfont.h \ COMCTRL = comctl32.lib -KEYDLLS = $(GAMEDIR)\nhdefkey.dll $(GAMEDIR)\nh340key.dll $(GAMEDIR)\nhraykey.dll - TILEUTIL16 = $(UTIL)\tile2bmp.exe TILEBMP16 = $(SRC)\tiles.bmp @@ -375,7 +373,27 @@ rc=Rc # 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) @@ -386,7 +404,8 @@ MAKEVERSION=$(MAKEVERSION: =) #!MESSAGE $(_NMAKE_VER) #!MESSAGE $(MAKEVERSION) -VSNEWEST=2019 +VSSPECIAL= +VSNEWEST=2022 !IF ($(MAKEVERSION) < 1000000000) VSVER=0000 #untested ancient version !ELSEIF ($(MAKEVERSION) > 1000000000) && ($(MAKEVERSION) < 1100000000) @@ -397,21 +416,26 @@ VSVER=2012 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 @@ -853,63 +877,6 @@ $(O)gamedir.tag: @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. # @@ -1289,9 +1256,6 @@ $(O)pdcscrn.o : $(PDCURSES_HEADERS) $(PDCWINCON)\pdcscrn.c $(MSWSYS)\stub-pdcscr 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)\JNetHack.exe del $(GAMEDIR)\JNetHack.exe if exist $(GAMEDIR)\JNetHack.pdb del $(GAMEDIR)\JNetHack.pdb if exist $(GAMEDIR)\nhdat$(NHV) del $(GAMEDIR)\nhdat$(NHV) @@ -1389,26 +1353,15 @@ clean: 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 --git a/sys/winnt/console.rc b/sys/winnt/console.rc index e817430..c1d2541 100644 --- a/sys/winnt/console.rc +++ b/sys/winnt/console.rc @@ -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,6,0 - PRODUCTVERSION 3,6,6,0 + FILEVERSION 3,6,7,0 + PRODUCTVERSION 3,6,7,0 FILEFLAGSMASK 0x1fL #ifdef _DEBUG FILEFLAGS 0x9L @@ -29,13 +29,13 @@ BEGIN BLOCK "041103a4" BEGIN VALUE "FileDescription", "JNetHack for Windows - TTY Interface\0" - VALUE "FileVersion", "3.6.6\0" + VALUE "FileVersion", "3.6.7\0" VALUE "InternalName", "JNetHack\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", "JNetHack.exe\0" VALUE "PrivateBuild", "050102\0" VALUE "ProductName", "JNetHack\0" - VALUE "ProductVersion", "3.6.6\0" + VALUE "ProductVersion", "3.6.7\0" END END BLOCK "VarFileInfo" diff --git a/sys/winnt/nh340key.c b/sys/winnt/nh340key.c deleted file mode 100644 index a4faa80..0000000 --- a/sys/winnt/nh340key.c +++ /dev/null @@ -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 --git a/sys/winnt/nhdefkey.c b/sys/winnt/nhdefkey.c deleted file mode 100644 index 7b87ad4..0000000 --- a/sys/winnt/nhdefkey.c +++ /dev/null @@ -1,416 +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)); - } -#if 0 /*JP*/ - /* 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; - } - } -#else - if(ch != 0){ - *valid = TRUE; - } -#endif - 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; -} - -#if 1 /*JP*/ -static INPUT_RECORD irbuf[2]; -static int irbufnext = 0; -#endif - -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 -#if 0 /*JP*/ - ReadConsoleInput(hConIn, ir, 1, count); -#else - /*JP - Windows8ˆÈ~‚Å‚Í“ú–{Œê‚ð“ü—Í‚·‚é‚Æ2ƒoƒCƒg‚Ü‚Æ‚ß‚Ä•Ô‚Á‚Ä‚­‚é‚Ì‚Å - 2ƒoƒCƒg–Ú‚ðƒLƒƒƒbƒVƒ…‚µ‚Ä1ƒoƒCƒg‚¸‚•Ԃ·B - */ - if (irbufnext == 1) { - memcpy(ir, &irbuf[1], sizeof(INPUT_RECORD)); - irbufnext = 0; - } else { - ReadConsoleInput(hConIn, irbuf, 2, count); - memcpy(ir, &irbuf[0], sizeof(INPUT_RECORD)); - if (*count == 2) { - irbufnext = 1; - } - } -#endif - 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 --git a/sys/winnt/nhraykey.c b/sys/winnt/nhraykey.c deleted file mode 100644 index 7ce4e0e..0000000 --- a/sys/winnt/nhraykey.c +++ /dev/null @@ -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 --git a/sys/winnt/nttty.c b/sys/winnt/nttty.c index 2818282..6759dea 100644 --- a/sys/winnt/nttty.c +++ b/sys/winnt/nttty.c @@ -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 * */ @@ -193,33 +193,36 @@ static char nullstr[] = ""; 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 */ @@ -323,7 +326,7 @@ static void back_buffer_flip() 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; @@ -338,7 +341,7 @@ void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y) 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); @@ -512,7 +515,7 @@ int portdebug; 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; @@ -526,7 +529,7 @@ int portdebug; int nttty_kbhit() { - return keyboard_handler.pNHkbhit(console.hConIn, &ir); + return keyboard_handling.pNHkbhit(console.hConIn, &ir); } int @@ -547,7 +550,7 @@ tgetch() return (program_state.done_hup) ? '\033' - : keyboard_handler.pCheckInput( + : keyboard_handling.pCheckInput( console.hConIn, &ir, &count, numpad, 0, &mod, &cc); } @@ -569,7 +572,7 @@ int *x, *y, *mod; #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; @@ -889,7 +892,7 @@ raw_clear_screen() 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(); } @@ -1174,38 +1177,6 @@ win32con_debug_keystrokes() (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; @@ -1246,81 +1217,6 @@ register char *op; 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*/ @@ -1943,7 +1839,7 @@ void set_cp_map() // code page 437 mappings. if (console.cpMap[i] < 32) console.cpMap[i] = cp437[console.cpMap[i]]; - } + } } } @@ -2140,18 +2036,13 @@ void nethack_enter_nttty() been loaded during options parsing. Needs to check first */ #if 0 /*JP*//* “ú–{Œê‚Å‚Ínhdefkey‚µ‚©Žg‚í‚È‚¢ */ - 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"); } } -#else - if (!load_keyboard_handler("nhdefkey")) - error("nhdefkey.dll‚ð“ǂݍž‚ß‚Ü‚¹‚ñ"); #endif } #endif /* TTY_GRAPHICS */ @@ -2206,4 +2097,1277 @@ VA_DECL(const char *, fmt) 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)); + } +#if 0 /*JP*//*‘SŠp•¶Žš‚ª’Ê‚é‚悤‚É‚·‚é*/ + /* 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; + } + } +#else + if(ch != 0){ + *valid = TRUE; + } +#endif + 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 --git a/sys/winnt/stubs.c b/sys/winnt/stubs.c index 2ee65bf..39352e0 100644 --- a/sys/winnt/stubs.c +++ b/sys/winnt/stubs.c @@ -198,4 +198,14 @@ set_altkeyhandler(const char *inName) { return; } +void +set_altkeyhandling(const char *inName) +{ +} + +int +set_keyhandling_via_option(void) +{ + return 1; +} #endif /* TTYSTUBS */ diff --git a/win/Qt4/qt4bind.cpp b/win/Qt4/qt4bind.cpp index 86358d1..5395787 100644 --- a/win/Qt4/qt4bind.cpp +++ b/win/Qt4/qt4bind.cpp @@ -455,7 +455,22 @@ int NetHackQtBind::qt_nhgetch() // 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 @@ int NetHackQtBind::qt_nh_poskey(int *x, int *y, int *mod) // 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 --git a/win/X11/winX.c b/win/X11/winX.c index e17cc76..698433f 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -87,11 +87,14 @@ static struct icon_info { 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 @@ -1548,6 +1551,33 @@ XErrorEvent *error; 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; @@ -1562,6 +1592,12 @@ char **argv; 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); @@ -1578,7 +1614,7 @@ char **argv; savuid = geteuid(); (void) seteuid(getuid()); - XSetIOErrorHandler((XIOErrorHandler) hangup); + XSetIOErrorHandler(X11_io_error_handler); #ifdef XI18N XtSetLanguageProc(NULL, NULL, NULL); @@ -2684,7 +2720,7 @@ init_standard_windows() 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 */ diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 1328a48..673ad9b 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -45,13 +45,16 @@ struct window_procs curses_procs = { #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 @@ curses_player_selection() 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 --git a/win/win32/NetHackW.rc b/win/win32/NetHackW.rc index bb0f8d8..ed7abae 100644 --- a/win/win32/NetHackW.rc +++ b/win/win32/NetHackW.rc @@ -443,8 +443,8 @@ END // 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 @@ -460,13 +460,13 @@ BEGIN BLOCK "041103a4" BEGIN VALUE "FileDescription", "JNetHack for Windows - Graphical Interface" - VALUE "FileVersion", "3.6.6" + VALUE "FileVersion", "3.6.7" VALUE "InternalName", "JNetHackW" - 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", "JNetHackW.exe" VALUE "PrivateBuild", "140606" VALUE "ProductName", "JNetHack" - VALUE "ProductVersion", "3.6.6" + VALUE "ProductVersion", "3.6.7" END END BLOCK "VarFileInfo" diff --git a/win/win32/dgnstuff.mak b/win/win32/dgnstuff.mak index 2339a8a..d32dec0 100644 --- a/win/win32/dgnstuff.mak +++ b/win/win32/dgnstuff.mak @@ -57,7 +57,7 @@ tools: 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 @@ tools: 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 @@ tools: $(LEX) dgn_comp.l copy $(LEXYYC) $@ @del $(LEXYYC) - chdir ..\build + chdir ..\src !ENDIF diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index 7a9052d..5973b82 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -35,8 +35,8 @@ typedef struct mswin_nethack_map_window { 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 */ @@ -143,7 +143,7 @@ mswin_init_map_window() } 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 @@ -368,10 +368,11 @@ mswin_map_stretch(HWND hWnd, LPSIZE map_size, BOOL redraw) 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 */ @@ -479,13 +480,38 @@ mswin_map_mode(HWND hWnd, int mode) 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() @@ -557,7 +583,7 @@ MapWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 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); @@ -979,11 +1005,8 @@ static void setGlyph(PNHMapWindow data, int i, int j, int fg, int bg) 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; } } @@ -993,28 +1016,23 @@ static void clearAll(PNHMapWindow data) 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 @@ -1033,7 +1051,7 @@ paint(PNHMapWindow data, int i, int j) paintTile(data, i, j, &rect); } - data->mapDirty[i][j] = FALSE; + data->locDirty[i][j] = FALSE; } @@ -1043,16 +1061,6 @@ onPaint(HWND hWnd) { 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 --git a/win/win32/mhmap.h b/win/win32/mhmap.h index 6957494..d6e6c7d 100644 --- a/win/win32/mhmap.h +++ b/win/win32/mhmap.h @@ -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 --git a/win/win32/mswproc.c b/win/win32/mswproc.c index e89b47c..7d3a0e4 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -1853,6 +1853,7 @@ void mswin_delay_output() { logDebug("mswin_delay_output()\n"); + mswin_map_update(mswin_hwnd_from_winid(WIN_MAP)); Sleep(50); } @@ -2121,9 +2122,11 @@ mswin_putmsghistory(const char *msg, BOOLEAN_P restoring) 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 @@ -2215,7 +2218,7 @@ initMapTiles(void) 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 --git a/win/win32/nethack.rc b/win/win32/nethack.rc index bcdbc17..cb3962c 100644 --- a/win/win32/nethack.rc +++ b/win/win32/nethack.rc @@ -60,8 +60,8 @@ IDI_ICON1 ICON "nethack.ico" // 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 @@ BEGIN BLOCK "041103a4" BEGIN VALUE "FileDescription", "JNetHack for Windows - TTY Interface" - VALUE "FileVersion", "3.6.6" + VALUE "FileVersion", "3.6.7" VALUE "InternalName", "JNetHack" - 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", "JNetHack.exe" VALUE "ProductName", "JNetHack" - VALUE "ProductVersion", "3.6.6" + VALUE "ProductVersion", "3.6.7" END END BLOCK "VarFileInfo" diff --git a/win/win32/vs2017/NetHack.sln b/win/win32/vs2017/NetHack.sln index b9840a6..265f7a0 100644 --- a/win/win32/vs2017/NetHack.sln +++ b/win/win32/vs2017/NetHack.sln @@ -54,29 +54,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uudecode", "uudecode.vcxpro 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}" @@ -172,30 +157,6 @@ Global {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 --git a/win/win32/vs2017/NetHackPackage.appxmanifest b/win/win32/vs2017/NetHackPackage.appxmanifest index 12b8d3a..c97a4ff 100644 --- a/win/win32/vs2017/NetHackPackage.appxmanifest +++ b/win/win32/vs2017/NetHackPackage.appxmanifest @@ -1,6 +1,6 @@  - + NetHack 3.6 NetHack DevTeam diff --git a/win/win32/vs2017/NetHackProperties.props b/win/win32/vs2017/NetHackProperties.props index b95cec9..f9c3ea4 100644 --- a/win/win32/vs2017/NetHackProperties.props +++ b/win/win32/vs2017/NetHackProperties.props @@ -4,7 +4,7 @@ 3 6 - 6 + 7 diff --git a/win/win32/vs2017/nhdefkey.def b/win/win32/vs2017/nhdefkey.def deleted file mode 100644 index 2950904..0000000 --- a/win/win32/vs2017/nhdefkey.def +++ /dev/null @@ -1,8 +0,0 @@ -LIBRARY nhdefkey -EXPORTS -ProcessKeystroke -NHkbhit -CheckInput -SourceWhere -SourceAuthor -KeyHandlerName diff --git a/win/win32/vs2017/nhdefkey.vcxproj b/win/win32/vs2017/nhdefkey.vcxproj deleted file mode 100644 index 71334f5..0000000 --- a/win/win32/vs2017/nhdefkey.vcxproj +++ /dev/null @@ -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 --git a/win/win32/vs2017/nhraykey.def b/win/win32/vs2017/nhraykey.def deleted file mode 100644 index 5432a1a..0000000 --- a/win/win32/vs2017/nhraykey.def +++ /dev/null @@ -1,8 +0,0 @@ -LIBRARY nhraykey -EXPORTS -ProcessKeystroke -NHkbhit -CheckInput -SourceWhere -SourceAuthor -KeyHandlerName diff --git a/win/win32/vs2017/nhraykey.vcxproj b/win/win32/vs2017/nhraykey.vcxproj deleted file mode 100644 index 5e0e43b..0000000 --- a/win/win32/vs2017/nhraykey.vcxproj +++ /dev/null @@ -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 --git a/win/win32/vs2017/travisci.sh b/win/win32/vs2017/travisci.sh index 812f4cd..f9fd227 100644 --- a/win/win32/vs2017/travisci.sh +++ b/win/win32/vs2017/travisci.sh @@ -13,6 +13,7 @@ export PATH=/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/$VSVER/$TOOLSVE 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 @@ export LIB=/c/Program\ Files\ \(x86\)/Windows\ Kits/10/lib/$WKITVER/um/x86:$LIB 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 .. -- 2.11.0