Difference between revisions of "Source diving"

From NetHackWiki
Jump to navigation Jump to search
(Tips)
Line 8: Line 8:
 
Most function declarations are in [[Source:NetHack_3.6.1/include/extern.h|extern.h]], sorted by the .c file they're defined in. If you're looking for a function's definition, you can search for the function name in extern.h, then scroll up to the comment giving the file name. Note that some things that look like functions, such as <code>resists_fire(mon)</code>, are actually preprocessor macros; most of those are defined in other header files such as [[Source:NetHack_3.6.1/include/youprop.h|youprop.h]] or [[Source:NetHack_3.6.1/include/mondata.h|mondata.h]].
 
Most function declarations are in [[Source:NetHack_3.6.1/include/extern.h|extern.h]], sorted by the .c file they're defined in. If you're looking for a function's definition, you can search for the function name in extern.h, then scroll up to the comment giving the file name. Note that some things that look like functions, such as <code>resists_fire(mon)</code>, are actually preprocessor macros; most of those are defined in other header files such as [[Source:NetHack_3.6.1/include/youprop.h|youprop.h]] or [[Source:NetHack_3.6.1/include/mondata.h|mondata.h]].
  
Even if you aren't proficient in Coding, oftentimes you can look up printed messages (where the message in game should be pretty much the same as the one in the code) to get hints of what's happening
+
Even if you aren't proficient in coding, oftentimes you can look up printed messages in the code to get an idea of what governs certain output.
  
 
==See also==
 
==See also==

Revision as of 23:56, 4 July 2021

Source diving is the action of examining the source code of NetHack. A person who practices source diving is called a source diver. The source code is freely available for anyone, unlike in most commercial programs.

Source diving is usually done when someone wants to know how something really works in the game. Source divers may also program their own patches to the game. Some people may just want to look for easter eggs or interesting comments in the source.

Grep, GEMA, AWK, and Doxygen are useful tools when source diving.

Tips

Most function declarations are in extern.h, sorted by the .c file they're defined in. If you're looking for a function's definition, you can search for the function name in extern.h, then scroll up to the comment giving the file name. Note that some things that look like functions, such as resists_fire(mon), are actually preprocessor macros; most of those are defined in other header files such as youprop.h or mondata.h.

Even if you aren't proficient in coding, oftentimes you can look up printed messages in the code to get an idea of what governs certain output.

See also