From NetHackWiki
Jump to: navigation, search

Here is a short guide on patching your NetHack sources, assuming you have already managed to compile your copy.

On Windows

This assumes you have a basic knowledge of compiling and similar.

  • Find the diff-file you want to patch, and download it on to your computer, preferably in the NetHack sources root directory, c:\nh343.

Note that linux-style line endings will cause problems, you need to convert those into Windows-style ones! You can do this for example copypasting the contents of that file from a browser window into Notepad, and then saving the notepad file. The following code assumes the patch is Menucolors, so to use any other patch just replace nh343-menucolor.diff with the filename of the patch.

  • Start cmd.exe and do the following:
cd c:\nh343
patch -p1 < nh343-menucolor.diff

The 1 after the -p might need to be changed to 0 or possibly 2 for other patches.

note: On MS-Windows, the patchfile must be a text file, i.e. CR-LF must be used as line endings. A file with LF may give the error: "Assertion failed, hunk, file patch.c, line 343," unless the option '--binary' is given.

note: Newer version of windows require administrative privileges to run files named patch, which can break GNU patch, see here for a workaround:

Linux, and Unix in general

The typical way to patch is to stand in the root directory of the nethack source tree, apply the patch:

patch -pnum < my.patch

and then examine the warning or error messages, if any.

"-pnum" is used to strip path prefixes from the patch before trying to apply it. For example, if the patch contains lines on the form:

--- slashem-0.0.7E7F1-orig/dat/Jedi.des 1970-01-01 01:00:00.000000000 +0100
+++ slashem-0.0.7E7F1/dat/Jedi.des      2005-07-20 14:55:01.434612456 +0200

you should strip off one level. You should strip off two levels if the patch says:

--- a/slashem/dat/Jedi.des 1970-01-01 01:00:00.000000000 +0100
+++ b/slashem/dat/Jedi.des 2005-07-20 14:55:01.434612456 +0200