Commit graph

569 commits

Author SHA1 Message Date
bors[bot] 13bbe68ee3
Merge #5765
5765: Add libpng dylib to mac dmg (fixes #5764) r=Jupeyy a=def-

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2022-08-22 17:25:27 +00:00
bors[bot] 7765171559
Merge #5733
5733: Added map_find_env tool r=def- a=sctt


a simple tool which given an envelope id returns a list of all quads associated with that envelope, screenshot attached below.
![Screenshot from 2022-08-13 18-48-41](https://user-images.githubusercontent.com/3328841/184503762-521ff3c7-2c0f-47df-a0e6-e4b30f2826ec.png)

p.s.
deen told me its not a problem to commit these kind of map tools to ddnet

Co-authored-by: sctt <scottistefano91@gmail.com>
2022-08-22 09:07:40 +00:00
Dennis Felsing ead73d7bb4 Add libpng dylib to mac dmg (fixes #5764) 2022-08-22 10:35:34 +02:00
Robert Müller 21fe945ca7 Make file link absolute, add fs_is_relative_path
This fixes links not opening for relative paths, as links like `file://temp/skins` cannot be resolved by the shell.
2022-08-20 20:56:46 +02:00
Alexander Akulich 8ac84948c5 Extract server main() to its own file
Also extract CServerLogger to own files.
2022-08-15 16:07:27 +03:00
sctt 513271b618
Update CMakeLists.txt
build map_find_env
2022-08-13 18:55:33 +02:00
Robert Müller 51fb3e9a22 Merge CUIEx class into CUI
There is no need to separate the UI in two classes anymore, as the dependency on `CRenderTools` has been removed.
2022-08-12 19:59:19 +02:00
Robert Müller b50309dd5c Move CUIRect class into its own files 2022-08-12 19:37:07 +02:00
def b33cbdde0a Remove unused backend_opengles.h 2022-07-31 09:44:50 +02:00
def fc5cfb6f6c Remove CFlag dead code (fixes #5677) 2022-07-31 09:44:50 +02:00
Danny Harpigny 8e203cb84c
2022-07-20 00:26:18 +02:00
heinrich5991 6600024f24 Allow multiple addresses per server in the serverbrowser
Support is incomplete for `leak_ip_address_to_all_servers` (will only
ping the first address of each server) and for the `leak_ip` setting
(which will also only ping the first address of each server).
2022-07-10 16:52:07 +02:00
bors[bot] 6ec8bdbc12
Merge #5506
5506: Don't register integration test servers r=heinrich5991 a=def-

Also print out more of the diff

Should help with debugging sporadic failures like https://github.com/ddnet/ddnet/runs/7058704316?check_suite_focus=true

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
2022-06-26 23:16:28 +00:00
def 3a8c5e31b5 Also copy autoexec_server.cfg to build dir
found by c0d3d3v
2022-06-26 11:13:30 +02:00
bors[bot] 1e31db257f
Merge #5420
5420: Improvments for new HUD r=def- a=C0D3D3V

for testing set `#define CLIENT_VERSIONNR 16020`
Some of the changes are only available in the next version

Impressions: https://youtu.be/E770vGp4KKY

Implements a few of the recommendations from https://github.com/ddnet/ddnet/issues/5159 and Discord
- removes all player capability messages send by the server, that are now displayed in the HUD
- ~~remove `cl_ddrace_hud` and cl_show_freeze_bars~~, 
- Added option `cl_freezebars_alpha_inside_freeze` setting to change the opacity if the player is inside a freeze tile (default visible 100%)
- Added option `cl_show_jumps_indicator`
- We send now the real weapon the player is holding if he is frozen
    -> for that we added a new particle "snow flakes" or frozen flakes :D that are spawned over the tees body, to indicate he is frozen.
    -> new extras.png asset (+ corresponding asset tab, that can potentially be used for all sorts of extras for our mod, e.g. material particles, but in the future maybe also for other mods using a similar structure like it is for entities)
- stars are no longer send to new clients, because it is duplication to the freezebar, and we decided to not allow to disable it 
- also ninja stars are no longer send. They are not vanilla, and we now have a ninja bar in the new HUD.
- display target angle from 0 to 360 (looks mirrored on the x-axis to the normal trigonometry circle, but that is just how the world coordinates are) 
- dummy action display is increased in size ( but only the border margin :D not the icons. so the icons are still the same size as the icons on the left side)
- allow the server to also show old HUD elements (see https://github.com/ddnet/ddnet/pull/5427 for screenshots)


fixes #5149
fixes #198
closes #5159

fixes #2252   ~~(But not clear if we should also display the weapon, still investigating)~~
- we do no longer display a weapon inside freeze, instead we have nice freeze particles

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
2022-06-26 07:57:33 +00:00
Dennis Felsing 4d43567948 Move twping to tools directory 2022-06-25 01:28:05 +02:00
Dennis Felsing a7492c1038 Upgrade Discord SDK to version 3.2.1 (incldues macOS arm64) 2022-06-22 18:43:22 +02:00
bors[bot] b75289df35
Merge #4829 #5343 #5465
4829: Added map_replace_area tool r=def- a=sctt

Motivation:
sometimes mappers need to copy a certain area from a map to another (but also to a different position of the same map).
that's very time consuming on complex maps, as tiles and quads layers have to be manually copied one by one.

map_replace_area is designed to automatically replace all the tiles and quads from a specific area to another.
`Usage: map_replace_area <from_map> <from_x> <from_y> <to_map> <to_x> <to_y> <width> <height> <output_map>`

PoW screenshots attached below.

note: for the moment map_replace_area suppose that you are working on the same map  (that's what i needed), that means source and destination maps must have the same layers structure, or else an error is returned.
but i understand it might be useful to also work on totally different maps, in that case users must be able specify layers they want to consider by associating source map layers to destination map layers (by using a config file maybe).
i'm probably going to make another PR to add this enhancement in the future.

PoW:
![Screenshot from 2022-03-16 18-08-12](https://user-images.githubusercontent.com/3328841/158650515-17c31639-28f7-4e19-954a-b5734ee82703.png)
![Screenshot from 2022-03-16 18-08-43](https://user-images.githubusercontent.com/3328841/158650512-6e21f2b4-538f-4974-aaa2-2983551d24b4.png)
![Screenshot from 2022-03-16 18-11-50](https://user-images.githubusercontent.com/3328841/158650510-d00a05a9-a2e8-4df2-8674-0c80fd894f66.png)

5343: Add rcon and chat to integration test r=def- a=ChillerDragon

Add more action to the integration test script: chat messages, chat commands, rcon commands.
This unlocks more code coverage at runtime to catch asan issues.

It adds a very restrictive regex on the log format. But I am happy to maintain that in case changes to the log output happen.
The current version is already supporting heinrichs refactor https://github.com/ddnet/ddnet/pull/5036

Also ensure chat messages arrive in the correct format. Would have catched the following issues:
https://github.com/ddnet/ddnet/issues/5342
https://github.com/ddnet/ddnet/issues/5340
https://github.com/ddnet/ddnet/issues/5302
https://github.com/ddnet/ddnet/pull/5126

DEPENDS ON:

https://github.com/ddnet/ddnet/issues/5342
https://github.com/ddnet/ddnet/issues/5340

5465: Change from pnglite to libpng for PNG reading r=def- a=heinrich5991

This is desirable mainly because libpng is maintained and pnglite is
not. pnglite was last updated in 2007 (15 years ago) and probably has a
lot of security vulnerabilities.

libpng is an actively maintained library also used by browsers like
Firefox or Chromium, so it's less likely to contain security
vulnerabilities, also it's more likely to be packaged by Linux
distributions.

This also refuses to load images of types not supported by pnglite,
which allows us to think about backward compatibility while also
introducing libpng.

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: sctt <scottistefano91@gmail.com>
Co-authored-by: term <term@term.sinervis.pri>
Co-authored-by: f <scottistefano91@gmail.com>
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
Co-authored-by: ChillerDragon <ChillerDragon@gmail.com>
Co-authored-by: def <dennis@felsin9.de>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2022-06-21 16:21:47 +00:00
heinrich5991 4625b55ad6 Move PNG handling to src/engine/gfx
This way, it's no longer compiled into the server.
2022-06-21 15:26:23 +02:00
sctt f3bde7cf7a
map_replace_area: fixed alphabetical order in CMakeLists.txt 2022-06-21 14:00:50 +02:00
Jupeyy 65ad57a448 Change from pnglite to libpng for PNG reading
This is desirable mainly because libpng is maintained and pnglite is
not. pnglite was last updated in 2007 (15 years ago) and probably has a
lot of security vulnerabilities.

libpng is an actively maintained library also used by browsers like
Firefox or Chromium, so it's less likely to contain security
vulnerabilities, also it's more likely to be packaged by Linux
distributions.
2022-06-21 13:37:14 +02:00
heinrich5991 fad8afc083 Fix whitespace is CMakeLists.txt 2022-06-21 13:37:14 +02:00
sctt e207fa5c9f
Merge branch 'ddnet:master' into sctt-map_replace_area 2022-06-20 11:38:53 +02:00
c0d3d3v 2475e844e0
Add extras texture + asset tab 2022-06-15 22:03:52 +02:00
def 442ae7dc13 Make it easier to run integration tests
Entire worflow is now:

mkdir san
cd san
CC=clang CXX=clang++ CXXFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ..
ninja run_integration_tests
2022-06-06 18:53:59 +02:00
Dennis Felsing 51909c19ab Add CLockScope
Remove unused lock and scope in threading.h

Not sure if this is preferred

We could also try switching to std::mutex
2022-06-03 12:21:23 +02:00
bors[bot] 9dd46eb764
Merge #5260
5260: Pr thread safety negative r=heinrich5991 a=def-

WorkerThread is hard because `REQUIRES(!((CJobPool *)pUser)->m_Lock)` would require alias analysis or the function using that everywhere.

https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#negative

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2022-06-01 11:17:30 +00:00
Dennis Felsing 8c781f6a2c Add back compiler warnings on macOS (oops) 2022-06-01 09:42:11 +02:00
heinrich5991 eb2823231f Work around Windows's definition of min/max
This allows us to use `std::min`/`std::max`.
2022-05-31 17:26:35 +02:00
bors[bot] 719e3e4385
Merge #5264 #5266
5264: Prevent users from setting port 1-1023 r=Jupeyy a=def-

Following user report that they set cl_port 1 and it didn't work

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


5266: Use std::make_unique (fixes #5166) r=Jupeyy a=def-

No idea why clang-tidy's modernize-... didn't work

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
2022-05-28 16:01:32 +00:00
def 19dcd44fbe Use std::make_unique (fixes #5166)
No idea why clang-tidy's modernize-... didn't work
2022-05-28 14:46:55 +02:00
Dennis Felsing 174b855774 Enable -Wthread-safety-negative (as suggested by Chairn) 2022-05-28 02:14:46 +02:00
Dennis Felsing f9a05ebb21 Add back compiler warnings on macOS (oops) 2022-05-28 01:52:18 +02:00
Robert Müller a2465605df Remove base/tl/range.h 2022-05-27 16:36:40 +02:00
Robert Müller f9d49bd53e Remove base/tl/allocator.h 2022-05-27 16:36:40 +02:00
Robert Müller 47098daa42 Remove base/tl/algorithm.h 2022-05-27 16:36:40 +02:00
Robert Müller ca309d6ef8 Remove base/tl/array.h 2022-05-27 16:36:39 +02:00
Robert Müller bea74f3d4f Remove base/tl/sorted_array.h 2022-05-27 00:03:13 +02:00
Dennis Felsing 604142da3a Try other fix for tautological 2022-05-26 00:37:33 +02:00
Dennis Felsing 64e6ba55a1 Increase macOS target version to 10.13
src/game/client/components/tooltips.cpp:58:39: error: 'value' is unavailable: introduced in macOS 10.13
                CTooltip &Tooltip = m_ActiveTooltip.value();
                                                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/optional:959:27: note: 'value' has been explicitly marked unavailable here
    constexpr value_type& value() &
                          ^
2022-05-26 00:37:33 +02:00
Dennis Felsing f25a7d902b Don't try other linkers on macOS
ld64.lld: warning: /opt/homebrew/opt/freetype/lib/libfreetype.6.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/opt/freetype/lib/libfreetype.6.dylib
ld64.lld: warning: /usr/local/lib/libGLEW.2.2.0.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /usr/local/lib/libGLEW.2.2.0.dylib
ld64.lld: warning: /opt/homebrew/Cellar/wavpack/5.4.0/lib/libwavpack.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/wavpack/5.4.0/lib/libwavpack.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavformat.59.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavformat.59.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavcodec.59.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavcodec.59.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavutil.57.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libavutil.57.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libswscale.6.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libswscale.6.dylib
ld64.lld: warning: /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libswresample.4.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/ffmpeg/5.0.1/lib/libswresample.4.dylib
ld64.lld: warning: /opt/homebrew/Cellar/opusfile/0.12/lib/libopusfile.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/opusfile/0.12/lib/libopusfile.dylib
ld64.lld: warning: /opt/homebrew/Cellar/opus/1.3.1/lib/libopus.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/opus/1.3.1/lib/libopus.dylib
ld64.lld: warning: /opt/homebrew/Cellar/libogg/1.3.5/lib/libogg.dylib has version 12.0.0, which is newer than target minimum of 11.0.0
ld64.lld: error: LC_DYLD_INFO_ONLY not found in /opt/homebrew/Cellar/libogg/1.3.5/lib/libogg.dylib
ld64.lld: error: undefined symbol: ___glewBindSampler
>>> referenced by CMakeFiles/DDNet.dir/src/engine/client/backend/opengl/backend_opengl.cpp.o

ld64.lld: error: undefined symbol: ___glewBindSampler
>>> referenced by CMakeFiles/DDNet.dir/src/engine/client/backend/opengl/backend_opengl.cpp.o
[...]
2022-05-26 00:37:33 +02:00
ChillerDragon 630ff22303 Use CMAKE_PROJECT_NAME instead of hardcoding ddnet 2022-05-25 09:44:11 +02:00
c0d3d3v b751a2e098
Reworked Draggers 2022-05-22 21:59:33 +02:00
def 8923b75733 Disable link-time LTO-induced warning
Couldn't disable it even with gcc diagnostic ignore, since it happens
only at linktime
2022-05-22 12:20:30 +02:00
def 557253da39 Keep one C compiler flag for compiling zlib 2022-05-22 12:16:03 +02:00
def e0a55f8bdd Use better available linkers (mold > lld > gold > ld) 2022-05-22 02:00:45 +02:00
def 41b17e6ead Disable IPO by default since it slows down linking a lot 2022-05-22 01:34:34 +02:00
heinrich5991 6b65ccb945 Add HTTP masterserver registering and HTTP masterserver
Registering
-----------

The idea is that game servers push their server info to the
masterservers every 15 seconds or when the server info changes, but not
more than once per second.

The game servers do not support the old registering protocol anymore,
the backward compatibility is handled by the masterserver.

The register call is a HTTP POST to a URL like
`https://master1.ddnet.tw/ddnet/15/register` and looks like this:
```json
POST /ddnet/15/register HTTP/1.1
Address: tw-0.6+udp://connecting-address.invalid:8303
Secret: 81fa3955-6f83-4290-818d-31c0906b1118
Challenge-Secret: 81fa3955-6f83-4290-818d-31c0906b1118:tw0.6/ipv6
Info-Serial: 0

{
	"max_clients": 64,
	"max_players": 64,
	"passworded": false,
	"game_type": "TestDDraceNetwork",
	"name": "My DDNet server",
	"map": {
		"name": "dm1",
		"sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf",
		"size": 5805
	},
	"version": "0.6.4, 16.0.3",
	"clients": []
}
```

The `Address` header declares that the server wants to register itself as
a `tw-0.6+udp` server, i.e. a server speaking a Teeworlds-0.6-compatible
protocol.

The free-form `Secret` header is used as a server identity, the server
list will be deduplicated via this secret.

The free-form `Challenge-Secret` is sent back via UDP for a port forward
check.  This might have security implications as the masterserver can be
asked to send a UDP packet containing some user-controlled bytes. This
is somewhat mitigated by the fact that it can only go to an
attacker-controlled IP address.

The `Info-Serial` header is an integer field that should increase each
time the server info (in the body) changes. The masterserver uses that
field to ensure that it doesn't use old server infos.

The body is a free-form JSON object set by the game server. It should
contain certain keys in the correct form to be accepted by clients. The
body is optional if the masterserver already confirmed the reception of
the info with the given `Info-Serial`.

Not shown in this payload is the `Connless-Token` header that is used
for Teeworlds 0.7 style communication.

Also not shown is the `Challenge-Token` that should be included once the
server receives the challenge token via UDP.

The masterserver responds with a `200 OK` with a body like this:

```
{"status":"success"}
```

The `status` field can be `success` if the server was successfully
registered on the masterserver, `need_challenge` if the masterserver
wants the correct `Challenge-Token` header before the register process
is successful, `need_info` if the server sent an empty body but the
masterserver doesn't actually know the server info.

It can also be `error` if the request was malformed, only in this case
an HTTP status code except `200 OK` is sent.

Synchronization
---------------

The masterserver keeps state and outputs JSON files every second.

```json
{
	"servers": [
		{
			"addresses": [
				"tw-0.6+udp://127.0.0.1:8303",
				"tw-0.6+udp://[::1]:8303"
			],
			"info_serial": 0,
			"info": {
				"max_clients": 64,
				"max_players": 64,
				"passworded": false,
				"game_type": "TestDDraceNetwork",
				"name": "My DDNet server",
				"map": {
					"name": "dm1",
					"sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf",
					"size": 5805
				},
				"version": "0.6.4, 16.0.3",
				"clients": []
			}
		}
	]
}
```

`servers.json` (or configured by `--out`) is a server list that is
compatible with DDNet 15.5+ clients. It is a JSON object containing a
single key `servers` with a list of game servers. Each game server is
represented by a JSON object with an `addresses` key containing a list
of all known addresses of the server and an `info` key containing the
free-form server info sent by the game server. The free-form `info` JSON
object re-encoded by the master server and thus canonicalized and
stripped of any whitespace characters outside strings.

```json
{
	"kind": "mastersrv",
	"now": 1816002,
	"secrets": {
		"tw-0.6+udp://127.0.0.1:8303": {
			"ping_time": 1811999,
			"secret": "42d8f991-f2fa-46e5-a9ae-ebcc93846feb"
		},
		"tw-0.6+udp://[::1]:8303": {
			"ping_time": 1811999,
			"secret": "42d8f991-f2fa-46e5-a9ae-ebcc93846feb"
		}
	},
	"servers": {
		"42d8f991-f2fa-46e5-a9ae-ebcc93846feb": {
			"info_serial": 0,
			"info": {
				"max_clients": 64,
				"max_players": 64,
				"passworded": false,
				"game_type": "TestDDraceNetwork",
				"name": "My DDNet server",
				"map": {
					"name": "dm1",
					"sha256": "0b0c481d77519c32fbe85624ef16ec0fa9991aec7367ad538bd280f28d8c26cf",
					"size": 5805
				},
				"version": "0.6.4, 16.0.3",
				"clients": []
			}
		}
	}
}
```

`--write-dump` outputs a JSON file compatible with `--read-dump-dir`,
this can be used to synchronize servers across different masterservers.
`--read-dump-dir` is also used to ingest servers from the backward
compatibility layer that pings each server for their server info using
the old protocol.

The `kind` field describe that this is `mastersrv` output and not from a
`backcompat`. This is used for prioritizing `mastersrv` information over
`backcompat` information.

The `now` field contains an integer describing the current time in
milliseconds relative an unspecified epoch that is fixed for each JSON
file. This is done instead of using the current time as the epoch for
better compression of non-changing data.

`secrets` is a map from each server address and to a JSON object
containing the last ping time (`ping_time`) in milliseconds relative to
the same epoch as before, and the server secret (`secret`) that is used
to unify server infos from different addresses of the same logical
server.

`servers` is a map from the aforementioned `secret`s to the
corresponding `info_serial` and `info`.

```json
[
	"tw-0.6+udp://127.0.0.1:8303",
	"tw-0.6+udp://[::1]:8303"
]
```

`--write-addresses` outputs a JSON file containing all addresses
corresponding to servers that are registered to HTTP masterservers. It
does not contain the servers that are obtained via backward
compatibility measures.

This file can be used by an old-style masterserver to also list
new-style servers without the game servers having to register there.

An implementation of this can be found at
https://github.com/heinrich5991/teeworlds/tree/mastersrv_6_backcompat
for Teeworlds 0.5/0.6 masterservers and at
https://github.com/heinrich5991/teeworlds/tree/mastersrv_7_backcompat
for Teeworlds 0.7 masterservers.

All these JSON files can be sent over the network in an efficient way
using https://github.com/heinrich5991/twmaster-collect. It establishes a
zstd-compressed TCP connection authenticated by a string token that is
sent in plain-text. It watches the specified file and transmits it every
time it changes. Due to the zstd-compression, the data sent over the
network is similar to the size of a diff.

Implementation
--------------

The masterserver implementation was done in Rust.

The current gameserver register implementation doesn't support more than
one masterserver for registering.
2022-05-20 08:58:32 +02:00
heinrich5991 ac0a792dd6 Use check_cxx_compiler_flag instead of check_c_compiler_flag
We only have C++ source files left, take advantage of this and check
whether the C++ compiler supports the flags, not the C compiler. GCC for
example warns about `-Wsuggest-override` in C mode, but supports it in
C++ mode.
2022-05-19 11:16:03 +02:00
heinrich5991 2b7e1c629e Make Objective-C file Objective-C++
This removes the last C file we have, allows us to set C++ options
unilaterally.
2022-05-19 11:16:03 +02:00