How to search the sources

From The Cataclysm: Dark Days Ahead Wiki
Revision as of 09:13, 23 January 2018 by Soyweiser (talk | contribs) (→‎Windows: fixed ugly link)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The ultimate spoilers: searching the source code itself.

Getting the sources

Go to github and select "Download ZIP". Unpack it somewhere.

Alternately, you may be able to use the search box directly on github.com.

Tools

Unix-like

GNU/Linux and MacOS have the `grep` command. Usage example: `grep "string to find" -r src`.

In case of strings with special symbols (for example, "), you may need to escape them with a '\'. For example, to find '"id" : "water"', the command will be `grep "\"id\" : \"water\"" -r data`.

Result of a grep search is a file name and a line that contains the searched string.

Windows

Windows has the `findstr` command, but due to how clunky the default Windows console is, it may be a good idea to get a different tool instead.

There are many grep replacements for Windows, for example grepWin. Alternatively, MinGW/MSYS distributions tend to come with grep on board.

How to search

IDs vs. names

Many objects in the game have separate names (translatable, with spaces) and IDs. Searching for the IDs will usually give much better results than searching for names.

In order to find an ID given a name, search the data directory for the name and open the file with line that looks like `"name" : "what you wanted to find"`. Near that line, in the same block, there should be a line that looks like `"id" : "the_id_here"`. The string on the right is the ID of the object.

data vs. src

Data directory contains items, recipes, monsters and some of the mapgen definitions. Most of the stats are found there. Data describes "what things are".

Src directory contains the implementations of the above, some specific items (for example, corpses) and some mapgen definitions (labs, hospitals). Sources describe "how things act".

For example, Zombie hulk's stats will be in data/json/monsters.json, but in the same file its smash attack will only be described by "SMASH" in special abilities line. The actual implementation of the attack is in src/monattack.cpp.

The structure of save files is very similar to structure of data files, except with much more repetition.