Commit graph

20665 commits

Author SHA1 Message Date
Robert Müller 4f0ba0d5fa Fix rustup toolchain overrides not working with MSVC
Use the build folder as the working directory for the cargo build so rustup overrides of individual build folders are respected.
2024-07-05 18:23:17 +02:00
Robert Müller b05ca91a15 Use SDL_OpenURL to open links and files on Android
Opening links and files with the `open_link` and `open_file` functions does not work on Android, as the `open_link` function uses `fork` which is not supported on Android. This also seems to cause a strange bug where client networking partially breaks. Currently, after trying to open any link, connecting to servers is not possible anymore but the server browser still works, with the connection getting stuck randomly in the connecting/loading state.

SDL implements URL opening, including of file URIs, with the `SDL_OpenURL` function for most systems including Android. However, using `SDL_OpenURL` for all systems has several downsides:

1. The `SDL_OpenURL` function is only available since SDL 2.0.14, in particular not for the Ubuntu 20 CI runner. Hence, we would either have to conditionally compile the link opening function to a null-implementation or fallback to using the existing `open_link` function.
2. We would be undoing some additional fixes in the `open_link` function for Windows, which are not included in the Windows implementation of `SDL_OpenURL`.
3. This would also replace the use of `open` on UNIX with `xdg-open`.
4. This would move the functionality to open links and files from the base to the engine client, so we could not have tools or the server potentially making use of this functionality in the future (e.g. open a folder for convenience).

Implementing link and file opening for Android ourselves is too much effort and potentially made even harder by SDL already managing all the unique JVM resources in the `SDLActivity`.

Therefore, the `SDL_OpenURL` function is only used for Android, which is always based on the latest SDL2 version. The original `open_link` functionality is kept for the other systems. For this purpose, the `IClient::ViewLink` and `ViewFile` functions are added to wrap `open_link` and `open_file` for the client and also reduce some duplicate code for error logging.

Unfortunately, testing also revealed that `SDL_OpenURL` does not currently support opening file URIs, at least not of files the internal storage location, which all the DDNet client's files would be located in. At least opening URLs works and neither breaks networking anymore.
2024-07-05 17:53:11 +02:00
heinrich5991 447b44d290
Merge pull request #8558 from def-/pr-int-overflow
Fix integer overflow when computing tilemap size
2024-07-04 10:52:58 +00:00
Dennis Felsing 429777236b Fix integer overflow when computing tilemap size
Cherry-picked from d25869626a
2024-07-04 12:35:33 +02:00
Dennis Felsing 3806f324d8 Version 18.3.1 2024-07-04 12:33:40 +02:00
Dennis Felsing 610381d29e
Merge pull request #8556 from heinrich5991/pr_ddnet_ign
Use `Client()->PlayerName()` for copied server info
2024-07-03 13:29:15 +00:00
heinrich5991 77054c1134 Use Client()->PlayerName() for copied server info
Fixes #8554.

Alternative to #8555.
2024-07-03 14:22:15 +02:00
heinrich5991 9db780ebbc
Merge pull request #8549 from edg-l/fix_rust_workspace_resolver
fix resolver version warning for workspaces in rust
2024-07-02 16:41:28 +00:00
Edgar 91ddec0b5b
fix resolver version warning for workspaces in rust2 2024-07-02 17:49:52 +02:00
Dennis Felsing 83abf98c9a
Merge pull request #8546 from ChillerDragon/pr_07_winter
Add winter_main_0.7 mapres
2024-07-02 10:11:39 +00:00
ChillerDragon 22b051ce22 Add winter_main_0.7 mapres
```
$ wget https://raw.githubusercontent.com/teeworlds/teeworlds/a1911c8f7d8458fb4076ef8e7651e8ef5e91ab3e/datasrc/mapres/winter_main.png -O winter_main_0.7.png
$ dilate winter_main_0.7.png
```

https://github.com/ChillerDragon/ddnet/issues/8
2024-07-02 10:40:10 +08:00
heinrich5991 9ccb87bf6b
Merge pull request #8538 from def-/pr-upnp
Support new UPNP API
2024-07-01 22:56:06 +00:00
Dennis Felsing a0da2d0978 Support new UPNP API
See c0a50ce33e
2024-07-02 00:32:46 +02:00
Dennis Felsing 8c21fa1928
Merge pull request #8544 from heinrich5991/pr_ddnet_libloc
mastersrv: Use `libloc` instead of our own CSV format for GeoIP
2024-07-01 22:15:47 +00:00
Dennis Felsing 222a7a7453
Merge pull request #8545 from Robyt3/Scoreboard-Refactoring
Various improvements to scoreboard rendering, refactoring
2024-07-01 21:54:52 +00:00
heinrich5991 20d58e6edb mastersrv: Fix warning about unused mut 2024-07-01 22:18:50 +02:00
Robert Müller dc56651c39 Various improvements to scoreboard rendering, refactoring
Scoreboard title

- In teamplay, color the title background red/blue for the respective teams (like in 0.7).
- In teamplay, swap the score location for the blue team, so the scores line up in the center (like in 0.7).
- Use textrender ellipsis instead of cutting the title string manually and potentially creating broken UTF-8.

Game over title

- Render the game over message in the color of the winning team (or yellow in case of draws).
- Adjust size and spacing of the message to prevent overlap.

Player list

- Add player list size variant for 17-24 players with two columns of up to 12 players. This previously used the variant for 32 players.

Goals

- Use textrender for alignment and properly center the time limit goal.
- Change localization text from `Round` to `Round %d/%d` so the numbers and punctuation can be formatted more correctly in some languages (e.g. right-to-left languages, Korean, Chinese).

Spectators

- Render spectators title and spectators starting in the same line to use space more effectively.
- Render as many lines of spectators as fit instead of only 4 lines.
- Render a placeholder text at the end when there are more spectators than fit.

Refactoring

- Use correct class for `NETMSGTYPE_SV_RECORDLEGACY` instead of depending on the structs `CNetMsg_Sv_Record` and `CNetMsg_Sv_RecordLegacy` being identical.
- Use `CUIRect` and `DoLabel` when possible.
2024-07-01 22:18:10 +02:00
heinrich5991 e0b62edb0b mastersrv: Use libloc instead of our own CSV format for GeoIP
This also makes GeoIP data more precise than our current state, from
`eu` to `eu:de` for Germany, i.e. adding country codes for all countries
and not only for China.

https://git.ipfire.org/?p=location/libloc.git

Current location data can be obtained from
https://location.ipfire.org/databases/1/location.db.xz.
2024-07-01 22:17:12 +02:00
archimede67 726e5c9a49
Merge pull request #8536 from Robyt3/Editor-Help-Wiki-Button
Add button and F1 hotkey in editor to open Wiki page for editor
2024-06-30 14:12:40 +00:00
Robert Müller 9f698d20c8 Add button and F1 hotkey in editor to open Wiki page for editor
Add a question mark-button next to the x-button to open the Wiki page https://wiki.ddnet.org/wiki/Mapping in the default web browser. The link is localized so translators can replace it with the respective translated Wiki pages. The hotkey F1 is also added to activate this button.
2024-06-30 15:40:04 +02:00
Dennis Felsing 2ed17ac8b3
Merge pull request #8530 from Robyt3/Engine-LineReader-io_read_all
Rewrite and fix line reader, read entire file into memory
2024-06-29 07:28:43 +00:00
Robert Müller a17f7b5c2f Rewrite and fix line reader, read entire file into memory
Read the entire file into memory immediately when the line reader is initialized instead of using a fixed size buffer of size 32769, which leads to broken line reading for larger files (closes #8431).

Replace the `CLineReader::Init` function with the `CLineReader::OpenFile` function, which additionally checks whether the file contains any null bytes (indicates that the file is likely not a text file).

As the file will be read into memory entirely in the `OpenFile` function, is can also be closed immediately, since using the `io_read_all_str` function should ensure that nothing more can be read from the file. This also simplifies the usage of the `CLineReader` class, as manually closing the file is inconvenient and error-prone. In fact, the file handle for the `ddnet-serverlist-urls.cfg` file was previously not closed properly.

Benchmarking on Windows did not show any noticeable performance impact of this change both for smaller files (config and language files) and larger files (synthetic ~10 MiB files).

Let the `CLineReader::Get` function return `const char *` instead of `char *`, since users of this class should not modify the internal buffer. Also, since the entire file is read into memory now, the returned strings are now valid until the respective line reader object is destructed, instead of only until the `Get` function is called again. This simplifies the usage in some cases where all lines are handled, since additional temporary buffers are now unnecessary.

Remove the `IOFLAG_SKIP_BOM` flag from the `io_open` function, as this flag was only used together with the line reader. This was inconvenient to use, as any use of the `io_open` function specifically for line readers had to be used with `IOFLAG_SKIP_BOM`. Now, the line reader transparently skips the UTF-8 BOM internally. Skipping the UTF-8 BOM never worked with the `IStorage::ReadFileStr` function, because `io_length` is used in the `io_read_all` function, which rewinds the file position to before the UTF-8 BOM that was skipped by using `IOFLAG_SKIP_BOM`. In any case, as the `ReadFileStr` function is currently unused, this has/had no further effect. The respective test cases for `IOFLAG_SKIP_BOM` are removed.

Add more test cases for the `CLineReader` class. All test cases are checked both with and without the UTF-8 BOM. Additional tests with mixed new lines,  empty lines with different new lines, and internal null bytes are added.

Consistently use the construct `while(const char *pLine = LineReader.Get())` to iterate over all lines of a line reader. In this case, the assignment inside the `while`-loop seems acceptable over the alternatives, e.g. `while(true)` with `break` or adding a function `CLineReader::ForAll(std::function<const char *> Consumer)`.
2024-06-28 22:18:42 +02:00
Dennis Felsing b0b89d54a0
Merge pull request #8529 from Robyt3/Server-Dnsbl-Ban-Reason
Add `sv_dnsbl_ban_reason`, increase maximum ban reason length
2024-06-27 21:52:04 +00:00
Robert Müller 905047dd16 Add sv_dnsbl_ban_reason, increase maximum ban reason length
Add `sv_dnsbl_ban_reason` config variable with size 128 to specify the ban reason for `sv_dnsbl_ban`.

Increase the maximum size for ban reasons on the server from 64 to 128 to support this new config variable. Adjust buffer sizes for formatting ban messages accordingly.

Additionally, increase the size of the buffer for unpacking the connection closed message from 128 to 256. Due to this limitation, old clients will see truncated disconnect messages if the entire message is longer than 127, which can now happen with long ban reasons as the ban message additionally contains the duration (e.g. `You have been banned for 10 minutes (Reason)`).

Closes #8518.
2024-06-27 21:49:08 +02:00
Dennis Felsing 6c5095203f
Merge pull request #8527 from Robyt3/Client-GenerateTimeoutCode
Extract `GenerateTimeoutCode` function to reduce duplicate code, avoid magic numbers for generating timeout code
2024-06-26 21:51:48 +00:00
Robert Müller 872052b5b2 Avoid magic numbers for generating timeout code 2024-06-26 22:01:29 +02:00
Robert Müller 04b37f2db7 Extract GenerateTimeoutCode function to reduce duplicate code 2024-06-26 21:53:53 +02:00
Dennis Felsing f21976b0ed
Merge pull request #8524 from ChillerDragon/pr_test_crc_overflow
Add tests for snapshot crc overflow
2024-06-26 15:07:14 +00:00
ChillerDragon b138cc9f13 Add tests for snapshot crc overflow 2024-06-26 20:36:52 +08:00
Dennis Felsing 1cf8761b44
Merge pull request #8522 from Yacinello-droid/patch-1
Update russian.txt
2024-06-25 22:00:11 +00:00
Dennis Felsing b0a1135de6
Merge pull request #8521 from Robyt3/Client-Loading-Improvements
Refactor client loading and loading screen, fix progress bar alignment when updating
2024-06-25 21:57:29 +00:00
Yacinello-droid 313f44ffbd
Update russian.txt 2024-06-26 02:42:29 +05:00
Robert Müller 877096f977 Fix alignment of progress bar while updating client
The progress bar was positioned relative to the updating message. Now the progress bar is always right-aligned with the other buttons.
2024-06-25 22:44:45 +02:00
Robert Müller e135145363 Ensure logged time covers whole CGameClient::OnInit function
Get start time as soon as possible and log time for gameclient initialization at the end of the `CGameClient::OnInit` function so this time measurement should cover the entire function.

Use `log_trace` and change spelling for consistency (`initialisation` -> `initialization`).
2024-06-25 22:44:22 +02:00
Robert Müller ab729e0346 Minor refactoring of client loading
Avoid duplicate `Localize` calls while loading.

Start component counters at 1 instead of 0 since the value was always incremented by 1 before being used.

Extract variable `NumComponents` and also use it for the special loading message, so it should consistently be shown only for the first component (i.e. the last component being initialized) also when more components will be added.
2024-06-25 22:43:21 +02:00
Robert Müller d1516a14a5 Refactor client loading screen rendering
Use `CUi::RenderProgressBar` function also for client loading, which means the filled progress bar background will also be rendered while loading.

Replace static variable `s_LastLoadRender` with member variable.

Encapsulate menu loading state in class `CLoadingState`.
2024-06-25 22:41:02 +02:00
Robert Müller 5f9d97a2aa Extract CUi::RenderProgressBar function 2024-06-25 22:40:58 +02:00
Dennis Felsing e29409de64
Merge pull request #8519 from Robyt3/Client-Browser-Refresh-UiPage-Fix
Fix browser not refreshing if `ui_page` is changed in start menu, refresh LAN tab after starting/stopping local server
2024-06-24 21:03:17 +00:00
Robert Müller 3947ba40b1 Refresh LAN tab after starting/stopping local server
After starting/stopping the local server from the main menu, refresh the LAN tab on its next activation, so it immediately shows/hides the started/stopped server without needing a manual refresh.

This is not a perfect solution, as the server would not show up when activating the LAN tab immediately after starting the server, because the server needs some time before it will respond to server info requests, but this works well enough unless the hotkeys are used.
2024-06-24 22:10:34 +02:00
Robert Müller 2974e5197e Fix browser not refreshing if ui_page is changed in start menu
When changing `ui_page` via the console while the start menu is active, the browser tab was not refreshed when clicking the Play-button, leading to the old server list being shown for the new browser tab.
2024-06-24 22:10:20 +02:00
Dennis Felsing 0f61b173a8
Merge pull request #8493 from furo321/practice-max-team-size
Don't check `sv_max_team_size` for teams in practice
2024-06-24 18:06:01 +00:00
furo 93bf7cbc59 Don't check sv_max_team_size for teams in practice 2024-06-24 18:21:42 +02:00
Dennis Felsing 248a24845e
Merge pull request #8513 from MilkeeyCat/pr_ddnet_fix_da_translations
Add context to translations & add removed translations
2024-06-23 18:32:01 +00:00
archimede67 62c3c4274d
Merge pull request #8514 from Robyt3/Updater-Cleanup
Minor cleanup of updater and HTTP client
2024-06-23 18:18:54 +00:00
archimede67 76b53d7b7a
Merge pull request #8515 from MilkeeyCat/pr_ddnet_fix_browser_settings_argument_highlighting
Correct arguments highlighting after removing entry
2024-06-23 18:02:43 +00:00
MilkeeyCat cdfe451880 fix: correct arguments highlighting after removing entry 2024-06-23 20:31:20 +03:00
MilkeeyCat 635f91be12 fix: add context to translations & add removed translations 2024-06-23 17:54:18 +03:00
Robert Müller 51b37aa240 Fix HTTP progress values being above 100 if total size is unknown
If the total download size is unknown (i.e. zero), return 0% instead of returning a very large value above 100%.
2024-06-23 16:08:54 +02:00
Robert Müller c4b9924b28 Use named enum EUpdaterState instead of int 2024-06-23 16:08:46 +02:00
Robert Müller 80ff5157d0
Merge pull request #8504 from MilkeeyCat/pr_ddnet_trim_strings_in_search_and_exclude_inputs
Trim Strings on Search/Exclude Filter & Add Tooltip
2024-06-23 13:13:31 +00:00