1# Multiplayer manual for OpenTTD 2 3## Table of contents 4 5- 1.0) [Starting a server](#10-starting-a-server) 6- 2.0) [Connecting to a server](#20-connecting-to-a-server) 7 - 2.1) [Connecting to a server over the console](#21-connecting-to-a-server-over-the-console) 8- 3.0) [Playing internet games](#30-playing-internet-games) 9- 4.0) [Tips for servers](#40-tips-for-servers) 10 - 4.1)[Imposing landscaping limits](#41-imposing-landscaping-limits) 11- 5.0) [Some useful things](#50-some-useful-things) 12- 6.0) [Troubleshooting](#60-troubleshooting) 13 14 15## 1.0) Starting a server 16 17- Click on "Multiplayer" in the Start Menu. 18- Click on "Start Server". 19- Give your server a name. 20- Select the visibility of your server: 21 - "Public": your server will be publicly listed. 22 - "Invite Only": only players who have the invite code for your server can 23 join. 24 - "Local": only players on your local network can join. 25- (optional) Set a password for your server. 26- Click "New Game", "Load Game", or "Play Scenario". 27- Start playing. 28 29## 2.0) Connecting to a server 30 31- Click on "Multiplayer" in the Start Menu. 32- There are three ways to join a server: 33 - If you want to connect to a local server, click "Search LAN". 34 - If you want to connect to a public game, click "Search internet". 35 - If the server-owner shared an invite code with you: 36 - Click "Add Server". 37 - Fill in the invite code, which always starts with a `+`. 38 - Click "OK". 39- Click on the server you want to join. 40- Click "Join Game". 41- If the server has a password, it will ask you for this. 42- You see a progressbar how far you are with joining the server. 43- Happy playing. 44 45## 2.1) Connecting to a server over the console 46 47- Open the console and type `connect` for help how to connect via the console. 48 49## 3.0) Playing internet games 50 51- Servers with a red dot behind it have a different version then you have. You 52 will not be able to join those servers. 53 54- Servers with a yellow dot behind it have NewGRFs that you do not have. You 55 will not be able to join those servers. However, via "NewGRF Settings" and 56 "Find missing content online" you might be able to download the needed 57 NewGRFs after which you can join the server. 58 59- It can happen that a connection is that slow, or you have that many clients 60 connected to your server, that your clients start to loose their connection. 61 Some things you can do about it: 62 - `[network] frame_freq`: 63 change it in console with: `set network.frame_freq <number>` 64 the number should be between the 0 and 10, not much higher. It indicates 65 the delay between clicking and showing up. The higher, the more you notice 66 it, but the less bandwidth you use. 67 A good value for Internet-games is 2 or 3. 68 69 - `[network] sync_freq`: 70 change it in console with: `set network.sync_freq <number>` 71 the number should be between the 50 and 1000, not much lower, not much 72 higher. It indicates the time between sync-frames. A sync-frame is a frame 73 which checks if all clients are still in sync. When the value it too high, 74 clients can desync in 1960, but the server detects it in 1970. Not really 75 handy. The lower the value, the more bandwidth it uses. 76 77 NB: changing `frame_freq` has more effect on the bandwidth then `sync_freq`. 78 79## 4.0) Tips for servers 80 81- You can launch a dedicated server by adding `-D` as parameter. 82- In UNIX like systems, you can fork your dedicated server by adding `-f` as 83 parameter. 84 85- You can automatically clean companies that do not have a client connected to 86 them, for, let's say, 3 years. You can do this via: `set autoclean_companies` 87 and `set autoclean_protected` and `set autoclean_unprotected`. Unprotected 88 removes a password from a company when it is not used for more then the 89 defined amount of months. `set autoclean_novehicles` can be used to remove 90 companies without any vehicles quickly. 91 92- You can also do this manually via the console: `reset_company`. 93 94- You can let your server automatically restart a map when, let's say, 95 year 2030 is reached. See `set restart_game_date` for detail. 96 97- If you want to be on the server-list, make your server public. You can do 98 this either from the Start Server window, via the in-game Online Players 99 window, or by typing in the console: `set server_game_type public`. 100 101- You can protect your server with a password via the console: `set server_pw`, 102 or via the Start Server menu. 103 104- When you have many clients connected to your server via Internet, watch your 105 bandwidth (if you have any limit on it, set by your ISP). One client uses 106 about 1.5 kilobytes per second up and down. To decrease this amount, setting 107 `frame_freq` to 1 will reduce it to roughly 1 kilobyte per second per client. 108 109- OpenTTD's default settings for maximum number of clients, and amount of data 110 from clients to process are chosen to not influence the normal playing of 111 people, but to prevent or at least make it less likely that someone can 112 perform a (distributed) denial-of-service attack on your server by causing 113 an out-of-memory event by flooding the server with data to send to all 114 clients. The major factor in this is the maximum number of clients; with 115 32 clients "only" sending one chat message causes 1024 messages to be 116 distributed in total, with 64 clients that already quadruples to 4096. Given 117 that upstream bandwidth is usually the limiting factor, a queue of packets 118 that need to be sent will be created. 119 To prevent clients from exploiting this "explosion" of packets to send we 120 limit the number of incoming data, resulting in effectively limiting the 121 amount of data that OpenTTD will send to the clients. Even with the default 122 limits it is possible to generate about 70.000 packets per second, or about 123 7 megabit per second of traffic. 124 Given that OpenTTD kicks clients after they have not reacted within about 9 125 seconds from sending a frame update packet it would be possible that OpenTTD 126 keeps about 600.000 packets in memory, using about 50 megabytes of memory. 127 Given that OpenTTD allows short bursts of packets, you can have slightly 128 more packets in memory in case of a distributed denial of service attack. 129 When increasing the amount of incoming data, or the maximum number of 130 clients the amount of memory OpenTTD needs in case of a distributed denial 131 of service attack is linearly related to the amount of incoming data and 132 quadratic to the amount of clients. In short, a rule of thumb for, the 133 maximum memory usage for packets is: 134 `#max_clients * #max_clients * bytes_per_frame * 10 KiB`. 135 136### 4.1) Imposing landscaping limits 137 138- You can impose limits on companies by the following 4 settings: 139 - `terraform_per_64k_frames` 140 - `terraform_frame_burst` 141 - `clear_per_64k_frames` 142 - `clear_frame_burst` 143 144- Explaining `NNN_burst` and `NNN_per_64K_frames` 145 - `NNN_burst` defines 3 things, the maximum limit, the limit of a single 146 action, and the initial value for the limit assigned to a new company. 147 This setting is fairly simple and requires no math. 148 149 A value of 1 means a single tile can be affected by a single action. 150 This results in having to click 400 times when wanting to cover an area 151 of 20 x 20 tiles. 152 153 The default value 4096 covers an area of 64 x 64 tiles. 154 155 - `NNN_per_64K_frames` defines the number of tiles added to each companies 156 limit per frame (however not past the possible maximum value,the 157 `NNN_burst`). 64k rather resembles the exact number of 65536 frames. So 158 setting this variable to 65536 means: `65536 / 65536 = 1 tile per frame`. 159 160 As a day consists of 74 frames, a company's limit is increased by 74 161 tiles during the course of a single day (2.22 seconds). 162 To achieve a 1 tile per day increase the following calculation is needed: 163 `1 / 74 (frames per day) * 65536 (per_64k_frames) = 885.62...`. 164 After rounding: a value of 886 means adding a bit over 1 tile per day. 165 166 There is still enough space to scale this value downwards: 167 decreasing this value to 127 results in a bit over 1 tile added to the 168 allowance per week (7 days). 169 170 To create a setup in which a company gets an initial allowance only, 171 set the value to 0 - no increase of the allowance per frame. 172 173- Even though construction actions include a clear tile action, they are not 174 affected by the above settings. 175 176## 5.0) Some useful things 177 178- You can protect your company so nobody else can join uninvited. To do this, 179 set a password in your Company window. 180 181- You can chat with other players via ENTER or via SHIFT+T or via the Online 182 Players window 183 184- Servers can kick players, so don't make them use it! 185 186## 6.0) Troubleshooting 187 188### My server does not show up in the serverlist 189 190Check if the visibility of your server is set to `public`. 191 192If it is, and your server still isn't showing up, start OpenTTD with 193`-d net=4` as extra argument. This will show debug message related to the 194network, including communication to/from the Game Coordinator. 195 196### My server warns a lot about getaddrinfo taking N seconds 197 198This could be a transient issue with your (local) DNS server, but if the 199problem persists there is likely a configuration issue in DNS resolving on 200your computer. 201 202#### Running OpenTTD in a Docker container? 203 204This is an issue with dual-stack Docker containers. If there is no default 205IPv6 resolver and IPv6 traffic is preferred, DNS requests will time out after 2065 seconds. To resolve this, use an IPv4 DNS server for your Docker container, 207for example by adding `--dns 1.1.1.1` to your `docker run` command. 208