Commit graph

4671 commits

Author SHA1 Message Date
Robert Müller ad69d62015 Fix long words being printed over maximum line width
When the text render encounters long words which must be broken up, ensure that the words do not exceed the maximum line width.

Closes #6354.
2023-04-09 20:09:52 +02:00
Dennis Felsing 90861d9dda Get rid of unused warning 2023-04-04 09:08:38 +02:00
VoxelDoesCode df48c44e78 Bring every Font Icon unicode into a namespace
Fix namespace hopefully
2023-04-03 20:25:28 -04:00
bors[bot] 02086e4023
Merge #6268
6268: Quit when configured bindaddr cannot be resolved, quit client when failing to open network client for 25 times  r=def- a=Robyt3



## 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 (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: Robert Müller <robytemueller@gmail.com>
2023-03-31 15:44:26 +00:00
bors[bot] a9674afb02
Merge #6451 #6466
6451: Fix `console_enable_colors` not being used, save `console_output_level` and `console_enable_colors` variables r=def- a=Robyt3

Closes #6447.

## 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 (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)


6466: Fix rcon login when disconnecting dummy and when username used r=def- a=Robyt3

When connecting a dummy and then logging into rcon only the dummy is logged in. When disconnecting the dummy, the main client was not automatically logged in. When logging in with the main client and then connecting the dummy, the dummy was already authenticated automatically. Now the main client is also authenticated automatically when disconnecting an authenticated dummy.

This automatic authentication was also not working correctly if the login used a username, as only the password was stored. Now both username and password are stored to correctly authenticate the main or dummy client.

The stored username and password are completely cleared when disconnecting, so they are not stored in memory longer than necessary.

Closes #5586.

## 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 (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: Robert Müller <robytemueller@gmail.com>
2023-03-26 12:59:00 +00:00
bors[bot] 0cf6f15590
Merge #6461
6461: Check if HTTP request task is aborted in completion callback r=def- a=Robyt3

It's possible for the HTTP request task to be aborted after the curl request has finished, so the returned `State` will be `HTTP_DONE` but `m_Abort` is `true`. The `State` never changes to `HTTP_ABORTED`, because the progress callback is not called after the HTTP request has completed.

This causes the client to crash when a skin download is aborted after the HTTP request finished but before the completion callback is called.

This is fixed by checking if `m_Abort` is `true` and setting the `State` to `HTTP_ABORTED` at the beginning of the completion callback.

Closes #3567.

## 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 (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: Robert Müller <robytemueller@gmail.com>
2023-03-26 12:40:47 +00:00
Robert Müller 7bc17b2bd8 Fix rcon login when disconnecting dummy and when username used
When connecting a dummy and then logging into rcon only the dummy is logged in. When disconnecting the dummy, the main client was not automatically logged in. When logging in with the main client and then connecting the dummy, the dummy was already authenticated automatically. Now the main client is also authenticated automatically when disconnecting an authenticated dummy.

This automatic authentication was also not working correctly if the login used a username, as only the password was stored. Now both username and password are stored to correctly authenticate the main or dummy client.

The stored username and password are completely cleared when disconnecting, so they are not stored in memory longer than necessary.

Closes #5586.
2023-03-26 14:00:50 +02:00
Robert Müller fd98ed0295 Add IStorage::RemoveFolder
Wrapper for `fs_removedir`.
2023-03-25 16:58:51 +01:00
Robert Müller ddb21ec49e Check if HTTP request task is aborted in completion callback
It's possible for the HTTP request task to be aborted after the curl request has finished, so the returned `State` will be `HTTP_DONE` but `m_Abort` is `true`. The `State` never changes to `HTTP_ABORTED`, because the progress callback is not called after the HTTP request has completed.

This causes the client to crash when a skin download is aborted after the HTTP request finished but before the completion callback is called.

This is fixed by checking if `m_Abort` is `true` and setting the `State` to `HTTP_ABORTED` at the beginning of the completion callback.

Closes #3567.
2023-03-25 12:43:19 +01:00
Robert Müller 156a1e9d14 Quit client when failing to open network client for 25 times
Prevent endless loop when client fails to open network client forever, by quitting the client after 25 failed attempts.

As described in #5555, although it doesn't fix the actual issue.
2023-03-23 21:36:04 +01:00
Robert Müller 85f5e9c5f9 Quit when configured bindaddr cannot be resolved
Quit client and server if the configured bindaddr cannot be resolved.

Disable econ if configured bindaddr cannot be resolved.

To ensure that the configured bindaddr is not silently ignored.
2023-03-23 21:34:07 +01:00
Robert Müller 2c518f2778 Remove redundant return value and rename method
Rename `LoadData` to `LoadDebugFont` so it's clearer what the method does.

The return value that is always `1` and not checked in some cases is removed.
2023-03-23 21:07:22 +01:00
Robert Müller 9f3c59000e Save console_output_level and console_enable_colors variables 2023-03-22 22:16:53 +01:00
Robert Müller 6760532491 Fix console_enable_colors not being used 2023-03-22 22:11:47 +01:00
Robert Müller 8d4f851493 Fix console chain of inp_controller_guid
The console chain was broken due to `joystick_guid` being renamed to `inp_controller_guid`, so the active controller was not being updated when the GUID is changed via the console.
2023-03-20 22:20:09 +01:00
marmare314 1ccd357f53 check for success when decoding audio 2023-03-17 10:39:17 +01:00
marmare314 115cd4c4a3 fix bug when loading invalid opus file 2023-03-17 09:12:15 +01:00
Robert Müller f88622085c Use bool + size_t for os_version_str, return true on success
Abort the test if the function fails, as the version output will be undefined in that case.
2023-03-16 20:09:08 +01:00
Robert Müller 40cee85558 Fix typo operation system -> operating system 2023-03-16 19:50:13 +01:00
Robert Müller 1b1fc8de3e Save screenshot in separate thread to avoid lags
Encoding the image as PNG and saving it to a file comprises the majority of the time when taking a screenshot.

To avoid the client freezing while a screenshot is being saved, this task is moved to a separate background thread.
2023-03-11 13:19:57 +01:00
Dennis Felsing 3428968702 Fix deprecation warning in ffmpeg 6 (fixes #6398) 2023-03-10 14:38:37 +01:00
Robert Müller f7d7592cb7 Add CTextCursor::Height() to calculate actual height of cursor 2023-03-09 23:04:18 +01:00
Robert Müller a0f1b4118d Use round_to_int in text render
For positive numbers, which the text positions always are, the result of `(int)(x + 0.5f)` is identical to `round_to_int(x)`.
2023-03-09 23:04:18 +01:00
Robert Müller 92615617b2 Use mem_copy instead of memcpy for websockets
Replace all remaining usages of `memcpy`.
2023-03-09 13:16:49 +01:00
bors[bot] 5107b38d04
Merge #6324 #6345
6324: Optimize client ids map update r=def- a=0xfaulty

I have launched support for 128 players in testing mode on my server, it's means it's time for another step in this direction here. Perhaps not all changes will be clear, I am ready to answer/discuss them as usual. Let me know if I forgot or didn't take anything into account.

## 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 (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)


6345: Set constant and uniform names for the server and client CMake targets r=def- a=Kaffeine

This MR set the server and client CMake target names to `game-server` and `game-client` which are uniform with other targets such as `engine-gfx`, `engine-shared`, and `game-shared`.

Set uniform names for the targets to:
1. Avoid long rebuilds on the target _executable_ name changed
2. Provide the same name for different executables and/or different setup (use-cases are `cmake --build . --target game-server` and various CMake target lookups in IDEs)

Those changes are necessary but not enough to allow CI for custom app name on all platforms.

Personally this 'll allow me switch to between DDNet and Infclass branches faster and without breaking the targets configuration (e.g. with that patchset I can have `game-client` as an active target in both branches), and also reduces the conflicts in `CMakeLists.txt`.
Easier to switch between the forks => easier to contribute.

Co-authored-by: Valentin Bashkirov <valenteen3d@ya.ru>
Co-authored-by: Valentin Bashkirov <v.bashkirov@dev.tassta.com>
Co-authored-by: Alexander Akulich <akulichalexander@gmail.com>
2023-03-05 16:53:37 +00:00
ChillerDragon 97ac4e791e Flush NETMSG_PING and NETMSG_PING_REPLY
The client measures the time difference between
ping send and ping reply receive.
Without MSGFLAG_FLUSH the server keeps the chunk
until the next flush which makes the ping dependend
on when the next flush happens.
2023-03-05 17:29:14 +01:00
bors[bot] a14f32cf47
Merge #6369
6369: Fix Move also requesting the current canvas size, which should report… r=Robyt3 a=Jupeyy

… a resize event

fixes #6368

For some reason KDE seems to set the current window'd size of the window (even if i use fullscreen)  for the window when its minimized. And ::Move re-requests the canvas size.

This resulted in the incorrect viewport.

Funnily enough for me under KDE this also means that the check for GotResized, to only notify the components when the canvas actually resized is now useless.

`@Robyt3` can you check if Windows is not doing this behavior? Else the previous patch is useless for the crash bug :D
On the other hand, this *could* have been part of the text container bug, tho I cannot imagine yet why

## 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: Jupeyy <jupjopjap@gmail.com>
2023-03-05 11:53:12 +00:00
ChillerDragon 20853793ee Fix server logfile error message 2023-03-02 09:44:27 +01:00
Robert Müller db4ec4a12d Replace usages of C math functions
Replacing the C standard headers with the C++ standard headers causes various `error: call to 'floor' promotes float to double [performance-type-promotion-in-math-fn,-warnings-as-errors]`, which are fixed by using the C++ std math functions or our own math functions instead of the C math functions.

- Use `absolute` instead of `abs` and `fabs`.
- Use `std::floor` instead of `floor` and `floorf`.
- Use `std::ceil` instead of `ceil`, `ceilf` and `round_ceil`.
- Use `std::round` instead of `round` and `roundf`.
- Use `std::sin` instead of `sin` and `sinf`.
- Use `std::asin` instead of `asin` and `asinf`.
- Use `std::cos` instead of `cos` and `cosf`.
- Use `std::acos` instead of `acos` and `acosf`.
- Use `std::tan` instead of `tan` and `tanf`.
- Use `std::atan` instead of `atan` and `atanf`.
- Use `std::pow` instead of `pow` and `powf`.
- Use `std::log` instead of `log` and `logf`.
- Use `std::log2` instead of `log2` and `log2f`.
- Use `std::log10` instead of `log10` and `log10f`.
- Use `std::pow` instead of `pow` and `powf`.
- Use `std::sqrt` instead of `sqrt` and `sqrtf`.
- Use `std::fmod` instead of `fmod` and `fmodf`.
- Use `direction(Angle)` instead of `vec2(std::cos(Angle), std::sin(Angle))`.
- Use `length(vec2(x, y))` instead of `std::sqrt(x * x + y * y)`.
- Remove unused `NormalizeAngular` and `AngularDistance` functions.
2023-03-01 19:26:53 +01:00
Robert Müller a76fb9b99a Replace all usages of C standard headers with C++ headers 2023-03-01 19:26:51 +01:00
Jupeyy c7362ba6c4 Fix Move and SetWindowScreen also requesting the current canvas size, which should report a resize event 2023-02-26 13:56:37 +01:00
Jupeyy 9530077588 Only call onresize events if actual size changed
clearify difference between resize and window property change for resolution list
2023-02-25 16:02:38 +01:00
Dennis Felsing fa3675d328 Improve warning text in backend_sdl 2023-02-25 10:40:36 +01:00
Robert Müller aace33fc3c Support 4 and 8 digit RGBA color values in console
In addition to values in `$RGB` and `$RRGGBB` format, also support the `$RGBA` and `$RRGGBBAA` formats for color variables.
2023-02-24 20:32:44 +01:00
Robert Müller cd15b93517 Remove unnecessary temporary variables 2023-02-24 18:11:16 +01:00
bors[bot] ebe605ab2e
Merge #6355
6355: Mark absolute #includes as absolute r=def- a=heinrich5991

Also verify that absolute imports are done using `#include <>` in CI.

## 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: heinrich5991 <heinrich5991@gmail.com>
2023-02-23 15:26:02 +00:00
heinrich5991 1a2c82c0b1 Mark absolute #includes as absolute 2023-02-23 10:53:16 +01:00
Robert Müller 3cd294372a Fix text rendering over maximum line width with newline
When a word is rendered over the maximum line width it should be moved to the next line.

However, this was not working correctly if the word ends with a newline instead of a space, because then the text x-advance including this word did not exceed the maximum width, as the newline caused the x-advance to be reset before it can be used.

This is fixed by replacing the unused flag `TEXTFLAG_ALLOW_NEWLINE` with the flag `TEXTFLAG_DISALLOW_NEWLINE`, which causes newline characters to be replaced with space characters. This flag is then used when calculating whether the next word fits in the current line.

Closes #4541.
2023-02-21 23:38:41 +01:00
Robert Müller 8286105804 Use RecreateTextContainer, reorder parameters
The `RecreateTextContainer` function calls `DeleteTextContainer` and then `CreateTextContainer`.

The arguments of `RecreateTextContainer` and `RecreateTextContainerSoft` are reordered so all functions take the text container as their first argument.
2023-02-20 23:39:43 +01:00
bors[bot] 0f37591af7
Merge #6340
6340: Various refactoring of text render r=def- a=Robyt3



## 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 (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: Robert Müller <robytemueller@gmail.com>
2023-02-20 22:19:58 +00:00
Robert Müller f386eff45c Remove unused argument of Text/TextWidth/TextLineCount
The `void *pFontSetV` argument is unused and all invocations except one were already passing `0`, `0x0` or `nullptr` for this argument.
2023-02-20 20:06:17 +01:00
Robert Müller 4284f78bb7 Various refactoring and cleanup of text render
- Use `nullptr` instead of `NULL` and `0`.
- Consistently use `unsigned` for render flags instead of mixing `int` and `unsigned`.
- Use `constexpr` instead of `#define` for constants.
- Use prefix `S` for struct instead of `C`.
- Use `\0` instead of `0` for characters.
- Mark various methods as `const` when possible.
- Mark variables and pointer parameters as `const` when possible.
- Remove `const` from pointer parameters where constness was later removed by casting to `void *` anyway.
- Use `size_t` directly for loop variables and parameters which are being cast to `size_t` later anyway.
- Move variable declarations closer to usages.
- Fix variable names.
- Add/remove empty lines to improve readability.
- Use loops to reduce duplicate code.
- Use `bool` instead of `int`.
- Replace nested `if`s with single `if` using `&&` to reduce indentation and improve readability.
- Remove unnecessary temporary variables.
- Reorder includes.
2023-02-20 20:06:17 +01:00
Robert Müller 12e8f19421 Add comments explaining UUID generation 2023-02-20 20:05:26 +01:00
Robert Müller ec7f5560a3 Fix possible integer overflows using mem_* functions 2023-02-19 13:45:48 +01:00
Alexander Akulich bb5f0f8894 Cleanup unused or not defined functions 2023-02-18 20:05:52 +03:00
Robert Müller d09393e379 Add reset command to server
Move `reset` command from client to console, so it's also available on the server.
2023-02-18 16:35:12 +01:00
Robert Müller 3173aeec6a Simplify io_write_newline error handling
Instead of returning the number of bytes written, which are platform specific, return `true` on success and `false` on failure, so no platform specific code is required when checking the result.
2023-02-18 14:13:55 +01:00
Robert Müller 3280f1824f Reset graphics container indices after deletion
Reduce duplicate code and improve correctness by passing indices of quad, buffer and text containers by reference and always setting them to `-1` after they are deleted.

Also check if index is `-1` before trying to delete it to reduce duplicate code when calling the methods.
2023-02-15 21:05:15 +01:00
bors[bot] 3fcabec30b
Merge #6328
6328: Remove `bytes_be_to_int` and `int_to_bytes_be`, static assert size of `int` and `unsigned`, refactoring r=heinrich5991 a=Robyt3

Supersedes #6263.

## 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 (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: Robert Müller <robytemueller@gmail.com>
2023-02-14 22:11:05 +00:00
ChillerDragon 4772428256 Add 0.7 system message constants 2023-02-14 11:40:55 +01:00
Robert Müller be6862e997 Use sizeof(int32_t) instead of 4 2023-02-11 13:59:08 +01:00
Alexander Akulich 2ad5c020e0 Add a simpler IServer::SnapNewItem() API based on some more generated data 2023-02-10 23:12:24 +03:00
Robert Müller 218e6f7985 Remove bytes_be_to_int and int_to_bytes_be
Use `bytes_be_to_uint` and `uint_to_bytes_be` instead.

As casting between `int` and `unsigned` preserves the bit representation of the value, it's not necessary to apply additional tricks to convert between `char` arrays and `int`.
2023-02-04 01:24:03 +01:00
Robert Müller 0a32e58367 Add error message when saving screenshot fails 2023-02-02 21:50:32 +01:00
Robert Müller bd5c39f528 Fix wrong system name being used for logging client git revision 2023-02-01 23:54:43 +01:00
bors[bot] 9bd43795c8
Merge #6293
6293: rewrite int64_t to bitset for clients mask r=Robyt3 a=0xfaulty

Alternative version for PR [#6292](https://github.com/ddnet/ddnet/pull/6292) with bitset used.
I did the naming as I would like, but I can change it if there is a more suitable one, typedef is just for shortening, can be removed.

## 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 (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: Valentin Bashkirov <v.bashkirov@dev.tassta.com>
Co-authored-by: Valentin Bashkirov <valenteen3d@ya.ru>
2023-01-31 17:06:49 +00:00
Valentin Bashkirov 056ae4091d removed bitmask.h 2023-01-31 10:07:25 +01:00
Robert Müller 31bcc59a86 Print database connection error that was previously unused
The string copied into `aError` was previously unused because the function immediately returns.

Now the error is logged to the console.
2023-01-28 16:35:32 +01:00
Robert Müller 854dc47cf7 Replace unnecessary char buffers with pointers 2023-01-28 16:35:29 +01:00
Robert Müller 25216bfddb Increase relative joystick movement based on input update time
For relative mouse movement in SDL, the `SDL_GetRelativeMouseState` function always returns distance that the mouse moved since the last call of this function.

For joysticks, we only have access to the current axis values and no accumulated values.
This made the relative joystick movement speed decrease a lot when the client's refresh rate is low.
This is now counteracted by measuring the average time between calls of `IInput::Update` and multiplying the joystick movement by this number.

Closes #6296.
2023-01-26 23:37:52 +01:00
Robert Müller 35c863b4d2 Disable relative joystick when console is open or window not focused
It shouldn't be possible to move the joystick when the console is open or when the window is not focused.
2023-01-26 23:35:55 +01:00
Robert Müller f25ffd9669 Remove unused IInput::VideoRestartNeeded
The variable is never set to `true` so the function always returns `false` and any code depend on this variable was never executed.
2023-01-26 23:35:00 +01:00
Robert Müller c2e8f6738a Use bool instead of int for m_InputGrabbed 2023-01-26 23:35:00 +01:00
Robert Müller 25872820d7 Fix division by zero when joystick deadzone is at maximum
By preventing the actual deadzone value from reaching `1.0f`.
2023-01-26 23:34:54 +01:00
Valentin Bashkirov 79f72a5d55 move typedef to protocol.h 2023-01-26 11:56:48 +01:00
bors[bot] b8e7160555
Merge #6299
6299: Show error message when downloaded map cannot be saved r=def- a=Robyt3

Check if deleting the old map file or renaming the temporary downloaded map fails. If so, show an error message which indicates that the user should delete the map file manually.

Sometimes downloaded map files seem to end up with wrong permissions, ownership or with read-only flag set, which makes the client unable to delete them.

![screenshot_2023-01-22_17-19-12](https://user-images.githubusercontent.com/23437060/213927019-ff49cb72-f60a-4c1a-b48b-d34e40d1420e.png)

Closes #5825.

## 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 (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: Robert Müller <robytemueller@gmail.com>
2023-01-23 11:41:51 +00:00
bors[bot] 54e56b0048
Merge #6302
6302: Use OpenGL 3.3 on macOS by default r=Jupeyy a=def-

Otherwise falls back to OpenGL 1.5, since 3.0 is not supported

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

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your 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 (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>
2023-01-23 11:15:46 +00:00
Dennis Felsing ec30fc7043 Use OpenGL 3.3 on macOS by default
Otherwise falls back to OpenGL 1.5, since 3.0 is not supported
2023-01-23 12:06:04 +01:00
Dennis Felsing 1af3c2274a More minimal clang-tidy 15 run
Alternative to #6294

The only remaining problems are:
/home/deen/git/ddnet/src/engine/client/backend/glsl_shader_compiler.cpp:22:26: warning: unnecessary temporary object created while calling emplace_back [modernize-use-emplace]
        m_vDefines.emplace_back(SGLSLCompilerDefine(DefineName, DefineValue));
                                ^~~~~~~~~~~~~~~~~~~~                       ~
2023-01-23 11:20:05 +01:00
bors[bot] 3ffd4205ef
Merge #6295
6295: Implement FIFO on Windows using Named Pipes r=def- a=Robyt3

Reimplement the Linux FIFO file server and client controls on Windows by using Named Pipes.

The DDNet server/client acts as a named pipe server and receives messages.
Messages can be posted to the named pipe server by connecting to it as a client.
The named pipe client can for instance be controlled from the command line with PowerShell.

The PowerShell script `scripts/send_named_pipe.ps1` is added for this purpose.
For example the PowerShell command `./send_named_pipe.ps1 "testpipe" "echo a"` sends the command `echo a` to the pipe named `testpipe`.
Multiple commands can be sent at the same time by separating them with semicolons or newlines.

## 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 (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: Robert Müller <robytemueller@gmail.com>
2023-01-22 21:40:17 +00:00
Robert Müller e29a6e2f0a Show error message when downloaded map cannot be saved
Check if deleting the old map file or renaming the temporary downloaded map fails. If so, show an error message which indicates that the user should delete the map file manually.

Sometimes downloaded map files seem to end up with wrong permissions, ownership or with read-only flag set, which makes the client unable to delete them.
2023-01-22 17:22:11 +01:00
Robert Müller f80e962888 Add IStorage::FileExists and IStorage::FolderExists
As wrappers around `fs_is_file` and `fs_is_dir`.
2023-01-22 17:22:11 +01:00
bors[bot] cd13871053
Merge #6215
6215: Don't count (connecting) players for voting r=Robyt3 a=def-

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

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your 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: def <dennis@felsin9.de>
2023-01-21 12:41:02 +00:00
Robert Müller 7eb5966f6f Implement FIFO on Windows using Named Pipes
Reimplement the Linux FIFO file server and client controls on Windows by using Named Pipes.

The DDNet server/client acts as a named pipe server and receives messages.
Messages can be posted to the named pipe server by connecting to it as a client.
The named pipe client can for instance be controlled from the command line with PowerShell.

The PowerShell script `scripts/send_named_pipe.ps1` is added for this purpose.
For example the PowerShell command `./send_named_pipe.ps1 "testpipe" "echo a"` sends the command `echo a` to the pipe named `testpipe`.
Multiple commands can be sent at the same time by separating them with semicolons or newlines.
2023-01-21 11:13:02 +01:00
Robert Müller f78fd6bda1 Minor refactoring of CFifo
- Remove unused include.
- Instead of quitting entirely, only disable the fifo component when file cannot be used.
- Return early to reduce indentation.
2023-01-20 22:52:55 +01:00
heinrich5991 e06052292e CMsgPacker doesn't know about message ID encoding
CC #6289
2023-01-20 21:09:58 +01:00
bors[bot] 4a4d6c5483
Merge #6284
6284: Ensure integer wrapping instead of preventing overflow/underflow r=heinrich5991 a=Robyt3

As the integer overflow/underflow in `UndiffItem` can happen during normal gameplay, we should in this case neither ignore the snapshot delta nor show an error message.

Instead of depending on the particular compiler doing integer wrapping, when integer overflows or underflows occur, we make it part of the design, by casting to `unsigned`, which ensures that integer wrapping is being used.

## 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 (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: Robert Müller <robytemueller@gmail.com>
2023-01-18 22:46:52 +00:00
Robert Müller 1a9357b961 Fix sv_vanilla_antispoof for vanilla 0.6.5 clients
This fixes issues that prevented vanilla 0.6.5 clients from joining DDNet servers with `sv_vanilla_antispoof 1` (closes #2074).

The dummy map was not valid. The size of the tiles and game layers was calculated incorrectly. The last member variable included in `CMapItemLayerTilemap` version 2 should be `m_Data`. Previously only the size of the member `m_aName` was subtracted from the total size, which was resulting in an incorrect item size, as the size of the following 5 members also needs to be subtracted.

The handshake messages were packed incorrectly. The message ID and the system flag were not added to the six packers that are passed to `SendMsgs`. The lines that are removed in this function seemed to assume that the message ID was already added but not packed, which was no longer the case. Presumable at some point `CMsgPacker` was changed without adapting the vanilla antispoof feature. Now, the message ID and system flag are properly packed when initially creating the message packers.

The `dummy_map` tool is improved to also print the generated map file's hashes and data as a C style array, so the data can immediately be copied to `network_server.cpp`.
2023-01-18 20:21:12 +01:00
Robert Müller 65cb2ed7de Ensure integer wrapping instead of preventing overflow/underflow
As the integer overflow/underflow in `UndiffItem` can happen during normal gameplay, we should in this case neither ignore the snapshot delta nor show an error message.

Instead of depending on the particular compiler doing integer wrapping, when integer overflows or underflows occur, we make it part of the design, by casting to `unsigned`, which ensures that integer wrapping is being used.
2023-01-16 18:12:28 +01:00
Dennis Felsing 43e994a002 Fix announcement feature, don't depend on buffer staying consistent
There is a change in behavior: The file is now only reread if the
filename changed, previously it was reread every time.
2023-01-13 16:22:22 +01:00
Dennis Felsing b62e7f1299 Quick fix for old client on new server
Introduced in https://github.com/ddnet/ddnet/pull/6214/
Not a proper solution yet
2023-01-13 14:46:01 +01:00
bors[bot] dd09c59710
Merge #6269
6269: Fix ddnet.org change in UUIDs r=def- a=heinrich5991

One case was a ddnet.tw UUID's string being changed (but the UUID was not), and the other case is a ddnet.tw UUID's string being changed in one place but not in another in documentation.

Fixes the commit c479230d71.

CC #5312

## 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: heinrich5991 <heinrich5991@gmail.com>
2023-01-12 16:45:27 +00:00
heinrich5991 f2530cfbf2 Add forgotten call 2023-01-12 16:18:03 +01:00
heinrich5991 a0221c3038 Fix ddnet.org change in UUIDs
One case was a ddnet.tw UUID's string being changed (but the UUID was
not), and the other case is a ddnet.tw UUID's string being changed in
one place but not in another in documentation.

Fixes the commit c479230d71.

CC #5312
2023-01-12 15:38:17 +01:00
bors[bot] a93f89c72a
Merge #6266
6266: Show current memory usage in assert too r=def- a=Jupeyy

Since it seems a rather common problem:
![image](https://user-images.githubusercontent.com/6654924/211884998-11486383-a1a2-4313-9a4c-7bfa6034164c.png)


## 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: Jupeyy <jupjopjap@gmail.com>
2023-01-11 18:53:03 +00:00
Jupeyy 69c3fa2a61 Show current memory usage in assert too 2023-01-11 19:26:04 +01:00
Jupeyy 8a8dab5611 Missing parameter in error list 2023-01-11 18:46:33 +01:00
heinrich5991 05f2c1e43f Hand the client IP addresses to the antibot module 2023-01-11 01:35:50 +01:00
Robert Müller 066768cf70 Use distinct error return codes for CSnapshotDelta::UnpackDelta
Use a different error code for every return statement, so it's easier to determine why unpacking a delta failed.

The codes are grouped by the first digit of the error code:

- `-1xx`: not enough data to read
- `-2xx`: value is invalid
- `-3xx`: could not build snapshot item
2023-01-08 14:31:07 +01:00
bors[bot] 69931336fc
Merge #6242
6242: Add skin to serverbrowser's scoreboard r=def- a=Jupeyy

with #6240 we might get few more pixels for either flag or margin

![image](https://user-images.githubusercontent.com/6654924/211063976-4acb60ca-9a49-4d1b-b556-a82f88b28303.png)


## 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: Jupeyy <jupjopjap@gmail.com>
2023-01-07 10:29:22 +00:00
Jupeyy 1182180e23 Add skin to serverbrowser player list 2023-01-07 09:20:25 +01:00
Adrian Bunk abb1979d20 src/engine/shared/datafile.cpp: Re-add #include <base/math.h> for big endian 2023-01-07 04:38:06 +02:00
bors[bot] f79412c59c
Merge #6244 #6245 #6246
6244: Minor base refactoring r=def- a=Robyt3


## 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)


6245: Add ingame and browser buttons to copy server info to clipboard r=def- a=Robyt3

Add "Copy info" buttons to server browser and ingame menu to copy the server info of the selected/current server to the clipboard.

The margins around the server browser details are improved.

Closes #5440.

Screenshots:
- browser (old):
![browser old](https://user-images.githubusercontent.com/23437060/211093742-b877f1e2-6be0-4827-b1c8-0fd209f697aa.png)
- browser (new):
![browser new](https://user-images.githubusercontent.com/23437060/211093750-f0b3e2c2-8f95-42e1-94bf-ec8b9da4132f.png)
- ingame: 
![ingame](https://user-images.githubusercontent.com/23437060/211093736-04569b8e-96d6-40ab-a37e-8c581f2d8aea.png)


## Checklist

- [X] Tested the change ingame
- [X] 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)


6246: Remove dead freeze code r=def- a=Zwelf

Remove unused `m_FreezeTime == -1` state

Reduces code complexity. Both `g_Config.m_SvFreezeDelay`[[1]] and `GetSwitchDelay(int Index)`[[2]] can only return non-negative numbers, therefore this is currently dead code and can be removed.

The last time it was possible to pass a negative number was removed in 561ce64666 (diff-29ffe32916052e1066eed938021aadfeb29f855d7c63d9c1ca3350aceffb79f3L1624)

[1]: c8ea372d98/src/engine/shared/config_variables.h (L213)
[2]: c8ea372d98/src/game/mapitems.h (L467)

## 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: Robert Müller <robytemueller@gmail.com>
Co-authored-by: Zwelf <zwelf@strct.cc>
2023-01-06 22:56:49 +00:00
Robert Müller fc7c376738 Add ingame and browser buttons to copy server info to clipboard
Add "Copy info" buttons to server browser and ingame menu to copy the server info of the selected/current server to the clipboard.

The margins around the server browser details are improved.

Closes #5440.
2023-01-06 21:23:33 +01:00
Jupeyy 9cf82dfcbc Add warning for missing integrated CPU driver 2023-01-06 20:57:31 +01:00
Jupeyy 334b0fe757 Followup fixes for physical devices 2023-01-06 20:57:27 +01:00
Jupeyy fda0f5a29d Add error handling when enumerating physical devices 2023-01-06 15:11:46 +01:00
Dennis Felsing 6a13008147 Update translations for upcoming 16.7 2023-01-05 09:39:34 +01:00
bors[bot] c7192d703e
Merge #6226 #6230
6226: Remove projectiles on save and load r=def- a=Zwelf

Restructured CSaveTeam a bit, because I also needed access to CGameWorld. I don't store pointer to IGameController in CSaveTeam anymore, because we pass CSaveTeam to the database thread. If it would be accessed there, it could cause a race conditions.

## 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 (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
- [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


6230: For integrated and discrete GPUs always prefer what comes first in the list r=def- a=Jupeyy

fixes #6200

## 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: Zwelf <zwelf@strct.cc>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2023-01-04 18:03:11 +00:00
Jupeyy 7ca20a5873 For integrated and discrete GPUs always prefer what comes first in the list 2023-01-04 18:25:35 +01:00
Jupeyy a077c01b80 Less translations for vk errors from backend 2023-01-04 18:19:53 +01:00
bors[bot] 6d3af742dd
Merge #6180
6180: Implement exact matches in search and exclude strings r=Robyt3 a=def-

Thanks to bencie for discussion

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

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your 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 (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>
2023-01-03 18:16:03 +00:00
Robert Müller 9ea665cd69 Fix undefined demo timeline markers when recording is not stopped
When the demo recording is not stopped properly (e.g. client crashes during recording), the timeline markers and the demo length are not updated.
The length is always set to zero when starting the recording, but uninitialized memory is written for the timeline markers, which causes these demos to likely show the maximum number of markers with some markers possibly being outside the ticks that the demo contains.
This is fixed by initially setting all timeline marker data to zero when starting the recording.
2023-01-03 15:38:54 +01:00
Robert Müller c2c21298e2 Fix signed integer overflow on client input message
Swap mathematical operations to avoid multiplication by `1000`. As `time_freq()` returns the nanoseconds in a second (1e9), first dividing this number by 1000 does not lose any precision.

Also ensure that `IntendedTick` is in the valid range of ticks.

```
src/engine/server/server.cpp:1585:64: runtime error: signed integer overflow: 24185120014282423 * 1000 cannot be represented in type 'long int'
    0 0x55c165f220aa in CServer::ProcessClientPacket(CNetChunk*) src/engine/server/server.cpp:1579
    1 0x55c165f3a8d3 in CServer::PumpNetwork(bool) src/engine/server/server.cpp:2383
    2 0x55c165f51166 in CServer::Run() src/engine/server/server.cpp:2821
    3 0x55c165eb37d0 in main src/engine/server/main.cpp:191
    4 0x7f99e4c3ad8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    5 0x7f99e4c3ae3f in __libc_start_main_impl ../csu/libc-start.c:392
    6 0x55c165e7ab64 in _start (build-asan/DDNet-Server+0xd7ab64)
```
2023-01-03 14:10:58 +01:00
Robert Müller 706eb0d015 Remove unnecessary include in protocol, move definitions to cpp file
The include of `base/system.h` in `src/engine/shared/protocol.h` is not required and only used transitively in `teamscore.h` for `dbg_assert`.

To avoid adding back the include in `teamscore.h`, the function definitions are moved to the cpp file. Both definitions are moved for consistency.
2023-01-03 14:10:58 +01:00
Robert Müller e4b1db1b6d Fix spelling of NETMSG_AUTH_CHALLENGE constant 2023-01-03 14:10:57 +01:00
Robert Müller 25e01eb762 Add constants for minimum and maximum tick values 2023-01-03 14:10:57 +01:00
Robert Müller 179e3b1c4c Register application separately to specify its displayed name
The application itself must also be registered in a separate registry key, so its displayed name can be set.

See: https://learn.microsoft.com/en-us/windows/win32/shell/app-registration
2023-01-02 17:35:16 +01:00
Robert Müller 6e28ca6fe4 Extract method IStorage::GetBinaryPathAbsolute 2023-01-02 15:29:43 +01:00
bors[bot] b252f2e344
Merge #6199
6199: Register protocol and file extensions on client launch on Windows r=def- a=Robyt3

When launching the client on Windows, associate the protocol `ddnet` and the file extensions `.map` and `.demo` with the client executable.

See #6072.

## 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 (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: Robert Müller <robytemueller@gmail.com>
2023-01-02 12:58:15 +00:00
def 39b34bf40c Don't count (connecting) players for voting 2023-01-02 11:25:13 +01:00
Robert Müller 4118074768 Fix signed integer overflow when unpacking snapshot delta
```
src/engine/shared/snapshot.cpp:219:18: runtime error: signed integer overflow: -2011501152 + -1594687485 cannot be represented in type 'int'
    0 0x5593cbc3534c in CSnapshotDelta::UndiffItem(int const*, int*, int*, int, int*) src/engine/shared/snapshot.cpp:219
    1 0x5593cbc3852d in CSnapshotDelta::UnpackDelta(CSnapshot*, CSnapshot*, void const*, int) src/engine/shared/snapshot.cpp:442
    2 0x5593cbb881a6 in CDemoPlayer::DoTick() src/engine/shared/demo.cpp:624
    3 0x5593cbb9a907 in CDemoPlayer::Update(bool) src/engine/shared/demo.cpp:1016
    4 0x5593ca9f44da in CClient::Update() src/engine/client/client.cpp:2628
    5 0x5593caa199dd in CClient::Run() src/engine/client/client.cpp:3220
    6 0x5593caa970f3 in main src/engine/client/client.cpp:4717
    7 0x7fe086d04d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    8 0x7fe086d04e3f in __libc_start_main_impl ../csu/libc-start.c:392
    9 0x5593ca55e6f4 in _start (build-demofuzz/DDNet+0x24936f4)
```
2022-12-31 12:06:31 +01:00
Robert Müller d63a7a3c84 Fix left shift of negative value when unpacking snapshot delta
```
src/engine/shared/snapshot.cpp:693:28: runtime error: left shift of negative value -1
    0 0x55cae1608071 in CSnapshotBuilder::NewItem(int, int, int) src/engine/shared/snapshot.cpp:686
    1 0x55cae1603fe0 in CSnapshotDelta::UnpackDelta(CSnapshot*, CSnapshot*, void const*, int) src/engine/shared/snapshot.cpp:390
    2 0x55cae15544c6 in CDemoPlayer::DoTick() src/engine/shared/demo.cpp:624
    3 0x55cae1566c27 in CDemoPlayer::Update(bool) src/engine/shared/demo.cpp:1016
    4 0x55cae03c07fa in CClient::Update() src/engine/client/client.cpp:2628
    5 0x55cae03e5cfd in CClient::Run() src/engine/client/client.cpp:3220
    6 0x55cae0463413 in main src/engine/client/client.cpp:4717
    7 0x7fbc7d855d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    8 0x7fbc7d855e3f in __libc_start_main_impl ../csu/libc-start.c:392
    9 0x55cadff2aa14 in _start (build-demofuzz/DDNet+0x2493a14)
```
2022-12-31 12:06:31 +01:00
Robert Müller 6800bd90a4 Fix edge cases where demo tick seeking did not work
Instead of using hardcoded tick offsets, use the current/previous/next tick values from the demo info.

This fixes seeking the next tick not working for demos where the difference between the current and the next tick was greater than 3.
2022-12-30 21:05:46 +01:00
Robert Müller a3e48bef27 Prevent temporary demo file from being deleted multiple times
Each time the client disconnected or stopped a demo, it tried to delete the previous temporary replay file, which causes an error message "could not delete file" to be shown in the console.

This is prevented by clearing the current filename of the demo recorder after deleting the file.
2022-12-30 14:20:42 +01:00
Robert Müller a61eec8f1e Add DDNet settings button to unregister protocol and file extensions
Add a button to the Miscellaneous DDNet settings to manually unregister the protocol and file extension handlers.
2022-12-29 18:03:08 +01:00
Robert Müller db3d1f19a9 Register protocol and file extensions on client launch on Windows
When launching the client on Windows, associate the protocol `ddnet` and the file extensions `.map` and `.demo` with the client executable.
2022-12-29 18:03:08 +01:00
bors[bot] f230ad0bdc
Merge #6191
6191: Use own defines of format specifiers for MinGW (fixes #6187) r=Jupeyy a=Chairn

Counter proposition to #6188. Redefines our own specifiers

## 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: Chairn <chairn.nq@hotmail.fr>
2022-12-28 20:59:17 +00:00
bors[bot] 46209376ad
Merge #6164
6164: Automatically register ddnet:// url handler on macOS r=Robyt3 a=def-

Should work automatically on first time running client.

See https://hublog.hubmed.org/archives/001154

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

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your 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-12-26 15:53:33 +00:00
bors[bot] 667d588e55
Merge #6179
6179: Ignore connecting players in search terms when "Filter connecting players" is on r=heinrich5991 a=def-

Thanks to bencie for reporting

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

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your 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 (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-12-26 01:27:13 +00:00
Chairn 3132c96a80 Use own defines of format specifiers for MinGW (fixes #6187) 2022-12-25 21:18:05 +01:00
def c3909d7cdb Just quiet curl warnings for now 2022-12-25 19:34:19 +01:00
Dennis Felsing 779b44fde5 Support .demo and .map files being dragged into client
Only tested on macOS, but should work everywhere
2022-12-24 01:06:06 +01:00
Dennis Felsing bfe4ced662 Automatically register ddnet:// url handler on macOS
Works automatically on first time running client. Whenever you click on
a URL it is automatically opened in the current client, same as writing
"connect ip:port" into F1.

See https://hublog.hubmed.org/archives/001154 and
https://wiki.libsdl.org/SDL2/SDL_DropEvent
2022-12-24 00:26:35 +01:00
Dennis Felsing 68625dd370 Implement exact matches in search and exclude strings
Thanks to bencie for discussion
2022-12-23 23:25:11 +01:00
Dennis Felsing f65f2bd1d1 Ignore connecting players in search terms when "Filter connecting players" is on
Thanks to bencie for reporting
2022-12-23 15:59:46 +01:00
Robert Müller 51e99b99cb Pass SDL event structure directly to handler functions
Instead of passing the generic `SDL_Event` to the handler functions and getting the specific structure inside the functions, pass the specific structure directly to the functions.
2022-12-18 12:41:54 +01:00
Robert Müller 2579f0be2f Add support for hot-plugging gamecontrollers
Handle the appropriate SDL events to open new joysticks when they are connected and remove joysticks when they are disconnected.

If the active joystick gets disconnected, then the first joystick in the list will be activated as a fallback.
If the previously activated joystick gets reconnected, it will be activated again automatically, as it is identified by the GUID stored in the configuration.
The stored joystick GUID is only updated when the user manually selects a new joystick in the controls settings or with the console.

Closes #6152.
2022-12-18 12:41:17 +01:00
Robert Müller 1eaa88b236 Handle ordinal joystick hat keys as combined cardinal hat keys
Instead of considering diagonal hat inputs (e.g. up-left) as separate keys, consider them as inputs for both cardinal directions (e.g. up and left) at the same time.

This improves input with gamecontrollers that map the D-Pad to a joystick hat, as it was impossible with the previous handling to move with hat-left/right and jump with hat-up at the same time.

This means that diagonal hat buttons can no longer be used in binds, because they are no longer considered distinct buttons. It's unlikely that they would ever be useful in this game, as real joystick POV hats would not be used anyway.

Closes #6120.
2022-12-17 17:18:01 +01:00
Dennis Felsing a59613e56f Use %zu formatter for size_t, not PRIu64 (which is for uint64_t) 2022-12-16 16:40:10 +01:00
Robert Müller a0553f2d40 Fix editor smooth zooming when joining/reloading game
Using `IClient::LocalTime` for smooth zooming in the editor causes the zoom to behave incorrectly when joining a game, as the local time is reset when joining a game.
This is fixed by adding a separate `IClient::GlobalTime` which is only set once when the client launches and never resets.
2022-12-15 18:18:06 +01:00
Jupeyy 5341fc37fd Minimal changes to default to Vulkan 2022-12-13 19:37:03 +01:00
Jupeyy 870ea8566e Improve error handling in vulkan
so it doesn't assert & shows a message box with the error and some tips
2022-12-13 18:11:26 +01:00
Jupeyy dff876d58c Add Localizable hint 2022-12-13 17:53:32 +01:00
Dennis Felsing 412a9461c0 Fix conflict resolution between #6013 and #5948
Thanks @Robyt3 for noticing
2022-12-12 14:13:32 +01:00
bors[bot] c96310464e
Merge #6119
6119: Fix client attempting to delete user directory when stopping replay demo r=Chairn a=Robyt3

When the client stops a replay demo and tries to remove the temporary file when being disconnected, it's not checked whether a recording of a replay demo has ever been started. In this case the filename is empty, which leads to the client trying to delete the user's directory, which will fail with an error message, as it's a folder and cannot be deleted with the function designed for deleting files.

This is fixed by calling the function `DemoRecorder_Stop` to delete the temporary demo file, as this function already makes sure that the filename is not empty.

## 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 (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: Robert Müller <robytemueller@gmail.com>
2022-12-11 14:43:51 +00:00
Robert Müller 144a69266c Fix client attempting to delete user directory when stopping replay demo
When the client stops a replay demo and tries to remove the temporary file when being disconnected, it's not checked whether a recording of a replay demo has ever been started.
In this case the filename is empty, which leads to the client trying to delete the user's directory, which will fail with an error message, as it's a folder and cannot be deleted with the function designed for deleting files.

This is fixed by calling the function `DemoRecorder_Stop` to delete the temporary demo file, as this function already makes sure that the filename is not empty.
2022-12-11 15:05:31 +01:00
Robert Müller 7958b999a3 Copy the demo timeline markers when slicing a demo
When slicing a demo, also copy the demo markers that are within the sliced segment to the new demo.

This also fixes timeline markers not being added to replay demos, as the replay demos are always created by slicing.

Closes #6116.
2022-12-11 14:34:21 +01:00
bors[bot] 5290193f1f
Merge #6110
6110: Remove successful queries from write backup r=def- a=Zwelf

Fixes #6106

Seems like I didn't tested before whether the rank got removed in the successful path.

## 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 (especially base/) or added coverage to integration test
- [x] Considered possible null pointers and out of bounds array indexing
- [x] 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: Zwelf <zwelf@strct.cc>
2022-12-09 23:22:44 +00:00
bors[bot] ebe9024a66
Merge #6051
6051: Null-terminate string returned by mysql r=Zwelf a=def-

Found in #6050 that a 16 byte long name would be written, filling up the string entirely, no terminating '\0'

## 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-12-09 21:58:45 +00:00
Zwelf 9f1bbbe63b Remove successful queries from write backup 2022-12-09 20:06:14 +01:00
bors[bot] 3438e272af
Merge #6101
6101: Remove check for `pResponseToken`, which isn't used on this code path r=def- a=Robyt3

Closes #6100.

## 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 (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: Robert Müller <robytemueller@gmail.com>
2022-12-06 20:01:41 +00:00
Robert Müller 9bc0028b94 Remove check for pResponseToken, which isn't used on this code path
Closes #6100.
2022-12-06 20:37:59 +01:00
Robert Müller 7e1fc0344e Reduce duplicate code by extracting CNetBan::CBanPool::InsertUsed 2022-12-06 20:18:08 +01:00
Dennis Felsing b04cdacaeb Bump friends limit from 1024 to 4096 (fixes #6096) 2022-12-06 10:31:43 +01:00
Robert Müller 57d5c5a3d5 Use for-each loop instead of for-loop 2022-12-05 23:15:35 +01:00
Robert Müller 6d8fad775d Encapsulate m_ResortServerBrowser inside CServerBrowser
The variable `m_ResortServerBrowser` was only used in the client to pass it to the server browser. For better separation of concerns, this variable is moved inside `CServerBrowser` and the function `RequestResort` should be called to set it to `true`.

The existing variable `m_SortOnNextUpdate` is replaced with this, as it served the same purpose already. The variable name from upstream is used to reduce conflicts.
2022-12-05 23:15:35 +01:00
Robert Müller d0635246c8 Remove unused m_NeedRefresh variable 2022-12-05 23:13:06 +01:00
Robert Müller a6e0e37c4a Use consistent system name serverbrowser for log messages 2022-12-05 23:13:06 +01:00
Robert Müller 0c8aac6f05 Remove unnecessary MatchFound variable
This variable is always `1` when `m_ppServerlist[i]->m_Info.m_QuickSearchHit` is not `0`.
2022-12-05 23:13:02 +01:00