├── .gitignore ├── .indent.pro ├── .travis.yml ├── COPYING ├── GNUmakefile ├── README.md ├── aimake ├── aimake.rules ├── binary-copyright.pod ├── copyright ├── dist ├── common │ ├── icon16.png │ ├── icon256.png │ ├── icon32.png │ └── icon64.png ├── debian │ ├── changelog │ ├── compat │ ├── control │ ├── nethack4.docs │ ├── rules │ └── source │ │ └── format └── version-number-updates.txt ├── doc ├── ai.txt ├── changelog-fiqhack.txt ├── changelog.txt ├── changelog_fiqhack.txt ├── developer-information.txt ├── dgn_comp.pod ├── dlb.pod ├── dungeon.txt ├── faq.txt ├── guidebook.asc ├── lev_comp.pod ├── mainloop.txt ├── nethack4.pod ├── nh4ct.pod ├── philosophy.txt ├── saves.txt ├── server_protocol.txt ├── tilecompile.pod └── tilesets.txt ├── dumbmake ├── dumbmake.h └── dumbmake_get_option.c ├── libjansson ├── dump.c ├── error.c ├── hashtable.c ├── hashtable.h ├── jansson.h ├── jansson_config.h ├── jansson_private.h ├── load.c ├── memory.c ├── pack_unpack.c ├── strbuffer.c ├── strbuffer.h ├── strconv.c ├── utf.c ├── utf.h └── value.c ├── libnethack ├── dat │ ├── .gitignore │ ├── Arch.des │ ├── Barb.des │ ├── Caveman.des │ ├── Healer.des │ ├── Knight.des │ ├── Monk.des │ ├── Priest.des │ ├── Ranger.des │ ├── Rogue.des │ ├── Samurai.des │ ├── Tourist.des │ ├── Valkyrie.des │ ├── Wizard.des │ ├── bigroom.des │ ├── castle.des │ ├── data.base │ ├── dungeon.def │ ├── endgame.des │ ├── gehennom.des │ ├── gpl │ ├── history │ ├── knox.des │ ├── license │ ├── medusa.des │ ├── mines.des │ ├── oracle.des │ ├── oracles.txt │ ├── quest.txt │ ├── rumors.fal │ ├── rumors.tru │ ├── sokoban.des │ ├── tower.des │ └── yendor.des ├── include │ ├── .gitignore │ ├── align.h │ ├── artifact.h │ ├── artilist.h │ ├── attrib.h │ ├── color.h │ ├── config.h │ ├── coord.h │ ├── decl.h │ ├── dgn_file.h │ ├── display.h │ ├── dlb.h │ ├── drawing.h │ ├── dungeon.h │ ├── engrave.h │ ├── extern.h │ ├── flag.h │ ├── global.h │ ├── hack.h │ ├── hungerstatus.h │ ├── iomodes.h │ ├── lev.h │ ├── lz4.h │ ├── lz4hc.h │ ├── magic.h │ ├── memfile.h │ ├── message.h │ ├── mextra.h │ ├── mfndpos.h │ ├── mkroom.h │ ├── monattk.h │ ├── mondata.h │ ├── monflag.h │ ├── monst.h │ ├── monsym.h │ ├── monuse.h │ ├── ntconf.h │ ├── obj.h │ ├── objclass.h │ ├── patchlevel.h │ ├── permonst.h │ ├── prop.h │ ├── qtext.h │ ├── quest.h │ ├── rect.h │ ├── region.h │ ├── rm.h │ ├── rnd.h │ ├── role.h │ ├── skills.h │ ├── sp_lev.h │ ├── spell.h │ ├── system.h │ ├── timeout.h │ ├── trap.h │ ├── unixconf.h │ ├── vision.h │ ├── winprocs.h │ ├── you.h │ ├── youprop.h │ └── zap.h ├── src │ ├── .gitignore │ ├── allmain.c │ ├── apply.c │ ├── artifact.c │ ├── attrib.c │ ├── ball.c │ ├── bones.c │ ├── botl.c │ ├── cmd.c │ ├── dbridge.c │ ├── decl.c │ ├── detect.c │ ├── dig.c │ ├── display.c │ ├── dlb.c │ ├── do.c │ ├── do_name.c │ ├── do_wear.c │ ├── dog.c │ ├── dogmove.c │ ├── dokick.c │ ├── dothrow.c │ ├── drawing.c │ ├── dump.c │ ├── dungeon.c │ ├── eat.c │ ├── end.c │ ├── engrave.c │ ├── exper.c │ ├── explode.c │ ├── extralev.c │ ├── files.c │ ├── fountain.c │ ├── hack.c │ ├── history.c │ ├── invent.c │ ├── level.c │ ├── light.c │ ├── livelog.c │ ├── localtime.c │ ├── lock.c │ ├── log.c │ ├── logreplay.c │ ├── lz4.c │ ├── lz4hc.c │ ├── mail.c │ ├── makemon.c │ ├── memfile.c │ ├── memobj.c │ ├── messages.c │ ├── mextra.c │ ├── mhitm.c │ ├── mhitq.c │ ├── mhitu.c │ ├── minion.c │ ├── mklev.c │ ├── mkmap.c │ ├── mkmaze.c │ ├── mkobj.c │ ├── mkroom.c │ ├── mon.c │ ├── mondata.c │ ├── monmove.c │ ├── monst.c │ ├── mplayer.c │ ├── mthrowu.c │ ├── muse.c │ ├── music.c │ ├── newrng.c │ ├── o_init.c │ ├── objects.c │ ├── objnam.c │ ├── options.c │ ├── pager.c │ ├── pickup.c │ ├── pline.c │ ├── polyself.c │ ├── potion.c │ ├── pray.c │ ├── priest.c │ ├── prop.c │ ├── quest.c │ ├── questpgr.c │ ├── read.c │ ├── rect.c │ ├── region.c │ ├── restore.c │ ├── role.c │ ├── rumors.c │ ├── save.c │ ├── shk.c │ ├── shknam.c │ ├── sit.c │ ├── sounds.c │ ├── sp_lev.c │ ├── spell.c │ ├── spoiler.c │ ├── steal.c │ ├── steed.c │ ├── symclass.c │ ├── teleport.c │ ├── timeout.c │ ├── topten.c │ ├── track.c │ ├── trap.c │ ├── u_init.c │ ├── uhitm.c │ ├── vault.c │ ├── version.c │ ├── vision.c │ ├── weapon.c │ ├── were.c │ ├── wield.c │ ├── windows.c │ ├── wizard.c │ ├── worm.c │ ├── worn.c │ ├── write.c │ └── zap.c └── util │ ├── checkglobals.sh │ ├── dgn_comp.l │ ├── dgn_comp.y │ ├── dgn_compiler.h │ ├── dgn_main.c │ ├── dlb_main.c │ ├── lev_comp.l │ ├── lev_comp.y │ ├── lev_compiler.h │ ├── lev_main.c │ ├── makedefs.c │ └── savemap.pl ├── libnethack_client ├── .gitignore ├── include │ └── nhclient.h └── src │ ├── clientapi.c │ ├── connection.c │ └── netcmd.c ├── libnethack_common ├── dat │ └── motd.txt ├── include │ ├── common_options.h │ ├── compilers.h │ ├── hacklib.h │ ├── mail.h │ ├── menulist.h │ ├── messagechannel.h │ ├── netconnect.h │ ├── nethack.h │ ├── nethack_client.h │ ├── nethack_types.h │ ├── trietable.h │ ├── utf8conv.h │ └── xmalloc.h └── src │ ├── common_options.c │ ├── hacklib.c │ ├── mail.c │ ├── menulist.c │ ├── netconnect.c │ ├── trietable.c │ ├── utf8conv.c │ └── xmalloc.c ├── libuncursed ├── doc │ └── uncursed.txt ├── include │ ├── uncursed.h │ ├── uncursed_hooks.h │ ├── uncursed_sdl.h │ ├── uncursed_tty.h │ └── uncursed_wincon.h └── src │ ├── libuncursed.c │ ├── plugins.c │ ├── plugins │ ├── sdl.c │ ├── sdl.cxx │ ├── tty.c │ ├── tty.cxx │ ├── wincon.c │ └── wincon.cxx │ └── test_uncursed.c ├── nethack ├── .gitignore ├── include │ ├── brandings.h │ └── nhcurses.h ├── rc │ ├── nh.ico │ └── nh_ico.rc └── src │ ├── brandings.c │ ├── color.c │ ├── dialog.c │ ├── extrawin.c │ ├── gameover.c │ ├── getline.c │ ├── keymap.c │ ├── mail.c │ ├── main.c │ ├── map.c │ ├── menu.c │ ├── messages.c │ ├── motd.c │ ├── netgame.c │ ├── netplay.c │ ├── options.c │ ├── outchars.c │ ├── playerselect.c │ ├── replay.c │ ├── rungame.c │ ├── sidebar.c │ ├── status.c │ ├── topten.c │ └── windows.c ├── nethack_server ├── .gitignore ├── include │ └── nhserver.h └── src │ ├── auth.c │ ├── clientcmd.c │ ├── clientmain.c │ ├── config.c │ ├── db_pgsql.c │ ├── log.c │ ├── miscsetup.c │ ├── server.c │ ├── srvmain.c │ └── winprocs.c ├── prebuilt └── README.prebuilt ├── scripts ├── build-debian-package ├── build-windows-installer.bat ├── dawnlike-import.pl ├── generate-etags.sh ├── random-motd.sh ├── update-timestamps.sh ├── vcs-hooks │ └── git-hooks-post-commit ├── vim │ └── resolve-date-conflicts.vim └── xterm-suppression.vg ├── testbench ├── include │ ├── tap.h │ └── testgame.h └── src │ ├── tap.c │ ├── testgame.c │ └── testmain.c └── tilesets ├── dat ├── catalogues │ ├── dawnlike-16.txt │ ├── rltiles-32.txt │ ├── slashem-16.txt │ ├── slashem-32.txt │ ├── slashem-32.txt.old │ ├── slashem-3d.txt.old │ ├── textascii.txt │ └── textunicode.txt ├── fonts │ ├── font14.txt │ ├── font20.txt │ ├── font22.txt │ └── font8.txt ├── maps │ ├── dawnlike.map │ ├── nh343.map │ ├── nh4new.map │ └── s7e7f3.map ├── palettes │ └── slashem.txt ├── text │ ├── ascii_overrides.txt │ ├── dungeoncolors.txt │ ├── rogue_overrides.txt │ └── unicode_overrides.txt └── tiles │ ├── dawnlike-16.txt │ ├── dawnlike-343.txt │ ├── dawnlike-4.txt │ ├── dawnlike-dragons.txt │ ├── dawnlike-fourk-extras.txt │ ├── los-transformations.txt │ ├── n-343-32.txt │ ├── n-343.txt │ ├── n-4-16.txt │ ├── n-4-32.txt │ ├── rltiles-32.png │ ├── rltiles.map │ ├── s-extras.txt │ ├── s-mon32al2.txt │ ├── s-mon32alg.txt │ ├── s-mon32aw.txt │ ├── s-mon32mi.txt │ ├── s-mon32se.txt │ ├── s-mon3dmi.txt │ ├── s-monsters.txt │ ├── s-obj32al2.txt │ ├── s-obj32alg.txt │ ├── s-obj32mi.txt │ ├── s-obj32se.txt │ ├── s-objects.txt │ ├── s-oth-2kmi.txt │ ├── s-oth32al2.txt │ ├── s-oth32alg.txt │ ├── s-oth32fl.txt │ ├── s-oth32mi.txt │ ├── s-oth32se.txt │ ├── s-oth3dmi.txt │ ├── s-oth3dse.txt │ ├── s-other.txt │ └── s-zap.txt ├── include ├── tilecompile.h └── tilesequence.h ├── missing-slashem-32-tiles.txt ├── src ├── bigtile.c ├── fallback-tileset-image.c ├── magtile.c └── tilesequence.c └── util ├── basecchar.c ├── tilecompile.c ├── tileset-image.c ├── tileset-read.c └── tileset-write.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Last modified by Fredrik Ljungdahl, 2020-01-11 2 | build/* 3 | *.swp 4 | *.kate-swp 5 | *~ 6 | \#*\# 7 | .\#* 8 | *.d 9 | *.o 10 | *.tag 11 | .emacs.desktop 12 | .emacs.desktop.lock 13 | aimake.local 14 | CMakeFiles/ 15 | CMakeCache.txt 16 | Makefile 17 | cscope.* 18 | cmake_install.cmake 19 | install_manifest.txt 20 | tags 21 | TAGS 22 | libnethack/util/savemap.txt 23 | -------------------------------------------------------------------------------- /.indent.pro: -------------------------------------------------------------------------------- 1 | -bad 2 | -bap 3 | -nbbb 4 | -nbbo 5 | -nbc 6 | -nbfda 7 | -nbfde 8 | -blf 9 | -bli0 10 | -br 11 | -brs 12 | -bs 13 | -c0 14 | -cbi4 15 | -cd0 16 | -cdw 17 | -ce 18 | -ci4 19 | -cli0 20 | -cp0 21 | -ncs 22 | -d0 23 | -di0 24 | -ndj 25 | -nfc1 26 | -fca 27 | -hnl 28 | -i4 29 | -il-4 30 | -ip4 31 | -l80 32 | -lc80 33 | -lp 34 | -npcs 35 | -ppi1 36 | -nprs 37 | -psl 38 | -saf 39 | -sai 40 | -saw 41 | -sbi0 42 | -nsc 43 | -nsob 44 | -ss 45 | -ts8 46 | -nut 47 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | compiler: 8 | - clang 9 | 10 | # Disable aimake for now, for performance purposes 11 | script: 12 | - make install 13 | 14 | notifications: 15 | irc: 16 | channels: 17 | - "chat.freenode.net#nethack4" 18 | - "ircs://chat.freenode.net:7070#ascension.run" 19 | on_success: always 20 | on_failure: always 21 | template: 22 | - "%{commit_subject} (%{result} %{branch} #%{build_number}) %{build_url} 23 | Diff: %{compare_url}" 24 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | (This file itself is Copyright (C) 2013, 2014, 2015 Alex Smith, and 2 | may be freely redistributed. See license for details.) 3 | 4 | FIQHack is licensed under the the NetHack General Public License 5 | (see libnethack/dat/license for the license terms). The license is 6 | similar to old versions of the GPL (both the GPL and the NGPL were 7 | based on the same license, the BISON general public license). 8 | 9 | Additionally, some of the newer files in the repository offer a choice 10 | of license; they can be distributed under the terms of the NGPL, but 11 | additionally, can also be distributed under the terms of the GNU 12 | General Public License (or GPL), version 2 or later. If a file offers 13 | this choice of license, that fact will be specified in a comment in 14 | the file itself. If you plan to redistribute or modify these 15 | dual-licensed files, you can follow the terms of either or both 16 | licenses, at your option. You can find a copy of version 2 of the GPL 17 | as libnethack/dat/gpl. 18 | 19 | The build system, version 3 of aimake, is licensed under version 3 of 20 | the GPL and is *not* licensed under the NGPL. However, the license of 21 | the build system does not transfer onto the files that it is used to 22 | build, leaving the resulting executables as purely NGPL. There is a 23 | copy of version 3 of the GPL inside aimake's source code; it can most 24 | conveniently be viewed via "./aimake --license", or else you can read 25 | it via opening the source code of aimake in a text editor. 26 | 27 | libjansson is not part of FIQHack, although it is compiled into it 28 | during a static build (and used as a shared library during a dynamic 29 | build), and is distributed under the Expat license. (See the 30 | "copyright" file for details.) 31 | 32 | The art in the "tilesets/" directories has its own licenses. View the 33 | files themselves, or the "copyright" file, for full details. 34 | 35 | For full, machine-readable detail on the licenses of all the source 36 | files that make up FIQHack, see the "copyright" file. The licenses 37 | to the files included in a binary distribution (either compiled from 38 | the source, or copied from elsewhere) are listed in the 39 | "binary-copyright.rtf" file. 40 | 41 | Please note: 42 | 43 | FIQHack DOES NOT COME WITH ANY SORT OF WARRANTY. 44 | -------------------------------------------------------------------------------- /dist/common/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FredrIQ/fiqhack/dc309067ce179c5f11ab929f3c1e5a5bf798058e/dist/common/icon16.png -------------------------------------------------------------------------------- /dist/common/icon256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FredrIQ/fiqhack/dc309067ce179c5f11ab929f3c1e5a5bf798058e/dist/common/icon256.png -------------------------------------------------------------------------------- /dist/common/icon32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FredrIQ/fiqhack/dc309067ce179c5f11ab929f3c1e5a5bf798058e/dist/common/icon32.png -------------------------------------------------------------------------------- /dist/common/icon64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FredrIQ/fiqhack/dc309067ce179c5f11ab929f3c1e5a5bf798058e/dist/common/icon64.png -------------------------------------------------------------------------------- /dist/debian/changelog: -------------------------------------------------------------------------------- 1 | fiqhack (4.3.1~beta2) unstable; urgency=low 2 | * Updated packages for 4.3.1.0 3 | -- Fredrik Ljungdahl Mon 23 Nov 2015 15:53:35 +0100 4 | 5 | fiqhack (4.3.0~beta1) unstable; urgency=low 6 | * Updated packages for 4.3.0.0 7 | -- Fredrik Ljungdahl Tue 03 Nov 2015 15:09:01 +0100 8 | 9 | nethack4 (4.3.0~beta3) unstable; urgency=low 10 | * Updated packages for 4.3 11 | -- Alex Smith Sun, 05 Apr 2015 02:57:00 +0100 12 | 13 | nethack4 (4.3.0~beta2) unstable; urgency=low 14 | * Updated packages for 4.3 15 | -- Alex Smith Thu, 02 Apr 2015 02:08:48 +0100 16 | 17 | nethack4 (4.3.0~beta1) unstable; urgency=low 18 | * Updated packages for 4.3 19 | -- Alex Smith Thu, 29 May 2014 08:06:00 +0100 20 | 21 | nitrohack (4.0.2-1) unstable; urgency=low 22 | * Updated packages for 4.0.2 23 | 24 | -- Daniel Thaler Sun, 5 Feb 2012 19:00:00 +0100 25 | 26 | nitrohack (4.0.1-1) unstable; urgency=low 27 | * Updated packages for 4.0.1 28 | 29 | -- Daniel Thaler Sun, 22 Jan 2012 23:00:00 +0100 30 | 31 | nitrohack (4.0.0-1) unstable; urgency=low 32 | * Created a new debian/ directory with packaging info; lets hope this is all OK. 33 | 34 | -- Daniel Thaler Sat, 14 Jan 2012 20:22:00 +0100 35 | -------------------------------------------------------------------------------- /dist/debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /dist/debian/control: -------------------------------------------------------------------------------- 1 | Source: fiqhack 2 | Section: games 3 | Priority: optional 4 | Maintainer: Fredrik Ljungdahl 5 | Build-Depends: debhelper (>= 9.0.0), libz-dev, libjansson-dev, bison, flex, libsdl2-dev, libpng-dev, perl (>= 5.8.1) 6 | Standards-Version: 3.9.5 7 | Homepage: http://fiq.se 8 | Vcs-Git: git://github.com/FredrIQ/fiqhack.git 9 | 10 | Package: fiqhack 11 | Architecture: any 12 | Depends: ${shlibs:Depends}, ${misc:Depends} 13 | Description: modernized version of the classic roguelike NetHack 14 | FIQHack is a modernized version of the classic game NetHack, based off 15 | NetHack4's codebase, itself based on NetHack 3.4.3, but adds a completely new 16 | user interface, numberous bug fixes. It also tries to make the user interface 17 | less hostile and less willing to kill the player - its authors feel that player 18 | deaths should be the result of their actions, not their typos. 19 | On top of that, FIQHack does a few balance adjustments, tries to improve the 20 | monster AI and to make things more consistent between monsters and players. 21 | . 22 | NetHack itself is perhaps the best-known "roguelike" game: a screen-oriented 23 | dungeon crawler in which levels are randomly generated, giving a different 24 | gameplay experience each time. NetHack's emphasis is on developing your 25 | character in the way you want; if it feels like something should be possible, 26 | it probably is. The eventual goal of the game is to collect the Amulet of 27 | Yendor from deep in the dungeon, but concentrating on learning to survive in 28 | the dungeon should be most players' first priority; winning the game can take 29 | months of learning, as when a character dies, you have to restart the game from 30 | scratch. 31 | . 32 | This package contains the files required both to play in a terminal, and to 33 | play in a separate window with optional graphical tile support. 34 | -------------------------------------------------------------------------------- /dist/debian/nethack4.docs: -------------------------------------------------------------------------------- 1 | README 2 | doc/changelog.txt 3 | doc/faq.txt 4 | doc/philosophy.txt 5 | -------------------------------------------------------------------------------- /dist/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # Last modified by Fredrik Ljungdahl, 2015-11-03 3 | %: 4 | env DH_VERBOSE=1 dh $@ 5 | 6 | DESTDIR=debian/fiqhack 7 | PREFIX=/usr 8 | 9 | override_dh_auto_configure: 10 | mkdir -p build 11 | mkdir -p $(DESTDIR) 12 | touch debian/aimake-ignore-this 13 | (cd build; umask 022; ../aimake --without=jansson --config-only -i $(PREFIX) ..) 14 | 15 | override_dh_auto_build: 16 | (cd build; umask 022; ../aimake) 17 | 18 | override_dh_auto_install: 19 | (cd build; umask 022; ../aimake --install-only -i --destdir=../$(DESTDIR)) 20 | 21 | override_dh_auto_clean: 22 | rm -f $(DESTDIR) 23 | rm -f build 24 | rm -f debian/aimake-ignore-this 25 | 26 | override_dh_fixperms: 27 | dh_fixperms -X /var/games -X /usr/games/fiqhack 28 | 29 | override_dh_installdocs: 30 | dh_installdocs 31 | mv debian/fiqhack/usr/share/doc/fiqhack/changelog.txt debian/fiqhack/usr/share/doc/fiqhack/changelog 32 | -------------------------------------------------------------------------------- /dist/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /dist/version-number-updates.txt: -------------------------------------------------------------------------------- 1 | About this document: 2 | Last modified by Alex Smith, 2015-11-11 3 | 4 | Copyright (C) 2013 Alex Smith. 5 | 6 | This document is licensed under the NetHack General Public License. See 7 | libnethack/dat/license for details. 8 | 9 | 10 | This is a chart of all the places in the source distribution that need 11 | to be updated due to a new version of NetHack coming out (i.e. a "if 12 | you produced a new version, what's the minimum that has to change?"): 13 | 14 | * aimake.rules (packageversion option near the start of the file) 15 | [note: aimake translates this number into various formats 16 | automatically, so it should be in the format, e.g., 4.3.0 or 17 | 4.3.beta2; only the first 3 components are significant on Windows, 18 | which is a mess, but one which won't be relevant until/unless 19 | 4.3.1 has betas] 20 | * libnethack/include/patchlevel.h (VERSION_COMPATIBILITY constant, 21 | if and only if the new release breaks save compatibility) 22 | * libnethack/dat/history (first line) 23 | * dist/debian/changelog (summary changelog entry for Debian) 24 | * doc/changelog.txt (detailed description of the changes) 25 | * libnethack_common/include/nethack.h (this is the central place 26 | from which most C code should be pulling the version number) 27 | * libnethack/src/pline.c has special code for communicating with 28 | beta testers, which needs disabling in a release version 29 | * README (describe the new version) 30 | * scripts/build-debian-package (filename of the newly created 31 | package) 32 | * Port numbers (README, libnethack_client/include/nhclient.h) if you 33 | break server protocol compatibility (the port number should 34 | normally be "53" followed by the major, minor, and patchlevel 35 | version components) 36 | 37 | Additionally, almost every release will change the copyright status 38 | (typically just dates, but perhaps more extensively): 39 | 40 | * copyright, binary-copyright.pod 41 | * aimake.rules ($copyright statement) 42 | * libnethack/include/patchlevel.h (this is the central place from 43 | which most C code should be pulling the copyright statement) 44 | 45 | Places to announce a new release (including betas): 46 | 47 | * http://reddit.com/r/nethack 48 | * IRC channels on Freenode: #nethack (just say it's been released), 49 | #nethack4 (change the topic if necessary) 50 | * rec.games.roguelikes.nethack on Usenet 51 | * the networkmotd daemon on http://motd.nethack4.org (needs an admin 52 | to change this) 53 | 54 | Note that the NGPL also requires all modified files to specify who 55 | modified them and when, which is a pretty obnoxious requirement. 56 | Nowadays, we get git to do this automatically: see 57 | scripts/vcs-hooks/git-hooks-post-commit. 58 | 59 | -------------------------------------------------------------------------------- /doc/changelog_fiqhack.txt: -------------------------------------------------------------------------------- 1 | --- TODO: This changelog is currently incomplete --- 2 | * Monsters with energy regeneration regenerate "Pw" (the monster version of it) much faster 3 | * Monsters regenerate HP at the same speed as players with 12 constitution 4 | -------------------------------------------------------------------------------- /doc/dlb.pod: -------------------------------------------------------------------------------- 1 | =for comment 2 | Last modified by Alex Smith, 2015-03-16 3 | NetHack may be freely redistributed. See license for details. 4 | 5 | =encoding utf8 6 | 7 | =for aimake manualname dlb 8 | =for aimake manualsection 6 9 | 10 | =head1 NAME 11 | 12 | dlb - NetHack data librarian 13 | 14 | =head1 SYNOPSIS 15 | 16 | B {B} [B] I [B] 17 | 18 | =head1 DESCRIPTION 19 | 20 | F is a file archiving tool in the spirit (and tradition) of tar 21 | for NetHack version 3.1 and higher. (This manual page ships with 22 | NetHack 4, but the program it describes has not changed in usage from 23 | the NetHack 3 series.) It is used to maintain the archive files from 24 | which NetHack reads special level files and other read-only 25 | information. Note that like tar the command and option specifiers are 26 | specified as a continuous string and are followed by any arguments 27 | required in the same order as the option specifiers. 28 | 29 | =head1 COMMANDS 30 | 31 | The B command causes F to extract the contents of the archive 32 | into the current directory. 33 | 34 | The B command causes F to create a new archive from files in 35 | the current directory. 36 | 37 | The B command lists the files in the archive. 38 | 39 | =head1 OPTIONS AND ARGUMENTS 40 | 41 | =over 10 42 | 43 | =item B 44 | 45 | Verbose output. 46 | 47 | =item B I 48 | 49 | Specifies the archive. The default if B is not specified is 50 | C (usually the nhdat file in the playground). 51 | 52 | =item B I 53 | 54 | Specifies the file containing the list of files to put in to or 55 | extract from the archive if no files are listed on the command line. 56 | The default for archive creation if no files are listed is 57 | C. 58 | 59 | =item B I 60 | 61 | Changes directory before trying to read any files (including the 62 | I and the I). 63 | 64 | =back 65 | 66 | =head1 EXAMPLES 67 | 68 | Create the default archive from the default file list: 69 | 70 | dlb c 71 | 72 | List the contents of the archive 'foo': 73 | 74 | dlb tf foo 75 | 76 | =head1 AUTHOR 77 | 78 | Kenneth Lorber 79 | 80 | =head1 SEE ALSO 81 | 82 | L, L, L 83 | 84 | =head1 BUGS 85 | 86 | Not a good tar emulation; C<-> does not mean stdin or stdout. 87 | 88 | Should include an optional compression facility. 89 | 90 | Not all read-only files for NetHack can be read out of an archive; 91 | examining the source is the only way to know which files can be. 92 | -------------------------------------------------------------------------------- /dumbmake/dumbmake.h: -------------------------------------------------------------------------------- 1 | #ifndef DUMBMAKE 2 | #error !AIMAKE_FAIL_SILENTLY! 3 | #endif 4 | 5 | #define AIMAKE_ABI_VERSION(x) 6 | #define AIMAKE_IMPORT(x) x 7 | #define AIMAKE_EXPORT(x) x 8 | extern const char *aimake_get_option(const char *); 9 | -------------------------------------------------------------------------------- /dumbmake/dumbmake_get_option.c: -------------------------------------------------------------------------------- 1 | #ifndef DUMBMAKE 2 | #error !AIMAKE_FAIL_SILENTLY! 3 | #endif 4 | 5 | #include 6 | 7 | const char gamesdatadir[] = GAMESDATADIR; 8 | const char gamesstatedir[] = GAMESSTATEDIR; 9 | 10 | const char *aimake_get_option(const char *name) { 11 | if (!strcmp(name, "gamesdatadir")) 12 | return gamesdatadir; 13 | if (!strcmp(name, "gamesstatedir")) 14 | return gamesstatedir; 15 | return NULL; 16 | } 17 | -------------------------------------------------------------------------------- /libjansson/error.c: -------------------------------------------------------------------------------- 1 | /* Last modified by Alex Smith, 2013-09-21 */ 2 | #include 3 | #include "jansson_private.h" 4 | 5 | void jsonp_error_init(json_error_t *error, const char *source) 6 | { 7 | if(error) 8 | { 9 | error->text[0] = '\0'; 10 | error->line = -1; 11 | error->column = -1; 12 | error->position = 0; 13 | if(source) 14 | jsonp_error_set_source(error, source); 15 | else 16 | error->source[0] = '\0'; 17 | } 18 | } 19 | 20 | void jsonp_error_set_source(json_error_t *error, const char *source) 21 | { 22 | size_t length; 23 | 24 | if(!error || !source) 25 | return; 26 | 27 | length = strlen(source); 28 | if(length < JSON_ERROR_SOURCE_LENGTH) 29 | strcpy(error->source, source); 30 | else { 31 | size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; 32 | strcpy(error->source, "..."); 33 | strcpy(error->source + 3, source + extra); 34 | } 35 | } 36 | 37 | void jsonp_error_set(json_error_t *error, int line, int column, 38 | size_t position, const char *msg, ...) 39 | { 40 | va_list ap; 41 | 42 | va_start(ap, msg); 43 | jsonp_error_vset(error, line, column, position, msg, ap); 44 | va_end(ap); 45 | } 46 | 47 | void jsonp_error_vset(json_error_t *error, int line, int column, 48 | size_t position, const char *msg, va_list ap) 49 | { 50 | if(!error) 51 | return; 52 | 53 | if(error->text[0] != '\0') { 54 | /* error already set */ 55 | return; 56 | } 57 | 58 | error->line = line; 59 | error->column = column; 60 | error->position = position; 61 | 62 | vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap); 63 | } 64 | -------------------------------------------------------------------------------- /libjansson/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* Last modified by Alex Smith, 2013-09-21 */ 2 | /* 3 | * Copyright (c) 2010-2011 Petri Lehtinen 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify 6 | * it under the terms of the MIT license. See copyright for details. 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | */ 12 | 13 | #ifndef JANSSON_CONFIG_H 14 | #define JANSSON_CONFIG_H 15 | 16 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 17 | defined to `inline', otherwise empty. In C++, the inline is always 18 | supported. */ 19 | #ifdef __cplusplus 20 | #define JSON_INLINE inline 21 | #else 22 | #define JSON_INLINE inline 23 | #endif 24 | 25 | /* If your compiler supports the `long long` type, 26 | JSON_INTEGER_IS_LONG_LONG is defined to 1, otherwise to 0. */ 27 | #define JSON_INTEGER_IS_LONG_LONG 1 28 | 29 | /* If locale.h and localeconv() are available, define to 1, 30 | otherwise to 0. */ 31 | #define JSON_HAVE_LOCALECONV 1 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libjansson/jansson_private.h: -------------------------------------------------------------------------------- 1 | /* Last modified by Alex Smith, 2013-09-21 */ 2 | /* 3 | * Copyright (c) 2009-2011 Petri Lehtinen 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify 6 | * it under the terms of the MIT license. See copyright for details. 7 | */ 8 | 9 | #ifndef JANSSON_PRIVATE_H 10 | #define JANSSON_PRIVATE_H 11 | 12 | #define JANSSON_IN_LIBJANSSON 13 | #include 14 | #include "jansson.h" 15 | #include "hashtable.h" 16 | #include "strbuffer.h" 17 | 18 | #define container_of(ptr_, type_, member_) \ 19 | ((type_ *)((char *)ptr_ - offsetof(type_, member_))) 20 | 21 | /* On some platforms, max() may already be defined */ 22 | #ifndef max 23 | #define max(a, b) ((a) > (b) ? (a) : (b)) 24 | #endif 25 | 26 | /* va_copy is a C99 feature. In C89 implementations, it's sometimes 27 | available as __va_copy. If not, memcpy() should do the trick. */ 28 | #ifndef va_copy 29 | #ifdef __va_copy 30 | #define va_copy __va_copy 31 | #else 32 | #define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) 33 | #endif 34 | #endif 35 | 36 | typedef struct { 37 | json_t json; 38 | hashtable_t hashtable; 39 | size_t serial; 40 | int visited; 41 | } json_object_t; 42 | 43 | typedef struct { 44 | json_t json; 45 | size_t size; 46 | size_t entries; 47 | json_t **table; 48 | int visited; 49 | } json_array_t; 50 | 51 | typedef struct { 52 | json_t json; 53 | char *value; 54 | } json_string_t; 55 | 56 | typedef struct { 57 | json_t json; 58 | double value; 59 | } json_real_t; 60 | 61 | typedef struct { 62 | json_t json; 63 | json_int_t value; 64 | } json_integer_t; 65 | 66 | #define json_to_object(json_) container_of(json_, json_object_t, json) 67 | #define json_to_array(json_) container_of(json_, json_array_t, json) 68 | #define json_to_string(json_) container_of(json_, json_string_t, json) 69 | #define json_to_real(json_) container_of(json_, json_real_t, json) 70 | #define json_to_integer(json_) container_of(json_, json_integer_t, json) 71 | 72 | size_t jsonp_hash_str(const void *ptr); 73 | int jsonp_str_equal(const void *ptr1, const void *ptr2); 74 | 75 | typedef struct { 76 | size_t serial; 77 | char key[1]; 78 | } object_key_t; 79 | 80 | const object_key_t *jsonp_object_iter_fullkey(void *iter); 81 | 82 | void jsonp_error_init(json_error_t *error, const char *source); 83 | void jsonp_error_set_source(json_error_t *error, const char *source); 84 | void jsonp_error_set(json_error_t *error, int line, int column, 85 | size_t position, const char *msg, ...); 86 | void jsonp_error_vset(json_error_t *error, int line, int column, 87 | size_t position, const char *msg, va_list ap); 88 | 89 | /* Locale independent string<->double conversions */ 90 | int jsonp_strtod(strbuffer_t *strbuffer, double *out); 91 | int jsonp_dtostr(char *buffer, size_t size, double value); 92 | 93 | /* Wrappers for custom memory functions */ 94 | void* jsonp_malloc(size_t size); 95 | void jsonp_free(void *ptr); 96 | char *jsonp_strdup(const char *str); 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /libjansson/memory.c: -------------------------------------------------------------------------------- 1 | /* Last modified by Alex Smith, 2013-09-21 */ 2 | /* 3 | * Copyright (c) 2009-2011 Petri Lehtinen 4 | * Copyright (c) 2011 Basile Starynkevitch 5 | * 6 | * Jansson is free software; you can redistribute it and/or modify it 7 | * under the terms of the MIT license. See copyright for details. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "jansson_private.h" 14 | 15 | /* memory function pointers */ 16 | static json_malloc_t do_malloc = malloc; 17 | static json_free_t do_free = free; 18 | 19 | void *jsonp_malloc(size_t size) 20 | { 21 | if(!size) 22 | return NULL; 23 | 24 | return (*do_malloc)(size); 25 | } 26 | 27 | void jsonp_free(void *ptr) 28 | { 29 | if(!ptr) 30 | return; 31 | 32 | (*do_free)(ptr); 33 | } 34 | 35 | char *jsonp_strdup(const char *str) 36 | { 37 | char *new_str; 38 | 39 | new_str = jsonp_malloc(strlen(str) + 1); 40 | if(!new_str) 41 | return NULL; 42 | 43 | strcpy(new_str, str); 44 | return new_str; 45 | } 46 | 47 | void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn) 48 | { 49 | do_malloc = malloc_fn; 50 | do_free = free_fn; 51 | } 52 | -------------------------------------------------------------------------------- /libjansson/strbuffer.c: -------------------------------------------------------------------------------- 1 | /* Last modified by Alex Smith, 2013-09-21 */ 2 | /* 3 | * Copyright (c) 2009-2011 Petri Lehtinen 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify 6 | * it under the terms of the MIT license. See copyright for details. 7 | */ 8 | 9 | #define _GNU_SOURCE 10 | #include 11 | #include 12 | #include "jansson_private.h" 13 | #include "strbuffer.h" 14 | 15 | #define STRBUFFER_MIN_SIZE 16 16 | #define STRBUFFER_FACTOR 2 17 | #define STRBUFFER_SIZE_MAX ((size_t)-1) 18 | 19 | int strbuffer_init(strbuffer_t *strbuff) 20 | { 21 | strbuff->size = STRBUFFER_MIN_SIZE; 22 | strbuff->length = 0; 23 | 24 | strbuff->value = jsonp_malloc(strbuff->size); 25 | if(!strbuff->value) 26 | return -1; 27 | 28 | /* initialize to empty */ 29 | strbuff->value[0] = '\0'; 30 | return 0; 31 | } 32 | 33 | void strbuffer_close(strbuffer_t *strbuff) 34 | { 35 | jsonp_free(strbuff->value); 36 | strbuff->size = 0; 37 | strbuff->length = 0; 38 | strbuff->value = NULL; 39 | } 40 | 41 | void strbuffer_clear(strbuffer_t *strbuff) 42 | { 43 | strbuff->length = 0; 44 | strbuff->value[0] = '\0'; 45 | } 46 | 47 | const char *strbuffer_value(const strbuffer_t *strbuff) 48 | { 49 | return strbuff->value; 50 | } 51 | 52 | char *strbuffer_steal_value(strbuffer_t *strbuff) 53 | { 54 | char *result = strbuff->value; 55 | strbuffer_init(strbuff); 56 | return result; 57 | } 58 | 59 | int strbuffer_append(strbuffer_t *strbuff, const char *string) 60 | { 61 | return strbuffer_append_bytes(strbuff, string, strlen(string)); 62 | } 63 | 64 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte) 65 | { 66 | return strbuffer_append_bytes(strbuff, &byte, 1); 67 | } 68 | 69 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size) 70 | { 71 | if(size >= strbuff->size - strbuff->length) 72 | { 73 | size_t new_size; 74 | char *new_value; 75 | 76 | /* avoid integer overflow */ 77 | if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR 78 | || size > STRBUFFER_SIZE_MAX - 1 79 | || strbuff->length > STRBUFFER_SIZE_MAX - 1 - size) 80 | return -1; 81 | 82 | new_size = max(strbuff->size * STRBUFFER_FACTOR, 83 | strbuff->length + size + 1); 84 | 85 | new_value = jsonp_malloc(new_size); 86 | if(!new_value) 87 | return -1; 88 | 89 | memcpy(new_value, strbuff->value, strbuff->length); 90 | 91 | jsonp_free(strbuff->value); 92 | strbuff->value = new_value; 93 | strbuff->size = new_size; 94 | } 95 | 96 | memcpy(strbuff->value + strbuff->length, data, size); 97 | strbuff->length += size; 98 | strbuff->value[strbuff->length] = '\0'; 99 | 100 | return 0; 101 | } 102 | 103 | char strbuffer_pop(strbuffer_t *strbuff) 104 | { 105 | if(strbuff->length > 0) { 106 | char c = strbuff->value[--strbuff->length]; 107 | strbuff->value[strbuff->length] = '\0'; 108 | return c; 109 | } 110 | else 111 | return '\0'; 112 | } 113 | -------------------------------------------------------------------------------- /libjansson/strbuffer.h: -------------------------------------------------------------------------------- 1 | /* Last modified by Alex Smith, 2013-10-29 */ 2 | /* 3 | * Copyright (c) 2009-2011 Petri Lehtinen 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify 6 | * it under the terms of the MIT license. See copyright for details. 7 | */ 8 | 9 | #ifndef STRBUFFER_H 10 | #define STRBUFFER_H 11 | 12 | #include 13 | 14 | typedef struct { 15 | char *value; 16 | size_t length; /* bytes used */ 17 | size_t size; /* bytes allocated */ 18 | } strbuffer_t; 19 | 20 | int strbuffer_init(strbuffer_t *strbuff); 21 | void strbuffer_close(strbuffer_t *strbuff); 22 | 23 | void strbuffer_clear(strbuffer_t *strbuff); 24 | 25 | const char *strbuffer_value(const strbuffer_t *strbuff); 26 | char *strbuffer_steal_value(strbuffer_t *strbuff); 27 | 28 | int strbuffer_append(strbuffer_t *strbuff, const char *string); 29 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte); 30 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); 31 | 32 | char strbuffer_pop(strbuffer_t *strbuff); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libjansson/strconv.c: -------------------------------------------------------------------------------- 1 | /* Last modified by Alex Smith, 2013-09-21 */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "jansson_private.h" 7 | #include "strbuffer.h" 8 | 9 | #if JSON_HAVE_LOCALECONV 10 | #include 11 | 12 | /* 13 | - This code assumes that the decimal separator is exactly one 14 | character. 15 | 16 | - If setlocale() is called by another thread between the call to 17 | localeconv() and the call to sprintf() or strtod(), the result may 18 | be wrong. setlocale() is not thread-safe and should not be used 19 | this way. Multi-threaded programs should use uselocale() instead. 20 | */ 21 | 22 | static void to_locale(strbuffer_t *strbuffer) 23 | { 24 | const char *point; 25 | char *pos; 26 | 27 | point = localeconv()->decimal_point; 28 | if(*point == '.') { 29 | /* No conversion needed */ 30 | return; 31 | } 32 | 33 | pos = strchr(strbuffer->value, '.'); 34 | if(pos) 35 | *pos = *point; 36 | } 37 | 38 | static void from_locale(char *buffer) 39 | { 40 | const char *point; 41 | char *pos; 42 | 43 | point = localeconv()->decimal_point; 44 | if(*point == '.') { 45 | /* No conversion needed */ 46 | return; 47 | } 48 | 49 | pos = strchr(buffer, *point); 50 | if(pos) 51 | *pos = '.'; 52 | } 53 | #endif 54 | 55 | int jsonp_strtod(strbuffer_t *strbuffer, double *out) 56 | { 57 | double value; 58 | char *end; 59 | 60 | #if JSON_HAVE_LOCALECONV 61 | to_locale(strbuffer); 62 | #endif 63 | 64 | errno = 0; 65 | value = strtod(strbuffer->value, &end); 66 | assert(end == strbuffer->value + strbuffer->length); 67 | 68 | if(errno == ERANGE && value != 0) { 69 | /* Overflow */ 70 | return -1; 71 | } 72 | 73 | *out = value; 74 | return 0; 75 | } 76 | 77 | int jsonp_dtostr(char *buffer, size_t size, double value) 78 | { 79 | int ret; 80 | size_t length; 81 | 82 | ret = snprintf(buffer, size, "%.17g", value); 83 | if(ret < 0) 84 | return -1; 85 | 86 | length = (size_t)ret; 87 | if(length >= size) 88 | return -1; 89 | 90 | #if JSON_HAVE_LOCALECONV 91 | from_locale(buffer); 92 | #endif 93 | 94 | /* Make sure there's a dot or 'e' in the output. Otherwise 95 | a real is converted to an integer when decoding */ 96 | if(strchr(buffer, '.') == NULL && 97 | strchr(buffer, 'e') == NULL) 98 | { 99 | if(length + 2 >= size) { 100 | /* No space to append ".0" */ 101 | return -1; 102 | } 103 | buffer[length] = '.'; 104 | buffer[length + 1] = '0'; 105 | length += 2; 106 | } 107 | 108 | return (int)length; 109 | } 110 | -------------------------------------------------------------------------------- /libjansson/utf.h: -------------------------------------------------------------------------------- 1 | /* Last modified by Alex Smith, 2013-09-21 */ 2 | /* 3 | * Copyright (c) 2009-2011 Petri Lehtinen 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify 6 | * it under the terms of the MIT license. See copyright for details. 7 | */ 8 | 9 | #ifndef UTF_H 10 | #define UTF_H 11 | 12 | #ifdef HAVE_CONFIG_H 13 | #include 14 | 15 | #ifdef HAVE_INTTYPES_H 16 | /* inttypes.h includes stdint.h in a standard environment, so there's 17 | no need to include stdint.h separately. If inttypes.h doesn't define 18 | int32_t, it's defined in config.h. */ 19 | #include 20 | #endif /* HAVE_INTTYPES_H */ 21 | 22 | #else /* !HAVE_CONFIG_H */ 23 | #ifdef _WIN32 24 | typedef int int32_t; 25 | #else /* !_WIN32 */ 26 | /* Assume a standard environment */ 27 | #include 28 | #endif /* _WIN32 */ 29 | 30 | #endif /* HAVE_CONFIG_H */ 31 | 32 | int utf8_encode(int codepoint, char *buffer, int *size); 33 | 34 | int utf8_check_first(char byte); 35 | int utf8_check_full(const char *buffer, int size, int32_t *codepoint); 36 | const char *utf8_iterate(const char *buffer, int32_t *codepoint); 37 | 38 | int utf8_check_string(const char *string, int length); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /libnethack/dat/.gitignore: -------------------------------------------------------------------------------- 1 | # Last modified by Alex Smith, 2013-09-21 2 | *.lev 3 | data 4 | dungeon 5 | dungeon.pdf 6 | nhdat 7 | oracles 8 | quest.dat 9 | rumors 10 | -------------------------------------------------------------------------------- /libnethack/dat/oracle.des: -------------------------------------------------------------------------------- 1 | # Last modified by Fredrik Ljungdahl, 2018-04-29 2 | # NetHack may be freely redistributed. See license for details. 3 | # 4 | # Oracle level 5 | # 6 | 7 | LEVEL: "oracle" 8 | 9 | ROOM: "ordinary" , lit, (37,10), (center,center), (11,9) 10 | NAME: "central" 11 | OBJECT:'`',"statue",(0,0),"forest centaur",1 12 | OBJECT:'`',"statue",(0,8),"mountain centaur",1 13 | OBJECT:'`',"statue",(10,0),"mountain centaur",1 14 | OBJECT:'`',"statue",(10,8),"forest centaur",1 15 | OBJECT:'`',"statue",(5,1),"plains centaur",1 16 | OBJECT:'`',"statue",(5,7),"plains centaur",1 17 | OBJECT:'`',"statue",(2,4),"plains centaur",1 18 | OBJECT:'`',"statue",(8,4),"plains centaur",1 19 | MONSTER: random, random, random 20 | MONSTER: random, random, random 21 | 22 | SUBROOM: "delphi" , lit , (4,3) , (3,3), "central" 23 | FOUNTAIN: (0, 1) 24 | FOUNTAIN: (1, 0) 25 | FOUNTAIN: (1, 2) 26 | FOUNTAIN: (2, 1) 27 | MONSTER: '@', "Oracle", (1,1) 28 | DOOR: false , nodoor , random, random 29 | 30 | ROOM: "ordinary" , random, random, random, random 31 | STAIR: random, up 32 | OBJECT: random,random,random 33 | 34 | ROOM: "ordinary" , random, random, random, random 35 | STAIR: random, down 36 | OBJECT: random, random, random 37 | TRAP: random, random 38 | MONSTER: random, random, random 39 | MONSTER: random, random, random 40 | 41 | ROOM: "ordinary" , random, random, random, random 42 | OBJECT: random, random, random 43 | OBJECT: random, random, random 44 | MONSTER: random, random, random 45 | 46 | ROOM: "ordinary" , random, random, random, random 47 | OBJECT: random, random, random 48 | TRAP: random, random 49 | MONSTER: random, random, random 50 | 51 | ROOM: "ordinary" , random, random, random, random 52 | OBJECT: random, random, random 53 | TRAP: random, random 54 | MONSTER: random, random, random 55 | 56 | RANDOM_CORRIDORS 57 | -------------------------------------------------------------------------------- /libnethack/dat/tower.des: -------------------------------------------------------------------------------- 1 | # Last modified by Alex Smith, 2013-09-21 2 | # Copyright (c) 1989 by Jean-Christophe Collet 3 | # NetHack may be freely redistributed. See license for details. 4 | # 5 | # Upper stage of Vlad's tower 6 | MAZE:"tower1",' ' 7 | FLAGS: noteleport,hardfloor 8 | GEOMETRY:half-left,center 9 | MAP 10 | --- --- --- 11 | |.| |.| |.| 12 | ---S---S---S--- 13 | |.......+.+...| 14 | ---+-----.----- 15 | |...\.|.+.| 16 | ---+-----.----- 17 | |.......+.+...| 18 | ---S---S---S--- 19 | |.| |.| |.| 20 | --- --- --- 21 | ENDMAP 22 | LADDER:(11,05),down 23 | # The lord and his court 24 | MONSTER:'V',"Vlad the Impaler",(06,05) 25 | MONSTER:'V',random,(03,09) 26 | MONSTER:'V',random,(07,09) 27 | MONSTER:'V',random,(11,09) 28 | MONSTER:'V',random,(03,01) 29 | MONSTER:'V',random,(07,01) 30 | MONSTER:'V',random,(11,01) 31 | # The doors 32 | DOOR:closed,(08,03) 33 | DOOR:closed,(10,03) 34 | DOOR:closed,(03,04) 35 | DOOR:locked,(10,05) 36 | DOOR:locked,(08,07) 37 | DOOR:locked,(10,07) 38 | DOOR:closed,(03,06) 39 | # treasures 40 | OBJECT:'(',"chest",(07,05) 41 | OBJECT:'(',"chest",(03,09) 42 | OBJECT:'(',"chest",(07,09) 43 | OBJECT:'(',"chest",(11,09) 44 | OBJECT:'(',"chest",(03,01) 45 | OBJECT:'(',"chest",(07,01) 46 | OBJECT:'(',"chest",(11,01) 47 | # We have to protect the tower against outside attacks 48 | NON_DIGGABLE:(00,00,14,10) 49 | 50 | 51 | # Intermediate stage of Vlad's tower 52 | MAZE:"tower2",' ' 53 | FLAGS: noteleport,hardfloor 54 | GEOMETRY:half-left,center 55 | MAP 56 | --- --- --- 57 | |.| |.| |.| 58 | ---S---S---S--- 59 | |.S.........S.| 60 | ---.------+---- 61 | |......|..| 62 | --------.------ 63 | |.S......+..S.| 64 | ---S---S---S--- 65 | |.| |.| |.| 66 | --- --- --- 67 | ENDMAP 68 | # Random places are the 10 niches 69 | RANDOM_PLACES:(03,01),(07,01),(11,01),(01,03),(13,03), 70 | (01,07),(13,07),(03,09),(07,09),(11,09) 71 | LADDER:(11,05),up 72 | LADDER:(03,07),down 73 | DOOR:locked,(10,04) 74 | DOOR:locked,(09,07) 75 | MONSTER:'&',random,place[0] 76 | MONSTER:'&',random,place[1] 77 | MONSTER:'d',"hell hound pup",place[2] 78 | MONSTER:'d',"hell hound pup",place[3] 79 | MONSTER:'d',"winter wolf",place[4] 80 | CONTAINER:'(',"chest",place[5] 81 | OBJECT:'"',"amulet of life saving",contained 82 | CONTAINER:'(',"chest",place[6] 83 | OBJECT:'"',"amulet of strangulation",contained 84 | OBJECT:'[',"water walking boots",place[7] 85 | OBJECT:'[',"crystal plate mail",place[8] 86 | OBJECT:'+',"invisibility",place[9] 87 | # Walls in the tower are non diggable 88 | NON_DIGGABLE:(00,00,14,10) 89 | 90 | 91 | # Bottom most stage of Vlad's tower 92 | MAZE:"tower3",' ' 93 | FLAGS: noteleport,hardfloor 94 | GEOMETRY:half-left,center 95 | MAP 96 | --- --- --- 97 | |.| |.| |.| 98 | ---S---S---S--- 99 | |.S.........S.| 100 | -----.........----- 101 | |...|.........+...| 102 | |.---.........---.| 103 | |.|.S.........S.|.| 104 | |.---S---S---S---.| 105 | |...|.|.|.|.|.|...| 106 | ---.---.---.---.--- 107 | |.............| 108 | --------------- 109 | ENDMAP 110 | # Random places are the 10 niches 111 | RANDOM_PLACES:(05,01),(09,01),(13,01),(03,03),(15,03), 112 | (03,07),(15,07),(05,09),(09,09),(13,09) 113 | BRANCH:(02,05,02,05),(00,00,00,00) 114 | LADDER:(05,07),up 115 | # Entry door is, of course, locked 116 | DOOR:locked,(14,05) 117 | # Let's put a dragon behind the door, just for the fun... 118 | MONSTER:'D',random,(13,05) 119 | MONSTER:random,random,(12,04) 120 | MONSTER:random,random,(12,06) 121 | MONSTER:random,random,random 122 | MONSTER:random,random,random 123 | MONSTER:random,random,random 124 | MONSTER:random,random,random 125 | MONSTER:random,random,random 126 | MONSTER:random,random,random 127 | OBJECT:')',"long sword",place[0] 128 | TRAP:random,place[0] 129 | OBJECT:'(',"lock pick",place[1] 130 | TRAP:random,place[1] 131 | OBJECT:'[',"elven cloak",place[2] 132 | TRAP:random,place[2] 133 | OBJECT:'(',"blindfold",place[3] 134 | TRAP:random,place[3] 135 | # Walls in the tower are non diggable 136 | NON_DIGGABLE:(00,00,18,12) 137 | -------------------------------------------------------------------------------- /libnethack/include/.gitignore: -------------------------------------------------------------------------------- 1 | # Last modified by Alex Smith, 2013-09-21 2 | date.h 3 | onames.h 4 | pm.h 5 | verinfo.h 6 | -------------------------------------------------------------------------------- /libnethack/include/align.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2017-12-19 */ 3 | /* Copyright (c) Mike Stephenson, Izchak Miller 1991. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef ALIGN_H 7 | # define ALIGN_H 8 | 9 | #include "global.h" 10 | #include "quest.h" 11 | 12 | typedef schar aligntyp; /* basic alignment type */ 13 | 14 | typedef struct align { /* alignment & record */ 15 | aligntyp type; 16 | int record; 17 | } align; 18 | 19 | /* bounds for "record" -- respect initial alignments of 10 */ 20 | # define ALIGNLIM ((10L + (moves/200L)) > MIN_QUEST_ALIGN ? \ 21 | (10L + (moves/200L)) : MIN_QUEST_ALIGN) 22 | 23 | # define A_NONE (-128) /* the value range of type */ 24 | /* A_{CHAOTIC,NEUTRAL,LAWFUL} moved to nethack_types.h */ 25 | 26 | # define A_COALIGNED 1 27 | # define A_OPALIGNED (-1) 28 | 29 | # define AM_NONE 0 30 | # define AM_CHAOTIC 1 31 | # define AM_NEUTRAL 2 32 | # define AM_LAWFUL 4 33 | 34 | # define AM_MASK 7 35 | 36 | # define AM_SPLEV_CO 3 37 | # define AM_SPLEV_NONCO 7 38 | 39 | # define AR_PIOUS 20 40 | # define AR_DEVOUT 14 41 | # define AR_FERVENT 9 42 | # define AR_STRIDENT 4 43 | # define AR_OK 3 44 | # define AR_HALTING 1 45 | # define AR_NOMINAL 0 46 | # define AR_STRAYED (-1) 47 | # define AR_SINNED (-4) 48 | # define AR_TRANSGRESSED (-9) 49 | 50 | # define Amask2align(x) ((aligntyp) ((!(x)) ? A_NONE \ 51 | : ((x) == AM_LAWFUL) ? A_LAWFUL : ((int)x) - 2)) 52 | # define Align2amask(x) (((x) == A_NONE) ? AM_NONE \ 53 | : ((x) == A_LAWFUL) ? AM_LAWFUL : (x) + 2) 54 | # define Align2asave(x) ((x) == A_LAWFUL ? 0 : \ 55 | (x) == A_NEUTRAL ? 1 : \ 56 | (x) == A_CHAOTIC ? 2 : \ 57 | 3) 58 | # define Asave2align(x) ((x) == 0 ? A_LAWFUL : \ 59 | (x) == 1 ? A_NEUTRAL : \ 60 | (x) == 2 ? A_CHAOTIC : \ 61 | A_NONE) 62 | # define Align2typ(x) ((x) > 0 ? A_LAWFUL : \ 63 | (x) == -128 ? A_NONE : \ 64 | (x) < 0 ? A_CHAOTIC : \ 65 | A_NEUTRAL) 66 | 67 | #endif /* ALIGN_H */ 68 | -------------------------------------------------------------------------------- /libnethack/include/artifact.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2019-10-26 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef ARTIFACT_H 7 | # define ARTIFACT_H 8 | 9 | # include "global.h" 10 | # include "align.h" 11 | # include "permonst.h" 12 | 13 | # define SPFX_NONE 0x0000000L /* no special effects, just a bonus */ 14 | # define SPFX_NOGEN 0x0000001L /* item is special, bequeathed by gods */ 15 | # define SPFX_RESTR 0x0000002L /* item is restricted - can't be named */ 16 | # define SPFX_INTEL 0x0000004L /* item is self-willed - intelligent */ 17 | # define SPFX_SPEAK 0x0000008L /* item can speak (not implemented) */ 18 | # define SPFX_SEEK 0x0000010L /* item helps you search for things */ 19 | # define SPFX_WARN 0x0000020L /* item warns you of danger */ 20 | # define SPFX_FLYING 0x0000040L /* Flight */ 21 | # define SPFX_FREEACT 0x0000080L /* Free action (paralyzation resistance) */ 22 | # define SPFX_MAXCON 0x0000100L /* Max constitution */ 23 | # define SPFX_SEARCH 0x0000200L /* helps searching */ 24 | # define SPFX_BEHEAD 0x0000400L /* beheads monsters */ 25 | # define SPFX_HALRES 0x0000800L /* blocks hallucinations */ 26 | # define SPFX_ESP 0x0001000L /* ESP (like amulet of ESP) */ 27 | # define SPFX_DISPLACE 0x0002000L /* Displacement */ 28 | # define SPFX_REGEN 0x0004000L /* Regeneration */ 29 | # define SPFX_EREGEN 0x0008000L /* Energy Regeneration */ 30 | # define SPFX_HSPDAM 0x0010000L /* 1/2 spell damage (on player) in combat */ 31 | # define SPFX_HPHDAM 0x0020000L /* 1/2 physical damage (on player) in combat */ 32 | # define SPFX_TCTRL 0x0040000L /* Teleportation Control */ 33 | # define SPFX_LUCK 0x0080000L /* Increase Luck (like Luckstone) */ 34 | # define DBONUS(wep, typ) (((wep)->spfx & SPFX_DBONUS) == typ) 35 | # define SPFX_DMONS 0x0100000L /* attack bonus on one monster type */ 36 | # define SPFX_DCLAS 0x0200000L /* attack bonus on monsters w/ symbol mtype */ 37 | # define SPFX_DFLAG1 0x0300000L /* attack bonus on monsters w/ mflags1 flag */ 38 | # define SPFX_DFLAG2 0x0400000L /* attack bonus on monsters w/ mflags2 flag */ 39 | # define SPFX_DALIGN 0x0500000L /* attack bonus on non-aligned monsters */ 40 | # define SPFX_ATTK 0x0600000L /* item has a special attack (attk) */ 41 | # define SPFX_DBONUS 0x0700000L /* attack bonus mask */ 42 | # define SPFX_XRAY 0x0800000L /* gives X-RAY vision to player */ 43 | # define SPFX_REFLECT 0x1000000L /* Reflection */ 44 | # define SPFX_WTREDUC 0x2000000L /* Reduced weight (halved) */ 45 | 46 | struct artifact { 47 | const char *name; 48 | long cost; /* price when sold to hero (default 100 x base cost) */ 49 | unsigned long spfx; /* special effect from wielding/wearing */ 50 | unsigned long cspfx; /* special effect just from carrying obj */ 51 | unsigned long mtype; /* monster type, symbol, or flag */ 52 | struct attack attk, defn, cary; 53 | aligntyp alignment; /* alignment of bequeathing gods */ 54 | uchar inv_prop; /* property obtained by invoking artifact */ 55 | short role; /* character role associated with */ 56 | short race; /* character race associated with */ 57 | short otyp; 58 | }; 59 | 60 | enum artigen_type { 61 | ag_none, 62 | ag_other, /* This is the value of old existing artifacts before this was implemented */ 63 | ag_gift, 64 | ag_wish, 65 | ag_monwish, 66 | ag_named, 67 | ag_bones, 68 | }; 69 | 70 | # define nartifact_gifted() nartifact_value(ag_gift) 71 | # define nartifact_wished() (nartifact_value(ag_wish) + nartifact_value(ag_monwish)) 72 | 73 | /* invoked properties with special powers */ 74 | # define TAMING (LAST_PROP+1) 75 | # define HEALING (LAST_PROP+2) 76 | # define ENERGY_BOOST (LAST_PROP+3) 77 | # define CHARGE_OBJ (LAST_PROP+4) 78 | # define LEV_TELE (LAST_PROP+5) 79 | # define CREATE_PORTAL (LAST_PROP+6) 80 | # define ENLIGHTENING (LAST_PROP+7) 81 | # define CREATE_AMMO (LAST_PROP+8) 82 | # define SELF_UNCURSE (LAST_PROP+9) 83 | 84 | #endif /* ARTIFACT_H */ 85 | -------------------------------------------------------------------------------- /libnethack/include/attrib.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2017-12-13 */ 3 | /* Copyright 1988, Mike Stephenson */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | /* attrib.h - Header file for character class processing. */ 7 | 8 | #ifndef ATTRIB_H 9 | # define ATTRIB_H 10 | 11 | # include "global.h" 12 | 13 | /* attribute IDs */ 14 | # define A_STR 0 15 | # define A_INT 1 16 | # define A_WIS 2 17 | # define A_DEX 3 18 | # define A_CON 4 19 | # define A_CHA 5 20 | 21 | # define A_MAX 6 /* used in rn2() selection of attrib */ 22 | 23 | # define ABASE(x) (u.acurr.a[x]) 24 | # define AEXE(x) (u.aexe.a[x]) 25 | # define ACURR(x) (acurr(&youmonst, x)) 26 | /* should be: */ 27 | /* #define ACURR(x) (ABON(x) + ATEMP(x) + (Upolyd ? MBASE(x) : ABASE(x)) */ 28 | # define MCURR(x) (u.macurr.a[x]) 29 | # define AMAX(x) (u.amax.a[x]) 30 | # define MMAX(x) (u.mamax.a[x]) 31 | 32 | # define ATEMP(x) (u.atemp.a[x]) 33 | # define ATIME(x) (u.atime.a[x]) /* TODO: is this actually used? */ 34 | 35 | struct attribs { 36 | schar a[A_MAX]; 37 | }; 38 | 39 | # define ATTRMAX(x) \ 40 | ((x == A_STR && Upolyd && strongmonst(youmonst.data)) ? 21 : \ 41 | urace.attrmax[x]) 42 | # define ATTRMIN(x) (urace.attrmin[x]) 43 | 44 | #endif /* ATTRIB_H */ 45 | -------------------------------------------------------------------------------- /libnethack/include/color.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) Steve Linhart, Eric Raymond, 1989. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef COLOR_H 7 | # define COLOR_H 8 | 9 | /* these can be configured */ 10 | # define HI_OBJ CLR_MAGENTA 11 | # define HI_METAL CLR_CYAN 12 | # define HI_COPPER CLR_YELLOW 13 | # define HI_SILVER CLR_GRAY 14 | # define HI_GOLD CLR_YELLOW 15 | # define HI_LEATHER CLR_BROWN 16 | # define HI_CLOTH CLR_BROWN 17 | # define HI_ORGANIC CLR_BROWN 18 | # define HI_WOOD CLR_BROWN 19 | # define HI_PAPER CLR_WHITE 20 | # define HI_GLASS CLR_BRIGHT_CYAN 21 | # define HI_MINERAL CLR_GRAY 22 | # define DRAGON_SILVER CLR_BRIGHT_CYAN 23 | # define HI_ZAP CLR_BRIGHT_BLUE 24 | 25 | #endif /* COLOR_H */ 26 | 27 | -------------------------------------------------------------------------------- /libnethack/include/config.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2017-10-08 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef CONFIG_H /* make sure the compiler does not see the typedefs 7 | twice */ 8 | # define CONFIG_H 9 | 10 | /* swap byte order while reading and writing saves and bones files. This should 11 | * enable portability between architectures. 12 | * If you do not intend to import or export saves or bones files, this option 13 | * doesn't matter. 14 | * Endianness can be autodetected on some systems. */ 15 | 16 | /* #define IS_BIG_ENDIAN */ 17 | 18 | # define PANICLOG "paniclog" /* log of panic and impossible events */ 19 | 20 | # include "global.h" /* Define everything else according to choices above */ 21 | 22 | #endif /* CONFIG_H */ 23 | -------------------------------------------------------------------------------- /libnethack/include/coord.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef COORD_H 7 | # define COORD_H 8 | 9 | # include "global.h" 10 | 11 | typedef struct nhcoord { 12 | xchar x, y; 13 | } coord; 14 | 15 | #endif /* COORD_H */ 16 | 17 | -------------------------------------------------------------------------------- /libnethack/include/dgn_file.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) 1989 by M. Stephenson */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef DGN_FILE_H 7 | # define DGN_FILE_H 8 | 9 | # ifndef ALIGN_H 10 | # include "align.h" 11 | # endif 12 | 13 | /* 14 | * Structures manipulated by the dungeon loader & compiler 15 | */ 16 | 17 | struct couple { 18 | short base, rand; 19 | }; 20 | 21 | struct tmpdungeon { 22 | char name[24], protoname[24]; 23 | struct couple lev; 24 | int flags, chance, levels, branches; 25 | int entry_lev; /* entry level for this dungeon */ 26 | char boneschar; 27 | }; 28 | 29 | struct tmplevel { 30 | char name[24]; 31 | struct couple lev; 32 | int chance, rndlevs, chain, flags; 33 | char boneschar; 34 | }; 35 | 36 | struct tmpbranch { 37 | char name[24]; /* destination dungeon name */ 38 | struct couple lev; 39 | int chain; /* index into tmplevel array (chained branch) */ 40 | int type; /* branch type (see below) */ 41 | int up; /* branch is up or down */ 42 | }; 43 | 44 | /* 45 | * Values for type for tmpbranch structure. 46 | */ 47 | # define TBR_STAIR 0 /* connection with both ends having a staircase */ 48 | # define TBR_NO_UP 1 /* connection with no up staircase */ 49 | # define TBR_NO_DOWN 2 /* connection with no down staircase */ 50 | # define TBR_PORTAL 3 /* portal connection */ 51 | 52 | /* 53 | * Flags that map into the dungeon flags bitfields. 54 | */ 55 | # define TOWN 1 /* levels only */ 56 | # define HELLISH 2 57 | # define MAZELIKE 4 58 | # define ROGUELIKE 8 59 | 60 | # define D_ALIGN_NONE 0 61 | # define D_ALIGN_CHAOTIC (AM_CHAOTIC << 4) 62 | # define D_ALIGN_NEUTRAL (AM_NEUTRAL << 4) 63 | # define D_ALIGN_LAWFUL (AM_LAWFUL << 4) 64 | 65 | # define D_ALIGN_MASK 0x70 66 | 67 | /* 68 | * Max number of prototype levels and branches. 69 | */ 70 | # define LEV_LIMIT 50 71 | # define BRANCH_LIMIT 32 72 | 73 | #endif /* DGN_FILE_H */ 74 | 75 | -------------------------------------------------------------------------------- /libnethack/include/dlb.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) Kenneth Lorber, Bethesda, Maryland, 1993. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef DLB_H 7 | # define DLB_H 8 | 9 | # include "iomodes.h" 10 | # include "global.h" 11 | 12 | /* directory structure in memory */ 13 | typedef struct dlb_directory { 14 | char *fname; /* file name as seen from calling code */ 15 | long foffset; /* offset in lib file to start of this file */ 16 | long fsize; /* file size */ 17 | char handling; /* how to handle the file (compression, etc) */ 18 | } libdir; 19 | 20 | /* information about each open library */ 21 | typedef struct dlb_library { 22 | FILE *fdata; /* opened data file */ 23 | long fmark; /* current file mark */ 24 | libdir *dir; /* directory of library file */ 25 | char *sspace; /* pointer to string space */ 26 | long nentries; /* # of files in directory */ 27 | long rev; /* dlb file revision */ 28 | long strsize; /* dlb file string size */ 29 | } library; 30 | 31 | /* library definitions */ 32 | # ifndef DLBFILE 33 | # define DLBFILE "nhdat" 34 | /* name of library */ 35 | # endif 36 | # ifndef FILENAME_CMP 37 | # define FILENAME_CMP strcmp /* case sensitive */ 38 | # endif 39 | 40 | 41 | 42 | typedef struct dlb_handle { 43 | FILE *fp; /* pointer to an external file, use if non-null */ 44 | library *lib; /* pointer to library structure */ 45 | long start; /* offset of start of file */ 46 | long size; /* size of file */ 47 | long mark; /* current file marker */ 48 | } dlb; 49 | 50 | # define DLB_P dlb * 51 | 52 | boolean dlb_init(void); 53 | void dlb_cleanup(void); 54 | 55 | dlb *dlb_fopen(const char *, const char *); 56 | int dlb_fclose(DLB_P); 57 | int dlb_fread(void *, int, int, DLB_P); 58 | int dlb_fseek(DLB_P, long, int); 59 | char *dlb_fgets(void *, int, DLB_P); 60 | int dlb_fgetc(DLB_P); 61 | long dlb_ftell(DLB_P); 62 | 63 | #endif /* DLB_H */ 64 | 65 | -------------------------------------------------------------------------------- /libnethack/include/drawing.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-10-05 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* Copyright (c) 2013 Alex Smith. */ 5 | /* NetHack may be freely redistributed. See license for details. */ 6 | 7 | /* drawing.c is pretty self-contained in its own right, so it gets a 8 | self-contained header file. */ 9 | 10 | #ifndef DRAWING_H 11 | # define DRAWING_H 12 | 13 | # include "nethack_types.h" 14 | 15 | extern const char *make_mon_name(int); 16 | extern char *make_object_name(int); 17 | 18 | extern void populate_mon_symdef(int, struct nh_symdef *); 19 | extern void populate_obj_symdef(int, struct nh_symdef *); 20 | 21 | extern const struct nh_symdef defsyms[]; 22 | extern const struct nh_symdef warnsyms[]; 23 | extern const struct nh_symdef trapsyms[]; 24 | extern const struct nh_symdef explsyms[]; 25 | extern const struct nh_symdef zapsyms[]; 26 | extern const struct nh_symdef effectsyms[]; 27 | extern const struct nh_symdef swallowsyms[]; 28 | 29 | extern const struct nh_symdef expltypes[]; 30 | extern const struct nh_symdef zaptypes[]; 31 | 32 | extern const char *const defexplain[]; 33 | extern const char *const warnexplain[]; 34 | extern const char *const trapexplain[]; 35 | extern const char *const invismonexplain; 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /libnethack/include/engrave.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef ENGRAVE_H 7 | # define ENGRAVE_H 8 | 9 | # include "global.h" 10 | 11 | struct engr { 12 | struct engr *nxt_engr; 13 | char *engr_txt; 14 | unsigned engr_lth; /* for save & restore; not length of text */ 15 | long engr_time; /* moment engraving was (will be) finished */ 16 | xchar engr_x, engr_y; 17 | xchar engr_type; 18 | # define DUST 1 19 | # define ENGRAVE 2 20 | # define BURN 3 21 | # define MARK 4 22 | # define ENGR_BLOOD 5 23 | # define HEADSTONE 6 24 | # define N_ENGRAVE 6 25 | }; 26 | 27 | # define newengr(lth) malloc((unsigned)(lth) + sizeof(struct engr)) 28 | # define dealloc_engr(engr) free((engr)) 29 | 30 | #endif /* ENGRAVE_H */ 31 | 32 | -------------------------------------------------------------------------------- /libnethack/include/hungerstatus.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef HUNGER_STATUS_H 7 | # define HUNGER_STATUS_H 8 | 9 | /* hunger texts used on bottom line (each 8 chars long) */ 10 | # define SATIATED 0 11 | # define NOT_HUNGRY 1 12 | # define HUNGRY 2 13 | # define WEAK 3 14 | # define FAINTING 4 15 | # define FAINTED 5 16 | # define STARVED 6 17 | 18 | /* Corpse rotness */ 19 | enum corpserot { 20 | corpserot_maybe_tainted, 21 | corpserot_tainted, 22 | corpserot_maybe_sick, 23 | corpserot_sick, 24 | corpserot_ok, 25 | corpserot_last_harmful = corpserot_sick, 26 | }; 27 | 28 | #endif /* HUNGER_STATUS_H */ 29 | -------------------------------------------------------------------------------- /libnethack/include/iomodes.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-05-09 */ 3 | /* Copyright (c) Kenneth Lorber, Bethesda, Maryland, 1993. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef IOMODES_H 7 | # define IOMODES_H 8 | 9 | #include 10 | 11 | /* various I/O stuff we don't want to replicate everywhere */ 12 | 13 | # ifndef SEEK_SET 14 | # define SEEK_SET 0 15 | # endif 16 | # ifndef SEEK_CUR 17 | # define SEEK_CUR 1 18 | # endif 19 | # ifndef SEEK_END 20 | # define SEEK_END 2 21 | # endif 22 | 23 | # define RDTMODE "r" 24 | 25 | # if defined(WIN32) 26 | # define WRTMODE "w+b" 27 | # define RDBMODE "rb" 28 | # define WRBMODE "w+b" 29 | # else 30 | # define WRTMODE "w+" 31 | # define RDBMODE "r" 32 | # define WRBMODE "w+" 33 | # endif 34 | 35 | enum locktype 36 | { 37 | LT_NONE, /* do not lock at all */ 38 | LT_MONITOR, /* for use only on program_state.logfile; do a server cancel 39 | whenever the file is write-locked by another process */ 40 | LT_READ, /* do not allow other processes to write to this file */ 41 | LT_WRITE, /* do not allow other processes to read or write to this file */ 42 | }; 43 | 44 | #endif /* IOMODES_H */ 45 | 46 | -------------------------------------------------------------------------------- /libnethack/include/lev.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Sean Hunt, 2014-10-17 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | /* Common include file for save and restore routines */ 7 | 8 | #ifndef LEV_H 9 | # define LEV_H 10 | 11 | # include "global.h" 12 | 13 | /* The following are used in mkmaze.c */ 14 | struct container { 15 | struct container *next; 16 | xchar x, y; 17 | short what; 18 | void *list; 19 | }; 20 | 21 | # define CONS_OBJ 0 22 | # define CONS_MON 1 23 | # define CONS_HERO 2 24 | # define CONS_TRAP 3 25 | 26 | struct bubble { 27 | xchar x, y; /* coordinates of the upper left corner */ 28 | schar dx, dy; /* the general direction of the bubble's movement */ 29 | const uchar *bm; /* pointer to the bubble bit mask */ 30 | struct bubble *prev, *next; /* need to traverse the list up and down */ 31 | struct container *cons; 32 | }; 33 | 34 | /* used in light.c */ 35 | typedef struct ls_t { 36 | struct ls_t *next; 37 | xchar x, y; /* source's position */ 38 | short range; /* source's current range */ 39 | short flags; 40 | short type; /* type of light source */ 41 | void *id; /* source's identifier */ 42 | } light_source; 43 | 44 | extern int n_dgns; 45 | 46 | #endif /* LEV_H */ 47 | 48 | -------------------------------------------------------------------------------- /libnethack/include/magic.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2015-11-17 */ 3 | /* Copyright (c) Daniel Thaler, 2011 */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef MAGIC_H 7 | # define MAGIC_H 8 | 9 | /* magic numbers to mark sections in the savegame */ 10 | # define LEVEL_MAGIC 0x4c56454c /* "LEVL" */ 11 | # define STATE_MAGIC 0x54415453 /* "STAT" */ 12 | # define OBJ_MAGIC 0x004a424f /* "OBJ\0" */ 13 | # define MON_MAGIC 0x004e4f4d /* "MON\0" */ 14 | # define OBJCHAIN_MAGIC 0x4e48434f /* "OCHN" */ 15 | # define MONCHAIN_MAGIC 0x4e48434d /* "MCHN" */ 16 | # define FRUITCHAIN_MAGIC 0x48435246 /* "FRCH" */ 17 | # define TRAPCHAIN_MAGIC 0x53505254 /* "TRPS" */ 18 | # define REGION_MAGIC 0x49474552 /* "REGI" */ 19 | # define ROOMS_MAGIC 0x54424452 /* "RDAT" */ 20 | # define OCLASSES_MAGIC 0x4c4c434f /* "OCLL" */ 21 | # define ENGRAVE_MAGIC 0x52474e45 /* "ENGR" */ 22 | # define HISTORY_MAGIC 0x54534948 /* "HIST" */ 23 | # define DIG_MAGIC 0x53474944 /* "DIGS" */ 24 | # define DGN_MAGIC 0x004e4744 /* "DGN\0" */ 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libnethack/include/mfndpos.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2018-01-17 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef MFNDPOS_H 7 | # define MFNDPOS_H 8 | 9 | # define ALLOW_RANGED 0x00002000L /* allow ranged combat */ 10 | # define ALLOW_MELEE 0x00004000L /* allow melee combat */ 11 | # define ALLOW_JUMP 0x00008000L /* can jump */ 12 | # define ALLOW_PEACEFUL 0x00010000L /* can displace peacefuls */ 13 | # define ALLOW_TRAPS 0x00020000L /* can enter traps */ 14 | # define ALLOW_MUXY 0x00040000L /* can attack your believed location */ 15 | # define ALLOW_M 0x00080000L /* can attack other monsters */ 16 | # define ALLOW_ALL (ALLOW_MUXY | ALLOW_M | ALLOW_TRAPS) 17 | # define NOTONL 0x00200000L /* avoids direct line to player */ 18 | # define OPENDOOR 0x00400000L /* opens closed doors */ 19 | # define UNLOCKDOOR 0x00800000L /* unlocks locked doors */ 20 | # define BUSTDOOR 0x01000000L /* breaks any doors */ 21 | # define ALLOW_ROCK 0x02000000L /* pushes rocks */ 22 | # define ALLOW_WALL 0x04000000L /* walks thru walls */ 23 | # define ALLOW_DIG 0x08000000L /* digs */ 24 | # define ALLOW_BARS 0x10000000L /* may pass thru iron bars */ 25 | # define ALLOW_SANCT 0x20000000L /* enters temples */ 26 | # define ALLOW_SSM 0x40000000L /* ignores scare monster */ 27 | # define NOGARLIC 0x80000000UL /* hates garlic */ 28 | 29 | #endif /* MFNDPOS_H */ 30 | -------------------------------------------------------------------------------- /libnethack/include/monuse.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2018-12-31 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef MONUSE_H 7 | # define MONUSE_H 8 | 9 | /* Defines for various types of stuff. The order in which monsters prefer 10 | * to use them is determined by the order of the code logic, not the 11 | * numerical order in which they are defined. 12 | */ 13 | enum monuse { 14 | MUSE_NONE = 0, 15 | 16 | /* dungeon interaction */ 17 | MUSE_TRAPDOOR, 18 | MUSE_TELEPORT_TRAP, 19 | MUSE_UPSTAIRS, 20 | MUSE_DOWNSTAIRS, 21 | MUSE_UP_LADDER, 22 | MUSE_DN_LADDER, 23 | MUSE_SSTAIRS, 24 | MUSE_POLY_TRAP, 25 | MUSE_ASCEND, 26 | 27 | /* general items */ 28 | MUSE_CAST, 29 | MUSE_QUAFF, 30 | MUSE_ZAP, 31 | MUSE_SCR, 32 | MUSE_THROW, 33 | MUSE_CONTAINER, 34 | MUSE_EAT, 35 | MUSE_BOOK, 36 | 37 | /* misc (TODO: merge tools into a single function) */ 38 | MUSE_UNICORN_HORN, 39 | MUSE_DIRHORN, 40 | MUSE_BUGLE, 41 | MUSE_BAG_OF_TRICKS, 42 | MUSE_KEY, 43 | MUSE_INNATE_TPT, 44 | MUSE_BULLWHIP, 45 | NUM_MUSE, 46 | }; 47 | 48 | struct musable { 49 | struct monst *mon; 50 | struct obj *obj; 51 | struct obj *tobj; /* target obj, currently only used when unlocking chests */ 52 | int spell; /* for spells */ 53 | int x; 54 | int y; 55 | int z; 56 | int limit; /* arg limit equivalent */ 57 | enum monuse use; 58 | /* =0, no capability; otherwise, different numbers. If it's an object, the 59 | object is also set (it's 0 otherwise). */ 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /libnethack/include/ntconf.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) NetHack PC Development Team 1993, 1994. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef NTCONF_H 7 | # define NTCONF_H 8 | 9 | # ifndef AIMAKE_BUILDOS_MSWin32 10 | # error !AIMAKE_FAIL_SILENTLY! This file is only of use on Windows systems. 11 | # endif 12 | 13 | /* The following is needed for prototypes of certain functions */ 14 | # if defined(_MSC_VER) 15 | # include /* Provides prototypes of exit(), spawn() */ 16 | # endif 17 | 18 | # include /* Provides prototypes of strncmpi(), etc. */ 19 | # define strncmpi(a,b,c) strnicmp(a,b,c) 20 | 21 | # include 22 | # include 23 | 24 | # define PATHLEN BUFSZ /* maximum pathlength */ 25 | # define FILENAME BUFSZ /* maximum filename length (conservative) */ 26 | 27 | # if defined(_MAX_PATH) && defined(_MAX_FNAME) 28 | # if (_MAX_PATH < BUFSZ) && (_MAX_FNAME < BUFSZ) 29 | # undef PATHLEN 30 | # undef FILENAME 31 | # define PATHLEN _MAX_PATH 32 | # define FILENAME _MAX_FNAME 33 | # endif 34 | # endif 35 | 36 | # include 37 | 38 | # define FILENAME_CMP stricmp /* case insensitive */ 39 | # define ftruncate _chsize 40 | 41 | # define getuid() 1 42 | # define getlogin() (NULL) 43 | 44 | # include 45 | # include 46 | 47 | # ifdef _MSC_VER 48 | # pragma warning(disable:4761)/* integral size mismatch in arg; conv supp */ 49 | # pragma warning(disable:4996)/* POSIX name is deprecated */ 50 | # define inline __inline 51 | # ifdef YYPREFIX 52 | # pragma warning(disable:4102) 53 | /* unreferenced label */ 54 | # endif 55 | # define YY_NO_UNISTD_H 56 | # define snprintf(buf, len, fmt, ...) \ 57 | _snprintf_s(buf, len, len-1, fmt, __VA_ARGS__) 58 | # endif 59 | 60 | #endif /* NTCONF_H */ 61 | 62 | -------------------------------------------------------------------------------- /libnethack/include/patchlevel.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2017-10-16 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | /* 7 | * Incrementing EDITLEVEL can be used to force invalidation of old bones 8 | * and save files. 9 | */ 10 | #define EDITLEVEL 0 11 | 12 | #define COPYRIGHT_BANNER_A \ 13 | "FIQHack, Copyright (C) 2017; based on NetHack, Copyright (C) 1985-2006" 14 | 15 | #define COPYRIGHT_BANNER_B \ 16 | " FIQHack is based on NetHack4 by Alex Smith and many others." 17 | 18 | #define COPYRIGHT_BANNER_C \ 19 | " NetHack by Stichting Mathematisch Centrum and M. Stephenson. See " \ 20 | "dat/licence." 21 | 22 | /* 23 | * If two or more successive releases have compatible data files, define 24 | * this with the version number of the oldest such release so that the 25 | * new release will accept old save and bones files. The format is 26 | * 0xMMmmPPeeL 27 | * 0x = literal prefix "0x", MM = major version, mm = minor version, 28 | * PP = patch level, ee = edit level, L = literal suffix "L", 29 | * with all four numbers specified as two hexadecimal digits. 30 | * Keep this consistent with nethack.h. 31 | */ 32 | #define VERSION_COMPATIBILITY 0x04030000L /* 4.3.0-0 */ 33 | 34 | 35 | /*patchlevel.h*/ 36 | -------------------------------------------------------------------------------- /libnethack/include/qtext.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) Mike Stephenson 1991. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef QTEXT_H 7 | # define QTEXT_H 8 | 9 | # define N_HDR 16 /* Maximum number of categories (i.e., num roles + 1) */ 10 | # define LEN_HDR 3 /* Maximum length of a category name */ 11 | 12 | struct qtmsg { 13 | int msgnum; 14 | char delivery; 15 | long offset, size; 16 | }; 17 | 18 | # ifdef MAKEDEFS_C /***** MAKEDEFS *****/ 19 | 20 | # define N_MSG 100 /* arbitrary */ 21 | 22 | struct msghdr { 23 | int n_msg; 24 | struct qtmsg qt_msg[N_MSG]; 25 | }; 26 | 27 | struct qthdr { 28 | int n_hdr; 29 | char id[N_HDR][LEN_HDR]; 30 | long offset[N_HDR]; 31 | }; 32 | 33 | /* Error message macros */ 34 | # define CREC_IN_MSG \ 35 | "Control record encountered during message - line %d\n" 36 | # define DUP_MSG "Duplicate message number at line %d\n" 37 | # define END_NOT_IN_MSG "End record encountered before message - line %d\n" 38 | # define TEXT_NOT_IN_MSG "Text encountered outside message - line %d\n" 39 | # define UNREC_CREC "Unrecognized Control record at line %d\n" 40 | # define OUT_OF_HEADERS \ 41 | "Too many message types (line %d)\nAdjust N_HDR in qtext.h and " \ 42 | "recompile.\n" 43 | # define OUT_OF_MESSAGES \ 44 | "Too many messages in class (line %d)\nAdjust N_MSG in qtext.h and " \ 45 | "recompile.\n" 46 | 47 | 48 | # else /***** !MAKEDEFS *****/ 49 | 50 | struct qtlists { 51 | struct qtmsg *common, *chrole; 52 | }; 53 | 54 | 55 | /* 56 | * Quest message defines. Used in quest.c to trigger off "realistic" 57 | * dialogue to the player. 58 | */ 59 | # define QT_FIRSTTIME 1 60 | # define QT_NEXTTIME 2 61 | # define QT_OTHERTIME 3 62 | 63 | # define QT_GUARDTALK 5 /* 5 random things guards say before quest */ 64 | # define QT_GUARDTALK2 10 /* 5 random things guards say after quest */ 65 | 66 | # define QT_FIRSTLEADER 15 67 | # define QT_NEXTLEADER 16 68 | # define QT_OTHERLEADER 17 69 | # define QT_LASTLEADER 18 70 | # define QT_BADLEVEL 19 71 | # define QT_BADALIGN 20 72 | # define QT_ASSIGNQUEST 21 73 | 74 | # define QT_ENCOURAGE 25 /* 1-10 random encouragement messages */ 75 | 76 | # define QT_FIRSTLOCATE 35 77 | # define QT_NEXTLOCATE 36 78 | 79 | # define QT_FIRSTGOAL 40 80 | # define QT_NEXTGOAL 41 81 | 82 | # define QT_FIRSTNEMESIS 50 83 | # define QT_NEXTNEMESIS 51 84 | # define QT_OTHERNEMESIS 52 85 | # define QT_NEMWANTSIT 53 /* you somehow got the artifact */ 86 | 87 | # define QT_DISCOURAGE 60 /* 1-10 random maledictive messages */ 88 | 89 | # define QT_GOTIT 70 90 | 91 | # define QT_KILLEDNEM 80 92 | # define QT_OFFEREDIT 81 93 | # define QT_OFFEREDIT2 82 94 | 95 | # define QT_POSTHANKS 90 96 | # define QT_HASAMULET 91 97 | 98 | /* 99 | * Message defines for common text used in maledictions. 100 | */ 101 | # define COMMON_ID "-" /* Common message id value */ 102 | 103 | # define QT_ANGELIC 10 104 | # define QTN_ANGELIC 10 105 | 106 | # define QT_DEMONIC 30 107 | # define QTN_DEMONIC 20 108 | 109 | # define QT_BANISHED 60 110 | # endif /***** !MAKEDEFS *****/ 111 | 112 | #endif /* QTEXT_H */ 113 | 114 | -------------------------------------------------------------------------------- /libnethack/include/quest.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) Mike Stephenson 1991. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef QUEST_H 7 | # define QUEST_H 8 | 9 | struct q_score { /* Quest "scorecard" */ 10 | unsigned first_start:1; /* only set the first time */ 11 | unsigned met_leader:1; /* has met the leader */ 12 | unsigned not_ready:3; /* rejected due to alignment, etc. */ 13 | unsigned pissed_off:1; /* got the leader angry */ 14 | unsigned got_quest:1; /* got the quest assignment */ 15 | 16 | unsigned first_locate:1; /* only set the first time */ 17 | unsigned met_intermed:1; /* used if the locate is a person. */ 18 | unsigned got_final:1; /* got the final quest assignment */ 19 | 20 | unsigned made_goal:3; /* # of times on goal level */ 21 | unsigned met_nemesis:1; /* has met the nemesis before */ 22 | unsigned killed_nemesis:1; /* set when the nemesis is killed */ 23 | unsigned in_battle:1; /* set when nemesis fighting you */ 24 | 25 | unsigned cheater:1; /* set if cheating detected */ 26 | unsigned touched_artifact:1; /* for a special message */ 27 | unsigned offered_artifact:1; /* offered to leader */ 28 | unsigned got_thanks:1; /* final message from leader */ 29 | 30 | /* keep track of leader presence/absence even if leader is polymorphed, 31 | raised from dead, etc */ 32 | unsigned leader_is_dead:1; 33 | unsigned leader_m_id; 34 | }; 35 | 36 | # define MAX_QUEST_TRIES 7 /* exceed this and you "fail" */ 37 | 38 | /* at least this align.record to start */ 39 | # define MIN_QUEST_ALIGN 20 40 | /* note: align 20 matches "pious" as reported by enlightenment (cmd.c) */ 41 | # define MIN_QUEST_LEVEL 10 /* at least this u.ulevel to start */ 42 | /* note: exp.lev. 14 is threshold level for 5th rank (class title, role.c) */ 43 | 44 | #endif /* QUEST_H */ 45 | 46 | -------------------------------------------------------------------------------- /libnethack/include/rect.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2018-04-29 */ 3 | /* Copyright (c) 1990 by Jean-Christophe Collet */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef RECT_H 7 | # define RECT_H 8 | 9 | # include "global.h" 10 | 11 | struct nhrect { 12 | xchar lx, ly; 13 | xchar hx, hy; 14 | }; 15 | 16 | /* According to 1.3d and 3.0.0 source, these represent the minimum amount of 17 | required space around a room in any direction, counting the walls as part of 18 | the room. 19 | Rooms' XLIM and YLIM buffers can overlap with other rooms. */ 20 | #define XLIM 4 21 | #define YLIM 3 22 | 23 | #endif /* RECT_H */ 24 | -------------------------------------------------------------------------------- /libnethack/include/region.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) 1996 by Jean-Christophe Collet */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef REGION_H 7 | # define REGION_H 8 | 9 | # include "global.h" 10 | # include "rect.h" 11 | 12 | /* generic callback function */ 13 | 14 | typedef boolean(*callback_proc) (void *, void *); 15 | 16 | # define REG_HERO_INSIDE 1 17 | # define REG_NOT_HEROS 2 18 | # define hero_inside(r) ((unsigned)(r)->player_flags & REG_HERO_INSIDE) 19 | # define heros_fault(r) (!((unsigned)(r)->player_flags & REG_NOT_HEROS)) 20 | # define set_hero_inside(r) ((r)->player_flags |= REG_HERO_INSIDE) 21 | # define clear_hero_inside(r) ((r)->player_flags &= ~REG_HERO_INSIDE) 22 | # define set_heros_fault(r) ((r)->player_flags &= ~REG_NOT_HEROS) 23 | # define clear_heros_fault(r) ((r)->player_flags |= REG_NOT_HEROS) 24 | 25 | struct region { 26 | struct level *lev; /* the level this region is on */ 27 | struct nhrect *rects; /* Rectangles composing the region */ 28 | struct nhrect bounding_box; /* Bounding box of the region */ 29 | short nrects; /* Number of rectangles */ 30 | boolean attach_2_u; /* Region attached to player ? */ 31 | unsigned int attach_2_m; /* Region attached to monster ? */ 32 | /* struct obj *attach_2_o; *//* Region attached to object ? UNUSED YET */ 33 | const char *enter_msg; /* Message when entering */ 34 | const char *leave_msg; /* Message when leaving */ 35 | short ttl; /* Time to live. -1 is forever */ 36 | short expire_f; /* Function to call when region's ttl expire */ 37 | short can_enter_f; /* Function to call to check whether the player can, or 38 | can not, enter the region */ 39 | short enter_f; /* Function to call when the player enters */ 40 | short can_leave_f; /* Function to call to check whether the player can, or 41 | can not, leave the region */ 42 | short leave_f; /* Function to call when the player leaves */ 43 | short inside_f; /* Function to call every turn if player's inside */ 44 | xchar player_flags; /* (see above) */ 45 | unsigned int *monsters; /* Monsters currently inside this region */ 46 | short n_monst; /* Number of monsters inside this region */ 47 | short max_monst; /* Maximum number of monsters that can be listed 48 | without having to grow the array */ 49 | # define MONST_INC 5 50 | 51 | /* Should probably do the same thing about objects */ 52 | 53 | boolean visible; /* Is the region visible ? */ 54 | int effect_id; /* How to display if visible */ 55 | int arg; /* Optional user argument (Ex: strength of force field, damage 56 | of a fire zone, ... */ 57 | }; 58 | 59 | #endif /* REGION_H */ 60 | 61 | -------------------------------------------------------------------------------- /libnethack/include/spell.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-06-15 */ 3 | /* Copyright 1986, M. Stephenson */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef SPELL_H 7 | # define SPELL_H 8 | 9 | # include "global.h" 10 | 11 | /* special sp_id values for divine and supernatural abilities */ 12 | #define SPID_PRAY -1 /* #pray: available to everyone */ 13 | #define SPID_TURN -2 /* #turn: available to certain classes */ 14 | #define SPID_RLOC -3 /* teleport at will; requires two properties */ 15 | #define SPID_JUMP -4 /* #jump: from jumping boots, or the Knight ability */ 16 | #define SPID_MONS -5 /* #monster: from polyself */ 17 | #define SPID_COUNT 5 /* number of SPID_ constants */ 18 | #define SPID_PREFERRED_LETTER "WXVYZ" /* must be at the end of the alphabet */ 19 | /* debug mode commands sort-of belong here, but it'd be a UI nightmare and 20 | would probably overflow the list */ 21 | 22 | static_assert(sizeof SPID_PREFERRED_LETTER == SPID_COUNT + 1, 23 | "each supernatural spell has a preferred letter"); 24 | 25 | #define SPELL_IS_FROM_SPELLBOOK(spell) (spl_book[spell].sp_id > 0) 26 | 27 | struct spell { 28 | short sp_id; /* spell id (== object.otyp) */ 29 | xchar sp_lev; /* power level */ 30 | int sp_know; /* knowlege of spell */ 31 | int sp_key; /* key alias */ 32 | }; 33 | 34 | /* levels of memory destruction with a scroll of amnesia */ 35 | # define ALL_MAP 0x1 36 | # define ALL_SPELLS 0x2 37 | 38 | # define decrnknow(spell) spl_book[spell].sp_know-- 39 | # define spellid(spell) spl_book[spell].sp_id 40 | # define spellknow(spell) spl_book[spell].sp_know 41 | # define spellkey(spell) spl_book[spell].sp_key 42 | 43 | extern const char *const flash_types[]; 44 | 45 | #endif /* SPELL_H */ 46 | 47 | -------------------------------------------------------------------------------- /libnethack/include/system.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-05-30 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef SYSTEM_H 7 | # define SYSTEM_H 8 | 9 | /* Note: this header defines features of _UNIX_ systems. */ 10 | 11 | # if !defined(__cplusplus) 12 | 13 | # include 14 | 15 | # endif/* !__cplusplus */ 16 | 17 | /* You may want to change this to fit your system, as this is almost 18 | * impossible to get right automatically. 19 | * This is the type of signal handling functions. 20 | */ 21 | # if (defined(_MSC_VER) || defined(WIN32)) 22 | # define SIG_RET_TYPE void (__cdecl *)(int) 23 | # endif 24 | 25 | # ifndef SIG_RET_TYPE 26 | # define SIG_RET_TYPE void (*)(int) 27 | # endif 28 | 29 | # if !defined(__cplusplus) 30 | 31 | extern void exit(int); 32 | extern void perror(const char *); 33 | extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); 34 | 35 | # if !defined(__GNUC__) 36 | /* may already be defined */ 37 | 38 | extern long lseek(int, long, int); 39 | extern int write(int, const void *, unsigned); 40 | 41 | extern int unlink(const char *); 42 | 43 | # endif 44 | /* !__GNUC__ */ 45 | 46 | /* The POSIX string.h is required to define all the mem* and str* functions */ 47 | # include 48 | 49 | extern unsigned sleep(unsigned); 50 | 51 | extern char *getenv(const char *); 52 | extern char *getlogin(void); 53 | 54 | # ifndef AIMAKE_BUILDOS_MSWin32 55 | extern pid_t getpid(void); 56 | extern uid_t getuid(void); 57 | extern gid_t getgid(void); 58 | # endif 59 | 60 | 61 | /* time functions */ 62 | extern time_t time(time_t *); 63 | 64 | # endif/* !__cplusplus */ 65 | 66 | #endif /* SYSTEM_H */ 67 | 68 | -------------------------------------------------------------------------------- /libnethack/include/timeout.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright 1994, Dean Luick */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef TIMEOUT_H 7 | # define TIMEOUT_H 8 | 9 | # include "global.h" 10 | 11 | /* generic timeout function */ 12 | typedef void (*timeout_proc) (void *, long); 13 | 14 | /* kind of timer */ 15 | # define TIMER_LEVEL 0 /* event specific to level */ 16 | # define TIMER_GLOBAL 1 /* event follows current play */ 17 | # define TIMER_OBJECT 2 /* event follows a object */ 18 | 19 | /* save/restore timer ranges */ 20 | # define RANGE_LEVEL 0 /* save/restore timers staying on level */ 21 | # define RANGE_GLOBAL 1 /* save/restore timers following global play */ 22 | 23 | /* 24 | * Timeout functions. Add a define here, then put it in the table 25 | * in timeout.c. "One more level of indirection will fix everything." 26 | */ 27 | # define ROT_ORGANIC 0 /* for buried organics */ 28 | # define ROT_CORPSE 1 29 | # define REVIVE_MON 2 30 | # define BURN_OBJECT 3 31 | # define HATCH_EGG 4 32 | # define FIG_TRANSFORM 5 33 | # define NUM_TIME_FUNCS 6 34 | 35 | /* used in timeout.c */ 36 | typedef struct timer_element { 37 | struct timer_element *next; /* next item in chain */ 38 | void *arg; /* pointer to timeout argument */ 39 | unsigned int timeout; /* when we time out */ 40 | unsigned int tid; /* timer ID */ 41 | short kind; /* kind of use */ 42 | uchar func_index; /* what to call when we time out */ 43 | unsigned needs_fixup:1; /* does arg need to be patched? */ 44 | } timer_element; 45 | 46 | #endif /* TIMEOUT_H */ 47 | 48 | -------------------------------------------------------------------------------- /libnethack/include/trap.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2018-04-29 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | /* note for 3.1.0 and later: no longer manipulated by 'makedefs' */ 7 | 8 | #ifndef TRAP_H 9 | # define TRAP_H 10 | 11 | # include "global.h" 12 | # include "dungeon.h" 13 | 14 | union vlaunchinfo { 15 | short v_launch_otyp; /* type of object to be triggered */ 16 | coord v_launch2; /* secondary launch point (for boulders) */ 17 | }; 18 | 19 | struct trap { 20 | struct trap *ntrap; 21 | unsigned ttyp:5; 22 | unsigned tseen:1; 23 | unsigned once:1; /* has the trap been triggered previously? */ 24 | unsigned madeby_u:1; /* So monsters may take offence when you trap 25 | them. Recognizing who made the trap isn't 26 | completely unreasonable, everybody has their 27 | own style. This flag is also needed when 28 | you untrap a monster. It would be too easy 29 | to make a monster peaceful if you could set 30 | a trap for it and then untrap it. */ 31 | xchar tx, ty; 32 | d_level dst; /* destination for portals */ 33 | coord launch; 34 | union vlaunchinfo vl; 35 | # define launch_otyp vl.v_launch_otyp 36 | # define launch2 vl.v_launch2 37 | }; 38 | 39 | # define newtrap() malloc(sizeof(struct trap)) 40 | # define dealloc_trap(trap) free(trap) 41 | 42 | /* reasons for statue animation */ 43 | # define ANIMATE_NORMAL 0 44 | # define ANIMATE_SHATTER 1 45 | # define ANIMATE_SPELL 2 46 | 47 | /* reasons for animate_statue's failure */ 48 | # define AS_OK 0 /* didn't fail */ 49 | # define AS_NO_MON 1 /* makemon failed */ 50 | # define AS_MON_IS_UNIQUE 2 /* statue monster is unique */ 51 | 52 | /* Note: if adding/removing a trap, adjust trap_engravings[] in mklev.c */ 53 | 54 | /* unconditional traps */ 55 | # define NO_TRAP 0 56 | # define ARROW_TRAP 1 57 | # define DART_TRAP 2 58 | # define ROCKTRAP 3 59 | # define SQKY_BOARD 4 60 | # define BEAR_TRAP 5 61 | # define LANDMINE 6 62 | # define ROLLING_BOULDER_TRAP 7 63 | # define SLP_GAS_TRAP 8 64 | # define RUST_TRAP 9 65 | # define FIRE_TRAP 10 66 | # define PIT 11 67 | # define SPIKED_PIT 12 68 | # define HOLE 13 69 | # define TRAPDOOR 14 70 | # define VIBRATING_SQUARE 15 71 | # define TELEP_TRAP 16 72 | # define LEVEL_TELEP 17 73 | # define MAGIC_PORTAL 18 74 | # define WEB 19 75 | # define STATUE_TRAP 20 76 | # define MAGIC_TRAP 21 77 | # define ANTI_MAGIC 22 78 | # define POLY_TRAP 23 79 | # define TRAPNUM 24 80 | 81 | #endif /* TRAP_H */ 82 | -------------------------------------------------------------------------------- /libnethack/include/unixconf.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef UNIXCONF_H 7 | # define UNIXCONF_H 8 | 9 | # ifdef AIMAKE_BUILDOS_MSWin32 10 | # error !AIMAKE_FAIL_SILENTLY! This file is only of use on UNIX-like systems. 11 | # endif 12 | 13 | # include 14 | 15 | # include "system.h" 16 | 17 | # include 18 | # include 19 | # include 20 | # include 21 | # include 22 | 23 | # define strncmpi(a,b,c) strncasecmp(a,b,c) 24 | 25 | #endif/* UNIXCONF_H */ 26 | 27 | -------------------------------------------------------------------------------- /libnethack/include/vision.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2020-08-30 */ 3 | /* Copyright (c) Dean Luick, with acknowledgements to Dave Cohrs, 1990. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef VISION_H 7 | # define VISION_H 8 | 9 | # define COULD_SEE 0x1 /* location could be seen, if it were lit */ 10 | # define IN_SIGHT 0x2 /* location can be seen */ 11 | # define TEMP_LIT 0x4 /* location is temporarily lit */ 12 | 13 | /* 14 | * Light source sources 15 | */ 16 | # define LS_OBJECT 0 17 | # define LS_MONSTER 1 18 | 19 | /* 20 | * cansee() - Returns true if the hero can see the location. 21 | * 22 | * couldsee() - Returns true if the hero has a clear line of sight to 23 | * the location. 24 | */ 25 | # define cansee(x,y) (isok(x, y) && viz_array[y][x] & IN_SIGHT) 26 | # define couldsee(x,y) (isok(x, y) && viz_array[y][x] & COULD_SEE) 27 | # define templit(x,y) (isok(x, y) && viz_array[y][x] & TEMP_LIT) 28 | 29 | /* 30 | * mcansee() - Returns true if the monster has a clear line of sight to 31 | * a given square. Do not use on a square that contains an 32 | * engulfed player (due to ambiguity as to whether you're 33 | * aiming for the player's location, or the square's). 34 | */ 35 | # define m_cansee(mtmp,x2,y2) \ 36 | (!blind(mtmp) && mtmp == &youmonst ? couldsee(x2,y2) : \ 37 | clear_path((mtmp)->mx,(mtmp)->my,(x2),(y2),viz_array)) 38 | 39 | /* 40 | * Circle information 41 | */ 42 | # define MAX_RADIUS 15 /* this is in points from the source */ 43 | 44 | /* Use this macro to get a list of distances of the edges (see vision.c). */ 45 | # define circle_ptr(z) (&circle_data[(int)circle_start[z]]) 46 | 47 | extern const char circle_data[]; 48 | extern const char circle_start[]; 49 | 50 | #endif /* VISION_H */ 51 | -------------------------------------------------------------------------------- /libnethack/include/winprocs.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-05-29 */ 3 | /* Copyright (c) David Cohrs, 1992 */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef WINPROCS_H 7 | # define WINPROCS_H 8 | 9 | # include "nethack_types.h" 10 | 11 | extern struct nh_window_procs windowprocs; 12 | 13 | # define win_pause_output (*windowprocs.win_pause) 14 | # define display_buffer (*windowprocs.win_display_buffer) 15 | # define update_status (*windowprocs.win_update_status) 16 | # define print_message (*windowprocs.win_print_message) 17 | # define update_screen (*windowprocs.win_update_screen) 18 | # define raw_print (*windowprocs.win_raw_print) 19 | # define outrip (*windowprocs.win_outrip) 20 | # define level_changed (*windowprocs.win_level_changed) 21 | # define win_delay_output (*windowprocs.win_delay) 22 | 23 | struct display_menu_callback_data { 24 | const int *results; 25 | int nresults; 26 | }; 27 | struct display_objects_callback_data { 28 | const struct nh_objresult *results; 29 | int nresults; 30 | }; 31 | 32 | #endif /* WINPROCS_H */ 33 | 34 | -------------------------------------------------------------------------------- /libnethack/include/zap.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2017-11-27 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef ZAP_H 7 | # define ZAP_H 8 | 9 | # include "monattk.h" 10 | 11 | /* Defines for zap.c */ 12 | 13 | # define ZT_MAGIC_MISSILE (AD_MAGM-1) 14 | # define ZT_FIRE (AD_FIRE-1) 15 | # define ZT_COLD (AD_COLD-1) 16 | # define ZT_SLEEP (AD_SLEE-1) 17 | # define ZT_DEATH (AD_DISN-1) /* or disintegration */ 18 | # define ZT_LIGHTNING (AD_ELEC-1) 19 | # define ZT_POISON_GAS (AD_DRST-1) 20 | # define ZT_ACID (AD_ACID-1) 21 | # define ZT_STUN (AD_STUN-1) 22 | /* 9 is currently unassigned */ 23 | 24 | # define ZT_WAND(x) (x) 25 | # define ZT_SPELL(x) (10+(x)) 26 | # define ZT_BREATH(x) (20+(x)) 27 | 28 | # define BHIT_NONE 0x00 29 | # define BHIT_MON 0x01 30 | # define BHIT_DMON 0x02 /* displaced image was hit */ 31 | # define BHIT_OBJ 0x04 32 | # define BHIT_OBSTRUCT 0x08 33 | # define BHIT_SHOPDAM 0x10 34 | 35 | # define is_hero_spell(type) ((type) >= 10 && (type) < 20) 36 | 37 | #endif /* ZAP_H */ 38 | -------------------------------------------------------------------------------- /libnethack/src/.gitignore: -------------------------------------------------------------------------------- 1 | # Last modified by Alex Smith, 2013-09-21 2 | libnethack.dylib 3 | monstr.c 4 | -------------------------------------------------------------------------------- /libnethack/src/level.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2017-10-14 */ 3 | /* Copyright (c) Sean Hunt, 2013. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "hack.h" 7 | 8 | boolean has_sanctum(struct level *lev, xchar alignmask) { 9 | int sx, sy; 10 | for (sx = 0; sx < COLNO; ++sx) 11 | for (sy = 0; sy < ROWNO; ++sy) { 12 | xchar locmask = lev->locations[sx][sy].flags; 13 | if (IS_ALTAR(lev->locations[sx][sy].typ) && 14 | (locmask & AM_SANCTUM) && 15 | (locmask & alignmask)) 16 | return TRUE; 17 | } 18 | 19 | return FALSE; 20 | } 21 | 22 | boolean has_terrain(struct level *lev, schar typ) { 23 | int sx, sy; 24 | for (sx = 0; sx < COLNO; ++sx) 25 | for (sy = 0; sy < ROWNO; ++sy) 26 | if (lev->locations[sx][sy].typ == typ) 27 | return TRUE; 28 | 29 | return FALSE; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /libnethack/src/mail.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2018-01-02 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "hack.h" 7 | #include "mail.h" 8 | 9 | #ifdef WIN32 10 | # include "extern.h" 11 | void 12 | checkformail(void) 13 | { 14 | return; 15 | } 16 | #else 17 | # include 18 | # include 19 | # include 20 | # include "extern.h" 21 | 22 | static void delivermail(const char *from, const char *message); 23 | 24 | static void 25 | delivermail(const char *from, const char *message) 26 | { 27 | pline(msgc_mail, "Mail from %s: %s", from, message); 28 | } 29 | 30 | void 31 | checkformail(void) 32 | { 33 | if (program_state.followmode != FM_PLAY && 34 | program_state.followmode != FM_WATCH) 35 | return; 36 | 37 | const char *box; 38 | char *msg; 39 | FILE* mb; 40 | char curline[102]; 41 | struct flock fl = { 0 }; 42 | 43 | box = mail_filename(NULL); 44 | if (!box) 45 | return; 46 | 47 | mb = fopen(box, "r"); 48 | if (!mb) 49 | return; 50 | 51 | fl.l_type = F_RDLCK; 52 | fl.l_whence = SEEK_SET; 53 | fl.l_start = 0; 54 | fl.l_len = 0; 55 | 56 | /* Allow this call to block. */ 57 | if (fcntl (fileno (mb), F_SETLKW, &fl) == -1) 58 | return; 59 | 60 | while (fgets(curline, 102, mb) != NULL) { 61 | const char *who; 62 | const char *thetext; 63 | 64 | fl.l_type = F_UNLCK; 65 | fcntl (fileno(mb), F_UNLCK, &fl); 66 | 67 | msg = strchr(curline, ':'); 68 | if (!msg) 69 | return; 70 | 71 | *msg = '\0'; 72 | msg++; 73 | who = msgprintf("%s", curline); 74 | 75 | if (!flags.servermail) { 76 | # ifdef MAILOVERRIDE 77 | if (strcmpi(who, MAILOVERRIDE)) 78 | # endif 79 | return; 80 | } 81 | 82 | msg[strlen(msg) - 1] = '\0'; /* kill newline */ 83 | thetext = msgprintf("%s", msg); 84 | delivermail(who, thetext); 85 | 86 | fl.l_type = F_RDLCK; 87 | fcntl(fileno(mb), F_SETLKW, &fl); 88 | } 89 | 90 | fl.l_type = F_UNLCK; 91 | fcntl(fileno(mb), F_UNLCK, &fl); 92 | 93 | fclose(mb); 94 | 95 | if (program_state.followmode == FM_PLAY) 96 | unlink(box); 97 | return; 98 | } 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /libnethack/src/symclass.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) NetHack Development Team 1992. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "hack.h" 7 | 8 | /* Default object class symbols. See objclass.h. */ 9 | const char def_oc_syms[MAXOCLASSES] = { 10 | /* 0 */ '\0', 11 | /* placeholder for the "random class" */ 12 | ILLOBJ_SYM, 13 | WEAPON_SYM, 14 | ARMOR_SYM, 15 | RING_SYM, 16 | /* 5*/ AMULET_SYM, 17 | TOOL_SYM, 18 | FOOD_SYM, 19 | POTION_SYM, 20 | SCROLL_SYM, 21 | /*10*/ SPBOOK_SYM, 22 | WAND_SYM, 23 | GOLD_SYM, 24 | GEM_SYM, 25 | ROCK_SYM, 26 | /*15*/ BALL_SYM, 27 | CHAIN_SYM, 28 | VENOM_SYM 29 | }; 30 | 31 | /* Default monster class symbols. See monsym.h. */ 32 | const char def_monsyms[MAXMCLASSES] = { 33 | '\0', /* holder */ 34 | DEF_ANT, 35 | DEF_BLOB, 36 | DEF_COCKATRICE, 37 | DEF_DOG, 38 | DEF_EYE, 39 | DEF_FELINE, 40 | DEF_GREMLIN, 41 | DEF_HUMANOID, 42 | DEF_IMP, 43 | DEF_JELLY, /* 10 */ 44 | DEF_KOBOLD, 45 | DEF_LEPRECHAUN, 46 | DEF_MIMIC, 47 | DEF_NYMPH, 48 | DEF_ORC, 49 | DEF_PIERCER, 50 | DEF_QUADRUPED, 51 | DEF_RODENT, 52 | DEF_SPIDER, 53 | DEF_TRAPPER, /* 20 */ 54 | DEF_UNICORN, 55 | DEF_VORTEX, 56 | DEF_WORM, 57 | DEF_XAN, 58 | DEF_LIGHT, 59 | DEF_ZRUTY, 60 | DEF_ANGEL, 61 | DEF_BAT, 62 | DEF_CENTAUR, 63 | DEF_DRAGON, /* 30 */ 64 | DEF_ELEMENTAL, 65 | DEF_FUNGUS, 66 | DEF_GNOME, 67 | DEF_GIANT, 68 | '\0', 69 | DEF_JABBERWOCK, 70 | DEF_KOP, 71 | DEF_LICH, 72 | DEF_MUMMY, 73 | DEF_NAGA, /* 40 */ 74 | DEF_OGRE, 75 | DEF_PUDDING, 76 | DEF_QUANTMECH, 77 | DEF_RUSTMONST, 78 | DEF_SNAKE, 79 | DEF_TROLL, 80 | DEF_UMBER, 81 | DEF_VAMPIRE, 82 | DEF_WRAITH, 83 | DEF_XORN, /* 50 */ 84 | DEF_YETI, 85 | DEF_ZOMBIE, 86 | DEF_HUMAN, 87 | DEF_GOLEM, 88 | DEF_DEMON, 89 | DEF_EEL, 90 | DEF_LIZARD, 91 | DEF_WORM_TAIL, 92 | DEF_MIMIC_DEF, /* 60 */ 93 | }; 94 | 95 | 96 | /* 97 | * Convert the given character to an object class. If the character is not 98 | * recognized, then MAXOCLASSES is returned. Used in detect.c invent.c, 99 | * options.c, pickup.c, sp_lev.c, and lev_main.c. 100 | */ 101 | int 102 | def_char_to_objclass(char ch) 103 | { 104 | int i; 105 | 106 | for (i = 1; i < MAXOCLASSES; i++) 107 | if (ch == def_oc_syms[i]) 108 | break; 109 | return i; 110 | } 111 | 112 | 113 | /* 114 | * Convert a character into a monster class. This returns the _first_ 115 | * match made. If there are are no matches, return MAXMCLASSES. 116 | */ 117 | int 118 | def_char_to_monclass(char ch) 119 | { 120 | int i; 121 | 122 | for (i = 1; i < MAXMCLASSES; i++) 123 | if (def_monsyms[i] == ch) 124 | break; 125 | return i; 126 | } 127 | 128 | -------------------------------------------------------------------------------- /libnethack/src/track.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2017-12-19 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | /* track.c - version 1.0.2 */ 6 | 7 | #include "hack.h" 8 | 9 | #define UTSZ 50 10 | 11 | static int utcnt, utpnt; 12 | static coord utrack[UTSZ]; 13 | 14 | 15 | void 16 | initrack(void) 17 | { 18 | utcnt = utpnt = 0; 19 | memset(utrack, 0, sizeof utrack); 20 | } 21 | 22 | 23 | /* add to track */ 24 | void 25 | settrack(void) 26 | { 27 | if (utcnt < UTSZ) 28 | utcnt++; 29 | if (utpnt == UTSZ) 30 | utpnt = 0; 31 | utrack[utpnt].x = u.ux; 32 | utrack[utpnt].y = u.uy; 33 | utpnt++; 34 | } 35 | 36 | 37 | coord * 38 | gettrack(int x, int y) 39 | { 40 | int cnt, ndist; 41 | coord *tc; 42 | 43 | cnt = utcnt; 44 | for (tc = &utrack[utpnt]; cnt--;) { 45 | if (tc == utrack) 46 | tc = &utrack[UTSZ - 1]; 47 | else 48 | tc--; 49 | ndist = distmin(x, y, tc->x, tc->y); 50 | 51 | if (ndist <= 1) 52 | return ndist ? tc : 0; 53 | } 54 | return NULL; 55 | } 56 | 57 | 58 | void 59 | save_track(struct memfile *mf) 60 | { 61 | int i; 62 | 63 | mtag(mf, 0, MTAG_TRACK); 64 | for (i = 0; i < UTSZ; i++) { /* savemap: ignore */ 65 | mwrite8(mf, utrack[i].x); 66 | mwrite8(mf, utrack[i].y); 67 | } /* savemap: 784 bits (more) */ 68 | mwrite32(mf, utcnt); 69 | mwrite32(mf, utpnt); 70 | } 71 | 72 | 73 | void 74 | restore_track(struct memfile *mf) 75 | { 76 | int i; 77 | 78 | for (i = 0; i < UTSZ; i++) { 79 | utrack[i].x = mread8(mf); 80 | utrack[i].y = mread8(mf); 81 | } 82 | utcnt = mread32(mf); 83 | utpnt = mread32(mf); 84 | } 85 | 86 | /*track.c*/ 87 | -------------------------------------------------------------------------------- /libnethack/src/version.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2017-12-29 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "hack.h" 7 | #include "date.h" 8 | /* 9 | * All the references to the contents of patchlevel.h have been moved 10 | * into makedefs.... 11 | */ 12 | #include "patchlevel.h" 13 | 14 | /* #define BETA_INFO "" *//* "[ beta n]" */ 15 | 16 | static const char *getversionstring(void); 17 | 18 | 19 | /* fill buffer with short version (so caller can avoid including date.h) */ 20 | const char * 21 | version_string(void) 22 | { 23 | return VERSION_STRING; 24 | } 25 | 26 | /* fill and return the given buffer with the long nethack version string */ 27 | const char * 28 | getversionstring(void) 29 | { 30 | const char *rv = VERSION_ID; 31 | #if defined(BETA) && defined(BETA_INFO) 32 | rv = VERSION_ID " " BETA_INFO; 33 | #endif 34 | return rv; 35 | } 36 | 37 | int 38 | doversion(const struct nh_cmd_arg *arg) 39 | { 40 | (void) arg; 41 | 42 | pline(msgc_info, "%s", getversionstring()); 43 | return 0; 44 | } 45 | 46 | 47 | boolean 48 | check_version(struct version_info * version_data, const char *filename, 49 | boolean complain) 50 | { 51 | if ( 52 | #ifdef VERSION_COMPATIBILITY 53 | version_data->incarnation < VERSION_COMPATIBILITY || 54 | version_data->incarnation > VERSION_NUMBER 55 | #else 56 | version_data->incarnation != VERSION_NUMBER 57 | #endif 58 | ) { 59 | if (complain) 60 | pline(msgc_saveload, "Version mismatch for file \"%s\".", filename); 61 | return FALSE; 62 | } else if (version_data->feature_set != VERSION_FEATURES 63 | /* || version_data->entity_count != VERSION_SANITY1 */) { 64 | if (complain) 65 | pline(msgc_saveload, 66 | "Configuration incompatibility for file \"%s\".", filename); 67 | return FALSE; 68 | } 69 | return TRUE; 70 | } 71 | 72 | /* this used to be based on file date and somewhat OS-dependent, 73 | but now examines the initial part of the file's contents */ 74 | boolean 75 | uptodate(struct memfile * mf, const char *name) 76 | { 77 | struct version_info vers_info; 78 | boolean verbose = name ? TRUE : FALSE; 79 | 80 | vers_info.incarnation = mread32(mf); 81 | vers_info.feature_set = mread32(mf); 82 | vers_info.entity_count = mread32(mf); 83 | if (!check_version(&vers_info, name, verbose)) 84 | return FALSE; 85 | 86 | return TRUE; 87 | } 88 | 89 | void 90 | store_version(struct memfile *mf) 91 | { 92 | mtag(mf, 0, MTAG_VERSION); 93 | mwrite32(mf, VERSION_NUMBER); 94 | mwrite32(mf, VERSION_FEATURES); 95 | mwrite32(mf, VERSION_SANITY1); 96 | return; 97 | } 98 | 99 | 100 | /*version.c*/ 101 | -------------------------------------------------------------------------------- /libnethack/util/checkglobals.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Last modified by Alex Smith, 2015-07-20 3 | # Copyright (C) 2013, 2015 Alex Smith 4 | # NetHack may be freely redistributed. See license for details. 5 | for x in `nm "$1" | egrep -v '^[0-9a-f]* *[tTrUwAd]' | sort -k1.20 | cut -c20-` 6 | do 7 | echo "warning: found static or global variable $x" 1>&2 8 | done 9 | -------------------------------------------------------------------------------- /libnethack/util/dgn_comp.l: -------------------------------------------------------------------------------- 1 | %{ 2 | /* Last modified by Sean Hunt, 2014-10-17 */ 3 | /* Copyright (c) 1989 by Jean-Christophe Collet */ 4 | /* Copyright (c) 1990 by M. Stephenson */ 5 | /* NetHack may be freely redistributed. See license for details. */ 6 | 7 | #define DGN_COMP 8 | 9 | #include "config.h" 10 | #include "dgn_comp.h" 11 | #include "dgn_file.h" 12 | #include "dgn_compiler.h" 13 | 14 | #ifdef FLEX_SCANNER 15 | #define YY_MALLOC_DECL \ 16 | void * malloc(size_t); \ 17 | void * realloc(void *,size_t); 18 | #define YY_NO_INPUT 19 | #endif 20 | 21 | /* this doesn't always get put in dgn_comp.h 22 | * (esp. when using older versions of bison) 23 | */ 24 | 25 | extern YYSTYPE yylval; 26 | 27 | int line_number = 1; 28 | 29 | #ifdef __clang__ 30 | /* We can't control the generated code, so we have to disable the warning 31 | * instead. Otherwise, it will complain about yy_fatal_error and various 32 | * shadowed variables. */ 33 | # pragma clang diagnostic ignored "-Wmissing-noreturn" 34 | # pragma clang diagnostic ignored "-Wshadow" 35 | # pragma clang diagnostic ignored "-Wmissing-variable-declarations" 36 | #endif 37 | 38 | %} 39 | %option nounput 40 | %% 41 | DUNGEON return A_DUNGEON; 42 | up { yylval.i=1; return UP_OR_DOWN; } 43 | down { yylval.i=0; return UP_OR_DOWN; } 44 | ENTRY return ENTRY; 45 | stair return STAIR; 46 | no_up return NO_UP; 47 | no_down return NO_DOWN; 48 | portal return PORTAL; 49 | PROTOFILE return PROTOFILE; 50 | DESCRIPTION return DESCRIPTION; 51 | LEVELDESC return LEVELDESC; 52 | ALIGNMENT return ALIGNMENT; 53 | LEVALIGN return LEVALIGN; 54 | town { yylval.i=TOWN ; return DESCRIPTOR; } 55 | hellish { yylval.i=HELLISH ; return DESCRIPTOR; } 56 | mazelike { yylval.i=MAZELIKE ; return DESCRIPTOR; } 57 | roguelike { yylval.i=ROGUELIKE ; return DESCRIPTOR; } 58 | unaligned { yylval.i=D_ALIGN_NONE ; return DESCRIPTOR; } 59 | noalign { yylval.i=D_ALIGN_NONE ; return DESCRIPTOR; } 60 | lawful { yylval.i=D_ALIGN_LAWFUL ; return DESCRIPTOR; } 61 | neutral { yylval.i=D_ALIGN_NEUTRAL ; return DESCRIPTOR; } 62 | chaotic { yylval.i=D_ALIGN_CHAOTIC ; return DESCRIPTOR; } 63 | BRANCH return BRANCH; 64 | CHAINBRANCH return CHBRANCH; 65 | LEVEL return LEVEL; 66 | RNDLEVEL return RNDLEVEL; 67 | CHAINLEVEL return CHLEVEL; 68 | RNDCHLEVEL return RNDCHLEVEL; 69 | [-0-9]+ { yylval.i=atoi(yytext); return INTEGER; } 70 | \"[^"]*\" { yytext[yyleng-1] = 0; /* Discard the trailing \" */ 71 | yylval.str = malloc(strlen(yytext+1)+1); 72 | strcpy(yylval.str, yytext+1); /* Discard the first \" */ 73 | return STRING; } 74 | ^#.*\n { line_number++; } 75 | \r?\n { line_number++; } 76 | [ \t]+ ; /* skip trailing tabs & spaces */ 77 | . { return yytext[0]; } 78 | %% 79 | 80 | /* routine to switch to another input file; needed for flex */ 81 | void init_yyin( FILE *input_f ) 82 | { 83 | #if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER) 84 | if (yyin) 85 | yyrestart(input_f); 86 | else 87 | #endif 88 | yyin = input_f; 89 | } 90 | /* analogous routine (for completeness) */ 91 | void init_yyout( FILE *output_f ) 92 | { 93 | yyout = output_f; 94 | } 95 | 96 | /*dgn_comp.l*/ 97 | 98 | -------------------------------------------------------------------------------- /libnethack/util/dgn_compiler.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Sean Hunt, 2014-10-17 */ 3 | /* Copyright (c) 2014 by Sean Hunt */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef DGN_COMPILER_H 7 | #define DGN_COMPILER_H 8 | 9 | #include "config.h" 10 | 11 | /* dgn_comp.l */ 12 | void init_yyin(FILE *); 13 | void init_yyout(FILE *); 14 | int yylex(void); 15 | 16 | /* dgn_comp.y */ 17 | int yyparse(void); 18 | 19 | /* dgn_main.c */ 20 | void yyerror(const char *); 21 | void yywarning(const char *); 22 | int yywrap(void); 23 | 24 | /* dgn_comp.l */ 25 | extern int line_number; 26 | extern FILE *yyout; 27 | 28 | /* dgn_main.c */ 29 | extern const char *fname; 30 | extern int fatal_error; 31 | 32 | #endif /* DGN_COMPILER_H */ 33 | -------------------------------------------------------------------------------- /libnethack/util/lev_compiler.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Sean Hunt, 2014-10-17 */ 3 | /* Copyright (c) 2014 by Sean Hunt */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef LEV_COMPILER_H 7 | #define LEV_COMPILER_H 8 | 9 | #include "config.h" 10 | #include "hack.h" 11 | #include "verinfo.h" 12 | #include "sp_lev.h" 13 | #ifdef STRICT_REF_DEF 14 | # include "tcap.h" 15 | #endif 16 | 17 | /* lev_comp.l */ 18 | void init_yyin(FILE *); 19 | void init_yyout(FILE *); 20 | int yylex(void); 21 | 22 | /* lev_comp.y */ 23 | int yyparse(void); 24 | 25 | /* lev_main.c */ 26 | void yyerror(const char *); 27 | void yywarning(const char *); 28 | int yywrap(void); 29 | int get_floor_type(char); 30 | int get_room_type(char *); 31 | int get_trap_type(char *); 32 | int get_monster_id(char *,char); 33 | int get_object_id(char *,char); 34 | boolean check_monster_char(char); 35 | boolean check_object_char(char); 36 | char what_map_char(char); 37 | void scan_map(char *); 38 | void wallify_map(void); 39 | boolean check_subrooms(void); 40 | void check_coord(int,int,const char *); 41 | void store_part(void); 42 | void store_room(void); 43 | boolean write_level_file(char *,splev *,specialmaze *); 44 | void free_rooms(splev *); 45 | 46 | /* lev_comp.y */ 47 | extern char tmpmessage[]; 48 | extern char tmphallumsg[]; 49 | extern altar *tmpaltar[]; 50 | extern lad *tmplad[]; 51 | extern stair *tmpstair[]; 52 | extern digpos *tmpdig[]; 53 | extern digpos *tmppass[]; 54 | extern char *tmpmap[]; 55 | extern region *tmpreg[]; 56 | extern lev_region *tmplreg[]; 57 | extern door *tmpdoor[]; 58 | extern room_door *tmprdoor[]; 59 | extern trap *tmptrap[]; 60 | extern monster *tmpmonst[]; 61 | extern object *tmpobj[]; 62 | extern drawbridge *tmpdb[]; 63 | extern walk *tmpwalk[]; 64 | extern gold *tmpgold[]; 65 | extern fountain *tmpfountain[]; 66 | extern sink *tmpsink[]; 67 | extern pool *tmppool[]; 68 | extern engraving *tmpengraving[]; 69 | extern mazepart *tmppart[]; 70 | extern room *tmproom[]; 71 | 72 | extern int n_olist, n_mlist, n_plist; 73 | 74 | extern unsigned int nlreg, nreg, ndoor, ntrap, nmons, nobj; 75 | extern unsigned int ndb, nwalk, npart, ndig, npass, nlad, nstair; 76 | extern unsigned int naltar, ncorridor, nrooms, ngold, nengraving; 77 | extern unsigned int nfountain, npool, nsink; 78 | 79 | extern unsigned int max_x_map, max_y_map; 80 | 81 | extern int line_number, colon_line_number; 82 | 83 | /* lev_main.c */ 84 | extern const char *fname; 85 | extern int fatal_error; 86 | extern int want_warnings; 87 | 88 | #endif /* LEV_COMPILER_H */ 89 | -------------------------------------------------------------------------------- /libnethack/util/savemap.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Last modified by Alex Smith, 2014-11-23 3 | # savemap: Reads save.c and similar files and maps byte offsets to 4 | # variable names, dumping the results (typically to savemap.txt) for 5 | # debugging purposes. 6 | # 7 | # This file is free software; you can redistribute it and/or modify 8 | # it under the terms of the MIT license. See copyright for details. 9 | # 10 | # Copyright © 2014 Derrick Sund. 11 | use utf8; # this source file is UTF-8 12 | use warnings; 13 | use strict; 14 | 15 | if ($#ARGV < 1) { 16 | print "Usage: savemap.pl file file...\n"; 17 | print "inputs: the C files to scan, such as ../src/*.c\n"; 18 | print "output goes to stdout\n"; 19 | exit; 20 | } 21 | 22 | #The current tag. Empty string if we don't have one. 23 | my $tag = ""; 24 | my $tag_was_written = 0; 25 | my $offset = 0; 26 | 27 | while (my $line = <>) { 28 | #First, try to find a tag if we don't have one. 29 | if (!$tag) { 30 | if (index($line, "mtag") != -1) { 31 | $tag = $line; 32 | $tag =~ m/([A-Z]+_[A-Z]+)/; 33 | $tag = $1; 34 | $offset = 0; 35 | $tag_was_written = 0; 36 | } 37 | next; 38 | } 39 | 40 | #We have a tag. Now see if the line is an mwrite. 41 | $line =~s/^\s+//; 42 | #Skip whitespace lines, lines we're told to ignore, and lines with no 43 | #semicolon (which are part of a longer statement that we can ignore as 44 | #a block). 45 | if (!$line || $line =~ /savemap: ignore/ || $line !~ /;|savemap:/) { 46 | next; 47 | } 48 | 49 | unless ($line =~ /savemap: (\d+)/ || $line =~ /mwrite(\d+)/) { 50 | #It's a non-whitespace line that isn't mwrite and doesn't have 51 | #a comment for savemap; our tag has expired. 52 | $tag = ""; 53 | print "\n"; 54 | next; 55 | } 56 | 57 | my $offset_increase = $1 / 8; 58 | 59 | if(!$tag_was_written) { 60 | print "Current tag: $tag\n"; 61 | $tag_was_written = 1; 62 | } 63 | 64 | $line =~ m/(\s[][\w.\->]+)/; 65 | print "$1 $offset\n"; 66 | 67 | $offset += $offset_increase; 68 | } 69 | -------------------------------------------------------------------------------- /libnethack_client/.gitignore: -------------------------------------------------------------------------------- 1 | # Last modified by Alex Smith, 2013-09-21 2 | libnethack_client.dylib 3 | -------------------------------------------------------------------------------- /libnethack_client/include/nhclient.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-07-07 */ 3 | #ifndef NHCLIENT_H 4 | # define NHCLIENT_H 5 | 6 | # define NETHACK_CLIENT_H_IN_LIBNETHACK_CLIENT 7 | # include "nethack.h" 8 | # include "nethack_client.h" 9 | # include "netconnect.h" 10 | 11 | # include 12 | # include 13 | # include 14 | # include 15 | # include 16 | # include 17 | 18 | # include 19 | 20 | # define DEFAULT_PORT 53430 21 | 22 | extern struct nh_window_procs client_windowprocs; 23 | extern int current_game; 24 | extern jmp_buf ex_jmp_buf; 25 | extern int ex_jmp_buf_valid; 26 | extern int conn_err; 27 | extern int error_retry_ok; 28 | extern char saved_password[]; 29 | 30 | /* connection.c */ 31 | extern void print_error(const char *msg); 32 | extern json_t *send_receive_msg(const char *msgtype, json_t * jmsg); 33 | extern int restart_connection(void); 34 | 35 | /* netcmd.c */ 36 | extern json_t *handle_netcmd(const char *key, const char *expected, 37 | json_t *jmsg); 38 | extern void handle_display_list(json_t * display_list); 39 | 40 | # define api_entry() \ 41 | (!conn_err && (ex_jmp_buf_valid++ ? 1 : setjmp(ex_jmp_buf) ? 0 : 1)) 42 | # define api_exit() do {--ex_jmp_buf_valid; } while(0) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /libnethack_common/include/common_options.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2013-12-29 */ 3 | /* NetHack may be freely redistributed. See license for details. */ 4 | 5 | #ifndef COMMON_OPTIONS_H 6 | # define COMMON_OPTIONS_H 7 | 8 | # ifdef IN_LIBNETHACK_COMMON 9 | # define EXPORT(x) x 10 | # else 11 | # define EXPORT(x) x 12 | # endif 13 | 14 | # include "nethack_types.h" 15 | 16 | struct nhlib_boolopt_map { 17 | const char *optname; 18 | nh_bool *addr; 19 | }; 20 | 21 | extern struct nh_option_desc *EXPORT(nhlib_find_option)( 22 | struct nh_option_desc *optlist, const char *name); 23 | 24 | extern const struct nh_option_desc *EXPORT(nhlib_const_find_option)( 25 | const struct nh_option_desc *optlist, const char *name); 26 | 27 | extern nh_bool *EXPORT(nhlib_find_boolopt)( 28 | const struct nhlib_boolopt_map *map, const char *name); 29 | 30 | extern union nh_optvalue EXPORT(nhlib_string_to_optvalue)( 31 | const struct nh_option_desc *option, char *str); 32 | 33 | extern char *EXPORT(nhlib_optvalue_to_string)( 34 | const struct nh_option_desc *opt); 35 | 36 | /* Parse new autopickup rules, allocated on the heap */ 37 | extern struct nh_autopickup_rules *EXPORT(nhlib_parse_autopickup_rules)( 38 | const char *str); 39 | 40 | extern nh_bool EXPORT(nhlib_option_value_ok)( 41 | const struct nh_option_desc *option, union nh_optvalue value); 42 | 43 | /* Create a new copy of some autopickup rules, allocated on the heap */ 44 | extern struct nh_autopickup_rules *EXPORT(nhlib_copy_autopickup_rules)( 45 | const struct nh_autopickup_rules *in); 46 | 47 | /* Copy the option value into the existing option. Pointed-to objects are 48 | * reallocated if necessary and the old ones freed. */ 49 | extern nh_bool EXPORT(nhlib_copy_option_value)( 50 | struct nh_option_desc *option, union nh_optvalue value); 51 | 52 | extern void EXPORT(nhlib_free_optlist)( 53 | struct nh_option_desc *opt); 54 | 55 | extern struct nh_option_desc *EXPORT(nhlib_clone_optlist)( 56 | const struct nh_option_desc *opt); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /libnethack_common/include/hacklib.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-07-21 */ 3 | /* Copyright (c) Steve Creps, 1988. */ 4 | /* Copyright (c) Alex Smith, 2013. */ 5 | /* NetHack may be freely redistributed. See license for details. */ 6 | 7 | #ifndef HACKLIB_H 8 | # define HACKLIB_H 9 | 10 | # include "config.h" 11 | 12 | extern char *tabexpand(char *); /* TODO: Bounds check */ 13 | extern boolean letter(char); 14 | extern boolean digit(char); 15 | extern char lowc(char); 16 | extern char highc(char); 17 | extern char *mungspaces(char *); 18 | extern char *xcrypt(const char *, char *); 19 | extern int base85enclen(int); 20 | extern int base85declen(int); 21 | extern int base85enc(const unsigned char *, int, char *); 22 | extern int base85dec(const char *, unsigned char *); 23 | extern boolean onlyspace(const char *); 24 | extern boolean onlynul(const void *, int); 25 | extern const char *ordin(int); 26 | extern int sgn(int); 27 | extern int rounddiv(long, int); 28 | extern long long isqrt(long long); 29 | extern long long ilog2(long long); 30 | extern int popcount(unsigned long long); 31 | extern int nextprime(int); 32 | extern int dist2(int, int, int, int); 33 | extern int distmin(int, int, int, int); 34 | extern boolean online2(int, int, int, int); 35 | extern boolean pmatch(const char *, const char *); 36 | 37 | # ifndef STRSTRI 38 | extern const char *strstri(const char *, const char *); 39 | # endif 40 | extern char *strstri_mutable(char *, const char *); 41 | 42 | extern boolean fuzzymatch(const char *, const char *, const char *, boolean); 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /libnethack_common/include/mail.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2018-01-05 */ 3 | /* Copyright (c) Fredrik Ljungdahl, 2018. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "compilers.h" 7 | 8 | #ifndef MAIL_H 9 | # define MAIL_H 10 | 11 | extern const char *mail_filename(char *); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /libnethack_common/include/menulist.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-10 */ 3 | /* Copyright (c) Alex Smith, 2013. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef MENULIST_H 7 | # define MENULIST_H 8 | 9 | # include "nethack_types.h" 10 | 11 | extern void set_menuitem(struct nh_menuitem *, int, enum nh_menuitem_role, 12 | const char *, char, nh_bool); 13 | extern void add_menu_item(struct nh_menulist *, int, 14 | const char *, char, nh_bool); 15 | extern void add_menu_txt(struct nh_menulist *, const char *, 16 | enum nh_menuitem_role); 17 | extern void init_menulist(struct nh_menulist *); 18 | extern void dealloc_menulist(struct nh_menulist *); 19 | 20 | extern void init_objmenulist(struct nh_objlist *); 21 | extern void dealloc_objmenulist(struct nh_objlist *); 22 | 23 | extern void null_menu_callback(const int *, int, void *); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libnethack_common/include/netconnect.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2017-09-01 */ 3 | /* Copyright (c) Daniel Thaler, 2012. */ 4 | /* Copyright (c) 2014 Alex Smith. */ 5 | /* This network connection library may be freely redistributed under the terms of 6 | * either: 7 | * - the NetHack license 8 | * - the GNU General Public license v2 or later 9 | * Note that you do not have a warranty under either license. 10 | */ 11 | 12 | #ifndef NETCONNECT_H 13 | # define NETCONNECT_H 14 | 15 | # include "nethack_types.h" 16 | # include 17 | # include 18 | # include 19 | # include 20 | 21 | /* We don't have nethack_types to help us out with OS detection when 22 | calculating dependencies, so redo the calculation here. */ 23 | # if defined(UNIX) || (!defined(WIN32) && !defined(AIMAKE_BUILDOS_MSWin32)) 24 | # include 25 | # include 26 | # include 27 | # include 28 | # include 29 | # include 30 | # include 31 | # include 32 | # else 33 | # include 34 | # include 35 | # include 36 | 37 | # define snprintf(buf, len, fmt, ...) \ 38 | _snprintf_s(buf, len, len-1, fmt, __VA_ARGS__) 39 | # define close closesocket 40 | 41 | /* TODO: Find the header file this is defined in, and include it. */ 42 | extern int _snprintf_s(char *, size_t, size_t, const char *, ...); 43 | 44 | # endif 45 | 46 | extern int parse_ip_addr(const char *host, int port, int want_v4, 47 | struct sockaddr_storage *out, int *errcode); 48 | extern int connect_server(const char *host, int port, int want_v4, 49 | char *errmsg, int msglen); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /libnethack_common/include/nethack.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2018-04-06 */ 3 | /* NetHack may be freely redistributed. See license for details. */ 4 | 5 | /* this header defines the interface between libnethack and window ports 6 | * it should never include any private headers, as those are not on the 7 | * search path for window ports. */ 8 | 9 | #ifndef NETHACK_H 10 | # define NETHACK_H 11 | 12 | /* NetHack 4.3.0. Keep this consistent with patchlevel.h. */ 13 | /* (Note that the number in patchlevel.h may be older than the number 14 | here, if save/bones compatibility is not broken between versions.) */ 15 | # define VERSION_MAJOR 4 16 | # define VERSION_MINOR 3 17 | # define PATCHLEVEL 1 18 | 19 | # include "nethack_types.h" 20 | 21 | /* We want to export these symbols if in libnethack, import them otherwise. 22 | This is so much simpler than the code that was here before. Thanks, 23 | aimake! */ 24 | # ifdef NETHACK_H_IN_LIBNETHACK 25 | # define EXPORT(x) AIMAKE_EXPORT(x) 26 | # else 27 | # define EXPORT(x) AIMAKE_IMPORT(x) 28 | # endif 29 | 30 | /* allmain.c */ 31 | extern void EXPORT(nh_lib_init) (const struct nh_window_procs *, 32 | const char *const *paths); 33 | extern void EXPORT(nh_lib_exit) (void); 34 | extern nh_bool EXPORT(nh_exit_game) (int exit_type); 35 | extern enum nh_play_status EXPORT (nh_play_game) (int fd, enum nh_followmode); 36 | 37 | extern enum nh_create_response EXPORT(nh_create_game) ( 38 | int fd, struct nh_option_desc *opts); 39 | extern const_char_p_const_p EXPORT(nh_get_copyright_banner) (void); 40 | 41 | /* log.c */ 42 | extern enum nh_log_status EXPORT(nh_get_savegame_status) ( 43 | int fd, struct nh_game_info *si); 44 | 45 | /* cmd.c */ 46 | extern nh_cmd_desc_p EXPORT(nh_get_commands) (int *count); 47 | extern nh_cmd_desc_p EXPORT(nh_get_object_commands) (int *count, char invlet); 48 | 49 | /* drawing.c */ 50 | extern nh_drawing_info_p EXPORT(nh_get_drawing_info) (void); 51 | 52 | /* options.c */ 53 | extern nh_bool EXPORT(nh_set_option) ( 54 | const char *name, union nh_optvalue value); 55 | extern nh_option_desc_p EXPORT(nh_get_options) (void); 56 | 57 | /* pager.c */ 58 | extern void EXPORT(nh_describe_pos) ( 59 | int x, int y, struct nh_desc_buf *bufs, int *is_in); 60 | 61 | /* role.c */ 62 | extern nh_roles_info_p EXPORT(nh_get_roles) (void); 63 | extern char_p EXPORT(nh_build_plselection_prompt) ( 64 | char *, int, int, int, int, int); 65 | extern const_char_p EXPORT(nh_root_plselection_prompt) ( 66 | char *, int, int, int, int, int); 67 | 68 | /* topten.c */ 69 | extern nh_topten_entry_p EXPORT(nh_get_topten) ( 70 | int *out_len, char *statusbuf, const char *player, int top, 71 | int around, nh_bool own); 72 | 73 | # undef EXPORT 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /libnethack_common/include/nethack_client.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-07-07 */ 3 | /* NetHack may be freely redistributed. See license for details. */ 4 | 5 | #ifndef NETHACK_CLIENT_H 6 | # define NETHACK_CLIENT_H 7 | 8 | # include "nethack_types.h" 9 | 10 | # ifdef NETHACK_CLIENT_H_IN_LIBNETHACK_CLIENT 11 | # define EXPORT(x) AIMAKE_EXPORT(x) 12 | # else 13 | # define EXPORT(x) AIMAKE_IMPORT(x) 14 | # endif 15 | 16 | enum authresult { 17 | NO_CONNECTION, 18 | AUTH_FAILED_UNKNOWN_USER, 19 | AUTH_FAILED_BAD_PASSWORD, 20 | AUTH_SUCCESS_NEW 21 | }; 22 | 23 | 24 | struct nhnet_game { 25 | int gameid; 26 | enum nh_log_status status; 27 | struct nh_game_info i; 28 | }; 29 | 30 | 31 | struct nhnet_server_version { 32 | int major, minor, patchlevel; 33 | }; 34 | 35 | extern struct nhnet_server_version EXPORT(nhnet_server_ver); 36 | 37 | 38 | extern int EXPORT(nhnet_connect) ( 39 | const char *host, int port, const char *user, 40 | const char *pass, const char *email, int reg_user); 41 | extern void EXPORT(nhnet_disconnect) (void); 42 | extern int EXPORT(nhnet_connected) (void); 43 | extern int EXPORT(nhnet_active) (void); 44 | extern nhnet_game_p EXPORT(nhnet_list_games) ( 45 | int done, int show_all, int *count); 46 | 47 | extern int EXPORT(nhnet_get_socket_fd) (void); 48 | extern void EXPORT(nhnet_check_socket_fd) (void); 49 | 50 | extern void EXPORT(nhnet_lib_init) (const struct nh_window_procs *); 51 | extern void EXPORT(nhnet_lib_exit) (void); 52 | extern nh_bool EXPORT(nhnet_exit_game) (int exit_type); 53 | extern int EXPORT(nhnet_play_game) (int gid, enum nh_followmode); 54 | extern enum nh_create_response EXPORT(nhnet_create_game) ( 55 | struct nh_option_desc *opts); 56 | /* no nhnet_get_copyright_banner; the client should display its own copyright */ 57 | extern nh_cmd_desc_p EXPORT(nhnet_get_commands) (int *count); 58 | extern nh_cmd_desc_p EXPORT(nhnet_get_object_commands) ( 59 | int *count, char invlet); 60 | extern nh_drawing_info_p EXPORT(nhnet_get_drawing_info) (void); 61 | extern nh_bool EXPORT(nhnet_set_option) ( 62 | const char *name, union nh_optvalue value); 63 | extern nh_option_desc_p EXPORT(nhnet_get_options) (void); 64 | /* no nhnet_get_option_string; the client translates the values locally */ 65 | extern void EXPORT(nhnet_describe_pos) ( 66 | int x, int y, struct nh_desc_buf *bufs, int *is_in); 67 | extern nh_roles_info_p EXPORT(nhnet_get_roles) (void); 68 | extern char_p EXPORT(nhnet_build_plselection_prompt) ( 69 | char *, int, int, int, int, int); 70 | extern const_char_p EXPORT(nhnet_root_plselection_prompt) ( 71 | char *, int, int, int, int, int); 72 | extern nh_topten_entry_p EXPORT(nhnet_get_topten) ( 73 | int *out_len, char *statusbuf, const char *player, int top, 74 | int around, nh_bool own); 75 | extern int EXPORT(nhnet_change_email) (const char *email); 76 | extern int EXPORT(nhnet_change_password) (const char *password); 77 | 78 | # undef EXPORT 79 | 80 | # if defined(NHNET_TRANSPARENT) && \ 81 | !defined(NETHACK_CLIENT_H_IN_LIBNETHACK_CLIENT) 82 | # define nh_play_game nhnet_play_game 83 | # define nh_exit_game nhnet_exit_game 84 | # define nh_get_commands nhnet_get_commands 85 | # define nh_get_object_commands nhnet_get_object_commands 86 | # define nh_get_drawing_info nhnet_get_drawing_info 87 | # define nh_set_option nhnet_set_option 88 | # define nh_get_options nhnet_get_options 89 | # define nh_describe_pos nhnet_describe_pos 90 | # define nh_get_roles nhnet_get_roles 91 | # define nh_build_plselection_prompt nhnet_build_plselection_prompt 92 | # define nh_root_plselection_prompt nhnet_root_plselection_prompt 93 | # define nh_get_topten nhnet_get_topten 94 | # endif 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /libnethack_common/include/trietable.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-07-22 */ 3 | /* Copyright (c) Alex Smith, 2015. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "compilers.h" 7 | 8 | #ifndef TRIETABLE_H 9 | # define TRIETABLE_H 10 | 11 | /* 12 | * A trietable associates positive numeric keys with (arbitrary) values. The 13 | * values are here expressed via a void * pointer; the trietable does /not/ own 14 | * the values pointed to via these pointers. 15 | * 16 | * The trietable itself is a mutable struct trietable * (i.e. you have to pass 17 | * around a pointer to it to the trietable functions). An empty trietable is 18 | * a NULL pointer. Trietables have internal state that's allocated via malloc; 19 | * however, after emptying one, it goes back to being a NULL pointer with no 20 | * allocated internal state. 21 | * 22 | * The actual implementation is recursive: 23 | * 24 | * - An empty trietable is a NULL pointer; 25 | * - A trietable containing one element has NULL ptr0 and ptr1, and stores that 26 | * element in key and value; 27 | * - A trietable containing more than one element contains: 28 | * - the element with key 0 (if any) in key and value; 29 | * - a trietable of all the elements with even keys in ptr0 (with those keys 30 | * halved); 31 | * - a trietable of all the elements with odd keys in ptr1 (with those keys 32 | * rounded down and halved). 33 | * 34 | * Note that this wold technically work even without the second case here, 35 | * which would mean we wouldn't need a key field. However, it would make tables 36 | * that were empty (or nearly so) a lot larger. (If key is not 0, that implies 37 | * that the table contains only one element. If key is 0, the table might still 38 | * only contain one element, in which case that element's key is 0.) 39 | */ 40 | struct trietable { 41 | struct trietable *ptr0; /* pointer for a 0 bit */ 42 | struct trietable *ptr1; /* pointer for a 1 bit */ 43 | void *value; /* value at this location */ 44 | unsigned key; /* key at this location */ 45 | }; 46 | 47 | /* The operations NetHack 4 actually uses: add, find, empty. Delete can be 48 | implemented in this data structure, but there hasn't been a need for it 49 | yet. Adding a key that already exists to a trietable will overwrite whatever 50 | is already there. */ 51 | extern void trietable_add(struct trietable **table, unsigned key, void *value); 52 | extern void *trietable_find(struct trietable **table, unsigned key); 53 | extern void trietable_empty(struct trietable **table); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libnethack_common/include/utf8conv.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-03-18 */ 3 | /* Copyright (C) 2014 Alex Smith. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef COMMON_UTF8CONV_H 7 | # define COMMON_UTF8CONV_H 8 | 9 | # ifdef IN_LIBNETHACK_COMMON 10 | # define EXPORT(x) x 11 | # else 12 | # define EXPORT(x) x 13 | # endif 14 | 15 | # include "nethack_types.h" 16 | # include 17 | 18 | extern unsigned long decode_one_utf8_character(const char **); 19 | extern unsigned long EXPORT(utf8towc)(const char *); 20 | extern void EXPORT(wctoutf8)(unsigned long, char [static 7]); 21 | extern size_t EXPORT(utf8_mbstowcs)(wchar_t *, const char *, size_t); 22 | extern int EXPORT(utf8_wcswidth)(const char *, size_t); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libnethack_common/include/xmalloc.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-04-05 */ 3 | /* Copyright (c) Daniel Thaler, 2011. */ 4 | /* Copyright (c) Alex Smith, 2013. */ 5 | /* NetHack may be freely redistributed. See license for details. */ 6 | 7 | #include "compilers.h" 8 | #include /* for size_t */ 9 | #include /* for va_list */ 10 | 11 | struct tm; 12 | 13 | #ifndef XMALLOC_H 14 | # define XMALLOC_H 15 | 16 | struct xmalloc_block { 17 | void *mem; 18 | struct xmalloc_block *next; 19 | }; 20 | 21 | extern void *xmalloc(struct xmalloc_block **blocklist, size_t size); 22 | extern void xmalloc_cleanup(struct xmalloc_block **blocklist); 23 | extern void *xrealloc(struct xmalloc_block **blocklist, void *ptr, size_t size); 24 | extern char *xmvasprintf(struct xmalloc_block **blocklist, 25 | const char *fmt, va_list args) PRINTFLIKE(2,0); 26 | extern char *xmastrftime(struct xmalloc_block **blocklist, 27 | const char *fmt, 28 | const struct tm *tm) STRFTIMELIKE(2,0); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /libnethack_common/src/mail.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2018-01-05 */ 3 | /* Copyright (c) Fredrik Ljungdahl, 2018. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "mail.h" 7 | #include "nethack_types.h" 8 | #include 9 | #include 10 | #ifdef UNIX 11 | # include 12 | # include 13 | #endif 14 | 15 | #ifndef MAILBOXENVVAR 16 | /* Server admins: you can use -DMAILBOXENVVAR in CFLAGS to set the name of this 17 | environment variable. The game will then check for the variable you specify 18 | in the environment at runtime to know where to look for the mailbox file. */ 19 | # define MAILBOXENVVAR "NHMAILBOX" 20 | #endif 21 | 22 | # define MAILERROR(str) \ 23 | do { \ 24 | if (error) { \ 25 | strncpy(error, (str), BUFSZ); \ 26 | error[BUFSZ - 1] = '\0'; \ 27 | } \ 28 | return NULL; \ 29 | } while (0) 30 | 31 | /* Returns mail filename, or NULL if we encounter an error. If error isn't NULL, 32 | it is populated with an error message. 33 | error is assumed to be of size BUFSZ. */ 34 | const char * 35 | mail_filename(char *error) 36 | { 37 | #ifndef UNIX 38 | MAILERROR("Mail isn't available on this operating system."); 39 | #else 40 | if (getgid() != getegid() || getuid() != geteuid()) 41 | MAILERROR("You're not allowed to send mail in this environment."); 42 | 43 | const char *box = getenv(MAILBOXENVVAR); 44 | if (!box) 45 | MAILERROR("Mail is disabled in this installation."); 46 | 47 | return box; 48 | #endif 49 | } 50 | -------------------------------------------------------------------------------- /libnethack_common/src/menulist.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-11-11 */ 3 | /* Copyright (c) Alex Smith, 2013. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "menulist.h" 7 | #include 8 | #include 9 | 10 | /* Ensures that the given menu list has space for at least one more item. */ 11 | static void 12 | expand_menulist(struct nh_menulist *ml) 13 | { 14 | if (!ml->size && ml->items) 15 | return; /* memory is managed statically */ 16 | 17 | if (ml->icount >= ml->size) { 18 | if (ml->size < 2) 19 | ml->size = 2; 20 | ml->size *= 2; 21 | ml->items = realloc(ml->items, ml->size * sizeof *(ml->items)); 22 | if (!ml->items) /* out of memory */ 23 | abort(); 24 | } 25 | } 26 | 27 | void 28 | init_menulist(struct nh_menulist *ml) 29 | { 30 | ml->items = 0; 31 | ml->size = 0; 32 | ml->icount = 0; 33 | } 34 | 35 | void 36 | dealloc_menulist(struct nh_menulist *ml) 37 | { 38 | if (!ml->size && ml->items) 39 | return; /* memory is managed statically */ 40 | 41 | free(ml->items); 42 | init_menulist(ml); 43 | } 44 | 45 | 46 | void 47 | init_objmenulist(struct nh_objlist *ml) 48 | { 49 | ml->items = 0; 50 | ml->size = 0; 51 | ml->icount = 0; 52 | } 53 | 54 | void 55 | dealloc_objmenulist(struct nh_objlist *ml) 56 | { 57 | if (!ml->size && ml->items) 58 | return; /* memory is managed statically */ 59 | 60 | free(ml->items); 61 | init_objmenulist(ml); 62 | } 63 | 64 | 65 | void 66 | set_menuitem(struct nh_menuitem *item, int id, enum nh_menuitem_role role, 67 | const char *caption, char accel, nh_bool selected) 68 | { 69 | item->id = id; 70 | item->role = role; 71 | item->accel = accel; 72 | item->group_accel = 0; 73 | item->selected = selected; 74 | item->level = 0; 75 | 76 | strncpy(item->caption, caption, (sizeof item->caption) - 1); 77 | item->caption[(sizeof item->caption) - 1] = '\0'; 78 | } 79 | 80 | void 81 | add_menu_item(struct nh_menulist *ml, int id, const char *caption, 82 | char accel, nh_bool selected) 83 | { 84 | expand_menulist(ml); 85 | set_menuitem(ml->items + ml->icount, id, MI_NORMAL, 86 | caption, accel, selected); 87 | ml->icount++; 88 | } 89 | 90 | void 91 | add_menu_txt(struct nh_menulist *ml, const char *caption, 92 | enum nh_menuitem_role role) 93 | { 94 | expand_menulist(ml); 95 | set_menuitem(ml->items + ml->icount, 0, role, caption, 0, FALSE); 96 | ml->icount++; 97 | } 98 | 99 | 100 | void 101 | null_menu_callback(const int *results, int nresults, void *arg) 102 | { 103 | (void)results; 104 | (void)nresults; 105 | (void)arg; 106 | } 107 | -------------------------------------------------------------------------------- /libnethack_common/src/netconnect.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-10-05 */ 3 | /* Copyright (c) Daniel Thaler, 2012. */ 4 | /* Copyright (c) 2014 Alex Smith. */ 5 | /* This network connection library may be freely redistributed under the terms of 6 | * either: 7 | * - the NetHack license 8 | * - the GNU General Public license v2 or later 9 | * Note that you do not have a warranty under either license. 10 | */ 11 | 12 | #include "netconnect.h" 13 | 14 | /* convert a string (address or hosname) into an address */ 15 | int 16 | parse_ip_addr(const char *host, int port, int want_v4, 17 | struct sockaddr_storage *out, int *errcode) 18 | { 19 | int res; 20 | char portstr[16]; 21 | struct addrinfo *gai_res = NULL; 22 | struct addrinfo gai_hints; 23 | 24 | memset(&gai_hints, 0, sizeof (gai_hints)); 25 | #if defined(WIN32) || defined(AIMAKE_BUILDOS_darwin) 26 | gai_hints.ai_flags = 0; 27 | #else 28 | gai_hints.ai_flags = AI_NUMERICSERV; 29 | #endif 30 | gai_hints.ai_family = want_v4 ? AF_INET : AF_INET6; 31 | gai_hints.ai_socktype = SOCK_STREAM; 32 | 33 | snprintf(portstr, sizeof(portstr), "%d", port); 34 | 35 | res = getaddrinfo(host, portstr, &gai_hints, &gai_res); 36 | if (errcode) 37 | *errcode = res; 38 | 39 | if (res != 0 || !gai_res) 40 | return FALSE; 41 | if (want_v4) 42 | memcpy(out, gai_res->ai_addr, sizeof (struct sockaddr_in)); 43 | else 44 | memcpy(out, gai_res->ai_addr, sizeof (struct sockaddr_in6)); 45 | 46 | freeaddrinfo(gai_res); 47 | 48 | return TRUE; 49 | } 50 | 51 | int 52 | connect_server(const char *host, int port, int want_v4, char *errmsg, 53 | int msglen) 54 | { 55 | struct sockaddr_storage sa; 56 | int fd = -1; 57 | int errcode; 58 | 59 | errmsg[0] = '\0'; 60 | if (parse_ip_addr(host, port, want_v4, &sa, &errcode)) { 61 | fd = socket(sa.ss_family, SOCK_STREAM, 0); 62 | if (fd == -1) { 63 | snprintf(errmsg, msglen, "failed to create a socket: %s\n", 64 | strerror(errno)); 65 | return -1; 66 | } 67 | 68 | if (connect(fd, (struct sockaddr *)&sa, 69 | want_v4 ? sizeof (struct sockaddr_in) : 70 | sizeof (struct sockaddr_in6)) == -1) { 71 | snprintf(errmsg, msglen, "could not connect: %s\n", 72 | strerror(errno)); 73 | close(fd); 74 | return -1; 75 | } 76 | } else { 77 | snprintf(errmsg, msglen, "could not parse hostname: %s\n", 78 | gai_strerror(errcode)); 79 | } 80 | 81 | return fd; 82 | } 83 | -------------------------------------------------------------------------------- /libnethack_common/src/trietable.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-07-22 */ 3 | /* Copyright (c) Alex Smith, 2015. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "trietable.h" 7 | #include 8 | 9 | /* See trietable.h for information on what's going on here. */ 10 | 11 | void 12 | trietable_add(struct trietable **table, unsigned key, void *value) 13 | { 14 | if (*table == NULL) { 15 | *table = malloc(sizeof **table); 16 | (*table)->ptr0 = NULL; 17 | (*table)->ptr1 = NULL; 18 | (*table)->value = value; 19 | (*table)->key = key; 20 | } else if (key == 0) { 21 | unsigned oldkey = (*table)->key; 22 | void *oldvalue = (*table)->value; 23 | (*table)->key = 0; 24 | (*table)->value = value; 25 | if (oldkey != 0) 26 | trietable_add(table, oldkey, oldvalue); 27 | } else if (key & 1) 28 | trietable_add(&(*table)->ptr1, key >> 1, value); 29 | else 30 | trietable_add(&(*table)->ptr0, key >> 1, value); 31 | } 32 | 33 | /* Returns NULL on failure to find the key. */ 34 | void * 35 | trietable_find(struct trietable **table, unsigned key) 36 | { 37 | if (*table == NULL) 38 | return NULL; 39 | else if ((*table)->key == key) 40 | return (*table)->value; 41 | else if (key & 1) 42 | return trietable_find(&(*table)->ptr1, key >> 1); 43 | else 44 | return trietable_find(&(*table)->ptr0, key >> 1); 45 | } 46 | 47 | void 48 | trietable_empty(struct trietable **table) 49 | { 50 | if (*table == NULL) 51 | return; 52 | trietable_empty(&(*table)->ptr0); 53 | trietable_empty(&(*table)->ptr1); 54 | free(*table); 55 | *table = NULL; 56 | } 57 | -------------------------------------------------------------------------------- /libuncursed/include/uncursed_sdl.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-02-02 */ 3 | /* Copyright (c) 2013 Alex Smith. */ 4 | /* The 'uncursed' rendering library may be distributed under either of the 5 | * following licenses: 6 | * - the NetHack General Public License 7 | * - the GNU General Public License v2 or later 8 | * If you obtained uncursed as part of NetHack 4, you can find these licenses in 9 | * the files libnethack/dat/license and libnethack/dat/gpl respectively. 10 | */ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | struct uncursed_palette16; 16 | 17 | extern void sdl_hook_init(int *, int *, const char *); 18 | extern void sdl_hook_exit(void); 19 | extern void sdl_hook_beep(void); 20 | extern void sdl_hook_setcursorsize(int); 21 | extern void sdl_hook_positioncursor(int, int); 22 | extern void sdl_hook_setpalette16( const struct uncursed_palette16 *p ); 23 | extern void sdl_hook_resetpalette16(void); 24 | extern void sdl_hook_update(int, int); 25 | extern void sdl_hook_fullredraw(void); 26 | extern void sdl_hook_flush(void); 27 | extern void sdl_hook_set_faketerm_font_file(const char *); 28 | extern void sdl_hook_set_tiles_tile_file(const char *, int, int); 29 | extern void sdl_hook_get_tile_dimensions(int, int, int *, int *); 30 | extern void *sdl_hook_allocate_tiles_region(int, int, int, int, int, int); 31 | extern void sdl_hook_deallocate_tiles_region(void *); 32 | extern void sdl_hook_draw_tile_at(int, void *, int, int); 33 | extern void sdl_hook_delay(int); 34 | extern void sdl_hook_rawsignals(int); 35 | extern void sdl_hook_activatemouse(int); 36 | extern int sdl_hook_getkeyorcodepoint(int); 37 | extern void sdl_hook_signal_getch(void); 38 | extern void sdl_hook_watch_fd(int, int); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /libuncursed/include/uncursed_tty.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-02-02 */ 3 | /* Copyright (c) 2013 Alex Smith. */ 4 | /* The 'uncursed' rendering library may be distributed under either of the 5 | * following licenses: 6 | * - the NetHack General Public License 7 | * - the GNU General Public License v2 or later 8 | * If you obtained uncursed as part of NetHack 4, you can find these licenses in 9 | * the files libnethack/dat/license and libnethack/dat/gpl respectively. 10 | */ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | struct uncursed_palette16; 16 | 17 | extern void tty_hook_init(int *, int *, const char *); 18 | extern void tty_hook_exit(void); 19 | extern void tty_hook_beep(void); 20 | extern void tty_hook_setcursorsize(int); 21 | extern void tty_hook_positioncursor(int, int); 22 | extern void tty_hook_setpalette16( const struct uncursed_palette16 *p ); 23 | extern void tty_hook_resetpalette16(void); 24 | extern void tty_hook_update(int, int); 25 | extern void tty_hook_fullredraw(void); 26 | extern void tty_hook_flush(void); 27 | extern void tty_hook_delay(int); 28 | extern void tty_hook_rawsignals(int); 29 | extern void tty_hook_activatemouse(int); 30 | extern int tty_hook_getkeyorcodepoint(int); 31 | extern void tty_hook_signal_getch(void); 32 | extern void tty_hook_watch_fd(int, int); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /libuncursed/include/uncursed_wincon.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-05-24 */ 3 | /* Copyright (c) 2013 Alex Smith. */ 4 | /* The 'uncursed' rendering library may be distributed under either of the 5 | * following licenses: 6 | * - the NetHack General Public License 7 | * - the GNU General Public License v2 or later 8 | * If you obtained uncursed as part of NetHack 4, you can find these licenses in 9 | * the files libnethack/dat/license and libnethack/dat/gpl respectively. 10 | */ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | extern void wincon_hook_init(int *, int *, const char *); 17 | extern void wincon_hook_exit(void); 18 | extern void wincon_hook_beep(void); 19 | extern void wincon_hook_setcursorsize(int); 20 | extern void wincon_hook_positioncursor(int, int); 21 | extern void wincon_hook_update(int, int); 22 | extern void wincon_hook_fullredraw(void); 23 | extern void wincon_hook_flush(void); 24 | extern void wincon_hook_delay(int); 25 | extern void wincon_hook_rawsignals(int); 26 | extern void wincon_hook_activatemouse(int); 27 | extern int wincon_hook_getkeyorcodepoint(int); 28 | extern void wincon_hook_signal_getch(void); 29 | extern void wincon_hook_watch_fd(int, int); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /libuncursed/src/plugins/sdl.cxx: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c++;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Sean Hunt, 2014-12-29 */ 3 | /* Copyright (c) 2013 Alex Smith. */ 4 | /* The 'uncursed' rendering library may be distributed under either of the 5 | * following licenses: 6 | * - the NetHack General Public License 7 | * - the GNU General Public License v2 or later 8 | * If you obtained uncursed as part of NetHack 4, you can find these licenses in 9 | * the files libnethack/dat/license and libnethack/dat/gpl respectively. 10 | */ 11 | 12 | /* Plugin wrapper for the SDL 2 backend to the uncursed rendering library. 13 | Based on tty.cxx. */ 14 | 15 | /* Don't define UNCURSED_MAIN_PROGRAM; this goes into a separate library. */ 16 | #include "uncursed_hooks.h" 17 | #include "uncursed_sdl.h" 18 | 19 | static struct uncursed_hooks sdl_uncursed_hooks = { 20 | sdl_hook_init, 21 | sdl_hook_exit, 22 | sdl_hook_beep, 23 | sdl_hook_setcursorsize, 24 | sdl_hook_positioncursor, 25 | sdl_hook_resetpalette16, 26 | sdl_hook_setpalette16, 27 | sdl_hook_update, 28 | sdl_hook_fullredraw, 29 | sdl_hook_flush, 30 | sdl_hook_set_faketerm_font_file, 31 | sdl_hook_set_tiles_tile_file, 32 | sdl_hook_get_tile_dimensions, 33 | sdl_hook_allocate_tiles_region, 34 | sdl_hook_deallocate_tiles_region, 35 | sdl_hook_draw_tile_at, 36 | sdl_hook_delay, 37 | sdl_hook_rawsignals, 38 | sdl_hook_activatemouse, 39 | sdl_hook_getkeyorcodepoint, 40 | sdl_hook_signal_getch, 41 | sdl_hook_watch_fd, 42 | NULL, 43 | NULL, 44 | NULL, 45 | NULL, 46 | NULL, 47 | uncursed_hook_type_input, 48 | "sdl", 49 | 70, 50 | 0 51 | }; 52 | 53 | class sdl_uncursed_hook_import { 54 | public: 55 | sdl_uncursed_hook_import() { 56 | sdl_uncursed_hooks.next_hook = uncursed_hook_list; 57 | uncursed_hook_list = &sdl_uncursed_hooks; 58 | } 59 | }; 60 | 61 | static sdl_uncursed_hook_import importer; 62 | -------------------------------------------------------------------------------- /libuncursed/src/plugins/tty.cxx: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c++;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Sean Hunt, 2014-12-29 */ 3 | /* Copyright (c) 2013 Alex Smith. */ 4 | /* The 'uncursed' rendering library may be distributed under either of the 5 | * following licenses: 6 | * - the NetHack General Public License 7 | * - the GNU General Public License v2 or later 8 | * If you obtained uncursed as part of NetHack 4, you can find these licenses in 9 | * the files libnethack/dat/license and libnethack/dat/gpl respectively. 10 | */ 11 | 12 | /* Plugin wrapper for the terminal backend to the uncursed rendering library. 13 | This notifies uncursed that the tty library is available, merely by being 14 | loaded. (Thus, it has to be written in C++; in portable C, it's impossible 15 | for there to be side effects merely upon loading a file. An alternative would 16 | be to use the GCC-specific __attribute__((constructor)) syntax; but using C++ 17 | and simply creating an actual constructor is just as clear, and more 18 | portable. Another alternative would be to use common symbols, but that only 19 | works on UNIXen and would also require editing uncursed.c to add a new common 20 | symbol whenever a new backend were added. It also does not work correctly 21 | with shared libraries.) */ 22 | 23 | /* tty.cxx is always linked statically. */ 24 | #define UNCURSED_MAIN_PROGRAM 25 | 26 | #include "uncursed_hooks.h" 27 | #include "uncursed_tty.h" 28 | 29 | static struct uncursed_hooks tty_uncursed_hooks = { 30 | tty_hook_init, 31 | tty_hook_exit, 32 | tty_hook_beep, 33 | tty_hook_setcursorsize, 34 | tty_hook_positioncursor, 35 | tty_hook_resetpalette16, 36 | tty_hook_setpalette16, 37 | tty_hook_update, 38 | tty_hook_fullredraw, 39 | tty_hook_flush, 40 | NULL, 41 | NULL, 42 | NULL, 43 | NULL, 44 | NULL, 45 | NULL, 46 | tty_hook_delay, 47 | tty_hook_rawsignals, 48 | tty_hook_activatemouse, 49 | tty_hook_getkeyorcodepoint, 50 | tty_hook_signal_getch, 51 | tty_hook_watch_fd, 52 | NULL, 53 | NULL, 54 | NULL, 55 | NULL, 56 | NULL, 57 | uncursed_hook_type_input, 58 | "tty", 59 | 80, 60 | 0 61 | }; 62 | 63 | class tty_uncursed_hook_import { 64 | public: 65 | tty_uncursed_hook_import() { 66 | tty_uncursed_hooks.next_hook = uncursed_hook_list; 67 | uncursed_hook_list = &tty_uncursed_hooks; 68 | } 69 | }; 70 | 71 | static tty_uncursed_hook_import importer; 72 | -------------------------------------------------------------------------------- /libuncursed/src/plugins/wincon.cxx: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c++;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Sean Hunt, 2014-12-29 */ 3 | /* Copyright (c) 2013 Alex Smith. */ 4 | /* The 'uncursed' rendering library may be distributed under either of the 5 | * following licenses: 6 | * - the NetHack General Public License 7 | * - the GNU General Public License v2 or later 8 | * If you obtained uncursed as part of NetHack 4, you can find these licenses in 9 | * the files libnethack/dat/license and libnethack/dat/gpl respectively. 10 | */ 11 | 12 | /* Plugin wrapper for the Windows console backend to the uncursed rendering 13 | library. See tty.cxx for details; this is pretty much an exact copy with 14 | s/tty/wincon/g, and the priority reduced (although this depends only on 15 | libuncursed and libraries that ship with Windows, it is also very slow 16 | compared to most other backends). */ 17 | 18 | /* wincon.cxx is always linked statically. */ 19 | #define UNCURSED_MAIN_PROGRAM 20 | 21 | #include "uncursed_hooks.h" 22 | #include "uncursed_wincon.h" 23 | 24 | static struct uncursed_hooks wincon_uncursed_hooks = { 25 | wincon_hook_init, 26 | wincon_hook_exit, 27 | wincon_hook_beep, 28 | wincon_hook_setcursorsize, 29 | wincon_hook_positioncursor, 30 | NULL, 31 | NULL, 32 | wincon_hook_update, 33 | wincon_hook_fullredraw, 34 | wincon_hook_flush, 35 | NULL, 36 | NULL, 37 | NULL, 38 | NULL, 39 | NULL, 40 | NULL, 41 | wincon_hook_delay, 42 | wincon_hook_rawsignals, 43 | wincon_hook_activatemouse, 44 | wincon_hook_getkeyorcodepoint, 45 | wincon_hook_signal_getch, 46 | wincon_hook_watch_fd, 47 | NULL, 48 | NULL, 49 | NULL, 50 | NULL, 51 | NULL, 52 | uncursed_hook_type_input, 53 | "wincon", 54 | 30, 55 | 0 56 | }; 57 | 58 | class wincon_uncursed_hook_import { 59 | public: 60 | wincon_uncursed_hook_import() { 61 | wincon_uncursed_hooks.next_hook = uncursed_hook_list; 62 | uncursed_hook_list = &wincon_uncursed_hooks; 63 | } 64 | }; 65 | 66 | static wincon_uncursed_hook_import importer; 67 | -------------------------------------------------------------------------------- /libuncursed/src/test_uncursed.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2017-07-20 */ 3 | /* Copyright (c) 2013 Alex Smith. */ 4 | /* The 'uncursed' rendering library may be distributed under either of the 5 | * following licenses: 6 | * - the NetHack general public license 7 | * - the GNU General Public license v2 or later 8 | * If you obtained uncursed as part of NetHack 4, you can find these licenses in 9 | * the files libnethack/dat/license and libnethack/dat/gpl respectively. 10 | */ 11 | /* This is a test file in order to check that uncursed is operating correctly. 12 | */ 13 | 14 | #include "uncursed.h" 15 | #include 16 | 17 | #ifndef AIMAKE_BUILDOS_MSWin32 18 | # include 19 | 20 | static void 21 | handle_sigusr1(int unused) 22 | { 23 | (void)unused; 24 | uncursed_signal_getch(); 25 | } 26 | #endif 27 | 28 | int 29 | main(int argc, char **argv) 30 | { 31 | initialize_uncursed(&argc, argv); 32 | initscr(); 33 | set_faketerm_font_file("./tilesets/dat/fonts/font14.png"); 34 | 35 | #ifndef AIMAKE_BUILDOS_MSWin32 36 | struct sigaction sa; 37 | sa.sa_flags = 0; 38 | sigemptyset(&(sa.sa_mask)); 39 | 40 | sa.sa_handler = handle_sigusr1; 41 | sigaction(SIGUSR1, &sa, 0); 42 | #endif 43 | 44 | /* Test color pairs */ 45 | start_color(); 46 | init_pair(1, 10, 4); 47 | 48 | uncursed_enable_mouse(1); 49 | 50 | /* Testing input */ 51 | clear(); 52 | mvprintw(0, 0, "Press a key ('q' to exit)"); 53 | refresh(); 54 | 55 | while (1) { 56 | wint_t k; 57 | int r = get_wch(&k); 58 | 59 | if (r != KEY_CODE_YES && k == ('R' & 63)) 60 | clear(); 61 | erase(); 62 | mvaddch(LINES - 2, COLS - 2, 'A'); 63 | mvaddch(LINES - 2, COLS - 1, 'B'); 64 | mvaddch(LINES - 1, COLS - 2, 'C'); 65 | mvaddch(LINES - 1, COLS - 1, 'D'); /* ensure the bottom-right works */ 66 | 67 | if (r == KEY_CODE_YES || k < 32) { 68 | mvprintw(0, 0, "%d %s", k, keyname(k)); 69 | if (k == KEY_HANGUP) 70 | break; 71 | } else { 72 | cchar_t ct = { A_UNDERLINE | COLOR_PAIR(1), {k, 0} }; 73 | 74 | set_mouse_event(uncursed_mbutton_hover, '+', OK); 75 | mvprintw(0, 0, "%d '", k); 76 | set_mouse_event(uncursed_mbutton_hover, 0, ERR); 77 | 78 | set_mouse_event(uncursed_mbutton_left, 0xe9, OK); 79 | set_mouse_event(uncursed_mbutton_middle, 0xea, OK); 80 | set_mouse_event(uncursed_mbutton_right, 0xe8, OK); 81 | set_mouse_event(uncursed_mbutton_wheelup, KEY_F17, KEY_CODE_YES); 82 | set_mouse_event(uncursed_mbutton_wheeldown, KEY_MAX+1, KEY_CODE_YES); 83 | add_wch(&ct); 84 | set_mouse_event(uncursed_mbutton_left, 0, ERR); 85 | set_mouse_event(uncursed_mbutton_middle, 0, ERR); 86 | set_mouse_event(uncursed_mbutton_right, 0, ERR); 87 | set_mouse_event(uncursed_mbutton_wheelup, 0, ERR); 88 | set_mouse_event(uncursed_mbutton_wheeldown, 0, ERR); 89 | 90 | addch('\''); 91 | } 92 | 93 | refresh(); 94 | if (k == 'q') 95 | break; 96 | } 97 | 98 | endwin(); 99 | return 0; 100 | } 101 | -------------------------------------------------------------------------------- /nethack/.gitignore: -------------------------------------------------------------------------------- 1 | # Last modified by Alex Smith, 2013-09-21 2 | nethack 3 | nethack.sh 4 | -------------------------------------------------------------------------------- /nethack/rc/nh.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FredrIQ/fiqhack/dc309067ce179c5f11ab929f3c1e5a5bf798058e/nethack/rc/nh.ico -------------------------------------------------------------------------------- /nethack/rc/nh_ico.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON ".\\nh.ico" 2 | -------------------------------------------------------------------------------- /nethack/src/color.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-03-21 */ 3 | /* Copyright (c) Daniel Thaler, 2011 */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "nhcurses.h" 7 | 8 | static short colorlist[] = { 9 | COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, 10 | COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE, 11 | COLOR_BLACK + 8, COLOR_RED + 8, COLOR_GREEN + 8, COLOR_YELLOW + 8, 12 | COLOR_BLUE + 8, COLOR_MAGENTA + 8, COLOR_CYAN + 8, COLOR_WHITE + 8 13 | }; 14 | 15 | /* Initialize uncursed color pairs to the colors used by NetHack. */ 16 | void 17 | init_nhcolors(void) 18 | { 19 | int bg, fg; 20 | short bgColor, fgColor; 21 | 22 | start_color(); 23 | 24 | /* Set up all color pairs. We now unconditionally use A_BOLD plus colors 0 25 | to 7 foreground and background, with a total requirement of 64 pairs; 26 | uncursed folds colors beyond 7 into bold anyway. Note that a white 27 | background doesn't render correctly on some terminals, thus we use it 28 | only for solid rock. 29 | 30 | We also set up another 7 pairs for light-color-on-dark color, a 31 | combination that's not otherwise possible (dark-color-on-dark-color has 32 | its foreground replaced with black, black-on-dark-color has its 33 | foreground replaced with darkgray or blue respectively). */ 34 | for (bg = 0; bg <= 8; bg++) { 35 | 36 | /* Do not set up background colors if we're low on color pairs. */ 37 | if (bg == 1 && COLOR_PAIRS < MAINFRAME_PAIR) 38 | break; 39 | 40 | /* For no background, use black; otherwise use the color from the color 41 | map. */ 42 | bgColor = bg ? colorlist[bg] : COLOR_BLACK; 43 | 44 | for (fg = 0; fg <= 7; fg++) { 45 | 46 | /* Handle the darkgray setting. */ 47 | fgColor = colorlist[fg]; 48 | if (fgColor == COLOR_BLACK) { 49 | if (settings.darkgray) 50 | fgColor = COLOR_BLACK | 8; 51 | else 52 | fgColor = COLOR_BLUE; 53 | } 54 | 55 | /* Replace foreground=background with black foreground. */ 56 | if (fgColor == bgColor && fgColor != -1) 57 | fgColor = COLOR_BLACK; 58 | 59 | init_pair(bg * 8 + fg + 1, fgColor, bgColor); 60 | } 61 | } 62 | 63 | if (COLOR_PAIRS >= MAINFRAME_PAIR) 64 | for (bg = 1; bg <= 7; bg++) 65 | init_pair(64 + bg, bg | 8, bg); 66 | 67 | /* If we have at least 72 colour pairs, then we use pair 71 for the main 68 | background frame; this allows us to change its color to warn about 69 | critical situations via palette changes (which saves having to do a 70 | bunch of complex redrawing). The default color of the frame is color 7 71 | from the color map (light gray, if no explicit color was specified). */ 72 | if (COLOR_PAIRS > MAINFRAME_PAIR) 73 | init_pair(MAINFRAME_PAIR, colorlist[7], colorlist[0]); 74 | } 75 | 76 | int 77 | curses_color_attr(int nh_color, int bg_color) 78 | { 79 | int color = nh_color; 80 | int cattr = A_NORMAL; 81 | 82 | if (color >= 8) { 83 | color -= 8; 84 | if (color == bg_color && color && COLOR_PAIRS >= MAINFRAME_PAIR) 85 | bg_color = 8; /* "bold foreground on unbold background" */ 86 | else if (color > 0) 87 | cattr |= A_BOLD; 88 | } 89 | 90 | if (COLOR_PAIRS >= MAINFRAME_PAIR) 91 | color += bg_color * 8; 92 | 93 | cattr |= COLOR_PAIR(color + (bg_color == 8 ? 0 : 1)); 94 | return cattr; 95 | } 96 | 97 | void 98 | set_darkgray(void) 99 | { 100 | init_nhcolors(); 101 | } 102 | 103 | /* color.c */ 104 | -------------------------------------------------------------------------------- /nethack/src/mail.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Fredrik Ljungdahl, 2019-10-12 */ 3 | /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "mail.h" 7 | #include "nhcurses.h" 8 | #include 9 | #include 10 | #include 11 | 12 | static void 13 | mailstr_callback(const char *str, void *vmsg) 14 | { 15 | char *msg = vmsg; 16 | strcpy(msg, str); 17 | } 18 | 19 | /* Returns the username of the client: watcher's username 20 | if we're watching, the player's username if we're playing. */ 21 | const char * 22 | client_username(void) 23 | { 24 | const char *who = getenv("NH4SERVERUSER"); 25 | if (!who) 26 | who = getenv("USER"); 27 | 28 | if (ui_flags.autoload) 29 | who = getenv("NH4WATCHER"); 30 | 31 | if (!who || !*who) 32 | return NULL; 33 | return who; 34 | } 35 | 36 | void 37 | sendmail(void) 38 | { 39 | if (ui_flags.current_followmode != FM_WATCH && 40 | ui_flags.current_followmode != FM_PLAY) { 41 | curses_print_message(0, 0, player.moves, msgc_cancelled, 42 | "Mail can't be sent while replaying."); 43 | return; 44 | } 45 | 46 | char error[BUFSZ]; 47 | const char *box = mail_filename(error); 48 | if (!box) { 49 | curses_print_message(0, 0, player.moves, msgc_cancelled, error); 50 | return; 51 | } 52 | 53 | FILE* mb; 54 | const char *who = client_username(); 55 | if (!who) { 56 | curses_print_message(0, 0, player.moves, msgc_cancelled, 57 | "You need to be logged in to send mail!"); 58 | return; 59 | } 60 | 61 | char msg[BUFSZ] = {0}; 62 | curses_getline("What do you want to send?", &msg, mailstr_callback); 63 | if (!msg[0] || msg[0] == '\033') 64 | return; 65 | 66 | if (strlen(msg) > 80) { 67 | curses_print_message(0, 0, player.moves, msgc_cancelled, 68 | "Mail must be 80 characters or less."); 69 | return; 70 | } 71 | 72 | mb = fopen(box, "a"); 73 | if (!mb) { 74 | curses_print_message(0, 0, player.moves, msgc_cancelled, 75 | "Error sending mail."); 76 | return; 77 | } 78 | 79 | fprintf(mb, "%s:%s\n", who, msg); 80 | fclose(mb); 81 | 82 | curses_print_message(0, 0, player.moves, msgc_actionok, "Mail sent!"); 83 | } 84 | -------------------------------------------------------------------------------- /nethack/src/topten.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-06-06 */ 3 | /* Copyright (c) Daniel Thaler, 2011. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "nhcurses.h" 7 | 8 | static void 9 | topten_add_score(struct nh_topten_entry *entry, struct nh_menulist *menu, 10 | int maxwidth) 11 | { 12 | char line[BUFSZ], txt[BUFSZ], *txt2; 13 | char fmt[32], hpbuf[16], maxhpbuf[16]; 14 | int txtfw, initialfw, hpfw; /* field widths */ 15 | enum nh_menuitem_role role = entry->highlight ? MI_HEADING : MI_TEXT; 16 | 17 | initialfw = strlen(" No Points "); 18 | hpfw = strlen(" Hp [max] "); 19 | 20 | /* build padded hp strings */ 21 | if (entry->hp <= 0) { 22 | hpbuf[0] = '-'; 23 | hpbuf[1] = '\0'; 24 | } else 25 | snprintf(hpbuf, ARRAY_SIZE(hpbuf), "%d", entry->hp); 26 | snprintf(maxhpbuf, ARRAY_SIZE(maxhpbuf), "[%d]", entry->maxhp); 27 | 28 | /* calc maximum text field width for the current terminal. maxwidth already 29 | accounts for window borders and spacing. */ 30 | txtfw = maxwidth - initialfw - hpfw - 1; 31 | 32 | if (strlen(entry->entrytxt) > txtfw) { /* text needs to be split */ 33 | strncpy(txt, entry->entrytxt, BUFSZ); 34 | txt2 = &txt[txtfw]; 35 | while (*txt2 != ' ' && txt2 > txt) 36 | txt2--; 37 | /* special case: if about to wrap in the middle of maximum dungeon 38 | depth reached, wrap in front of it instead */ 39 | if (txt2 > txt + 5 && !strncmp(txt2 - 5, " [max", 5)) 40 | txt2 -= 5; 41 | *txt2++ = '\0'; 42 | 43 | snprintf(fmt, ARRAY_SIZE(fmt), "%%4d %%10d %%-%ds", maxwidth - initialfw); 44 | snprintf(line, ARRAY_SIZE(line), fmt, entry->rank, entry->points, txt); 45 | add_menu_txt(menu, line, role); 46 | 47 | snprintf(fmt, ARRAY_SIZE(fmt), "%%%ds%%-%ds %%3s %%5s ", initialfw, txtfw); 48 | snprintf(line, ARRAY_SIZE(line), fmt, "", txt2, hpbuf, maxhpbuf); 49 | add_menu_txt(menu, line, role); 50 | } else { 51 | snprintf(fmt, ARRAY_SIZE(fmt), "%%4d %%10d %%-%ds %%3s %%5s ", txtfw); 52 | snprintf(line, ARRAY_SIZE(line), fmt, entry->rank, entry->points, entry->entrytxt, hpbuf, 53 | maxhpbuf); 54 | add_menu_txt(menu, line, role); 55 | } 56 | } 57 | 58 | 59 | static void 60 | makeheader(char *linebuf) 61 | { 62 | size_t i; 63 | 64 | strcpy(linebuf, " No Points Name"); 65 | for (i = strlen(linebuf); i < min(BUFSZ, COLS) - strlen(" Hp [max] ") - 4; 66 | i++) 67 | linebuf[i] = ' '; 68 | strcpy(&linebuf[i], " Hp [max] "); 69 | } 70 | 71 | 72 | void 73 | show_topten(char *you, int top, int around, nh_bool own) 74 | { 75 | struct nh_topten_entry *scores; 76 | char buf[BUFSZ]; 77 | int i, listlen = 0; 78 | struct nh_menulist menu; 79 | 80 | scores = nh_get_topten(&listlen, buf, you, top, around, own); 81 | 82 | if (listlen == 0) { 83 | curses_msgwin("There are no scores to show.", krc_notification); 84 | return; 85 | } 86 | 87 | /* show the score list on a blank screen */ 88 | erase(); 89 | wnoutrefresh(stdscr); 90 | 91 | init_menulist(&menu); 92 | 93 | /* buf has the topten status if there is one, eg: "you did not beat your 94 | previous score" */ 95 | if (buf[0]) { 96 | add_menu_txt(&menu, buf, MI_TEXT); 97 | add_menu_txt(&menu, "", MI_TEXT); 98 | } 99 | 100 | makeheader(buf); 101 | add_menu_txt(&menu, buf, MI_HEADING); 102 | 103 | for (i = 0; i < listlen; i++) 104 | topten_add_score(&scores[i], &menu, min(COLS, BUFSZ) - 4); 105 | add_menu_txt(&menu, "", MI_TEXT); 106 | 107 | curses_display_menu(&menu, "Top scores:", PICK_NONE, 108 | PLHINT_ANYWHERE, NULL, null_menu_callback); 109 | } 110 | -------------------------------------------------------------------------------- /nethack_server/.gitignore: -------------------------------------------------------------------------------- 1 | # Last modified by Alex Smith, 2013-09-21 2 | nethack_server 3 | -------------------------------------------------------------------------------- /nethack_server/src/log.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-07-07 */ 3 | /* Copyright (c) Daniel Thaler, 2011. */ 4 | /* The NetHack server may be freely redistributed under the terms of either: 5 | * - the NetHack license 6 | * - the GNU General Public license v2 or later 7 | */ 8 | 9 | #include "nhserver.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | static FILE *logfile; 16 | 17 | 18 | void 19 | log_msg(const char *fmt, ...) 20 | { 21 | char msgbuf[512], timestamp[32], *last; 22 | struct tm *tm_local; 23 | struct timeval tv; 24 | va_list args; 25 | 26 | va_start(args, fmt); 27 | vsnprintf(msgbuf, sizeof (msgbuf), fmt, args); 28 | va_end(args); 29 | 30 | /* eliminate spaces and newlines at the end of msgbuf. There should be only 31 | exactly one newline, which gets added later. */ 32 | last = &msgbuf[strlen(msgbuf) - 1]; 33 | while (isspace(*last)) 34 | *last-- = '\0'; 35 | 36 | /* make a timestamp like "2011-11-30 18:45:59" */ 37 | gettimeofday(&tv, NULL); 38 | tm_local = localtime(&tv.tv_sec); 39 | if (!tm_local || 40 | !strftime(timestamp, sizeof (timestamp), "%Y-%m-%d %H:%M:%S", tm_local)) 41 | strcpy(timestamp, "???"); 42 | fprintf(logfile, "%s.%06ld [%d] %s\n", timestamp, tv.tv_usec, getpid(), 43 | msgbuf); 44 | fflush(logfile); 45 | } 46 | 47 | 48 | int 49 | begin_logging(void) 50 | { 51 | logfile = fopen(settings.logfile, "a"); 52 | if (!logfile) { 53 | fprintf(stderr, "Error opening/creating %s: %s.\n", settings.logfile, 54 | strerror(errno)); 55 | return FALSE; 56 | } 57 | 58 | return TRUE; 59 | } 60 | 61 | const char * 62 | addr2str(const void *sockaddr) 63 | { 64 | static char buf[INET6_ADDRSTRLEN + 1]; 65 | const struct sockaddr_in *sa4 = sockaddr; 66 | const struct sockaddr_in6 *sa6 = sockaddr; 67 | 68 | switch (sa4->sin_family) { 69 | case AF_INET: 70 | inet_ntop(AF_INET, &sa4->sin_addr, buf, INET6_ADDRSTRLEN); 71 | return buf; 72 | 73 | case AF_INET6: 74 | inet_ntop(AF_INET6, &sa6->sin6_addr, buf, INET6_ADDRSTRLEN); 75 | return buf; 76 | } 77 | 78 | return "(none)"; 79 | } 80 | 81 | void 82 | end_logging(void) 83 | { 84 | fclose(logfile); 85 | logfile = NULL; 86 | } 87 | 88 | /* log.c */ 89 | -------------------------------------------------------------------------------- /prebuilt/README.prebuilt: -------------------------------------------------------------------------------- 1 | Copying prebuilt libraries to this directory causes aimake to install them. 2 | -------------------------------------------------------------------------------- /scripts/build-debian-package: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Last modified by Fredrik Ljungdahl, 2015-11-03 3 | 4 | set -e 5 | 6 | test -f build-debian-package || echo Please run this script from its own directory. 7 | test -f build-debian-package || exit 1 8 | 9 | BUILDDIR=`mktemp -d /tmp/nh4build.XXXXXXXX` 10 | SUBDIR='fiqhack-4.3.0~beta1' 11 | mkdir "$BUILDDIR/$SUBDIR" 12 | (cd ..; git archive --format tar HEAD) | (cd "$BUILDDIR/$SUBDIR"; tar xf /dev/stdin) 13 | cd "$BUILDDIR/$SUBDIR" 14 | mv dist/debian debian 15 | mv copyright debian/copyright 16 | # Remove the GPL from "copyright", it's already there on Debian 17 | sed -i -e '/^License: GPL-2$/,$ d' debian/copyright 18 | # The 'debian' directory changed location during file arrangement 19 | sed -i -e 's/dist\/debian/debian/g' debian/copyright 20 | dpkg-buildpackage -us -uc 21 | echo Output files written to "$BUILDDIR". 22 | -------------------------------------------------------------------------------- /scripts/build-windows-installer.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | @echo Reminders: have you copied over zlib, libpng, SDL2 to prebuilt? 3 | 4 | rem rmdir /s ..\..\wix-build 5 | rem mkdir ..\..\wix-build 6 | cd ..\..\wix-build 7 | 8 | rmdir /s /q ..\wix-install 9 | mkdir ..\wix-install 10 | perl ..\nicehack\aimake -i "C:\Program Files" --filelist=wix --with=sourcecode --with=tilecompile --destdir ..\wix-install ..\nicehack 11 | 12 | cd ..\wix-install 13 | 14 | candle -arch x64 nethack4.wxs 15 | light -ext WixUIExtension "-dWixUILicenseRtf=CSIDL_PROGRAM_FILES/NetHack 4/doc/license.rtf" -sice:ICE38 -sice:ICE43 -sice:ICE57 -sice:ICE64 -sice:ICE90 nethack4.wixobj 16 | -------------------------------------------------------------------------------- /scripts/dawnlike-import.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use Fatal qw/open close/; 4 | use File::Temp qw/tempfile/; 5 | use File::Find qw/find/; 6 | use Carp; 7 | 8 | @ARGV == 5 && $ARGV[3] eq '-o' or die 9 | "This script requires five arguments: dawnlike.map; a directory ". 10 | "containing an unpacked copy of DawnLike; tilecompile; -o; and ". 11 | "the file to output in."; 12 | 13 | open my $mapfh, '<', $ARGV[0]; 14 | 15 | my %tiles_by_file; 16 | 17 | while (my $l = <$mapfh>) { 18 | $l =~ /^!/ and next; 19 | $l =~ /\[(.*)\] / or next; 20 | my $f = $1; 21 | $l =~ s/\[(.*)\] //; 22 | 23 | if ($l =~ /^(.*walls \*): (0x.*)/) { 24 | my $p = $1; 25 | my $n = oct $2; 26 | my @o = (20, 1, 0, 2, 40, 42, 24, 44, 4, 25, 23); 27 | $l = ""; 28 | for my $i (0..10) { 29 | my $p2 = $p; 30 | $p2 =~ s/walls \*/walls $i/g; 31 | $l .= sprintf "%s: 0x%X\n", $p2, $n+$o[$i]; 32 | } 33 | } 34 | 35 | $tiles_by_file{$f} .= $l; 36 | } 37 | 38 | close $mapfh; 39 | 40 | keys %tiles_by_file or die "No tile references found"; 41 | 42 | my %tempfile_by_file; 43 | 44 | for my $f (keys %tiles_by_file) { 45 | my ($fh, $fn); 46 | ($fh, $fn) = tempfile("dawnlike-import-XXXXXX", TMPDIR => 1, UNLINK => 1); 47 | $tempfile_by_file{$f} = $fn; 48 | $fh->print($tiles_by_file{$f}); 49 | close $fh; 50 | } 51 | 52 | my @cmdline; 53 | 54 | for my $f (sort keys %tiles_by_file) { 55 | my $found = undef; 56 | find sub { $_ eq $f and $found = $File::Find::name }, $ARGV[1]; 57 | defined $found or die "Could not locate image file '$f'"; 58 | push @cmdline, $found, $tempfile_by_file{$f}; 59 | } 60 | 61 | @cmdline = ("-z", 16, 16, "-W", "-t", "text", @cmdline, "-o", $ARGV[4]); 62 | 63 | print "$ARGV[2] @cmdline\n"; 64 | 65 | system $ARGV[2], @cmdline; 66 | -------------------------------------------------------------------------------- /scripts/generate-etags.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Last modified by Alex Smith, 2014-11-14 3 | 4 | # Generate a TAGS file for use with Emacs. 5 | # Run from the root of the distribution, not the scripts folder. 6 | etags */*/*.[ch] */*/*/*.[ch] 7 | -------------------------------------------------------------------------------- /scripts/random-motd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0` 3 | sed -e '/^#/d' ../libnethack_common/dat/motd.txt | shuf -n 3 | sed -e '/^+/q' | tail -n1 | sed -e 's/^+//' 4 | -------------------------------------------------------------------------------- /scripts/update-timestamps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Last modified by Alex Smith, 2013-09-25 3 | for x in `git ls-tree -r HEAD | cut -f 2` 4 | do 5 | sed -i -e "1,2s/Last modified by.*, ....-..-../$(git log -n 1 --pretty=format:'Last modified by %an, %at' $x | perl -pe 's/(\d+)$/`date --date=\@$1 +%F`/e')/" $x 6 | done 7 | -------------------------------------------------------------------------------- /scripts/vcs-hooks/git-hooks-post-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Last modified by Alex Smith, 2013-11-25 3 | 4 | # If there are any changes in the working copy, stash them. 5 | stashed_changes=`git stash create` 6 | git reset --hard -q 7 | 8 | # Work out which files to change. 9 | # We need to use git diff-tree, not git diff, in case this is a merge. 10 | # We would want to use --name-only, which is documented to do exactly 11 | # what we want, but its results seem buggy/nonsensical. So we grep the 12 | # filenames out of the result by hand instead. 13 | for x in $(git diff-tree --cc HEAD | pcregrep -o '^\+\+\+ b/\K.*') 14 | do 15 | # Update the timestamps on the files that were changed in the 16 | # commit that was just committed. 17 | sed -i -e "1,2s/Last modified by.*, ....-..-../Last modified by $(git log -n1 --pretty='%cn'), $(date +%F)/" $x 18 | git add $x 19 | done 20 | 21 | # If there are any changes to timestamps, amend the commit we just 22 | # commited to contain the new timestamps. (We need the conditional 23 | # here to prevent an infinite loop; the commit would amend itself 24 | # forever.) 25 | git diff --staged --quiet || git commit -C HEAD --amend 26 | 27 | # Re-apply the changes to the working copy. 28 | if [ "x$stashed_changes" != "x" ] 29 | then git stash apply -q $stashed_changes 30 | fi 31 | -------------------------------------------------------------------------------- /scripts/vim/resolve-date-conflicts.vim: -------------------------------------------------------------------------------- 1 | " NetHack4 date conflict resolver vim script 2 | " Last modified by Sean Hunt, 2014-08-25 3 | " Copyright (c) Sean Hunt, 2014 4 | " This script may be freely redistributed under the same license as NetHack. 5 | " See license for details. 6 | 7 | function! resolvediff() 8 | if getline(2) =~ "^<<<<<<<" && getline(3) =~ "Last modified" 9 | if getline(4) =~ "^=======" && getline(6) =~ "^>>>>>>>" 10 | 2d 11 | 3,5d 12 | elseif getline(4) =~ "^|||||||" && getline(6) =~ "^=======" && 13 | \ getline(8) =~ "^>>>>>>>" 14 | 2d 15 | 3,7d 16 | endif 17 | call cursor(0, 0) 18 | if search("^<<<<<<") 19 | let @/ = "^<<<<<<<" 20 | else 21 | w 22 | !git add % 23 | endif 24 | elseif search("^<<<<<<<", "w") 25 | let @/ = "^<<<<<<" 26 | endif 27 | endf 28 | 29 | augroup DateConflictResolve 30 | au! 31 | au BufReadPost * call resolvediff() 32 | augroup END 33 | -------------------------------------------------------------------------------- /scripts/xterm-suppression.vg: -------------------------------------------------------------------------------- 1 | { 2 | xterm_grantpt 3 | Memcheck:Cond 4 | fun:__GI_memchr 5 | obj:/usr/bin/xterm 6 | obj:/usr/bin/xterm 7 | fun:(below main) 8 | } 9 | -------------------------------------------------------------------------------- /testbench/include/tap.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-03-23 */ 3 | /* Copyright (c) 2015 Alex Smith. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "compilers.h" 7 | #include 8 | 9 | extern void tap_init(int); 10 | extern void tap_comment(const char *, ...) PRINTFLIKE(1, 2); 11 | extern void tap_test(int *, bool, const char *, ...) PRINTFLIKE(3, 4); 12 | extern void tap_skip(int *, const char *, ...) PRINTFLIKE(2, 3); 13 | extern noreturn void tap_bail(const char *); 14 | extern noreturn void tap_bail_errno(const char *); 15 | -------------------------------------------------------------------------------- /testbench/include/testgame.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-03-23 */ 3 | /* Copyright (c) 2015 Alex Smith. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "compilers.h" 7 | #include 8 | 9 | extern void init_test_system(unsigned long long, const char[static 4], int); 10 | extern void shutdown_test_system(void); 11 | extern void play_test_game(const char *, bool); 12 | extern void skip_test_game(const char *, bool); 13 | -------------------------------------------------------------------------------- /testbench/src/tap.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-03-23 */ 3 | /* Copyright (c) 2015 Alex Smith. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #include "tap.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /* Called when we start to test. (No special notation is needed for the end of 14 | the test.) */ 15 | void 16 | tap_init(int testcount) 17 | { 18 | printf("1..%d\n", testcount); 19 | } 20 | 21 | /* Outputs information to the test log. Typically used to report what went 22 | wrong, in the case that something goes wrong; but comments are not test 23 | failures in of themselves (so you could also report a random seed, etc.). 24 | 25 | Do not append a newline to the message. You can use printf formatting for 26 | it. */ 27 | void 28 | tap_comment(const char *message, ...) 29 | { 30 | va_list v; 31 | va_start(v, message); 32 | printf("# "); 33 | vprintf(message, v); 34 | printf("\n"); 35 | va_end(v); 36 | } 37 | 38 | /* Called when a test passes or fails. The test name may not contain '#' or 39 | vertical whitespace; you can use printf formatting for it. "testnumber" is a 40 | pointer to an integer holding TAP's internal state; it should be initialized 41 | to 1, and thereafter not touched (you can look at it if you like though; it 42 | holds the number of the next test to run). */ 43 | void 44 | tap_test(int *testnumber, bool passed, const char *name, ...) 45 | { 46 | va_list v; 47 | va_start(v, name); 48 | printf("%s %d - ", passed ? "ok" : "not ok", (*testnumber)++); 49 | vprintf(name, v); 50 | printf("\n"); 51 | va_end(v); 52 | } 53 | 54 | /* Called to skip a test. */ 55 | void 56 | tap_skip(int *testnumber, const char *name, ...) 57 | { 58 | va_list v; 59 | va_start(v, name); 60 | printf("ok %d - ", (*testnumber)++); 61 | vprintf(name, v); 62 | printf(" # skip\n"); 63 | va_end(v); 64 | } 65 | 66 | /* Called when something goes badly wrong. Exits the program. Do not append a 67 | newline to the message. */ 68 | noreturn void 69 | tap_bail(const char *message) 70 | { 71 | printf("Bail out! %s\n", message); 72 | abort(); 73 | } 74 | 75 | /* Like tap_bail, but also includes the contents of errno in the error. */ 76 | noreturn void 77 | tap_bail_errno(const char *message) 78 | { 79 | printf("Bail out! %s: %s\n", message, strerror(errno)); 80 | abort(); 81 | } 82 | -------------------------------------------------------------------------------- /tilesets/dat/catalogues/dawnlike-16.txt: -------------------------------------------------------------------------------- 1 | 16 16 2 | DawnLike 3 | dawnlike-16.txt 4 | dawnlike-343.txt 5 | dawnlike-4.txt 6 | dawnlike-dragons.txt 7 | dawnlike-fourk-extras.txt 8 | -------------------------------------------------------------------------------- /tilesets/dat/catalogues/rltiles-32.txt: -------------------------------------------------------------------------------- 1 | 32 32 2 | RLTiles 3 | rltiles-32.png 4 | rltiles.map 5 | los-transformations.txt 6 | -------------------------------------------------------------------------------- /tilesets/dat/catalogues/slashem-16.txt: -------------------------------------------------------------------------------- 1 | 16 16 2 | Slash'EM 3 | n-343.txt 4 | s-extras.txt 5 | s-monsters.txt 6 | s-objects.txt 7 | s-other.txt 8 | n-4-16.txt 9 | -------------------------------------------------------------------------------- /tilesets/dat/catalogues/slashem-32.txt: -------------------------------------------------------------------------------- 1 | 32 32 2 | Slash'EM32 3 | s-mon32mi.txt 4 | s-mon32se.txt 5 | s-mon32alg.txt 6 | s-mon32aw.txt 7 | s-obj32mi.txt 8 | s-obj32se.txt 9 | s-obj32alg.txt 10 | s-oth32mi.txt 11 | s-oth32se.txt 12 | s-oth32alg.txt 13 | n-343-32.txt 14 | n-4-32.txt 15 | -------------------------------------------------------------------------------- /tilesets/dat/catalogues/slashem-32.txt.old: -------------------------------------------------------------------------------- 1 | 32 32 2 | Slash'EM 3 | s-mon32mi.txt 4 | s-mon32se.txt 5 | s-mon32alg.txt 6 | s-mon32aw.txt 7 | s-obj32mi.txt 8 | s-obj32se.txt 9 | s-obj32alg.txt 10 | s-oth32mi.txt 11 | s-oth32se.txt 12 | s-oth32alg.txt 13 | -------------------------------------------------------------------------------- /tilesets/dat/catalogues/slashem-3d.txt.old: -------------------------------------------------------------------------------- 1 | 48 64 2 | Slash'EM-3D 3 | n-343.txt 4 | s-extras.txt 5 | s-monsters.txt 6 | s-objects.txt 7 | s-other.txt 8 | n-4-16.txt 9 | s-mon32mi.txt 10 | s-mon32se.txt 11 | s-mon32alg.txt 12 | s-mon32aw.txt 13 | s-obj32mi.txt 14 | s-obj32se.txt 15 | s-obj32alg.txt 16 | s-oth32mi.txt 17 | s-oth32se.txt 18 | s-oth32alg.txt 19 | s-mon3dmi.txt 20 | s-oth3dmi.txt 21 | s-oth-2kmi.txt 22 | s-oth3dse.txt 23 | -------------------------------------------------------------------------------- /tilesets/dat/catalogues/textascii.txt: -------------------------------------------------------------------------------- 1 | 0 0 2 | ASCII 3 | ascii_overrides.txt 4 | dungeoncolors.txt 5 | rogue_overrides.txt 6 | -------------------------------------------------------------------------------- /tilesets/dat/catalogues/textunicode.txt: -------------------------------------------------------------------------------- 1 | 0 0 2 | Unicode 3 | ascii_overrides.txt 4 | unicode_overrides.txt 5 | dungeoncolors.txt 6 | rogue_overrides.txt 7 | -------------------------------------------------------------------------------- /tilesets/dat/maps/nh4new.map: -------------------------------------------------------------------------------- 1 | ! Last modified by Fredrik Ljungdahl, 2017-10-12 2 | ! NetHack may be freely redistributed. See license for details. 3 | ! 4 | ! This tilemap lists the tiles in NetHack 4 that do not exist in 5 | ! NetHack 3.4.3 (or that do exist but with different meanings). 6 | ! 7 | unexplored area 8 | corridor 9 | sub lit corridor 10 | the floor of a room 11 | sub unlit the floor of a room 12 | long staircase up 13 | long staircase down 14 | remembered as stepped on 15 | remembered as locked 16 | remembered as unlocked 17 | remembered as trapped 18 | vibrating square 19 | monster is tame 20 | monster is peaceful 21 | monster is detected 22 | monster is ridden 23 | gas cloud 24 | solid rock 25 | remembered as object pile 26 | -------------------------------------------------------------------------------- /tilesets/dat/text/ascii_overrides.txt: -------------------------------------------------------------------------------- 1 | ! Last modified by Fredrik Ljungdahl, 2019-10-29 2 | ! Copyright (C) 2014 Alex Smith 3 | ! NetHack may be freely redistributed. See license for details. 4 | ! 5 | ! This text tileset lists the tiles that either aren't generated by 6 | ! basecchar, or that need overriding even in ASCII. 7 | 8 | ! Furthest backgrounds need to be opaque. 9 | unexplored area: bgblack black regular ' ' 10 | the floor of a room: bgblack gray regular '.' 11 | corridor: bgblack gray regular '#' 12 | 13 | ! Dark room, lit corridor. 14 | sub unlit the floor of a room: bgblack darkgray regular '.' 15 | sub lit corridor: bgblack white regular '#' 16 | 17 | ! Everyone hates the default boulder tile. 18 | boulder: gray '0' 19 | 20 | ! Corpse/statue/figurine substitutions. 21 | sub corpse *: basefg '%' 22 | sub statue *: basefg '`' 23 | sub figurine *: gray '(' 24 | 25 | ! Stairs and portals have red backgrounds (that show through). 26 | staircase *; ladder *; long staircase *: bgred basefg base_underline basechar 27 | magic portal; vibrating square: bgred basefg base_underline basechar 28 | 29 | ! The invisible monster symbol isn't defined in core. 30 | invisible monster: bright_blue 'I' 31 | 32 | ! Nor are the brandings. 33 | remembered as stepped on: disturb invisible 34 | remembered as locked: red invisible 35 | remembered as unlocked: green invisible 36 | remembered as trapped: bgcyan samefg invisible 37 | remembered as object pile: bgblue samefg invisible 38 | 39 | monster is tame: bgblue samefg invisible 40 | monster is peaceful: bgbrown samefg invisible 41 | monster is detected: bgmagenta samefg invisible 42 | monster is ridden: samefg invisible 43 | -------------------------------------------------------------------------------- /tilesets/dat/text/rogue_overrides.txt: -------------------------------------------------------------------------------- 1 | ! Last modified by Alex Smith, 2015-03-16 2 | ! Copyright (C) 2014 Alex Smith 3 | ! NetHack may be freely redistributed. See license for details. 4 | ! 5 | ! This text tileset lists the special rules for the Rogue level. 6 | 7 | ! General rule: no color on the Rogue level 8 | sub rogue sub * *: gray bgblack regular basechar 9 | 10 | ! Rogue used different backgrounds to ASCII NetHack in some cases, and 11 | ! to Unicode NetHack in many more cases. 12 | sub rogue walls 0: '|' 13 | sub rogue walls 1: '-' 14 | sub rogue walls 2: '-' 15 | sub rogue walls 3: '-' 16 | sub rogue walls 4: '-' 17 | sub rogue walls 5: '-' 18 | sub rogue walls 6: '-' 19 | sub rogue walls 7: '-' 20 | sub rogue walls 8: '-' 21 | sub rogue walls 9: '|' 22 | sub rogue walls 10: '|' 23 | sub rogue open doors ?: '+' 24 | sub rogue doorway: '+' 25 | sub rogue *staircase *: '%' 26 | 27 | ! Even for things that weren't in Rogue, Unicode looks weird. 28 | ! Some of these are probably impossible, but included anyway to make sure. 29 | sub rogue iron bars: '#' 30 | sub rogue fountain: '{' 31 | sub rogue altar: '_' 32 | sub rogue ice: '.' 33 | sub rogue water; sub rogue underwater; sub rogue lava: '}' 34 | sub rogue tree: '#' 35 | sub rogue web: '^' 36 | 37 | ! Some objects looked different in Rogue 38 | sub rogue gold piece: '*' 39 | sub rogue corpse; sub rogue sub corpse *: ':' 40 | 41 | ! Override the most common food; TODO: do other food too? 42 | sub rogue food ration: ':' 43 | -------------------------------------------------------------------------------- /tilesets/dat/text/unicode_overrides.txt: -------------------------------------------------------------------------------- 1 | ! Last modified by Fredrik Ljungdahl, 2017-10-19 2 | ! Copyright (C) 2014 Alex Smith 3 | ! NetHack may be freely redistributed. See license for details. 4 | ! 5 | ! This text tileset lists tiles that look different in Unicode and in 6 | ! ASCII. Note that this file is encoded in UTF-8. You will need a 7 | ! UTF-8-aware editor to edit it. 8 | ! 9 | ! Please restrict these to Unicode characters that exist on Windows 10 | ! Glyph List 4. (Windows is the worst out of the major operating 11 | ! systems at rendering fonts.) They should also have an exact or close 12 | ! approximation on code page 437. 13 | ! 14 | ! Note: When overriding something to Unicode here, you probably want 15 | ! to override it back to ASCII in rogue_overrides.txt. 16 | 17 | ! Unicodey terrain. 18 | walls 0: basefg '│' 19 | walls 1: basefg '─' 20 | walls 2: basefg '┌' 21 | walls 3: basefg '┐' 22 | walls 4: basefg '└' 23 | walls 5: basefg '┘' 24 | walls 6: basefg '┼' 25 | walls 7: basefg '┴' 26 | walls 8: basefg '┬' 27 | walls 9: basefg '┤' 28 | walls 10: basefg '├' 29 | doorway: basefg '·' 30 | open doors 0: basefg '■' 31 | open doors 1: basefg '■' 32 | iron bars: basefg '≡' 33 | fountain: basefg '⌠' 34 | the floor of a room: basefg '·' 35 | sub unlit the floor of a room: bgblack darkgray regular '·' 36 | corridor: basefg '░' 37 | sub lit corridor: bgblack white regular '▒' 38 | altar; * altar: basefg 'Ω' 39 | ice: basefg '·' 40 | lowered drawbridges ?: basefg '·' 41 | water: basefg '≈' 42 | underwater: basefg '≈' 43 | lava: basefg '≈' 44 | tree: basefg '±' 45 | 46 | ! Replace the characters in zaps and swallows with Unicode, while 47 | ! maintaining color. 48 | zap ? 0: basefg '│' 49 | zap ? 1: basefg '─' 50 | explosion * 1; explosion * 7: basefg '─' 51 | explosion * 3; explosion * 5: basefg '│' 52 | 53 | ! Swallows. 54 | swallow top center: basefg '─' 55 | swallow bottom center: basefg '─' 56 | swallow middle left: basefg '│' 57 | swallow middle right: basefg '│' 58 | 59 | ! Traps. 60 | web: basefg '╬' 61 | -------------------------------------------------------------------------------- /tilesets/dat/tiles/dawnlike-4.txt: -------------------------------------------------------------------------------- 1 | ! Last modified by Alex Smith, 2014-10-16 2 | ! 3 | ! Copyright (C) Andrew Rios, 2014 4 | ! This work is licensed under the Creative Commons Attribution 3.0 5 | ! Unported License. To view a copy of this license, visit 6 | ! http://creativecommons.org/licenses/by/3.0/ or send a letter to 7 | ! Creative Commons, 444 Castro Street, Suite 900, Mountain View, 8 | ! California, 94041, USA. 9 | ! 10 | ! Dawnbringer texture by DragonDePlatino 11 | ! Send requests and hate mail to: DragonDePlatino@gmail.com 12 | ! 13 | ! This file contains tiles from DawnHack that were created for NetHack 14 | ! 4, and that are not present in DawnLike. 15 | ! 16 | A = (20, 12, 28) 17 | B = (69, 36, 52) 18 | C = (48, 52, 109) 19 | D = (117, 113, 97) 20 | E = (77, 73, 77) 21 | F = (134, 150, 162) 22 | G = (109, 195, 203) 23 | H = (223, 239, 215) 24 | I = (219, 215, 93) 25 | J = (71, 108, 108) 26 | K = (211, 69, 73) 27 | L = (109, 170, 44) 28 | M = (211, 125, 44) 29 | N = (134, 77, 48) 30 | O = (211, 170, 154) 31 | # tile 7 (remembered as stepped on) 32 | { 33 | DDDDDDDDDDDDDDDD 34 | DDJJJJJJJJJJJJDD 35 | DJJJJJJJJJJJJJJD 36 | DJJJJJJJJJJJJJJD 37 | DJJJJJJJJJJJJJJD 38 | DJJJJJJJJJJJJJJD 39 | DJJJJJJJJJJJJJJD 40 | DJJJJJJJJJJJJJJD 41 | DJJJJJJJJJJJJJJD 42 | DJJJJJJJJJJJJJJD 43 | DJJJJJJJJJJJJJJD 44 | DJJJJJJJJJJJJJJD 45 | DJJJJJJJJJJJJJJD 46 | DJJJJJJJJJJJJJJD 47 | DDJJJJJJJJJJJJDD 48 | DDDDDDDDDDDDDDDD 49 | } 50 | # tile 8 (remembered as locked) 51 | { 52 | KKKKKKKKKKKKKKKK 53 | KKKKJJJJJJJJKKKK 54 | KKJJJJJJJJJJJJKK 55 | KJJJJJJJJJJJJJJK 56 | KJJJJJJJJJJJJJJK 57 | KJJJJJJJJJJJJJJK 58 | KJJJJJJJJJJJJJJK 59 | KJJJJJJJJJJJJJJK 60 | KJJJJJJJJJJJJJJK 61 | KJJJJJJJJJJJJJJK 62 | KJJJJJJJJJJJJJJK 63 | KJJJJJJJJJJJJJJK 64 | KJJJJJJJJJJJJJJK 65 | KJJJJJJJJJJJJJJK 66 | KJJJJJJJJJJJJJJK 67 | KJJJJJJJJJJJJJJK 68 | } 69 | # tile 9 (remembered as unlocked) 70 | { 71 | LLLLLLLLLLLLLLLL 72 | LLLLJJJJJJJJLLLL 73 | LLJJJJJJJJJJJJLL 74 | LJJJJJJJJJJJJJJL 75 | LJJJJJJJJJJJJJJL 76 | LJJJJJJJJJJJJJJL 77 | LJJJJJJJJJJJJJJL 78 | LJJJJJJJJJJJJJJL 79 | LJJJJJJJJJJJJJJL 80 | LJJJJJJJJJJJJJJL 81 | LJJJJJJJJJJJJJJL 82 | LJJJJJJJJJJJJJJL 83 | LJJJJJJJJJJJJJJL 84 | LJJJJJJJJJJJJJJL 85 | LJJJJJJJJJJJJJJL 86 | LJJJJJJJJJJJJJJL 87 | } 88 | # tile 10 (remembered as trapped) 89 | { 90 | MMMMMMMMMMMMMMMM 91 | MMJJJJJJJJJJJJMM 92 | MJJJJJJJJJJJJJJM 93 | MJJJJJJJJJJJJJJM 94 | MJJJJJJJJJJJJJJM 95 | MJJJJJJJJJJJJJJM 96 | MJJJJJJJJJJJJJJM 97 | MJJJJJJJJJJJJJJM 98 | MJJJJJJJJJJJJJJM 99 | MJJJJJJJJJJJJJJM 100 | MJJJJJJJJJJJJJJM 101 | MJJJJJJJJJJJJJJM 102 | MJJJJJJJJJJJJJJM 103 | MJJJJJJJJJJJJJJM 104 | MMJJJJJJJJJJJJMM 105 | MMMMMMMMMMMMMMMM 106 | } 107 | -------------------------------------------------------------------------------- /tilesets/dat/tiles/los-transformations.txt: -------------------------------------------------------------------------------- 1 | ! Last modified by Alex Smith, 2015-03-20 2 | ! 3 | ! Copyright (C) 2015 Alex Smith 4 | ! NetHack may be freely redistributed. See license for details. 5 | ! 6 | ! This file generates "darker" versions of unlit floor tiles. This allows 7 | ! tilesets such as RLTiles which have a large number of branch-specific tiles 8 | ! to avoid needing to explicitly specify unlit versions of those tiles. 9 | 10 | ! Suggestion by Raz: average 50:50 with black for unlit tiles. 11 | sub unlit sub * the floor of a room 12 | ( 13 | 0.5, 0.0, 0.0, 0.0, 0.0 14 | 0.0, 0.5, 0.0, 0.0, 0.0 15 | 0.0, 0.0, 0.5, 0.0, 0.0 16 | ) 17 | sub unlit sub * corridor 18 | ( 19 | 0.5, 0.0, 0.0, 0.0, 0.0 20 | 0.0, 0.5, 0.0, 0.0, 0.0 21 | 0.0, 0.0, 0.5, 0.0, 0.0 22 | ) 23 | -------------------------------------------------------------------------------- /tilesets/dat/tiles/n-343.txt: -------------------------------------------------------------------------------- 1 | ! Last modified by Alex Smith, 2013-09-24 2 | ! NetHack may be freely redistributed. See license for details. 3 | ! 4 | ! The tiles in this file are for tiles that are used by NetHack 3.4.3 but not 5 | ! Slash'EM. 6 | A = (0, 0, 0) 7 | B = (0, 182, 255) 8 | C = (255, 108, 0) 9 | D = (255, 0, 0) 10 | E = (0, 0, 255) 11 | F = (0, 145, 0) 12 | G = (108, 255, 0) 13 | H = (255, 255, 0) 14 | I = (255, 0, 255) 15 | J = (145, 71, 0) 16 | K = (204, 79, 0) 17 | L = (255, 182, 145) 18 | M = (72, 108, 108) 19 | N = (255, 255, 255) 20 | O = (218, 218, 182) 21 | P = (108, 145, 182) 22 | $ = (71, 108, 108) 23 | # tile 125 (apron / alchemy smock) 24 | { 25 | MMMMMMMMMMMMMMMM 26 | MMMMMMMMMMMMMMMM 27 | MMMMMNOMMNOMMMMM 28 | MMMMMNAOMNAOMMMM 29 | MMMMMNAOMNAOAMMM 30 | MMMMMNNNNNAOAMMM 31 | MMMMMNNNNNOOAMMM 32 | MMMMMNNNNNOOAMMM 33 | MMMMONNNNNOAAMMM 34 | MMMMONNNNNNAAMMM 35 | MMMMNNNNNNNAAMMM 36 | MMMMNNNNNNNAAMMM 37 | MMMMNNNNNNNAAMMM 38 | MMMMNNNNNNNAAMMM 39 | MMMMMNNNNNAAMMMM 40 | MMMMMMAAAAAMMMMM 41 | } 42 | # tile 149 (buckled boots / kicking boots) 43 | { 44 | MMMMMMMMMMMMMMMM 45 | MMMMMMMMMMMMMMMM 46 | MMMMMMMCCKKKKMMM 47 | MMMMMMCKAAAAJJMM 48 | MMMMMMKKKKKKKJAM 49 | MMMMMMMJKKKKKJAM 50 | MMMMMMMCJKKKKJAM 51 | MMMMMMHOOKKKCAMM 52 | MMMCKHKKHCCCCAMM 53 | MMCKKLOHCCCCJAMM 54 | MCKKKKKKKJKKJAMM 55 | MCKKKKKKKKKKJAMM 56 | MMJJJJJJJJJJJAMM 57 | MMMAAAAAAAAAAAMM 58 | MMMMMMMMMMMMMMMM 59 | MMMMMMMMMMMMMMMM 60 | } 61 | # tile 68 (flash beam) 62 | { 63 | MMMMMMMMMMMMMMMM 64 | MMMMMNNNNNNMMMMM 65 | MMMNNNNNNNNNNMMM 66 | MMNNNNNNNNNNNNMM 67 | MMNNNNNNNNNNNNMM 68 | MNNNNNNNNNNNNNNM 69 | MNNNNNNNNNNNNNNM 70 | MNNNNNNNNNNNNNNM 71 | MNNNNNNNNNNNNNNM 72 | MNNNNNNNNNNNNNNM 73 | MNNNNNNNNNNNNNNM 74 | MMNNNNNNNNNNNNMM 75 | MMNNNNNNNNNNNNMM 76 | MMMNNNNNNNNNNMMM 77 | MMMMMNNNNNNMMMMM 78 | MMMMMMMMMMMMMMMM 79 | } 80 | -------------------------------------------------------------------------------- /tilesets/dat/tiles/rltiles-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FredrIQ/fiqhack/dc309067ce179c5f11ab929f3c1e5a5bf798058e/tilesets/dat/tiles/rltiles-32.png -------------------------------------------------------------------------------- /tilesets/include/tilecompile.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-03-10 */ 3 | /* Copyright (C) 2014 Alex Smith. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #ifndef TILECOMPILE_H 7 | # define TILECOMPILE_H 8 | 9 | # include 10 | # include 11 | # include 12 | # include 13 | # include 14 | # include 15 | 16 | /* Definitions */ 17 | 18 | typedef struct { 19 | uint8_t r, g, b, a; 20 | } pixel; 21 | 22 | typedef struct { 23 | int tilenumber; 24 | unsigned long long substitution; 25 | uint32_t image_index; /* or cchar */ 26 | } tile; 27 | 28 | enum formatname { 29 | FN_TEXT, 30 | FN_NH4CT, 31 | FN_MAP, 32 | FN_HEX, 33 | FN_BINARY, 34 | FN_IMAGE, 35 | FN_PALETTE, 36 | }; 37 | 38 | enum iiformat { 39 | II_HEX, 40 | II_SPELTOUT, 41 | II_FILEPOS, 42 | II_NONE, 43 | }; 44 | 45 | /* The number of possible single-character keys. */ 46 | # define KEYSPACE 64 47 | /* Keys can be up to two characters wide. */ 48 | # define MAX_PALETTE_SIZE (KEYSPACE * KEYSPACE) 49 | /* The maximum length of a tileset name. */ 50 | # define TILESET_NAME_SIZE 80 51 | /* The header for a binary tileset. This ends with two NULs; one is implicit, 52 | we add the other here. */ 53 | # define BINARY_TILESET_HEADER "NH4TILESET\0" 54 | 55 | /* Palettes larger than a certain size must be converted to RGB to write them 56 | into a PNG image. */ 57 | # define MAX_PNG_PALETTE_SIZE 256 58 | /* The number of bytes in a PNG header. */ 59 | # define PNG_HEADER_SIZE 8 60 | /* The PNG header itself. */ 61 | # define PNG_HEADER "\x89PNG\x0d\x0a\x1a\x0a" 62 | 63 | /* Slash'EM's transparent color key. We need to know what this is for backwards 64 | compatibility. */ 65 | # define TRANSPARENT_R 71 66 | # define TRANSPARENT_G 108 67 | # define TRANSPARENT_B 108 68 | 69 | # define CCHAR_COLOR_COUNT 19 70 | # define CCHAR_FGCOLOR_TRANSPARENT 16 71 | # define CCHAR_FGCOLOR_DISTURB 17 72 | # define CCHAR_FGCOLOR_BASE 18 73 | # define CCHAR_BGCOLOR_TRANSPARENT 8 74 | # define CCHAR_BGCOLOR_BASE 9 75 | # define CCHAR_CHAR_BASE 0xd800 76 | 77 | /* Constant arrays */ 78 | extern const char *const cchar_color_names[CCHAR_COLOR_COUNT]; 79 | 80 | /* Globals; these are defined in tilecompile.c */ 81 | extern char tileset_name[TILESET_NAME_SIZE + 1]; 82 | extern long tileset_width; 83 | extern long tileset_height; 84 | 85 | extern int palettesize, palettechannels; 86 | extern pixel palette[MAX_PALETTE_SIZE]; 87 | extern bool palette_locking, palette_locked; 88 | 89 | extern pixel **locked_images_seen; 90 | extern int locked_image_count; 91 | extern bool image_locking, image_locked; 92 | 93 | extern pixel **images_seen; 94 | extern int start_of_reference_image, seen_image_count; 95 | 96 | extern tile *tiles_seen; 97 | extern int seen_tile_count, allocated_tile_count; 98 | 99 | extern bool copy_unknown_tile_names; 100 | extern char **unknown_tile_names; 101 | extern int unknown_name_count, allocated_name_count; 102 | 103 | /* Extern functions */ 104 | 105 | /* tileset-read.c */ 106 | extern bool load_text_tileset(uint8_t *, size_t); 107 | extern bool load_binary_tileset(uint8_t *, size_t); 108 | 109 | /* tileset-image.c */ 110 | extern bool load_png_file(FILE *); 111 | extern bool write_png_file(const char *, bool); 112 | 113 | /* tileset-write.c */ 114 | extern bool write_text_tileset(const char *, enum iiformat); 115 | extern bool write_binary_tileset(const char *); 116 | extern bool callback_with_text_tileset(enum iiformat, 117 | bool (*)(uint8_t *, size_t)); 118 | extern bool callback_with_binary_tileset(bool (*)(uint8_t *, size_t)); 119 | 120 | /* tilecompile.c */ 121 | extern bool slurp_file(FILE *, uint8_t *, size_t, const char *, 122 | bool (*)(uint8_t *, size_t)); 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /tilesets/include/tilesequence.h: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-03-16 */ 3 | /* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */ 4 | /* and Dave Cohrs, 1990. */ 5 | /* Copyright (c) 2013 Alex Smith. */ 6 | /* NetHack may be freely redistributed. See license for details. */ 7 | 8 | /* The main core of the program no longer orders all the glyphs in sequence, 9 | like NetHack 3.4.3 does. However, we need such a sequential numbering for 10 | the purpose of placing tiles into some order within a tileset. */ 11 | 12 | #ifndef TILESEQUENCE_H 13 | # define TILESEQUENCE_H 14 | 15 | # include "global.h" 16 | # include "timeout.h" 17 | # include "monst.h" 18 | # include "monsym.h" 19 | # include "dungeon.h" 20 | # include "pm.h" 21 | # include "onames.h" 22 | # include "objclass.h" 23 | # include "trap.h" 24 | # include "permonst.h" 25 | # include "decl.h" 26 | # include "mkroom.h" 27 | # include "rm.h" 28 | # include "display.h" 29 | # include "brandings.h" 30 | 31 | /* In stacking order: */ 32 | # define TILESEQ_CMAP_SIZE S_cmap_COUNT /* backgrounds */ 33 | # define TILESEQ_GENBRAND_SIZE NHCURSES_GENBRANDING_COUNT /* gen brandings */ 34 | # define TILESEQ_TRAP_SIZE (TRAPNUM-1) /* traps */ 35 | # define TILESEQ_OBJ_SIZE NUM_OBJECTS /* objects */ 36 | # define TILESEQ_INVIS_SIZE 1 /* mem invisible */ 37 | # define TILESEQ_MON_SIZE NUMMONS /* monsters */ 38 | # define TILESEQ_MONBRAND_SIZE NHCURSES_MONBRANDING_COUNT /* mon brandings */ 39 | # define TILESEQ_WARN_SIZE WARNCOUNT /* warnings */ 40 | # define TILESEQ_EXPLODE_SIZE (NUMEXPCHARS * EXPL_MAX) /* explosions */ 41 | # define TILESEQ_ZAP_SIZE (NUMZAPCHARS * NUM_ZAP) /* beams */ 42 | # define TILESEQ_SWALLOW_SIZE NUMSWALLOWCHARS /* engulfed */ 43 | # define TILESEQ_EFFECT_SIZE E_COUNT /* effects */ 44 | 45 | # define TILESEQ_CMAP_OFF 0 46 | # define TILESEQ_GENBRAND_OFF (TILESEQ_CMAP_OFF + TILESEQ_CMAP_SIZE) 47 | # define TILESEQ_TRAP_OFF (TILESEQ_GENBRAND_OFF + TILESEQ_GENBRAND_SIZE) 48 | # define TILESEQ_OBJ_OFF (TILESEQ_TRAP_OFF + TILESEQ_TRAP_SIZE) 49 | # define TILESEQ_INVIS_OFF (TILESEQ_OBJ_OFF + TILESEQ_OBJ_SIZE) 50 | # define TILESEQ_MON_OFF (TILESEQ_INVIS_OFF + TILESEQ_INVIS_SIZE) 51 | # define TILESEQ_MONBRAND_OFF (TILESEQ_MON_OFF + TILESEQ_MON_SIZE) 52 | # define TILESEQ_WARN_OFF (TILESEQ_MONBRAND_OFF + TILESEQ_MONBRAND_SIZE) 53 | # define TILESEQ_EXPLODE_OFF (TILESEQ_WARN_OFF + TILESEQ_WARN_SIZE) 54 | # define TILESEQ_ZAP_OFF (TILESEQ_EXPLODE_OFF + TILESEQ_EXPLODE_SIZE) 55 | # define TILESEQ_SWALLOW_OFF (TILESEQ_ZAP_OFF + TILESEQ_ZAP_SIZE) 56 | # define TILESEQ_EFFECT_OFF (TILESEQ_SWALLOW_OFF + TILESEQ_SWALLOW_SIZE) 57 | 58 | # define TILESEQ_COUNT (TILESEQ_EFFECT_OFF + TILESEQ_EFFECT_SIZE) 59 | # define TILESEQ_INVALID_OFF (-1) 60 | 61 | /* Tile sequencing functions */ 62 | extern unsigned long long substitution_from_name(const char **); 63 | extern int tileno_from_name(const char *, int); 64 | extern int tileno_from_api_name(const char *, const char *, int); 65 | extern const char *name_from_tileno(int); 66 | extern const char *name_from_substitution(unsigned long long); 67 | extern unsigned long long sensible_substitutions(int tileno); 68 | extern int mutually_exclusive_substitutions(unsigned long long); 69 | 70 | /* Not technically involved with tile sequencing, but this is the most sensible 71 | place to put it, as this file is already doing the "combine drawing.c with 72 | tile numbers" job. The purpose of this function is to get the NetHack core's 73 | opinion on how a given cchar should be rendered. In some cases, it may not 74 | have an opinion, in which case it returns ULONG_MAX (which is not a valid 75 | cchar). */ 76 | extern unsigned long cchar_from_tileno(int); 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /tilesets/missing-slashem-32-tiles.txt: -------------------------------------------------------------------------------- 1 | ! Last modified by Alex Smith, 2015-03-10 2 | ! Copyright (C) 2013 Alex Smith 3 | ! NetHack may be freely redistributed. See license for details. 4 | ! 5 | ! This file lists tiles that don't have a 32x32px version in the 6 | ! Slash'EM tilesets. It's currently unused, but if anyone wants 7 | ! to draw these tiles, go ahead! 8 | unexplored area 9 | solid rock 10 | air 11 | doorway 12 | long staircase up 13 | long staircase down 14 | lowered drawbridges 0 15 | lowered drawbridges 1 16 | raised drawbridges 0 17 | raised drawbridges 1 18 | remembered as stepped on 19 | remembered as locked 20 | remembered as unlocked 21 | remembered as trapped 22 | vibrating square 23 | bow 24 | mummy wrapping 25 | apron 26 | buckled boots 27 | brass lantern 28 | saddle 29 | whistles 0 30 | whistles 1 31 | iron hook 32 | eucalyptus leaf 33 | ragged spellbook 34 | coyote 35 | dingo 36 | lynx 37 | panther 38 | centipede 39 | zruty 40 | Aleax 41 | jabberwock 42 | kobold mummy 43 | orc mummy 44 | dwarf mummy 45 | elf mummy 46 | human mummy 47 | ettin mummy 48 | giant mummy 49 | ogre lord 50 | ogre king 51 | yeti 52 | sasquatch 53 | dwarf zombie 54 | paper golem 55 | human 56 | doppelganger 57 | prisoner 58 | sandestin 59 | jellyfish 60 | piranha 61 | baby crocodile 62 | Neferet the Green 63 | Minion of Huhetotl 64 | Thoth Amon 65 | Nalzok 66 | student 67 | chieftain 68 | neanderthal 69 | attendant 70 | acolyte 71 | thug 72 | guide 73 | monster is tame 74 | monster is peaceful 75 | monster is detected 76 | monster is ridden 77 | swallow top left 78 | swallow top center 79 | swallow top right 80 | swallow middle left 81 | swallow middle right 82 | swallow bottom left 83 | swallow bottom center 84 | swallow bottom right 85 | dig beam 86 | flash beam 87 | gas cloud 88 | unexplored area 89 | solid rock 90 | air 91 | doorway 92 | long staircase up 93 | long staircase down 94 | lowered drawbridges 0 95 | lowered drawbridges 1 96 | raised drawbridges 0 97 | raised drawbridges 1 98 | remembered as stepped on 99 | remembered as locked 100 | remembered as unlocked 101 | remembered as trapped 102 | vibrating square 103 | bow 104 | mummy wrapping 105 | apron 106 | buckled boots 107 | brass lantern 108 | saddle 109 | whistles 0 110 | whistles 1 111 | iron hook 112 | eucalyptus leaf 113 | ragged spellbook 114 | coyote 115 | dingo 116 | lynx 117 | panther 118 | centipede 119 | zruty 120 | Aleax 121 | jabberwock 122 | kobold mummy 123 | orc mummy 124 | dwarf mummy 125 | elf mummy 126 | human mummy 127 | ettin mummy 128 | giant mummy 129 | ogre lord 130 | ogre king 131 | yeti 132 | sasquatch 133 | dwarf zombie 134 | paper golem 135 | human 136 | doppelganger 137 | prisoner 138 | sandestin 139 | jellyfish 140 | piranha 141 | baby crocodile 142 | Neferet the Green 143 | Minion of Huhetotl 144 | Thoth Amon 145 | Nalzok 146 | student 147 | chieftain 148 | neanderthal 149 | attendant 150 | acolyte 151 | thug 152 | guide 153 | monster is tame 154 | monster is peaceful 155 | monster is detected 156 | monster is ridden 157 | swallow top left 158 | swallow top center 159 | swallow top right 160 | swallow middle left 161 | swallow middle right 162 | swallow bottom left 163 | swallow bottom center 164 | swallow bottom right 165 | dig beam 166 | flash beam 167 | gas cloud 168 | -------------------------------------------------------------------------------- /tilesets/src/fallback-tileset-image.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2015-03-10 */ 3 | /* Copyright (C) 2015 Alex Smith. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | /* Erroring-out implementations of load_png_file, write_png_file which are used 7 | when we don't compile with GUI support. The first line is indented 8 | differently from usual, so that a grep will find the implementations in 9 | tileset-image rather than these ones. */ 10 | 11 | #include "tilecompile.h" 12 | 13 | bool load_png_file(FILE *in) 14 | { 15 | fclose(in); 16 | fprintf(stderr, "Cannot open PNG image; PNG support " 17 | "was not compiled into this tilecompile\n"); 18 | return 0; 19 | } 20 | 21 | bool write_png_file(const char *filename, bool add_nhTb_nhTs) 22 | { 23 | fprintf(stderr, "Cannot write PNG image; PNG support " 24 | "was not compiled into this tilecompile\n"); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /tilesets/src/magtile.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-10-03 */ 3 | /* Copyright (c) NetHack Development Team 1995 */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | #error !AIMAKE_FAIL_SILENTLY! 7 | This is currently unused, and needs updating to the new tile system. 8 | 9 | 10 | /* Routines for magnifying tiles by a factor of 2, based on the Scale2X 11 | algorithm from AdvanceMAME . 12 | 13 | B 14 | Pixel E from a source image D E F is magnified to a set of 4 destination 15 | H 16 | E0 E1 17 | pixels E2 E3 by the following rules: 18 | 19 | E0 = D == B && B != F && D != H ? D : E; 20 | E1 = B == F && B != D && F != H ? F : E; 21 | E2 = D == H && D != B && H != F ? D : E; 22 | E3 = H == F && D != H && B != F ? F : E; */ 23 | 24 | #include "tile.h" 25 | 26 | void 27 | magnify_tile_in_place(pixel (*pixels)[MAX_TILE_X], const char *name, 28 | int *max_x, int *max_y) 29 | { 30 | int i, j; 31 | pixel bigpixels[MAX_TILE_Y][MAX_TILE_X]; 32 | pixel pixB, pixD, pixE, pixF, pixH; 33 | 34 | /* All tiles magnify the same way, regardless of their names. */ 35 | (void) name; 36 | 37 | if (*max_x * 2 > MAX_TILE_X || *max_y * 2 > MAX_TILE_Y) { 38 | fprintf(stderr, "error: magnifying tile makes it too large\n"); 39 | exit(EXIT_FAILURE); 40 | } 41 | 42 | for (j = 0; j < *max_y; j++) 43 | for (i = 0; i < *max_x; i++) { 44 | pixE = pixels[j][i]; 45 | pixB = ((j == 0) ? pixE : pixels[j - 1][i]); 46 | pixD = ((i == 0) ? pixE : pixels[j][i - 1]); 47 | pixF = ((i == (*max_x - 1)) ? pixE : pixels[j][i + 1]); 48 | pixH = ((j == (*max_y - 1)) ? pixE : pixels[j + 1][i]); 49 | bigpixels[2 * j][2 * i] = 50 | ((pixel_equal(pixD, pixB) && !pixel_equal(pixB, pixF) && 51 | !pixel_equal(pixD, pixH)) ? pixD : pixE); 52 | bigpixels[2 * j][2 * i + 1] = 53 | ((pixel_equal(pixB, pixF) && !pixel_equal(pixB, pixD) && 54 | !pixel_equal(pixF, pixH)) ? pixF : pixE); 55 | bigpixels[2 * j + 1][2 * i] = 56 | ((pixel_equal(pixD, pixH) && !pixel_equal(pixD, pixB) && 57 | !pixel_equal(pixH, pixF)) ? pixD : pixE); 58 | bigpixels[2 * j + 1][2 * i + 1] = 59 | ((pixel_equal(pixH, pixF) && !pixel_equal(pixD, pixH) && 60 | !pixel_equal(pixB, pixF)) ? pixF : pixE); 61 | } 62 | *max_x *= 2; 63 | *max_y *= 2; 64 | memcpy(pixels, bigpixels, sizeof bigpixels); 65 | } 66 | 67 | /*magtile.c*/ 68 | -------------------------------------------------------------------------------- /tilesets/util/basecchar.c: -------------------------------------------------------------------------------- 1 | /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ 2 | /* Last modified by Alex Smith, 2014-10-10 */ 3 | /* Copyright (c) 2014 Alex Smith. */ 4 | /* NetHack may be freely redistributed. See license for details. */ 5 | 6 | /* Generates a default ASCII tileset using information from the game core. This 7 | is missing a few tiles (invis, genbranding, monbranding) that the game core 8 | doesn't know about or doens't have data on; those will need to be specified 9 | in a separate data file. 10 | 11 | Almost all the hard work is done by tilesequence.c; this is just a 12 | wrapper. */ 13 | 14 | #include "tilesequence.h" 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | int main(int argc, char **argv) 21 | { 22 | if (argc != 3 || strcmp(argv[1], "-o") != 0) { 23 | fprintf(stderr, "Usage: basecchar -o outputfile.txt\n"); 24 | return EXIT_FAILURE; 25 | } 26 | 27 | FILE *out = fopen(argv[2], "w"); 28 | if (!out) { 29 | perror(argv[2]); 30 | return EXIT_FAILURE; 31 | } 32 | 33 | int i; 34 | for (i = 0; i < TILESEQ_COUNT; i++) { 35 | unsigned long cchar = cchar_from_tileno(i); 36 | if (cchar == ULONG_MAX) 37 | continue; 38 | 39 | /* Translate black to dark gray. */ 40 | if (!(cchar & (0x1fUL << 21))) 41 | cchar |= 8UL << 21; 42 | 43 | fprintf(out, "%s: 0x%08lX\n", name_from_tileno(i), cchar); 44 | } 45 | 46 | if (fclose(out)) { 47 | perror("Error: Closing output file"); 48 | return EXIT_FAILURE; 49 | } 50 | 51 | return EXIT_SUCCESS; 52 | } 53 | --------------------------------------------------------------------------------