Fix water infrastructure total when changing owner of object on water
[openttd-jgr.git] / docs / directory_structure.md
blob72a62eee42d678919a363e41f183c729c5e347e0
1 # OpenTTD directory structure
3 OpenTTD uses its own directory to store its required 3rd party base set files
4 (see section 4.1 'Required 3rd party files') and non-compulsory extension and
5 configuration files.
7 See below for their proper place within this OpenTTD main data directory.
9 The main OpenTTD directories can be found in various locations, depending on
10 your operating system:
12 1. The current working directory (from where you started OpenTTD)
14     For non-Windows operating systems OpenTTD will not scan for files in this
15     directory if it is your personal directory, i.e. '~/', or when it is the
16     root directory, i.e. '/'.
18 2. Your personal directory
19     - Windows:
20         - `C:\My Documents\OpenTTD` (95, 98, ME)
21         - `C:\Documents and Settings\<username>\My Documents\OpenTTD` (2000, XP)
22         - `C:\Users\<username>\Documents\OpenTTD` (7, 8.1, 10, 11)
23     - macOS: `~/Documents/OpenTTD`
24     - Linux: `$XDG_DATA_HOME/openttd` which is usually `~/.local/share/openttd`
25        when built with XDG base directory support, otherwise `~/.openttd`
26 3. The shared directory
27     - Windows:
28         - `C:\Documents and Settings\All Users\Shared Documents\OpenTTD` (2000, XP)
29         - `C:\Users\Public\Documents\OpenTTD` (7, 8.1, 10, 11)
30     - macOS: `/Library/Application Support/OpenTTD`
31     - Linux: not available
32 4. The binary directory (where the OpenTTD executable is)
33     - Windows: `C:\Program Files\OpenTTD`
34     - Linux: `/usr/games`
35 5. The installation directory (Linux only)
36     - Linux: `/usr/share/games/openttd`
37 6. The application bundle (macOS only)
39     It includes the OpenTTD files (grf+lng) and it will work as long as they
40     are not touched
42 Different types of data or extensions go into different subdirectories of the
43 chosen main OpenTTD directory:
45 | data type           | directory         | additional info             |
46 | ------------------- | ----------------- | --------------------------- |
47 | Config File         | (no subdirectory) |                             |
48 | Screenshots         | screenshot        |                             |
49 | Base Graphics       | baseset           | (or a subdirectory thereof) |
50 | Sound Sets          | baseset           | (or a subdirectory thereof) |
51 | NewGRFs             | newgrf            | (or a subdirectory thereof) |
52 | 32bpp Sets          | newgrf            | (or a subdirectory thereof) |
53 | Music Sets          | baseset           | (or a subdirectory thereof) |
54 | AIs                 | ai                | (or a subdirectory thereof) |
55 | AI Libraries        | ai/library        | (or a subdirectory thereof) |
56 | Game Scripts (GS)   | game              | (or a subdirectory thereof) |
57 | GS Libraries        | game/library      | (or a subdirectory thereof) |
58 | Savegames           | save              |                             |
59 | Automatic Savegames | save/autosave     |                             |
60 | Scenarios           | scenario          |                             |
62 The (automatically created) directory content_download is for OpenTTD's internal
63 use and no files should be added to it or its subdirectories manually.
65 ## Notes:
67 - Linux in the previous list means .deb, but most paths should be similar for
68    others.
69 - The previous search order is also used for NewGRFs and openttd.cfg.
70 - If openttd.cfg is not found, then it will be created using the 2, 4, 1, 3,
71    5 order. When built with XDG base directory support, openttd.cfg will be
72    created in $XDG_CONFIG_HOME/openttd which is usually ~/.config/openttd.
73 - Savegames will be relative to the config file only if there is no save/
74    directory in paths with higher priority than the config file path, but
75    autosaves and screenshots will always be relative to the config file.
76    Unless the configuration file is in $XDG_CONFIG_HOME/openttd, then all
77    other files will be saved under $XDG_DATA_HOME/openttd.
79 ## The preferred setup:
81 Place 3rd party files in shared directory (or in personal directory if you do
82 not have write access on shared directory) and have your openttd.cfg config
83 file in personal directory (where the game will then also place savegames and
84 screenshots).
86 ## Portable installations (portable media)
88 You can install OpenTTD on external media so you can take it with you, i.e.
89 using a USB key, or a USB HDD, etc.
90 Create a directory where you shall store the game in (i.e. OpenTTD/).
91 Copy the binary (OpenTTD.exe, OpenTTD.app, openttd, etc), baseset/ and your
92 openttd.cfg to this directory.
93 You can copy binaries for any operating system into this directory, which will
94 allow you to play the game on nearly any computer you can attach the external
95 media to.
96 As always - additional grf files are stored in the newgrf/ dir (for details,
97 again, see section 4.1).
99 ## Files in tar (archives)
101 OpenTTD can read files that are in an uncompressed tar (archive), which
102 makes it easy to bundle files belonging to the same script, NewGRF or base
103 set. Music sets are the only exception as they cannot be stored in a tar
104 file due to being played by external applications.
106 OpenTTD sees each tar archive as the 'root' of its search path. This means that
107 having a file with the same path in two different tar files means that one
108 cannot be opened, after all only one file will be found first. As such it is
109 advisable to put an uniquely named folder in the root of the tar and put all the
110 content in that folder. For example, all downloaded content has a path that
111 concatenates the name of the content and the version, which makes the path
112 unique. For custom tar files it is advised to do this as well.
114 The normal files are also referred to by their relative path from the search
115 directory, this means that also normal files could hide files in a tar as
116 long as the relative path from the search path of the normal file is the
117 same as the path in the tar file. Again it is advised to have an unique path
118 to the normal file so they do not collide with the files from other tar
119 files.
121 ## Configuration file
123 The configuration file for OpenTTD (openttd.cfg) is in a simple Windows-like
124 .INI format. It is mostly undocumented. Almost all settings can be changed
125 ingame by using the 'Advanced Settings' window.
127 When you cannot find openttd.cfg you should look in the directories as
128 described in this document. If you do not have an openttd.cfg OpenTTD will
129 create one after closing.