Commit graph

12110 commits

Author SHA1 Message Date
bors[bot] e71ce8fcde
Merge #5998
5998: Fix Ctrl+F hotkey not checking for Ctrl key, minor improvement to tile details popup layout 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>
2022-11-01 22:10:19 +00:00
Robert Müller 886ec990fe Add missing check for modifier of Ctrl+F hotkey
The hotkey for the "Find empty slot" button was not correctly checking for a pressed modifier, so it was already being trigger by just the key F instead of the desired Ctrl+F.
2022-11-01 23:01:32 +01:00
Robert Müller 8e9b4ddcd2 Refactor tile details popup height, variable names
The height is calculated based on the number of rows and the row height instead of being entirely hardcoded, which makes maintenance easier.
The total height of the speedup popup was slightly too large, which is also fixed by this.
Variable names and their declaration positions are also refactored.
2022-11-01 23:01:28 +01:00
Robert Müller 0db4b5fe0c Refactor border button condition, move button variable
The conditions can be combined into one if-statement to better readability.
2022-11-01 22:30:56 +01:00
Robert Müller c29d4b984c Remove redundant CUIRects, improve find button height
Some of the CUIRects were calculated but never used.
The height of the "Find empty slot" button is made consistent with the height of the properties shifters.
2022-11-01 22:29:12 +01:00
Robert Müller d6d88d4370 Allow selecting switch number 0 in editor again
This reverts part of #5993 to allow switch number 0 to be selected again.
Switch number 0 is permanently enabled, so it useful for tiles that should always be switched on.
Eventually tiles that don't work with switch 0 (e.g. switch open/close tiles) should be made unplaceable and the switch number should be hidden for tiles where it doesn't have any effect (e.g. jump tiles). See #5995.
2022-11-01 21:52:49 +01:00
heinrich5991 b502e678dc Allow the test suite to run offline
Allow host resolving to fail, but still check its results if it
succeeds.
2022-11-01 14:23:53 +01:00
bors[bot] 846b569a86
Merge #5994
5994: Change editor hotkey Ctrl+A to Ctrl+T for layer/tile details r=def- a=Robyt3

The hotkey Ctrl+A is already active universally in the editor to open and append a map to the current one. This collides with the hotkeys for opening the layer/tile details popup for tune, tele, speedup and switch layers, which is only active when a layer of said type is select. Pressing the hotkey in this context opens the popup and the append dialog at the same time, which is undesirable. Therefore the hotkey to open the layer/tile details is changed to Ctrl+T instead. This combination is currently unused and seems approriate, as the T could stand for "Tile details".

## 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-11-01 12:35:28 +00:00
Robert Müller c916e5d262 Change editor hotkey Ctrl+A to Ctrl+T for layer/tile details
The hotkey Ctrl+A is already active universally in the editor to open and append a map to the current one.
This collides with the hotkeys for opening the layer/tile details popup for tune, tele, speedup and switch layers, which is only active when a layer of said type is select.
Pressing the hotkey in this context opens the popup and the append dialog at the same time, which is undesirable.
Therefore the hotkey to open the layer/tile details is changed to Ctrl+T instead. This combination is currently unused and seems approriate, as the T could stand for "Tile details".
2022-11-01 13:13:22 +01:00
Robert Müller c6fa29eb56 Fix incorrect minimum values for tele, speedup and switch layers
It was possible to select tele number 0, speedup force 0 and switch number 0 in the layer details in the editor, because some of the bounds checks or calculations were not excluding the value 0.
As placing those tiles with the value 0 in the editor is not possible and the tiles with this value are ignored by server and client, it also shouldn't be possible to select those values in the first place.
2022-11-01 12:11:18 +01:00
bors[bot] 571b0b36de
Merge #5770
5770: Fix physics change by weak hook fix (fixes #5769) r=def- a=fokkonaut

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

## 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: fokkonaut <35420825+fokkonaut@users.noreply.github.com>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2022-11-01 10:29:53 +00:00
bors[bot] 1fe482232b
Merge #5991
5991: Handle all `MultiByteToWideChar` and `WideCharToMultiByte` return values r=def- a=Robyt3

Closes #5970.

## 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: Robert Müller <robytemueller@gmail.com>
2022-10-29 21:40:50 +00:00
Robert Müller 6501ae9b9d Add checks for remaining WideCharToMultiByte usages in system
Converting wide-char (UTF-16) to multi-byte (UTF-8) takes 1-2 wide-chars from the input and transforms them to 1-4 bytes, so having `char` and `WCHAR` buffers with equal static lengths means that this function can fail due to insufficient buffer sizes when the user has folder or files with very long names (many unicode codepoints).
Therefore checks are added that allow only the error `ERROR_INSUFFICIENT_BUFFER` when `WideCharToMultiByte` fails, which is expected on very long paths, as these would also lead to further errors later in the code. The respective functions will now fail with a return and ignore files that have too long names.
This could only completely be fixed using dynamically sized buffers for all paths, which seems like too much work and overhead.
Other errors are not expected and hence caught by the assertions, as those would indicate programming errors like wrong arguments being passed.

Reference: https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte
2022-10-29 21:17:48 +02:00
Robert Müller 6c30fb6f5a Remove duplicate buffer from fs_listdir functions
The second buffer was previously used when calling `fs_is_dir` explicity, but it has become from obsolete from #4657 by using the flag `FILE_ATTRIBUTE_DIRECTORY` instead.
2022-10-29 21:17:48 +02:00
Robert Müller 8bde109acb Use dynamic size for formatted Windows system messages
Extract `windows_format_system_message` and allocate appropriate buffer for the formatted system error messages, so messages of any length can be displayed.

The flag `FORMAT_MESSAGE_ALLOCATE_BUFFER` is used so `FormatMessageW` allocates the buffer which must later be freed with `LocalFree`.

The flag `FORMAT_MESSAGE_MAX_WIDTH_MASK` is also added so the formatted message will not contain any line breaks at the end, which would make log messages less readable.

Reference: https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessagew
2022-10-29 21:17:47 +02:00
Robert Müller a1c1a8f972 Add assertions for all MultiByteToWideChar usages in system
Converting multi-byte (UTF-8) to wide-char (UTF-16) take 1-4 bytes from the input and transforms them to 1-2 wide-chars, so having `char` and `WCHAR` buffers with equal lengths should mean that this function can't fail due to insufficient buffer sizes, unless a path that's already too long for Windows is being used internally.
Other errors are also not expected, as those would indicate programming errors like wrong arguments being passed.

The maximum length for paths in the Win32 API is 260 characters. This limitation can be lifted in Windows 10, but it must be done explicitly (opt-in) both in the Windows Registry by the user and in the application's manifest by us.

References:

- https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar
- https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
2022-10-29 21:17:47 +02:00
Robert Müller 72991fbe9a Use dynamic buffer size in CLoggerWindowsDebugger
Make sure the Windows debugger logger does not fail when log messages are too long.

The first call to `MultiByteToWideChar` gets the required size of the wide-char buffer, which should be at least one for the null termination. The second call is expected to produce exactly the same number of characters.
2022-10-29 21:17:47 +02:00
Robert Müller f74797ae0c Use assertions in CWindowsConsoleLogger instead of error messages
The function `MultiByteToWideChar` can't fail unless wrong arguments are passed, when the buffer size is set correctly by calling the function twice. The returned buffer size on the second call should always match the buffer size determined with the first call.
2022-10-29 21:17:47 +02:00
def a237ee5f6d Improve callvote arguments by making them more specific
Should make it a bit clearer how to call a vote from F1
2022-10-29 14:45:24 +02:00
Robert Müller 6c8fa6b4f0 Rename variable aBuf to pBuf, use size_t for buffer size 2022-10-27 22:21:08 +02:00
Robert Müller d551617c34 Use str_copy instead of str_format with format "%s"
Using `str_format(aBuf, sizeof(aBuf), "%s", pStr)` is equivalent to `str_copy(aBuf, pStr, sizeof(aBuf))`. Using `str_copy` is more readable and also more efficient as there is no overhead from parsing the format string and from passing varargs.
2022-10-27 21:42:14 +02:00
Jupeyy 3b2dd73614 Rename config var to no weak only 2022-10-27 17:51:30 +02:00
fokkonaut cedc315a70 Fix physics change by weak hook fix (fixes #5769) 2022-10-27 17:44:54 +02:00
bors[bot] 47b351134a
Merge #5985
5985: Fix large editor popups being outside of screen, add margin r=def- a=Robyt3

Large editor popups could be positioned outside of the screen area, when they could not be positioned below or to the right of the cursor without overflowing. This is fixed by making sure the popup does not overflow the top or left side of the screen after adjusting its position.

A small margin is also added so popups don't start or end immediately at the screen border.

Closes #5982.

## 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-10-25 22:08:44 +00:00
Dennis Felsing 1f5d7a0afd Version 16.5 2022-10-25 23:21:02 +02:00
Robert Müller 6b7563a90b Fix large editor popups being outside of screen, add margin
Large editor popups could be positioned outside of the screen area, when they could not be positioned below or to the right of the cursor without overflowing. This is fixed by making sure the popup does not overflow the top or left side of the screen after adjusting its position.

A small margin is also added so popups don't start or end immediately at the screen border.

Closes #5982.
2022-10-25 20:16:39 +02:00
Rafael Fontenelle cd14660307 Fix misspellings 2022-10-25 13:51:56 -03:00
ChillerDragon 668de11b2b Add tests for Huffman compression 2022-10-25 14:04:50 +02:00
Robert Müller 6ef3adaa23 Fix long demo names being truncated in popups and UI
Use `IO_MAX_PATH_LENGTH` for all demo filenames and paths, so long demo names and demo names containing many unicode characters are not so easily truncated in the cut, rename and render dialogs.

Use combination of `str_endswith` and `str_append` to append file extensions, instead of using `str_comp_nocase` and `str_format`. Thereby only support creating demos and video files with lower case file extension, as only demo files with lower case file extension are shown in the client anyway.
2022-10-24 20:42:52 +02:00
Robert Müller b486028838 Remove dead code
The `PopupMessage` was never shown, as the next line activates `POPUP_REPLACE_VIDEO` which immediates overrides the message popup.
2022-10-24 20:18:09 +02:00
Robert Müller 326a0a576d Fix slicing a demo opened with absolute path not working
Slicing a demo opened from command line with an absolute path did not work, as the game only tried to load the source demo from storage instead of using the given absolute path.
2022-10-24 20:15:49 +02:00
Robert Müller 997af452d0 Fix crash when cutting a demo opened from command line
When playing a demo without opening the demo menu first, i.e. from command line argument or with `play` command from the main menu, clicking the demo slice button crashes the game, as the code tries to use the filename of the currently selected demo while there is no demo selected, i.e. `m_DemolistSelectedIndex == -1`.
Also, when using the play command after opening the demo menu, the initial filename selected for cutting was incorrectly set to the currently selected demo.

This is fixed by getting the name of the current demo file from the demo player instead, when cutting a demo.
Though the cut demo will be saved to the last demo folder selected (or the demos directory) instead of being saved to the same directory as the original demo.
2022-10-24 20:14:04 +02:00
Robert Müller 3c1cd89ae6 Append file extension before checking for identical cut demo filename
The file extension needs to be appended to the cut demo name before checking whether the name matches the currently playing file, otherwise the "Please use a different name" error message is not shown and instead the "File already exists" question is shown.
2022-10-24 19:53:42 +02:00
Robert Müller be45604354 Fix demo file not being closed after showing error message
When entering the name of an existing demo file into the Slice demo dialog and pressing the Ok button twice, the file handle that's used for checking for the demo file's existence is not closed, hence the cut demo file cannot be deleted until the client is closed.
2022-10-24 19:48:44 +02:00
Robert Müller 5c11937543 Use fegetenv/fesetenv instead of _control87 on Windows
As `_control87` doesn't seem to be available for some MinGW compilers.

Closes #5969.
2022-10-23 10:59:53 +02:00
Robert Müller c0da3b93e4 Fix IME not being deactivated when editor is closed
Previously the IME was not deactivated when the editor is closed, so `SDL_TEXTINPUT` events where still being reported ingame after exiting the editor.
2022-10-21 21:31:21 +02:00
Robert Müller 75326e8393 Fix text input not working when entering editor with bind
When entering the editor with a custom bind (e.g. `bind e "cl_editor 1"`) or when opening it from the console while also immediately closing the console (e.g. with `cl_editor 1; toggle_local_console`), the IME state was not properly set to active, so SDL did not report any `SDL_TEXTINPUT` events, leading to editboxes in the editor not receiving any text.

The is fixed by always enabling the IME state when entering the editor, which was previously only done when using the Ctrl+Shift+E hotkey or coincidentally when the editor is activated while the IME is already active, i.e. when the menu or console is open.

Closes #5095.
2022-10-21 21:20:10 +02:00
Robert Müller f5a16c1c77 Fix crash in editor when using up/down keys on empty images list 2022-10-21 20:28:30 +02:00
Robert Müller 4a683e024a Fix crash in editor when using up/down keys on empty sounds list 2022-10-21 20:28:00 +02:00
bors[bot] 8feba4ecf6
Merge #5966
5966: Fix duplicate description of cl_default_zoom_level r=heinrich5991 a=def-

Since #5894 is not landing

<!-- 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-10-21 11:53:55 +00:00
bors[bot] 9c6a187ee9
Merge #5965
5965: Don't print max value when there is none (fixes #5953) r=edg-l 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

- [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-10-21 07:35:19 +00:00
Dennis Felsing eb27b26d8d Also ignore min value 2022-10-21 00:34:44 +02:00
Dennis Felsing f7bc58b056 Fix duplicate description of cl_default_zoom_level
Since #5894 is not landing
2022-10-21 00:12:07 +02:00
Dennis Felsing 26a08360f8 Don't print max value when there is none (fixes #5953) 2022-10-21 00:09:30 +02:00
Robert Müller 73fe4e6ed4 Use str_copy instead of snprintf to copy strings 2022-10-20 20:56:58 +02:00
Robert Müller c4cf26ea81 Replace atol usages with str_toint, as type is int anyway
As `atol` does not provide any way to detect errors and can cause undefined behavior on errors, i.e. when the result cannot be represented as a `long`.

The `atol` function was only used in `priv_net_extract` for parsing the port, which is an `int` and not a `long`, so the existing `str_toint` is used instead.

References:

- https://wiki.sei.cmu.edu/confluence/display/c/ERR07-C.+Prefer+functions+that+support+error+checking+over+equivalent+functions+that+don%27t
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/atol.html
2022-10-20 20:54:01 +02:00
Robert Müller 1469e88a79 Replace atof usages with strtod (str_tofloat wrapper)
As `atof` does not provide any way to detect errors and can cause undefined behavior on errors, i.e. when the result cannot be represented as a `float`.

References:

- https://wiki.sei.cmu.edu/confluence/display/c/ERR07-C.+Prefer+functions+that+support+error+checking+over+equivalent+functions+that+don%27t
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/atof.html
2022-10-20 20:30:12 +02:00
Robert Müller 6b043bf3b2 Replace atoi usages with strtol (str_toint wrapper)
As `atoi` does not provide any way to detect errors and can cause undefined behavior on errors, i.e. when the result cannot be represented as an `int`.

References:

- https://wiki.sei.cmu.edu/confluence/display/c/ERR07-C.+Prefer+functions+that+support+error+checking+over+equivalent+functions+that+don%27t
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/atoi.html
2022-10-20 20:30:11 +02:00
bors[bot] 53080e3e14
Merge #5938
5938: Hex Values in the editor's info feature r=heinrich5991 a=VoxelDoesCode

Add an option when the info button is selected, you can show the hexadecimal values for a tile rather than 1-255. This has some benefits, as it aligns in a perfect grid. Can help with making and test automappers.

![image](https://user-images.githubusercontent.com/95713843/195209286-82dd04d5-f469-4932-bbd7-93ec3fd32f99.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
- [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: VoxelDoesCode <bluheadcat@gmail.com>
2022-10-19 22:47:35 +00:00
heinrich5991 dcd76fd3e1 Add support for Rust code in DDNet
The glue is done using the [cxx crate](https://cxx.rs/) on the Rust
side.

As a proof-of-concept, only a small console command (`rust_version`)
printing the currently used Rust version was added.

You can generate and open the Rust documentation using
`DDNET_TEST_NO_LINK=1 cargo doc --open`.

You can run the Rust tests using `cmake --build <build dir> --target
run_rust_tests`, they're automatically included in the `run_tests`
target as well.

Rust tests don't work on Windows in debug mode on Windows because Rust
cannot currently link with the debug version of the C stdlib on Windows:
https://github.com/rust-lang/rust/issues/39016.

---

The stuff in `src/rust-bridge` is generated using
```
cxxbridge src/engine/shared/rust_version.rs --output src/rust-bridge/engine/shared/rust_version.cpp --output src/rust-bridge/engine/shared/rust_version.h
cxxbridge src/engine/console.rs --output src/rust-bridge/cpp/console.cpp --output src/rust-bridge/cpp/console.h
```
2022-10-19 23:46:06 +02:00
Jupeyy b70fc39571 fix skin click ptr 2022-10-19 20:18:43 +02:00
Robert Müller 25e6eed0e8 Fix compilation with VS2022 with exception handling enabled
By moving the calling convention `APIENTRY`, which expands to `__stdcall`, inside the parenthesis.

```
Severity	Code	Description	Project	File	Line	Suppression State
Error	C2143	syntax error: missing ')' before '('	engine-shared	src\base\system.cpp	4242
Warning	C4229	anachronism used: modifiers on data are ignored	engine-shared	src\base\system.cpp	4242
Error	C2059	syntax error: ')'	engine-shared	src\base\system.cpp	4242
Error	C2059	syntax error: ')'	engine-shared	src\base\system.cpp	4242
Error	C3536	'exception_log_file_path_func': cannot be used before it is initialized	engine-shared	src\base\system.cpp	4246
Error	C2446	'==': no conversion from 'nullptr' to 'int'	engine-shared	src\base\system.cpp	4246
Error	C2064	term does not evaluate to a function taking 1 arguments	engine-shared	src\base\system.cpp	4249
```
2022-10-16 18:16:58 +02:00
bors[bot] 24207b741c
Merge #5947
5947: Fix client crash when server does not send gameinfo r=def- a=Robyt3

As reported by `@ChillerDragon` on Discord.

## 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: Robert Müller <robytemueller@gmail.com>
2022-10-15 19:20:25 +00:00
Robert Müller c78f71b2b9 Fix client crash when server does not send gameinfo 2022-10-15 19:43:26 +02:00
Robert Müller 0a6ad9cf9d Add tests for too small/large sha256_str and md5_str buffers
Rename `Expect` to `ExpectSha256` and `Expect2` to `ExpectMd5` for better readability.

Pass buffer size by template parameter to reduce duplicate source code.
2022-10-15 18:18:18 +02:00
Robert Müller a07c51b637 Use size_t for indices in digest_str 2022-10-15 18:08:41 +02:00
Robert Müller c0b5e8965e Refactor usages of sha256_str
- Pass the actual array size instead of using the constant.
- Use the string length to write sha256 string to file.
2022-10-15 18:06:45 +02:00
bors[bot] 9e4da2244a
Merge #5944
5944: Fix example name in mapbug description r=heinrich5991 a=Zwelf

Fix typo: 6c3d0e999b/src/game/mapbugs_list.h (L3)

## 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>
2022-10-14 16:02:40 +00:00
Robert Müller 05eb1db436 Update zlib to version 1.2.13
Release notes: https://github.com/madler/zlib/releases/tag/v1.2.13
2022-10-14 14:53:24 +02:00
Zwelf 0e0e55eb43 Fix example name in mapbug description 2022-10-13 11:51:18 +02:00
heinrich5991 ea17fc753e Enable antispoof for vanilla by default
Having it disabled opens up the server for attacks.
2022-10-13 09:55:39 +02:00
bors[bot] 6c3d0e999b
Merge #5933 #5941
5933: Inline `Is(GameType)` functions and remove support for legacy 64 player info protocol r=def- a=heinrich5991

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


5941: Get away from vector for skins r=def- a=Jupeyy

most of the time it uses the index just to get the skin, downloaded skins change the index. Now its simply a heap object and downloaded skins load directly. Also the loading might be a bit faster bcs it had a loop lookup .Also O(1) lookup

not 100% tested. also fixes a bug with favorite skins hopefully
## 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: heinrich5991 <heinrich5991@gmail.com>
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2022-10-12 22:08:17 +00:00
bors[bot] bd3b4f2d50
Merge #5942
5942: Support unicode with ExcHndl, use upstream module offsets, handle errors r=def- a=Robyt3

Update Dr. Mingw (ExcHndl) to 0.9.8.

Use the new `ExcHndlSetLogFileNameW` function to set the exception log file name using wide characters, to support paths containing unicode.

It's not necessary to call `ExcHndlInit` explicitly after loading `exchndl.dll`, as the `DllMain` will already initialize the exception handler when the DLL is loaded. Module offsets are supported by upstream ExcHndl now, so we don't need to provide our own version that supplies the module offset to `ExcHndlInit` anymore. Upstream ExcHndl will also resolve the source code lines for addresses automatically, when the executable is build with debug information.

Handle the cases that the exception handling module cannot be loaded and that the `ExcHndlSetLogFileNameW` function cannot be found in the module.

Update `scripts/parse_drmingw.sh`:

- Parse both old and new module offsets.
- Use tabs instead of spaces consistently.
- Reset the ANSI color after printing colored messages.

Closes #5877.

Needs https://github.com/ddnet/ddnet-libs/pull/34.

Example crash logs:

- [crash_debug_old.RTP.txt](https://github.com/ddnet/ddnet/files/9768008/crash_debug_old.RTP.txt)
- [crash_debug_new.RTP.txt](https://github.com/ddnet/ddnet/files/9768011/crash_debug_new.RTP.txt)
- [crash_release_old.RTP.txt](https://github.com/ddnet/ddnet/files/9768010/crash_release_old.RTP.txt)
- [crash_release_new.RTP.txt](https://github.com/ddnet/ddnet/files/9768009/crash_release_new.RTP.txt)

## 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-10-12 21:44:43 +00:00
Jupeyy a804c3ca5b Get away from vector for skins
most of the time it uses the index just to get the skin, downloaded skins change the index.
Now its simply a heap object and downloaded skins load directly. Also the loading might be a bit faster bcs it had a loop lookup
Also O(1) lookup
2022-10-12 22:32:36 +02:00
Robert Müller fb317779fc Support unicode with ExcHndl, use upstream module offsets, handle errors
Update Dr. Mingw (ExcHndl) to 0.9.8.

Use the new `ExcHndlSetLogFileNameW` function to set the exception log file name using wide characters, to support paths containing unicode.

It's not necessary to call `ExcHndlInit` explicitly after loading `exchndl.dll`, as the `DllMain` will already initialize the exception handler when the DLL is loaded.
Module offsets are supported by upstream ExcHndl now, so we don't need to provide our own version that supplies the module offset to `ExcHndlInit` anymore.
Upstream ExcHndl will also resolve the source code lines for addresses automatically, when the executable is build with debug information.

Handle the cases that the exception handling module cannot be loaded and that the `ExcHndlSetLogFileNameW` function cannot be found in the module.

Update `scripts/parse_drmingw.sh`:

- Parse both old and new module offsets.
- Use tabs instead of spaces consistently.
- Reset the ANSI color after printing colored messages.
2022-10-12 21:11:35 +02:00
Robert Müller c68841a733 Ensure Windows DDE conversations are finished in open_link
Use `ShellExecuteExW` instead of `ShellExecuteW` to pass the additional flag `SEE_MASK_NOASYNC`. This should ensure that DDE (Dynamic data exchange) conversations are finished before the function returns, as it would otherwise be necessary to manually pump messages on the calling thread. DDE conversations may be initiated when shell extensions are loaded via `ShellExecute`. Failing to answer the DDE messages will block the calling UI thread and may cause a dead-lock.

The flag `SEE_MASK_FLAG_NO_UI` is used to prevent native error message popups when the link/file cannot be opened.

Additionally, the `ShellExecute` verb is changed from `"open"` to `NULL`, which will cause the default shell handler to be used instead, as the `"open"` verb may not be available for all targets. Though for most targets it will be the default verb anyway.

References:

- https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew
- https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shellexecuteinfow
- https://devblogs.microsoft.com/oldnewthing/20070430-00/?p=27063
- https://learn.microsoft.com/en-us/windows/win32/dataxchg/about-dynamic-data-exchange

Yet another attempt at solving #5744.
2022-10-12 17:18:57 +02:00
Robert Müller 4bb549b68e Initialize the Windows COM library on all threads
Use threading model `COINIT_APARTMENTTHREADED` on threads that own a window (the main client thread) and `COINIT_MULTITHREADED` on all other threads.

Add assertions to ensure that the COM library is initialized successfully and only once per thread.

References:

- https://learn.microsoft.com/en-us/windows/win32/learnwin32/initializing-the-com-library
- https://learn.microsoft.com/en-us/windows/win32/com/single-threaded-apartments
- https://learn.microsoft.com/en-us/windows/win32/com/multithreaded-apartments

Yet another attempt at solving #5744.
2022-10-12 17:18:57 +02:00
heinrich5991 a595936fb5 Remove chat timeout code fallback heuristic
KoG is now on the newest version, we no longer need this.
2022-10-12 16:12:02 +02:00
heinrich5991 150485e3b0 Remove support for legacy 64 player info protocol
It was only being used for "Leak IP" favorites and LAN servers. Since
KoG has upgraded to latest DDNet, there aren't much servers left that
don't understand the new 64 player info protocol.

Keywords: fstd, dtsf
2022-10-12 16:12:02 +02:00
VoxelDoesCode 484cb82872 Hex Values in the editor's info feature
Clang format before squash
2022-10-11 19:27:12 -04:00
heinrich5991 a97a597592 Inline Is(GameType) functions
They are used for two purposes, coloring gametypes in the serverbrowser
and enabling backward compatibility. These are independent, we shouldn't
add more stuff to the backward compatibility, hence I split them up and
inlined them.
2022-10-11 16:05:46 +02:00
bors[bot] 8de0247d00
Merge #5909
5909: Add favorite skins r=def- a=Jupeyy

Advantages:
- my friend fokkonaut can mark his favorite vanilla skins
- u can mark skin db skins which auto download if not loaded

untested, bad code, maybe buggy.
but still want feedback :)

![image](https://user-images.githubusercontent.com/6654924/193877801-6880a4f6-3f42-4e16-ad00-f44583aa2a87.png)


## 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: Jupeyy <jupjopjap@gmail.com>
2022-10-10 14:42:18 +00:00
def c2d1118c90 Only announce servers using Steam/Discord integration which are registered 2022-10-09 16:16:54 +02:00
bors[bot] 6d7df66448
Merge #5918
5918: Constify snap more (inspired by upstream) r=Robyt3 a=ChillerDragon

Incorporate const added in those upstream commits:
d86d576217
e6b8518b49

## 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
- [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: ChillerDragon <ChillerDragon@gmail.com>
2022-10-09 13:53:05 +00:00
bors[bot] 9a664c62e9
Merge #5924
5924: Grammer fix in snapshot doc "haven't" -> "hasn't" r=def- a=ChillerDragon

<!-- 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: ChillerDragon <ChillerDragon@gmail.com>
2022-10-09 13:29:10 +00:00
ChillerDragon 6d0b2ee44c Grammer fixes in snapshot doc
Thanks to @def-
2022-10-09 15:24:09 +02:00
ChillerDragon 9982a7bad3 Constify snap more (inspired by upstream)
Incorporate const added in those upstream commits:
d86d576217
e6b8518b49
2022-10-09 15:12:12 +02:00
ChillerDragon b2285855f5 Remove unused SnapInvalidateItem
suggested by @Robyt3 <3
2022-10-09 15:11:58 +02:00
bors[bot] b7da20826d
Merge #5919
5919: Tweak the running visuals r=def- a=VoxelDoesCode

Sorry for putting this off for so long. Turns out animating with raw code is harder than you'd think.

https://user-images.githubusercontent.com/95713843/194726134-40925aea-6ec4-40ae-9597-b80a28d1b6a2.mp4



## 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
- [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: VoxelDoesCode <bluheadcat@gmail.com>
2022-10-08 22:58:13 +00:00
VoxelDoesCode fc09212d43 Tweak the running visuals 2022-10-08 16:07:15 -04:00
bors[bot] 31b0c0a6cd
Merge #5916
5916: fix import on mastersrv r=heinrich5991 a=edg-l

<!-- 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: Edgar Luque <git@edgarluque.com>
2022-10-07 19:35:34 +00:00
Edgar 5cfec69fad fix import on mastersrv 2022-10-07 21:32:53 +02:00
bors[bot] 665f829759
Merge #5915
5915: Don't overlap menu + debug messages (fixes #5914) r=Robyt3 a=def-

![Screenshot 2022-10-07 at 19 03 03](https://user-images.githubusercontent.com/2335377/194611779-93062028-0684-4745-b3b9-9949cec074fa.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)


Co-authored-by: Dennis Felsing <dennis@felsin9.de>
2022-10-07 18:48:08 +00:00
Dennis Felsing 774f7a6f33 Don't overlap menu + debug messages (fixes #5914) 2022-10-07 19:03:20 +02:00
def 317b2df7c0 Support multiple values to search/exclude (fixes #4119) 2022-10-07 18:21:14 +02:00
Dennis Felsing c4463a3848 Only show ingame hint in Game tab
Since it looks ugly overlaid over the other tabs
2022-10-06 18:38:32 +02:00
Jupeyy fbc4c9cd6e Add favorite skins 2022-10-05 19:23:03 +02:00
bors[bot] d1463c62d1
Merge #5906
5906: Revert ingame menu close button, Add help text at bottom left when menu is open r=heinrich5991 a=def-

Even I got confused by it and accidentally hit power off button. Left side seems not popular for close either (#5888)

Since opening the menu requires Escape, players can probably figure out Escape to close it again.

Add help text at bottom left when menu is open

![screenshot-20221003@000950](https://user-images.githubusercontent.com/2335377/193478531-58ade8e6-074f-4710-8543-66c6bddfc963.png)

> Revert "Don't show home button ingame"
>
> This reverts commit d3ff903d44.
>
> Revert "Move home button to very right so it is consistent with close button ingame (fixes #5881)"
>
> This reverts commit 9cc08cc9d3.
>
> Revert "Add close button to close ingame menu"
>
> This reverts commit cfcfb7b3f0.

<!-- 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
- [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)


Co-authored-by: def <dennis@felsin9.de>
2022-10-05 11:38:17 +00:00
Robert Müller 3c5a9f7672 Print the operating system version on client/server launch 2022-10-03 13:19:31 +02:00
Robert Müller 1697231916 Handle non-default Windows directory in os_version_str
- Retrieve version information of `kernel32.dll` without providing a fixed path to the Windows directory, to handle the case that Windows is not installed in the default location `C:\Windows`. This works because `GetFileVersionInfoSizeW` and `GetFileVersionInfoW` use the search sequence defined by `LoadLibrary`, so they will find the DLL without the path explicitly being specified. The version is retrieved from `kernel32.dll` instead of `user32.dll`, as the former is more commonly used for this purpose.
- Use the unicode (wide character) functions consistently instead of the ANSI functions.
- Use the correct format specifier `%hu` for `unsigned short` (i.e. `WORD` in the Windows API).

References:

- https://learn.microsoft.com/en-us/windows/win32/api/winver/nf-winver-getfileversioninfosizew
- https://learn.microsoft.com/en-us/windows/win32/api/winver/nf-winver-getfileversioninfow
- https://stackoverflow.com/a/44672263/1708371
2022-10-03 13:17:26 +02:00
def 361622ec37 Add help text at bottom left when menu is open 2022-10-03 00:11:01 +02:00
def 9e5d830e34 Revert ingame menu close button
Even I got confused by it and accidentally hit power off button. Left
side seems not popular for close either (#5888)

Since opening the menu requires Escape, players can probably figure out
Escape to close it again.

> Revert "Don't show home button ingame"
>
> This reverts commit d3ff903d44.
>
> Revert "Move home button to very right so it is consistent with close button ingame (fixes #5881)"
>
> This reverts commit 9cc08cc9d3.
>
> Revert "Add close button to close ingame menu"
>
> This reverts commit cfcfb7b3f0.
2022-10-02 23:59:48 +02:00
def 55ff665894 Less logging when loading maps on expected path 2022-10-01 22:46:39 +02:00
Robert Müller 9d1f393c55 Fix unknown command handler for filenames containing spaces
Pass the original string to the unknown command callback instead of the parsed command, as the latter ends at the first whitespace, which breaks for unknown commands (filenames) containing spaces.

Closes #5902.
2022-10-01 20:10:59 +02:00
Robert Müller c924f6bb25 Use str_isspace in str_skip_(to_)whitespace(s), add tests
Update the `str_skip_to_whitespace(_const)` functions according to their documentation, which already stated that `\r` was also considered as whitespace.
2022-09-30 14:54:33 +02:00
Robert Müller 9472db419b Fix str_hex and add tests
- Properly null-terminate the destination buffer when the data size is zero.
- Fix early loop exit when destination buffer is too small for all data.
2022-09-30 14:54:33 +02:00
Robert Müller 3383b7dc0f Add tests for str_countchr, update documentation 2022-09-30 14:54:33 +02:00
Robert Müller b029452e99 Add tests for str_rchr, update documentation 2022-09-30 14:54:33 +02:00
Robert Müller da57768854 Add tests for str_clean_whitespaces, fix documentation 2022-09-30 14:54:33 +02:00
Robert Müller 6bc633ed35 Add tests for str_sanitize 2022-09-30 14:54:33 +02:00