Commit graph

12061 commits

Author SHA1 Message Date
Robert Müller abf795d9da Invoke static methods without a class instance
The methods `ReplaceImage` and `ReplaceSound` are static, so they should be called without an object.
2022-11-03 19:32:10 +01:00
Jupeyy 365c48413f Switch to Vulkan 1.1
Since the vulkan loader drops support for useful extensions (or the extension loading process changed between 1.0 & 1.1, not sure)
Which causes OBS not to work
2022-11-02 12:54:04 +01:00
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