Commit graph

15529 commits

Author SHA1 Message Date
ChillerDragon 7553ea6297 Improve clang variable naming checks
Introduces checks for more variable types.
And fixes false positives in newer clang versions.
2024-07-06 10:10:00 +08:00
ChillerDragon 43a493445b Also split commands on spaces 2024-07-06 07:59:52 +08:00
ChillerDragon 5d43d346e7 Also split commands on double quotes 2024-07-06 07:59:52 +08:00
ChillerDragon 6b0b49e414 Look at command under cursor not at the end of the line 2024-07-06 07:59:52 +08:00
ChillerDragon 54977d5745 Auto complete when chaining multiple commands
closed #7966
2024-07-06 07:59:51 +08:00
ChillerDragon 89437b7ef7 Fix console search with multiple commands 2024-07-06 07:59:51 +08:00
ChillerDragon c8656635b9 Show help text when chaining multiple commands 2024-07-06 07:59:51 +08:00
Dennis Felsing fb6a6ccc43
Merge pull request #8563 from Robyt3/Server-Random-Map-Crash
Fix server crash when starting with `random(_unfinished)_map`
2024-07-05 22:23:13 +00:00
Robert Müller ecafa10dfa Fix server crash when starting with random(_unfinished)_map
See #8559.
2024-07-05 20:31:52 +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
heinrich5991 77054c1134 Use Client()->PlayerName() for copied server info
Fixes #8554.

Alternative to #8555.
2024-07-03 14:22:15 +02: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
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
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
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
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
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
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
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
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
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
MilkeeyCat 31966d52a6 feat: trim strings in search & exclude inputs 2024-06-23 14:25:31 +03:00
Robert Müller 91cf20ced4 Faster map loading with sound disabled, fix map sound warning
Fix map sound loading warning being incorrectly shown when sound is disabled. Make map loading faster in this case by not unpacking the sound data and sound sources from the map at all if sound is disabled.

Closes #8450.
2024-06-21 17:38:56 +02:00
Robert Müller efa069ef80 Ensure sample indices are initialized also with sound disabled
The assertion of #8262 can be reproduced when sound is disabled or failed to be initialized, as the sample indices where not being initialized properly in these cases. It is still necessary to initialized them so sounds can be loaded in the editor also when sound is disabled.

The potential thread-safety issues of the `CSound::AllocSample` function are not yet resolved so the issue remains open.
2024-06-21 17:38:16 +02:00
Robert Müller 908ebc65ee Remove Spectate label from HUD, show Following {player} instead 2024-06-18 21:49:06 +02:00
Robert Müller 6df4ff3a44 Move CGameConsole::Dump function to CGameConsole::CInstance
Avoid the `int Type` parameter by making `CGameConsole::Dump` a member function of `CGameConsole::CInstance`.

Use `log_*` functions instead of `IConsole` for logging.
2024-06-17 22:36:25 +02:00
meloƞ b05620d1eb update practice help text 2024-06-15 04:14:53 +02:00
Robert Müller 4852dc435d Move double-click handling from engine input to UI
Instead of relying on SDL to determine when a click is a double-click, implement double-click handling specifically for the UI, as double-clicks are only supposed to be used there. This allows us to ensure that double-clicks only activate UI elements if both clicks were performed on the same UI element. Previously, only the position of the second click was considered, so UI element would incorrectly activate when double-clicking close to them as long as the second click starts and ends on them.

Implementing double-clicking handling separately is also necessary to support double-clicking in the UI with touch events, as SDL does not provide the double-click information for touch events.

The newly added `CUi::DoDoubleClickLogic` function should be called after a UI element has been clicked. It will return `true` if the current click should be interpreted as a double-click, i.e. if the same UI element was clicked, the click was within 0.5 seconds of the previous click (the default duration for SDL and Windows) and the distance from the previous click is within 32 screen pixels (the default distance for SDL).
2024-06-14 23:34:38 +02:00
Robert Müller 264df1f035 Improve envelope editor double-click handling
Only handle the double-click on the envelope editor when the second click is released instead of when it is pressed down already.

Remove unnecessary UI element `s_BoxSelectId`, the temporary activation of which was causing the tooltip to be missing for one frame when clicking the envelope editor.
2024-06-14 23:24:23 +02:00
Jupeyy f061dfdc84
Merge pull request #8480 from TylerStocks1/master
Readd is not a word, Reload makes more sense and is easier readablility.
2024-06-14 12:44:04 +00:00
Dennis Felsing ec42dea161 Version 18.3 2024-06-14 13:09:57 +08:00
Dennis Felsing b422c3cb26
Merge pull request #8486 from Robyt3/Server-Tile-Handling-Fix
Fix tiles being handled in same tick for dead tees in some cases
2024-06-14 04:31:51 +00:00
Tyler Stocks 249c8572ae
Update popups.cpp 2024-06-14 01:04:19 +01:00
Robert Müller cf6296c170
Merge pull request #8350 from ChillerDragon/pr_fix_button_overlap_teams
Fix in game menu buttons overlapping on team based gametypes
2024-06-13 19:58:47 +00:00
Robert Müller fbb2243a05 Fix tiles being handled in same tick for dead tees in some cases
The `CGameControllerDDRace::HandleCharacterTiles` function can kill the tee if the conditions for starting the race are not satisfied when touching a start tile. In this case, no further tiles should be handled in the `CCharacter::HandleTiles` function, else the effects of those tiles being handled may incorrectly be applied after the tee has respawned.
2024-06-13 21:26:03 +02:00
ChillerDragon 9a29c029a5 Fix in game menu buttons overlapping on team based gametypes
The ddnet buttons kill and pause do not fit in anymore if there is also
a join red/blue button.

This commit fixes that by hiding the buttons if
there is not enough space anymore.

Related prior work https://github.com/ddnet/ddnet/pull/2720
2024-06-13 09:34:16 +08:00
Dennis Felsing 0a243eea94
Merge pull request #8482 from Robyt3/UI-AntiStatic
Fix UI issues when switching between menus and editor
2024-06-12 01:30:26 +00:00
Robert Müller 71b3c8a35b Force default char to be signed on all architectures
We assume that `char` is `signed` in various places in the code. In particular, the `Str.StrToInts` test will fail when `char` is not `signed` and names containing special characters will be displayed incorrectly on servers.

Therefore, the compiler flag `-fsigned-char` is set unconditionally instead of only for ARM and ARM64, as we expect `char` to be `signed` on all architectures.

A static assertion is added to ensure at compile time that `char` is `signed` independently from the flag added in `CMakeLists.txt`.

This is necessary at least for ARM, ARM64, PPC, PPC64, and PPC64LE. According to some sources, `char` may also be `unsigned` by default when compiling for Android, although this could not be confirmed with the current Android NDK using Clang.

For the PowerPC architectures, Compiler Explorer can be used to confirm that `char` is not `signed` by default by checking whether the static assertion compiles (see https://godbolt.org/z/9rn5Mrf59) and that the assembly is different with the `-fsigned-char` flag (see https://godbolt.org/z/138zTj3Wa).

Closes #8386.
2024-06-11 23:37:46 +02:00
Robert Müller 7e9769c2c7 Fix UI issues when switching between menus and editor
Fix button logic being stuck when holding mouse button on UI elements with button logic in the menus/editor, switching between menus and editor with Ctrl+Shift+E, then using a UI element with button logic in the editor/menus and switching back.

Fix value selector text mode of color picker popups being deactivated when switching between menus and editor while the color picker popup is open in both.

Only update progress spinners once per frame in `CUi::Update` to ensure consistent rotation speed. Progress spinners in menus and editor now rotate independently.

In general, all `static` non-`const` variables in `CUi` are replaced with member variables, as the `static` variables are shared between the two `CUi` instances of the menus and the editor, causing the above issues.
2024-06-11 20:21:25 +02:00
Tyler Stocks 544f564044 Changed var name to match 2024-06-10 23:08:06 +01:00
Tyler Stocks c451289254 Readd is not a word, I think it meant re-add but Reload better fits its usecase 2024-06-10 21:25:07 +01:00
Robert Müller cef994d688 Fix demo seekbar tooltip not showing correct hovered time
Regression from #8318.
2024-06-10 18:44:08 +02:00
Robert Müller da25863cd2 Fix percentage not being used for console command progress spinner
The percentage of received console commands was not being shown with the progress spinner because the variable `ProgressProps` was not passed to the `RenderProgressSpinner` function.
2024-06-09 21:29:56 +02:00
archimede67 7741309ad8
Merge pull request #8447 from Robyt3/UI-ValueSelector-Consistency-DoubleClick
Consistent value selector behavior, support double-clicking
2024-06-09 11:52:22 +00:00
Emilcha 24ea8d8977 Consistancy, #8468 2024-06-08 19:28:06 +02:00
Emilcha 13fea24da3 Sort Compare Not Case Sensitive 2024-06-08 16:57:33 +02:00
Dennis Felsing 5a09da0782
Merge pull request #8465 from Robyt3/Client-Localize-Context-Fix
Fix wrong context value being used for translation lookup
2024-06-08 10:59:56 +00:00
Robert Müller f5de30ee88 Fix wrong context value being used for translation lookup
The trailing `]` was not being removed from the context anymore due to an off-by-one error introduced in #8430. Closes #8464.
2024-06-08 12:42:03 +02:00
Dennis Felsing 62f0849ca7 Update credits 2024-06-08 10:11:03 +08:00
Robert Müller fa58909dfe
Merge pull request #8459 from def-/pr-time-cp-diff
Add cl_showhud_time_cp_diff
2024-06-07 17:35:45 +00:00
Dennis Felsing 112e34fefe Add cl_showhud_time_cp_diff 2024-06-08 00:31:08 +08:00
Robert Müller 989a3765f7
Merge pull request #8342 from ChillerDragon/pr_multiview_pvp
Keep respawned players in multi view list on pvp servers
2024-06-06 20:49:43 +00:00
Robert Müller f494826dcf
Merge pull request #8154 from ChillerDragon/pr_worst_style_offenders
Fix worst local variable style offenses
2024-06-06 20:18:19 +00:00
Robert Müller ef7bebc73e Remove CUi::MouseButtonReleased function
Replace the last remaining usage of the `CUi::MouseButtonReleased` function with `!MouseButton(...)`. The `pMouseSelection->m_Selecting` flag is only set to `true` when the mouse button is already pressed down, so the additional check of `MouseButtonReleased` is unnecessary in this case. In general, this function is an anti-pattern in our UI, as only checking for the mouse button to be released does not guarantee that the mouse was also pressed down over the respective UI element. The `DoButtonLogic` function or similar code should be used instead of only handling the press or release of a mouse button.
2024-06-06 21:41:50 +02:00
Robert Müller 3bb60267f9 Consistent value selector behavior, support double-clicking
Make value selector behavior consistent with the generic button logic. Consistently check for completed mouse clicks on the value selector UI element instead of handling some mouse down and mouse up events separately. Fix text mode being activated when moving the mouse over value selectors with held down mouse button. Fix text mode being deactivated immediately when the mouse leaves text area while holding down the mouse button, which is inconvenient when selecting text. Remove unnecessary usage of `CUi::MouseButtonReleased` function.

Support double-clicking value selectors to enter text edit mode in addition to right-clicking. This feels more intuitive to use and also makes it usable without a second mouse button.

Select all text when entering text mode also in the editor, which was previously only a feature in the menus.

Fix value selector edit state being `EDITING` by default instead of `NONE` in the editor and fix maps being marked as modified immediately when a value selector text input is activated. The map will now be marked as modified only when the editing operation is completed, which should be synchonized with the undo history action being added.

Use the `CUi::ConsumeHotkey` function instead of checking the enter keys manually.

Remove unnecessary and unused `CUi::m_ValueSelectorTextMode` variable and its accessors as well as the equivalent `s_TextMode` variable in the editor. This separate flag is unnecessary as we can use the existing `s_pLastTextId` variable instead.
2024-06-06 21:41:50 +02:00
Dennis Felsing 85888c3aa3
Merge pull request #8456 from Robyt3/Editor-UI-MouseHandling
Unify editor UI mouse handling with `CUi`
2024-06-06 04:22:00 +00:00
archimede67 80228caddd
Merge pull request #8457 from Robyt3/Client-Warning-Button-Localize
Fix Ok-button of warning popup not being localized
2024-06-05 20:07:10 +00:00
Robert Müller f8e84216fc Fix Ok-button of warning popup not being localized 2024-06-05 21:48:52 +02:00
Robert Müller ca89162b06 Fix wrong file extension being removed in demo cut popup
The `.demo` extension is supposed to be removed from the target filename when slicing demos, but anything after the last dot was being removed instead, e.g. `test.abc.def` was incorrectly replaced with `test.abc`.
2024-06-05 21:11:50 +02:00
Robert Müller 60f3b5fb55 Unify editor UI mouse handling with CUi
Remove separate handling of UI mouse position and delta in the editor and use the UI directly for this like in the gameclient. Raw cursor movements are redirected to the UI with the `CUi::OnCursorMove` function. The editor separately updates its world positions and delta after the mouse position was changed. The mouse world position for the editor is passed to the UI with the `CUi::Update` funtion as before, whereas the world position is unused in the gameclient.

Use `vec2`s for mouse positions and deltas instead of two separate floats.
2024-06-05 20:13:42 +02:00
Learath e9d568db5b Fix console search highlighting. Close #8451 2024-06-05 18:01:42 +02:00
Robert Müller 0d9f673b03 Include types.h instead of system.h in input.h 2024-06-04 22:02:49 +02:00
Robert Müller 248225c7c4 Refactor client input event handling
Add `IInput::ConsumeEvents` function accepting a consumer `std::function` to replace the duplicate usage of the `IInput::NumEvents`, `IInput::GetEvent` and `IInput::IsEventValid` functions.

Use an `std::vector` to store the current input events to support any number of input events per client update instead of at most 32.

Use full `uint32_t` range for input counter instead of only using the range 0..0xFFFF. If the range is artificially reduced, then this can result in inputs being handled multiple times with high refresh rates, so the increased range should add future proofing for extremely fast devices.

Split `CInput::AddEvent` function into `CInput::AddKeyEvent` and `CInput::AddTextEvent` functions for readability and to make it easier to add additional input events (i.e. touch events).

Ensure double-click state is cleared at the end of each frame to prevent the double-click from being stored when no UI element consumes it.

Move member variables from `IInput` interface to `CInput` implementation.

Remove separate `CEditor::DispatchInputEvents` function.
2024-06-04 22:01:54 +02:00
Dennis Felsing 4f22468bf8
Merge pull request #8443 from Robyt3/Client-Controls-Minor-Refactoring
Minor refactoring of `CControls`
2024-06-04 02:46:49 +00:00
Robert Müller 4ec5b04a2e Use vec2 instead of two separate variables 2024-06-03 21:43:49 +02:00
Robert Müller 1fcb8a5469 Add GetMinMouseDistance function, remove variable MinDistance 2024-06-03 21:43:49 +02:00
Robert Müller 01be442280 Rename variable MDistance to MouseDistance 2024-06-03 21:43:49 +02:00
Robert Müller f94053bd66 Rename variable w to Weapon 2024-06-03 21:43:48 +02:00
Robert Müller 2904c4a2e8 Restructure input send checks without ifs 2024-06-03 21:43:48 +02:00
Andriy 950bbf31af
Make "Tee" tab name localisable 2024-06-03 22:24:31 +03:00
Robert Müller 178a0dabfa Remove dead code and unused variables 2024-06-03 20:55:39 +02:00
Robert Müller b7579b0f0f Ensure last input send time is reset when disconnecting
Reset send time when disconnecting so input sending should always behave consistently like on the first connection.
2024-06-03 20:54:57 +02:00
Robert Müller a7229e9892 Use array of size NUM_DUMMIES instead of two variables
Reduce duplicate code and improve clarity.

Remove unnecessary casts to `void *`.
2024-06-03 20:54:49 +02:00
Robert Müller 64f4ea1512
Merge pull request #7588 from ChillerDragon/pr_stop_demo_on_reset
Stop demo when gameworld is reset
2024-06-02 17:14:57 +00:00
ChillerDragon 05d97cafb2 Stop demo when gameworld is reset
Currently the per tee demos are only stopped when a character dies.
But the Reset() method in the gameworld destroys characters without
killing them.

This allows to do world resets without calling gamecontext shutdown
while sv_player_demo_record is active. Which is nice for round based
game modes.

```C++
void CGameWorld::Reset()
{
	// reset all entities
	for(auto *pEnt : m_apFirstEntityTypes)
		for(; pEnt;)
		{
			m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
			pEnt->Reset();
			pEnt = m_pNextTraverseEntity;
		}
	RemoveEntities();

	GameServer()->m_pController->OnReset();
	RemoveEntities();

	m_ResetRequested = false;

	GameServer()->CreateAllEntities(false);
}
```
2024-06-02 21:35:05 +08:00
Dennis Felsing 19b704d600
Merge pull request #8433 from Robyt3/Scoreboard-Recording-Notification-Refactoring
Fix truncated scoreboard recording notification, refactoring
2024-06-02 11:30:53 +00:00
Dennis Felsing 9986eaf6e9
Merge pull request #8435 from Robyt3/Translations-Ellipsis-Consistency
Consistently use `…` instead of `...` in translations
2024-06-02 11:28:15 +00:00
Dennis Felsing 3ba9fee8a8
Merge pull request #8430 from Robyt3/Localization-Fixes
Fix language file being loaded twice when starting, improve error handling for invalid translation files
2024-06-02 11:20:59 +00:00
Dennis Felsing da0df30497
Merge pull request #8356 from furo321/split-practice-commands
Add `/practicecmdlist`
2024-06-02 11:19:06 +00:00
Dennis Felsing bcc7412847
Merge pull request #8406 from l-ouis/master
Add confetti particles on finish
2024-06-02 11:15:16 +00:00
Robert Müller 37abc9039a Consistently use instead of ... in translations 2024-06-02 12:57:15 +02:00
Robert Müller cc7d6c393d Fix truncated scoreboard recording notification, refactoring
With some languages the buffers for the scoreboard recording notification were not large enough when recording all 4 types of demos at the same time.

Reduce duplicate code. Avoid unnecessary, slow `str_format` for concatenation. Use UI functions for drawing the background and text.
2024-06-02 11:54:23 +02:00
Robert Müller bbf54ec625
Merge pull request #8318 from ChillerDragon/pr_clang_tidy_19
Add support for clang tidy 19
2024-06-02 08:52:47 +00:00
Robert Müller 6cfe54b9c5
Merge pull request #8338 from ChillerDragon/pr_goto_tele_refactor
Fix `goto_tele` not finding all teleporters
2024-06-02 08:47:30 +00:00
Robert Müller 94325cdf78 Improve error handling for invalid translation files
Fix crash when reading a translation file that ends unexpectedly after a context line.

Make error messages about malformed translation files more detailed.

Fix incorrect line numbers in the error message because context lines were not counted.

Use `log_error` for error messages.
2024-06-02 10:36:00 +02:00
Louis Geer 9492ca574b Add confetti particles on finish
Add confetti particles on finish

added common base to finish netevent

review fixes

change netevent to ddnet.org
2024-06-02 11:00:06 +09:00
Robert Müller f762e2364f Fix language file being loaded twice when starting
Ignore language file config variable being set initially in the conchain (i.e. when `GlobalTime` still returns zero) and check whether the value changed before reloading the language.
2024-06-01 22:24:05 +02:00
furo 4e552d0f98 Add /practicecmdlist 2024-06-01 18:51:53 +02:00
Dennis Felsing f1c2d10cd7
Merge pull request #8424 from Robyt3/Cleanup-str_copy
Consistently use `str_copy` instead of `mem_copy` for strings
2024-06-01 15:18:37 +00:00
Robert Müller 24d12e4820 Consistently use str_copy instead of mem_copy for strings 2024-06-01 13:55:20 +02:00
Robert Müller 2a3cc8fd55 Make map download progress and speed label translatable 2024-06-01 13:01:37 +02:00
heinrich5991 a5ca7c64e0
Merge pull request #8409 from ChillerDragon/pr_const_char
Mark some character methods const
2024-05-29 00:31:19 +00:00
ChillerDragon ffd0da09e9 Mark some character methods const 2024-05-29 08:13:16 +08:00
Robert Müller bd5ca951a7 Prevent UI elements from being hovered while key reader is active
Since the key reader will intercept the next input, the other UI elements should not react to the hovered mouse.
2024-05-27 20:20:25 +02:00
ChillerDragon 59cb7ef5a9 Fix clang-analyzer-unix.StdCLibraryFunctions
```
/home/chiller/Desktop/git/ddnet/src/base/system.cpp:1989:10: error: The 1st argument to 'connect' is < 0 but should be >= 0 [clang-analyzer-unix.StdCLibraryFunctions,-warnings-as-errors]
 1989 |                 return connect(sock->ipv4sock, (struct sockaddr *)&addr, sizeof(addr));
      |                        ^
```
2024-05-26 19:31:54 +08:00
ChillerDragon 64505273a9 Remove redundant casts 2024-05-26 19:31:54 +08:00
ChillerDragon 0a505c25d7 Don't return from void methods 2024-05-26 19:31:54 +08:00
ChillerDragon c4f68f50ea Remove unnecessary object creation in emplace_front
Fixes

```
/home/chiller/Desktop/git/ddnet/src/engine/client/updater.cpp:186:27: error: unnecessary temporary object created while calling emplace_front [modernize-use-emplace,-warnings-as-errors]
  186 |         m_FileJobs.emplace_front(std::make_pair(pFile, Job));
      |                                  ^~~~~~~~~~~~~~~          ~
```
2024-05-26 19:31:54 +08:00
Robert Müller 583845fc60 Ensure return value of secure_random_init is always checked 2024-05-26 11:59:26 +02:00
Robert Müller 986508e091 Improve Android storage usage, faster launch, remove permissions
Split the user storage location and the data folder in the app specific external storage in the folders `data` and `user` instead of writing the user setting directly to the external storage.

Remove unnecessary storage permissions. The client only accesses files in its own external storage location, hence these permissions are not necessary for Android API 19 and higher, which is always given as we only target API 19 and higher.

Only unpack changed assets when their hash in the integrity index is different instead of unpacking all assets again, so the app starts faster after updates. Avoid unpacking the entire integrity index file unless it changed, by initially reading only the first hash directly from the asset, so the app starts faster when the data is up-to-date.

Add error handling for external storage not being accessible and other I/O errors during unpacking of assets.

Add `android_main.h` header to export the `InitAndroid` function and potentially other functions in the future. The `extern "C"` and `__attribute__((visibility("default")))` attributes seem to be unnecessary, as this function is only called directly from the native code like many other functions without these attributes.

Initialize the Android storage after the loggers, so the log message are printed properly.

Add documentation for the use of `std::exit` on Android, which is used to forcefully terminate the entire process, to ensure that static variables will be initialized correctly when the app is started again after quitting. Returning from the main function is not enough, as this only results in the native thread terminating, but the Java thread will continue. Java does not support unloading libraries once they have been loaded, so all static variables will not have their expected initial values anymore when the app is started again after quitting.

Use `fs_chdir` and `fs_makedir` instead of `chdir` and `mkdir`.
2024-05-25 21:09:42 +02:00
heinrich5991 1e11fffb03
Merge pull request #8390 from Robyt3/Base-chdir-getcwd-Cleanup
Minor refactoring of `fs_chdir` and `fs_getcwd` functions
2024-05-22 21:25:27 +00:00
heinrich5991 848f4a846b
Merge pull request #8334 from Robyt3/Android-Building-Fix
Fix the Android build and improve the Android building `README.md`
2024-05-22 21:19:40 +00:00
Robert Müller 68d474c81f
Merge pull request #8363 from heinrich5991/pr_ddnet_str_from_int
Optimize `str_format(…, …, "%d", …)` using templates
2024-05-22 21:01:17 +00:00
Robert Müller f04bea6b4b Minor refactoring of fs_chdir and fs_getcwd functions
Remove unnecessary `fs_is_dir` check in the `fs_chdir` function. The `SetCurrentDirectoryW` and `chdir` functions would already include such necessary checks anyway.

Assert that `GetCurrentDirectoryW` was successful instead of logging an error message. This function should only potentially fail if the current working directory was changed by another thread between the two calls, which should not happen in our code.
2024-05-22 19:22:23 +02:00
Dennis Felsing 9048bf2997
Merge pull request #7820 from gerdoe-jr/set-rescue
Add `/rescuemode` support
2024-05-22 17:22:07 +00:00
heinrich5991 df9980ee3e Optimize str_format(…, …, "%d", …) using templates
This would make the function `str_from_int` unnecessary, at least
user-facing.

Advantage: User doesn't have to care about `str_from_int`/`str_format`
distinction.

Disadvantage: We're adding some template programming to `system.h`,
potentially slowing all compilation.
2024-05-22 14:44:46 +02:00
heinrich5991 612a71f874
Merge pull request #8351 from ChillerDragon/pr_rcon_percentage
Show percentage of loaded rcon commands (closed #7769)
2024-05-22 08:39:40 +00:00
Steve Biedermann 3af8c00fc7 allow ipv4 econ to succeed, even if ipv6 econ fails to open port 2024-05-21 20:55:30 +02:00
Robert Müller dfae99da76 Fix unused variable Silent in client.cpp on Android 2024-05-21 17:36:46 +02:00
Robert Müller 4a2a23530c Fix integrity_save.txt file not being closed 2024-05-21 17:36:46 +02:00
Robert Müller b2b0cd0c81 Fix shadowed variable declarations in android_main.cpp 2024-05-21 17:36:46 +02:00
Robert Müller 7da8308c3f Remove cl_ddrace_scoreboard and cl_demo_assume_race settings
Time score will now always be used for any game with the flag `GAMEINFOFLAG_TIMESCORE` set in the `CNetObj_GameInfoEx` object. If the flag is not set, points score is used instead.

Backwards compatibility for old demos, that were recorded without this net object and flag, is removed. For old demos, points score is always assumed now.

Closes #6700.
2024-05-20 11:07:01 +02:00
Robert Müller c0a6f5a927 Revert "Always clear window with black color instead of background color"
This reverts commit caa062c88c.

As this decreased FPS and caused the background quad to be rendered twice when using a map background in entities mode.
2024-05-19 20:01:56 +02:00
Robert Müller 05c825947a Force landscape orientation and hide title bar on Android
Always force landscape orientation to be used for the game on Android.

Hide the title bar so it is not shown when starting the game. There is also a bug with SDL currently that leads to the title bar and status bar being shown permanently after minimizing and reopening the app, which is alleviated by hiding the title bar.
2024-05-19 12:58:33 +02:00
Robert Müller caa062c88c Always clear window with black color instead of background color
Always use black color to clear the window with all graphics backends, instead of using `cl_background_color` or `cl_background_entities_color`, respectively, as the clear color. The respective map background color is rendered using a quad in `CMapLayers` instead, so this should not affect appearance of maps. This does not have any noticeable effect on FPS. Previously, the unused part of the window (when it is resized smaller than 5:4 aspect ratio), was colored using the map background color, whereas now it will be cleared black consistently.

The color parameters of the `IGraphics::Clear` function and of the `SCommand_Clear` command are removed, as we always expect the screen to be cleared black now.

The parameter `ForceClearNow` of the `IGraphics::Clear` function was already unused previously and is also removed.
2024-05-18 15:20:17 +02:00
Dennis Felsing fcacef5fbb
Merge pull request #8362 from Robyt3/Android-Backbutton-Handling
Translate back-button to escape-key on Android, quit if Android back-button is pressed 3 times within 1 second
2024-05-18 01:10:32 +00:00
Robert Müller 91848f0be6 Quit if Android back-button is pressed 3 times within 1 second
Interpret fast repeated presses of the back-button (3 times within 1 second) as a quit-event, so the app can be quit cleanly and quickly without using the UI. The client settings are otherwise not saved if the app is closed by minimizing it using the home button and waiting for the OS to kill it or by discarding it in the recent apps view.
2024-05-17 19:37:44 +02:00
Robert Müller bba606feae Translate back-button to escape-key on Android
Translate the Android back-button to the escape-key, so it can be used to navigate back in menus, open/close the ingame menu, close the editor etc.

Trap the Android back button by setting the `SDL_ANDROID_TRAP_BACK_BUTTON` hint, so it can be handled in our code reliably instead of letting the system handle it.
2024-05-17 19:36:35 +02:00
Robert Müller 554f244ef2 Remove redundant graphics backend functions returning RGBA format
The graphics backends only support the RGBA format with the `SCommand_Texture_Create` and `SCommand_Texture_Update` commands, so the `TexFormatToOpenGLFormat`, `TextureFormatToVulkanFormat` and `TexFormatToNewOpenGLFormat` functions and the command member variables for the format are unnecessary. The `TexFormatToNewOpenGLFormat` function was unused.
2024-05-17 19:36:11 +02:00
archimede67 0f5b14c043
Merge pull request #8360 from Robyt3/UI-ButtonLogic-Consistency
Fix inconsistent behavior of scrollbars, key readers, edit boxes, value selectors and editor sound seekbars
2024-05-16 21:25:46 +00:00
heinrich5991 392fc0ba9a str_from_intstr_format 2024-05-14 21:37:02 +02:00
Vlad 4532a64b2b Add rescuemodes
May `/rescuemode` be case-insensitive

clang-tidy

conflicts

clang-tidy

`CMDFLAG_PRACTICE`
2024-05-14 09:19:50 +03:00
ChillerDragon f3a686bc62 Show percentage of loaded rcon commands
closed #7769
2024-05-14 08:46:17 +08:00
heinrich5991 03b13cb9f5
Merge pull request #8355 from Patiga/fix-pixelart
Fix off-by-one error in map_create_pixelart
2024-05-13 22:37:13 +00:00
yrrrmmbl a93ad48dce add cl_show_chat_team to only show team members' messages 2024-05-13 19:18:41 +02:00
Robert Müller f3bb5feffc
Merge pull request #8347 from Jupeyy/pr_vk_minirefactor
Fix segfault when swapchain images change (e.g. toggling Vsync)
2024-05-12 20:16:30 +00:00
Robert Müller 1c123f2324 Fix inconsistent button behavior of remaining UI elements
Fix edit boxes, scrollbars, value selectors and the editor sound seekbar being activated by holding the left mouse button from outside the UI element and then hovering it, which is inconsistent with the behavior of the `DoButtonLogic` function.
2024-05-12 18:16:06 +02:00
Robert Müller d431a5cdeb Fix inconsistent key reader button behavior
Use the `DoButtonLogic` function directly for the key reader buttons in the controls settings. Now, the key reader will only be activated when the left click is initiated and completed inside the key reader button. Previously, the key reader would be activated immediately when holding the left mouse button from outside and then hovering the key reader, and the key reader was already activated by the press-event, whereas now it will only be activated by the release event of the left mouse button. The active key reader UI ID is now tracked as a member variable of `CMenusKeyBinder` to avoid using static variables for this purpose.
2024-05-12 18:15:49 +02:00
Robert Müller e822d6878b Fix scrollregion scrollbar position offset after releasing handle
The scrollregion scrollbar was not being deactivated if the handle is continued to be hovered after releasing it, causing the handle to become offset with the position of the click on the next activation of the handle.
2024-05-12 18:15:39 +02:00
heinrich5991 0562be67f4
Merge pull request #8353 from Robyt3/Client-Demo-Seekbar-UX-Fixes
Fix demo seekbar tooltip not shown while seekbar is active, fix demo seekbar being activated by held button press
2024-05-12 01:45:33 +00:00
heinrich5991 acde8806db
Merge pull request #8354 from Robyt3/Menus-Settings-Controller-Size-Fix
Fix height of controller settings with exactly 1 controller
2024-05-12 01:26:08 +00:00
Patiga 4f62980541 Fix off-by-one error in map_create_pixelart 2024-05-11 19:53:56 +02:00
Robert Müller b8cb67379c Fix height of controller settings with exactly 1 controller
The controller name is also shown if there is only exactly one controller connected, but the height was not increased for the additional row.
2024-05-11 15:10:15 +02:00
Robert Müller c6c8f2eab6 Fix demo seekbar being activated by held button press
The seekbar is immediately activated if the mouse button is held while moving the mouse over the seekbar, which is inconsistent with the general `DoButtonLogic` behavior. This is problematic on Android, where the first mouse button is always pressed while the mouse is being moved, causing the seekbar to steal focus immediately when hovered.
2024-05-11 12:29:33 +02:00
Robert Müller 7d0774a00d Fix demo seekbar tooltip not shown while seekbar is active
The tooltip was not shown if the seekbar is the active item, i.e. when the first mouse button is held down and the seekbar is currently updating the demo player.
2024-05-11 12:26:46 +02:00
ChillerDragon 4f4f32615a Keep respawned players in multi view list on pvp servers
Assume every server that does not have ddnet or race in its gametype to be a pvp server.
This allows spectators to follow multiple players during a fng/ctf/gctf/ictf round.

Related issue #7509
2024-05-11 08:52:42 +08:00
Robert Müller 74e2e04b7d Remove unused CImageInfo::ImageFormatFromInt
Since the image format is not parsed from maps anymore, this function is unnecessary.
2024-05-10 21:44:49 +02:00
furo 3491624184 Fix crash when not specifying optimize, centralize or invalid amount of arguments 2024-05-10 19:05:58 +02:00
Jupeyy 15afc50865 Don't recreate DescriptorSetLayouts if swapchain image count changes 2024-05-10 18:48:09 +02:00
Jupeyy 128302d726 Cleanup Vulkan now takes SwapchainCount as explicit parameter.
This fixes a crash if the swapchain count changed.
fixes #8328
2024-05-10 18:48:09 +02:00
Jupeyy 2655627a4b Rename m_CurFrames to make clear it's about the sync objects.
Use one more sync object than there are inflight frames.
Remove unused memory sync objects.
2024-05-10 18:48:05 +02:00
furo 7cd9d8bbb4 Prevent using map_create_pixelart with the same input and output path 2024-05-10 18:42:55 +02:00
furo 39dd6ea499 Fix wrong filename used in dbg_msg 2024-05-10 18:20:33 +02:00
furo d5b06a4482 Use IO_MAX_PATH_LENGTH instead of 64 2024-05-10 18:18:24 +02:00
Robert Müller c80592063a Fix size of chat history entry allocation
The `-1` in the size calculation for the ringbuffer allocation of chat history entries was incorrect, so the entries potentially didn't fit the zero terminator. Because `mem_copy` was used, the string was also not zero terminated explicitly.
2024-05-10 10:53:23 +02:00
ChillerDragon 257a0bacc8 Store all tele types in vectors 2024-05-10 08:59:19 +08:00
heinrich5991 60dbd73ee3
Merge pull request #8333 from BlaiZephyr/change-time-timestamp-type
Change type from int to int64_t
2024-05-09 08:01:17 +00:00
meloƞ aec0dc9e0e Change type from int to int64_t 2024-05-09 08:42:19 +02:00
gerdoe-jr 4f0d8a5a1f add set_view_relative 2024-05-09 06:28:55 +03:00
ChillerDragon 6f75087d9f Refactor goto_tele
Fixes a bug of some teleporters being skipped.
Improves performance by only iterating all teleporters instead of every tile in the map.
2024-05-09 11:20:59 +08:00
heinrich5991 c211e874aa Fix 0.7 tokens after #8322
They're also read as big-endian integers now.

Thanks to @ChillerDragon for noticing.

Fixes #8330.
2024-05-08 14:17:02 +02:00
Dennis Felsing f214c1101b
Merge pull request #8326 from heinrich5991/pr_ddnet_no_map_image_rgb
Remove RGB images from the map file format
2024-05-08 04:56:19 +00:00
heinrich5991 8a64feabc3 Remove RGB images from the map file format
Cherry-picked from https://github.com/teeworlds/teeworlds/pull/2822.

CC https://github.com/teeworlds/teeworlds/issues/2812
CC https://github.com/teeworlds/teeworlds/issues/962

Since DDNet never saved these kinds of images, this should cause no
issues.
2024-05-07 14:31:06 +02:00
heinrich5991 3a48b8e6cf Revert "Initialize all ghost item member (Closed #8297)"
This reverts commit f319ed239a.

Initializing these variables with junk data doesn't seem to be an
improvement over not initializing them. It hides potential Valgrind
warnings about data accesses to uninitialized memory though.

f319ed239a (r1590801501)
2024-05-07 14:25:29 +02:00
Dennis Felsing df30321f52
Merge pull request #8324 from ewancg/chat-practice
Add chat commands for toggling weapons in practice mode
2024-05-07 05:42:38 +00:00
Dennis Felsing ae2c9e2999
Merge pull request #8323 from Robyt3/Client-Particles-Smoke-Nudge
Fix smoke particles sometimes being stuck inside solid tiles
2024-05-07 01:21:37 +00:00
Ewan Green 87cab3ebd9 change GetPracticeCharacter() to not be static, fix solo checks 2024-05-06 15:06:42 -06:00
Ewan Green ba5b39d294 change forgotten functions to use practice check 2024-05-06 14:08:51 -06:00
Ewan Green bf78d7fb48 cleanup 2024-05-06 14:03:17 -06:00
Ewan Green d6449872a4 add weapon chat commands for practice mode 2024-05-06 13:57:16 -06:00
heinrich5991 36712db0f1 Use network tokens in big-endian byte order consistently
Previously, it was handled inconsistently on big-endian machines and
caused connection failures.
2024-05-06 20:33:17 +02:00
Robert Müller 6cbc85f229 Fix smoke particles sometimes being stuck inside solid tiles
Nudge the initial position for explosions' smoke particles slightly towards the edge of the closest non-solid tile, if it would otherwise be inside a solid tile, so the smoke particles do not get stuck inside solid tiles on explosion events happening at the edges of tiles but slightly inside them. The physical position of the explosion event is unchanged, so this does not affect physics. The explosion sprite is still rendered at the physical position of the explosion, to preserve the apprearance.
2024-05-06 16:03:36 +02:00
Robert Müller d4e3f6fc01
Merge pull request #8316 from ChillerDragon/pr_use_sendchat
Use SendChat() in DbgStress
2024-05-06 08:52:47 +00:00
ChillerDragon 3c606dd1e4 Don't access static ConCommandStatus with a member
Fixes this clang-tidy 19 warning

```
/home/chiller/Desktop/git/ddnet/src/engine/shared/console.cpp:739:2: error: static member accessed through instance [readability-static-accessed-through-instance,-warnings-as-errors]
  739 |         pConsole->ConCommandStatus(&Result, pConsole);
      |         ^~~~~~~~~~
      |         CConsole::
```
2024-05-06 11:48:47 +08:00
ChillerDragon 28f3ac3e87 Use SendChat() in DbgStress 2024-05-06 11:09:18 +08:00
ChillerDragon 44d065888f Rename CChat::SayChat to CChat::SendChatQueued
Also replace one code snippet with a call to SendChatQueued
2024-05-06 09:49:35 +08:00
ChillerDragon 33baeb8f28 Rename CChat::Say to CChat::SendChat
Follows the convention set by the other methods that send network packets.
2024-05-06 09:23:19 +08:00
Robert Müller 1551dda3e9 Also unload collision and layers when unloading map
Ensure that the `CCollision` and `CLayers` instances do not keep any pointers to the map data after the map has been unloaded.
2024-05-05 12:41:18 +02:00
Robert Müller 7d640e1f98
Merge pull request #8309 from ChillerDragon/pr_init_ghost
Initialize all ghost item member (Closed #8297)
2024-05-05 09:37:54 +00:00
Robert Müller bf2343d60b
Merge pull request #8312 from ChillerDragon/pr_fix_misleading_demo_snap_var_names
Make demo snap variable names more obvious
2024-05-05 09:18:38 +00:00
ChillerDragon 1a3bb727c5 Make demo snap variable names more obvious
Closed #8245
2024-05-05 16:01:55 +08:00
Dennis Felsing 2b2e57c2bb
Merge pull request #8308 from ChillerDragon/pr_team_enum
Use enum for teams (Closed #8306)
2024-05-05 03:59:35 +00:00
ChillerDragon f319ed239a Initialize all ghost item member (Closed #8297) 2024-05-05 11:47:05 +08:00
ChillerDragon 0b6bb8287a Use enum for teams (Closed #8306) 2024-05-05 11:38:29 +08:00
Dennis Felsing aafb4e2e09
Merge pull request #8304 from Zwelf/pr-teehistorian-finish-2
Store player names in teehistorian and Finish/TeamFinish v2
2024-05-05 01:34:57 +00:00
Dennis Felsing fdc929d2b1
Merge pull request #8293 from BlaiZephyr/add-team0-indicator
add team0mode indicator
2024-05-05 01:33:27 +00:00
Zwelf f14dab4cfa Increment teehistorian version_minor to 8
Allows easily distinguishing between Teehistorian extension from #8221
with wrong Tick (divided by 50) and this fixed one.
2024-05-04 21:40:06 +02:00
Zwelf af4da41c4c Record Player and Team finishes in Teehistorian 2024-05-04 21:40:06 +02:00
Zwelf fcd8aae388 Record player name in Teehistorian files 2024-05-04 20:44:20 +02:00
Dennis Felsing 2f22447d44
Merge pull request #8302 from Robyt3/Video-Refactoring
Video recorder: improve error handling and log messages, fix crashes, refactoring
2024-05-04 14:59:06 +00:00
Robert Müller e5927d9024 Fix crashes when video recording is not started successfully
Add additional checks to ensure that the `CVideo::Stop` function and the functions called by it will correctly stop the current video also if the video was not started successfully, i.e. if `CVideo::Start` returned `false` from any of the error branches.

In the `CVideo::Stop` function, iterate over the vectors of video and audio threads directly instead of using `m_VideoThreads` and `m_AudioThreads`, which do not reflect the actual count if the initialization failed before the threads were created.

In the `CVideo::Stop` function, only call `av_write_trailer` if the video recording was stated successfully, i.e. only if `avformat_write_header` was called successfully, as this will otherwise cause the client to crash. Closes #6375.

In the `CVideo::Stop` function, only call `avio_closep` if the format context was allocated.

In the `CVideo::FinishFrames` function, ensure that the codec has been allocated and opened, otherwise using it is not allowed.

Add assertions to the `CVideo::Start` and `Stop` functions to ensure that the same video is not started/stopped multiple times.
2024-05-04 13:55:35 +02:00
Robert Müller 3a0e2429d1 Assert that size of image data matches size of video
Crash with assertion when the size of the graphics is different from the video currently being rendered, instead of causing weirder bugs and a corrupted video file.
2024-05-04 13:55:35 +02:00
Robert Müller a0465b67dd Improve various variable and class names of the video recorder
- Rename variable `m_vBuffer` -> `m_vAudioBuffers`
- Rename class `SAudioBuffer` -> `CAudioBuffer`
- Rename variable `m_vPixelHelper` -> `m_vVideoBuffers`
- Add class `CVideoBuffer` as wrapper
- Remove unused variable `m_Vframe`
- Rename variable `m_ASeq` -> `m_AudioFrameIndex`
- Rename variable `m_VSeq` -> `m_VideoFrameIndex`
- Rename variable `m_vVideoThreads` -> `m_vpVideoThreads`
- Rename variable `m_vAudioThreads` -> `m_vpAudioThreads`
- Rename function `ReadRGBFromGL` -> `UpdateVideoBufferFromGraphics`
- Remove unnecessary `ALEN` definition
- Remove unused variable `NextPts`
- Rename class `OutputStream` -> `COutputStream`
- Rename variable `pSt` -> `m_pStream`
- Rename variable `pEnc` -> `m_pCodecContext`
- Rename variable `m_vpSwsCtxs` -> `m_vpSwsContexts`
- Rename variable `m_vpSwrCtxs` -> `m_vpSwrContexts`
- Rename variable `pOC` -> `pFormatContext`
- Rename class `SVideoRecorderThread` -> `CVideoRecorderThread`
- Rename class `SAudioRecorderThread` -> `CAudioRecorderThread`
2024-05-04 13:55:35 +02:00
Robert Müller 5f647b97eb Ensure correct sample and bit rate are used for video recording
The wrong sampling rate was being used for video recording if the client is not restarted after changing the `snd_rate` config variable.

Ensure that the correct bit rate is used if the sample rate was adjusted because the selected value is not supposed.
2024-05-04 13:15:54 +02:00
Robert Müller 9d2c11d7ee Improve error handling and logging of video recorder
Use `log_error` for all errors and consistently format all error messages.

Handle all ffmpeg errors and output the formatted ffmpeg error message when possible.

Register a log callback for ffmpeg log messages to delegate them to our logging system, to fix the log messages being interleaved with our log messages and not using the correct line breaks on Windows.

Stop video and demo immediately and show an error message popup if the video could not be started successfully.

Remove unnecessary debug output from ffmpeg.
2024-05-04 13:15:54 +02:00
Robert Müller e595545cd6 Fix duplicate file extension .mp4 for demos rendered from menu
The file extension is always added in `CClient::StartVideo` now.
2024-05-04 13:04:58 +02:00
Robert Müller 33c5bfb09b Fix indentation of comments 2024-05-04 13:04:58 +02:00
Robert Müller c78eebfc67 Use nullptr instead of 0 and NULL 2024-05-04 13:04:58 +02:00
Robert Müller c4c1518709 Remove dead code 2024-05-04 13:04:58 +02:00
Robert Müller 15bebb8fb6 Remove unnecessary downcast to CGraphics_Threaded 2024-05-04 13:04:58 +02:00
ChillerDragon 8b0b09fffd Improve skin name validation error message (Closed #8300) 2024-05-04 17:43:59 +08:00
Dennis Felsing 43c03c4d54
Merge pull request #8296 from ChillerDragon/pr_camel_tools
Remove tools camel case style exception
2024-05-04 05:20:30 +00:00
ChillerDragon fcbd1fb1b1 Fix worst local variable style offenses
Removed member prefix m_ used for local variables.
Removed all b, c, i hungarian notation prefixes for boolean, const and integers.
Fixed local variables using lower_snake_case instead of UpperCamelCase.
Renamed all ``float wSearch = TextRender()->TextWidth..`` to ``float SearchWidth = ..``.
2024-05-04 11:17:06 +08:00
ChillerDragon f788a04892 Remove tools camel case style exception 2024-05-04 10:56:33 +08:00
Robert Müller b745d75306 Fix alignment of vote option heap entries with remove_vote
When using the `remove_vote` command, the entire heap of vote options is allocated again without the entry being removed. This allocation was not considering the required alignment for `CVoteOptionServer` objects and potentially wasting space by aligning with `alignof(std::max_align_t)`. When allocating the entries with the `add_vote` command, the alignment is already specified correctly.
2024-05-03 18:22:33 +02:00
Dennis Felsing fc180562f6
Merge pull request #8151 from ChillerDragon/pr_tidy_camel
Enforce UpperCamelCase for local variables
2024-05-02 13:48:56 +00:00
meloƞ 9bbe238159 added team0mode indicator 2024-05-02 14:23:30 +02:00
ChillerDragon 63c8172d11 Enforce UpperCamelCase for local variables 2024-05-02 18:52:16 +08:00
heinrich5991 2dbcb9795a
Merge pull request #8139 from ChillerDragon/pr_cui_noop
Remove useless operation in CUIRect SplitMid
2024-05-02 06:14:34 +00:00
Dennis Felsing 7b97138202 Version 18.2 2024-05-02 11:15:02 +08:00
heinrich5991 213222b72b
Merge pull request #8289 from Robyt3/Client-Address-Check-Cleanup
Remove unnecessary check excluding packets from wrong server
2024-05-01 15:24:34 +00:00
Dennis Felsing 70785eb0dd
Merge pull request #8281 from ChillerDragon/pr_fix_triggeredevents7
Make sixup TriggeredEvents reliable
2024-05-01 15:16:29 +00:00
Robert Müller dd62cda8ba Remove CCommandProcessorFragment_GLBase::Resize delegate
Use `ResizeImage` function directly instead.
2024-05-01 14:56:34 +02:00
Robert Müller 20c28f78ce Remove unnecessary check excluding packets from wrong server
This is already checked for all connection-oriented packets when feeding the connection in

952d3f6631/src/engine/shared/network_conn.cpp (L260-L266)

Closes #8285.
2024-05-01 13:34:19 +02:00
heinrich5991 2cd877f0ce
Merge pull request #8272 from ChillerDragon/pr_fix_snap_uuid_register
Fix ddnet ex snap item registration (closed #8271)
2024-05-01 09:56:42 +00:00
ChillerDragon 3c45134c8d Fix ddnet ex snap item registration (closed #8271) 2024-05-01 09:45:42 +08:00
ChillerDragon 740aada779 Add str_isnum 2024-05-01 09:08:02 +08:00
Robert Müller 3fc6ee4349
Merge pull request #8284 from ChillerDragon/pr_newline_cursor
Always update text cursor y (closed #8282)
2024-04-30 16:10:14 +00:00
ChillerDragon 508b6d1615 Always update text cursor y (closed #8282) 2024-04-29 14:12:38 +08:00
Dennis Felsing 7e857ce37e
Merge pull request #8280 from Robyt3/Client-Redirect-Password-Fix
Fix wrong server address used in password popup when redirected, minor refactoring
2024-04-29 04:23:57 +00:00
ChillerDragon 5f784cbcda Make sixup TriggeredEvents reliable
Relevant upstream commit:
d2924b5ad6

Closes https://github.com/ChillerDragon/ddnet/issues/7

The snap item obj_character contains a field called m_TriggeredEvents
https://chillerdragon.github.io/teeworlds-protocol/07/snap_items.html#obj_character

It is responsible for effects and sounds. Those flags are set in the gamecore.
So if the servers gamecore ticks twice and resets the flags before a snap is
sent the client misses the information. Which is not too big of a
problem since the client has his own gamecore running (prediction) which
also sets those flags. But it is still wrong and teeworlds does always
include the triggered events in the snap.

So this commit fixes it using the same approach as teeworlds.
By not resetting the triggered events until a snap was sent.
2024-04-29 08:57:14 +08:00
Dennis Felsing d265057591
Merge pull request #8278 from Robyt3/Client-Move-Resize-Fixes
Revert screen mode config variables when change not accepted, update screen index config variable after moving window
2024-04-28 15:18:16 +00:00
Robert Müller 938d264c43 Fix wrong server address used in password popup when redirected
Always use the server address from the network client to reconnect to the correct server after being disconnected due to wrong password. The password popup is only shown after being disconnected, so the server address of the network client should always the address of the server which the client should reconnect to with the password. Using `ui_server_address` was causing the wrong address to be used after being redirected to another server and if the config variable is changed while the password popup is open.

Closes #8260.
2024-04-28 17:05:28 +02:00
Robert Müller d2139e4bec Use net_addr_str directly to format address including port 2024-04-28 16:45:56 +02:00
Robert Müller b3bcfd39bc Add no-op logger to fix leak of CFutureLogger pending messages
Fix leak of pending future logger log messages if the future logger is not set, in particular when the `logfile` config variable is not set or the file could not be opened, by setting a logger that discards all log messages in this case.

Closes #8265.
2024-04-28 16:32:24 +02:00
Robert Müller e4dddb95ce Update screen index config variable after moving window
The wrong screen was shown in the settings when moving the window to another screen while in windowed mode.
2024-04-28 15:29:05 +02:00
Robert Müller 86bf5424e3 Revert screen mode config variables when change not accepted
When changing the screen width, height or refresh rate config variables to 0 or negative values, which are not allowed by the backend, automatically revert the config variables to the actual values again to ensure that the config variables stay in sync with the state of the window. This fixes the client crashing in the graphics settings when setting the screen width and height to 0 via the console, which causes a division by zero when calculating the aspect ratio.
2024-04-28 15:25:31 +02:00
Dennis Felsing 516315e0e2
Merge pull request #8273 from Robyt3/Sound-Various-Fixes
Fix crashes and memory leaks related to editor map sounds and opus file decoding, refactoring
2024-04-27 15:45:55 +00:00
Robert Müller 4f94316c72 Make change_map parameter non-optional
The command confusingly assumed the empty string if no argument was passed.
2024-04-27 13:45:51 +02:00
Robert Müller 9cf3094934 Also check for incorrect sample index with assertion
Ensure the sample being allocated is not currently used also by checking its next free sample index.
2024-04-27 13:11:35 +02:00
Robert Müller d06f6d3370 Handle failure of op_pcm_total function
According to the documentation, this function returns `0` on success and a negative number (error code) otherwise, which would cause an allocation of an invalid size.
2024-04-27 13:11:35 +02:00
Robert Müller d0e27fdcd4 Fix memory leak of opus file structure
We were not calling `op_free` for `OggOpusFile *` after decoding opus files.
2024-04-27 13:04:05 +02:00
Robert Müller cfb5b15222 Log error code if opus file cannot be opened 2024-04-27 13:03:58 +02:00
Robert Müller 51012bcc1b Fix potential out-of-bounds writes on invalid opus files
The third parameter of the `op_read` function specifies the remaining size of the buffer, but we always passed the total size of the buffer without respecting the position at which the data is written into the buffer.
2024-04-27 13:03:18 +02:00
Robert Müller 4d37775c17 Only change sample variables when it was decoded successfully
Avoid changing the sample member variables until the sample was decoded successfully.
2024-04-27 13:02:36 +02:00
Robert Müller 1153507216 Fix double-free when reading opus file fails
Set the data pointer of the sample only when the sample has been loaded successfully, so the invalid sample data is not freed again when decoding fails.
2024-04-27 13:02:23 +02:00
Robert Müller 941a302c4d Ensure editor preview image and sound are unloaded properly
The preview image was previously not unloaded and the preview state was not reset.
2024-04-27 13:01:56 +02:00
Robert Müller 3b0d9cd6c9 Fix editor crash with sound preview when sound is not valid
This happens if a sound could not be loaded successfully.
2024-04-27 13:01:26 +02:00
Robert Müller 690912e209 Fix invalid sound index used when loading external sound fails
This should be highly unlikely because external sound mapres were never supported by the editor.
2024-04-27 13:00:54 +02:00
Dennis Felsing c22ba00b59
Merge pull request #8270 from Robyt3/Image-size_t
Use `size_t` for `CImageInfo::m_Width` and `m_Height`
2024-04-27 04:37:28 +00:00
Robert Müller c5a0d850d2 Use size_t for CImageInfo::m_Width and m_Height 2024-04-26 21:12:39 +02:00
Robert Müller caccf05455 Fix warning because of incorrect format argument for size_t 2024-04-26 19:59:47 +02:00
Dennis Felsing 0eb319a951
Merge pull request #8263 from ChillerDragon/pr_line_author
Use LineAuthor variable to cleanup chat code
2024-04-25 17:11:04 +00:00
Robert Müller 0cedcdc3a7
Merge pull request #8236 from ChillerDragon/pr_delta_dump
Add delta debug dump
2024-04-25 16:05:26 +00:00
ChillerDragon 1937145fdb Use LineAuthor variable to cleanup chat code 2024-04-25 09:43:29 +08:00
ChillerDragon 29f6cc67db Add delta debug dump 2024-04-25 08:44:49 +08:00
Dennis Felsing 1a397ad995
Merge pull request #8252 from ChillerDragon/pr_num_skinparts
Use NUM_SKINPARTS instead of magic number
2024-04-23 08:32:22 +00:00
ChillerDragon 38cae7edcf Use NUM_SKINPARTS instead of magic number 2024-04-23 16:09:34 +08:00
Robert Müller 5958e9e4c5 Reset last dummy state when disconnecting
Otherwise the snapshots may incorrectly be invalidated because a change of the `cl_dummy` variable is detected when connecting to another server after disconnecting while the dummy is active.
2024-04-22 19:54:21 +02:00
Robert Müller efdd55613c Avoid using cl_dummy for demo playback
The `cl_dummy` config variable is always `0` during demo playback. Using the config variable makes the code less readable.
2024-04-22 19:54:21 +02:00
Robert Müller c7403ef06d Check CNetClient::State instead of SecurityTokenUnknown
Send dummy ready and enter game when connection is online based on its state instead of when the security token is not unknown anymore, which should effectively be the same condition but more understandable. This is also how it's already done for the main connection so the `SecurityTokenUnknown` function can be removed as it's unused now.
2024-04-22 19:54:21 +02:00
Robert Müller 9ffa9d8e0a Do not unpack map data packet if no map download is progress
There is no need to unpack map data packets if the client receives any without expecting them.
2024-04-22 19:33:20 +02:00
Robert Müller b264570218 Ignore all packets from other servers instead of only snapshots
The client should only ever handle game-related packets from the server that it is currently connecting/connected to.
2024-04-22 19:33:11 +02:00
Robert Müller 87f9ccdb22 Improve readability by renaming variable and changing condition
Rename variable `i` to `Conn`. Check for `CONN_MAIN` and `CONN_DUMMY` explicitly instead of using numeric index.
2024-04-22 19:32:55 +02:00
Robert Müller 9e5369bc9d Mark dummy connecting functions as const 2024-04-22 19:32:46 +02:00
Robert Müller 51a624d95c Use array index 0 explicitly instead of using array as pointer 2024-04-22 19:32:36 +02:00
Robert Müller fbe559ea79 Fix console not keeping scroll position when backlog is full
The console was not keeping its current scoll position if entries from the backlog are removed due to being recycled when new entries are added. For this purpose, a callback function is added to the ringbuffer to handle popped items, so the scrolling position of the console can be updated based on the number of lines of the removed backlog entries.
2024-04-21 12:52:55 +02:00
Robert Müller 151b2854e3 Fix potential client crash when console backlog is full
Fix backlog corruption in `CConsole::PumpBacklogPending` when many backlog entries are allocated at the same time. When allocating many entries from the `m_Backlog` ringbuffer at the same time, the first entries being allocated may already have been recycled again, so the pointers to them being stored in the temporary vector of new backlog entries were pointing arbitrarily into the ringbuffer data, which could cause corruption of the structural and user data of the ringbuffer. Now, we iterate over the entire backlog and only update uninitialized entries instead of storing the new entries separately.

This was sometimes caught as a misaligned access with UBSan:

```
src/engine/shared/ringbuffer.cpp:160:14: runtime error: member access within misaligned address 0x00014126f4df for type 'struct CItem', which requires 8 byte alignment
0x00014126f4df: note: pointer points here
<memory cannot be printed>
    0 0x5825349a6a1c in CRingBufferBase::Prev(void*) src/engine/shared/ringbuffer.cpp:160
    1 0x5825334e8934 in CTypedRingBuffer<CGameConsole::CInstance::CBacklogEntry>::Prev(CGameConsole::CInstance::CBacklogEntry*) src/engine/shared/ringbuffer.h:59
    2 0x5825334d13e6 in CGameConsole::OnRender() src/game/client/components/console.cpp:1259
    3 0x582533bce058 in CGameClient::OnRender() src/game/client/gameclient.cpp:715
    4 0x582532f3cc44 in CClient::Render() src/engine/client/client.cpp:894
    5 0x582532f9d236 in CClient::Run() src/engine/client/client.cpp:2971
    6 0x582533002e5e in main src/engine/client/client.cpp:4523
```
2024-04-21 12:52:54 +02:00
Robert Müller 9be40e1782 Fix OOB accesses rendering ghosts, fix ghost hook collision line
Fix out-of-bounds accesses when rendering ghost players, which use the client ID `-2`. This was causing the hook collision line of ghost players to be affected by real players, which is not correct, as ghosts do not interact with other characters.

Closes #8239.
2024-04-20 23:28:37 +02:00
Dennis Felsing b35503273c
Merge pull request #8234 from ChillerDragon/pr_typo_reckoning
Fix reckoning typo in comment
2024-04-20 02:18:52 +00:00
ChillerDragon db627976e5 Fix reckoning typo in comment 2024-04-20 09:53:58 +08:00
Dennis Felsing 173e675ec1
Merge pull request #8203 from Robyt3/Graphics-LoadPng-Cleanup
Change `PNG` in function names to `Png`, pass `CImageInfo` by reference to `IGraphics::LoadPng`
2024-04-20 00:55:02 +00:00
Robert Müller d2c8132fb6 Add optional name argument to start_video command, refactoring
Add optional filename argument to `start_video` command, to start recording to a video file with a specific filename, instead of always using the current timestamp.

Add log messages to `start_video` and `stop_video` commands to indicate success and errors.

Make the `CClient::StartVideo` function non-`static` and reduce duplicate code in the `Con_StartVideo` function.

Determine the video filename outside of the `CVideo` constructor, same as for demos.
2024-04-19 20:09:20 +02:00
Robert Müller 93d5a8be32 Improve descriptions of demo-related console commands 2024-04-19 20:08:41 +02:00
Robert Müller 12d3c8245d Fix prediction errors and incorrect rendering after changing map
Fix game times and prediction not being updated when only exactly two snapshots have been received, due to the conditions `m_aReceivedSnapshots[...] >= 3`. These specific condition are not necessary and replaced with simpler checks whether the current snapshot is set. Some duplicate nested conditions are also removed.

Pump the network first in `CClient::Update` before updating anything else, to ensure that snapshots are received from the network client before the game times and prediction are being updated based on the current snapshots.

Fix current and previous game tick always being `0` on the first call of `IGameClient::OnNewSnapshot` when two snapshot have been received. Now, the game ticks are properly initialized from the two initial snapshots.

Fix old inputs sometimes being used in prediction after changing map because inputs with tick `-1` were not being ignored.

Ensure all snapshots and game times are properly cleared when entering the game.
2024-04-18 20:40:31 +02:00
Dennis Felsing da09087416
Merge pull request #8227 from Zwelf/pr-disable-practice-while-saving
Disallow activating /practice while save is in progress and improve messaging for when `/save`/`/load` command does nothing
2024-04-18 01:53:19 +00:00
Zwelf e1355dc891 Improve messaging to players why /load command does nothing 2024-04-17 22:10:40 +02:00
Zwelf f6f5629fd0 Disallow /load when practice mode is enabled 2024-04-17 22:10:40 +02:00
Zwelf 25f85afef5 Improve messaging to players why /save command does nothing 2024-04-17 22:10:40 +02:00
Zwelf da5a466ac3 Disallow enabling practice while save and load is in progress 2024-04-17 22:10:40 +02:00
Robert Müller 3ef00d465e Fix assertion on Windows when redirecting console output to nul
`GetConsoleMode` can fail with `ERROR_INVALID_HANDLE` when redirecting output to `nul`, which is considered a character file but cannot be used as a console.
2024-04-17 20:00:32 +02:00
Robert Müller 36db1e604f Fix freeze not working during first 50 server ticks
The purpose of this condition is to only update the freeze time every 50 ticks so the freeze bar keeps being refilled after one second when standing in freeze, but it incorrectly prevented freeze from being applied during the first 50 ticks after the map has been loaded. Now, freeze is also applied if not currently frozen, so the behavior directly after changing the map is identical to subsequent respawns.
2024-04-16 20:55:31 +02:00
Dennis Felsing d028756bbb Revert "Record player name in Teehistorian files"
This reverts commit 783f4e3093.
2024-04-16 12:41:14 +08:00
Dennis Felsing 6c9af4d2cc Revert "Record Player and Team finishes in Teehistorian"
This reverts commit ece1ec07f5.
2024-04-16 12:41:10 +08:00
Dennis Felsing 68a64b4ae1
Merge pull request #8219 from Robyt3/Client-Component-Setter-Cleanup
Remove unnecessary client component variables and setters
2024-04-16 01:40:12 +00:00
Dennis Felsing 5f45e218ef
Merge pull request #8221 from Zwelf/pr-teehistorian-finish
Store player names in teehistorian and Finish/TeamFinish
2024-04-16 01:11:16 +00:00
Dennis Felsing 88ff8204db
Merge pull request #8220 from Zwelf/pr-practice-disallow-save
Disallow `/save` on teams with practice enabled
2024-04-16 01:11:13 +00:00
Dennis Felsing 17110ace66
Merge pull request #8171 from Zwelf/pr-simplify-base-hook
Simplify and fix HookBase calculation
2024-04-16 01:11:11 +00:00
Zwelf ece1ec07f5 Record Player and Team finishes in Teehistorian 2024-04-16 00:50:05 +02:00
Zwelf 783f4e3093 Record player name in Teehistorian files 2024-04-16 00:50:05 +02:00
Zwelf 868e6e0975 Disallow /save on teams with practice enabled 2024-04-16 00:34:23 +02:00
Robert Müller 8817a69269 Remove unnecessary client component variables and setters
Use the gameclient to access other components instead.
2024-04-15 20:26:26 +02:00
Dennis Felsing 2e211c9a31
Merge pull request #8218 from dobrykafe/pr-align-friendslist
Fix alignment of labels in friends list
2024-04-15 01:31:55 +00:00
Dennis Felsing fe41f58197
Merge pull request #8164 from murpii/pr_teleport_reset_jumps
Refresh air jumps after teleporting
2024-04-15 01:31:50 +00:00
Dennis Felsing aca25cc802
Merge pull request #8216 from Robyt3/Demo-ServerInfo-Fix
Fix incorrect score kind in demos depending on last server
2024-04-15 01:31:38 +00:00
dobrykafe 19b19262a4 fix alignment of labels in friends list 2024-04-15 00:29:46 +02:00
Robert Müller 8a378da89b
Merge pull request #8217 from dobrykafe/pr-remove-conmode
Remove unused `ConMode` function
2024-04-14 21:07:58 +00:00
dobrykafe 3b7019d3f7 remove unused ConMode function 2024-04-14 22:48:20 +02:00
Robert Müller 47e4505193
Merge pull request #8215 from furo321/fix-timecp-mysql
Fix `/timecp` not working with MySQL
2024-04-14 20:23:18 +00:00
Robert Müller 2423e35fd2 Fix incorrect score kind in demos depending on last server
Clear current server info when playing demos to ensure that the score kind (points, time) is detected correctly. Previously, when playing a demo with points score kind and `cl_demo_assume_race 0`, the score was not shown as points when the last server that the client connected to had a race gametype.

Move the implementation for `cl_demo_assume_race` together with the rest of the demo server info initialization in the `CClient::DemoPlayer_Play` function.
2024-04-14 22:18:49 +02:00
furo cf6569029f Fix /timecp not working with MySQL 2024-04-14 19:51:09 +02:00
Dennis Felsing 06f1db98e6
Merge pull request #8213 from furo321/fix-gametiles-button
Fix bug where certain tiles would not work in `Game tiles` menu
2024-04-14 13:28:22 +00:00
furo 2545c14a5d Fix bug where certain tiles would not work in Game tiles menu 2024-04-14 15:05:10 +02:00
Robert Müller 9abe501f77 Fix duplicated rendering of popup menus in demo player
The popup menus are already rendered in the `CMenus::Render` function, also for the demo player since #8156.
2024-04-14 11:30:47 +02:00
Robert Müller 717cbef375 Fix demo player hotkeys not working when menu is inactive
The demo player needs to be rendered also when the menu is inactive, to handle the hotkeys for controlling the demo player and to render the play/pause and speed indicators.

Closes #8208.
2024-04-14 11:30:42 +02:00
Dennis Felsing 1b77cbc821
Merge pull request #8209 from dobrykafe/pr-votes
Allow the vote creator to cancel the vote + sixup vote fix
2024-04-14 03:58:29 +00:00
dobrykafe 8ca395c8be allow the vote creator to cancel the vote 2024-04-13 23:57:59 +02:00
dobrykafe b6a1a124fe fix votes for sixup 2024-04-13 23:56:40 +02:00
Robert Müller 5295ba3ded Improve readability by breaking early and reducing indentation
Remove unnecessary temporary variables and parenthesis.
2024-04-13 11:10:47 +02:00
Robert Müller 9cd51576d4 Rename static variable ActionTaken to s_ActionTaken 2024-04-13 11:10:45 +02:00
Robert Müller fd7a1600f6 Remove redundant checks of client state
These conditions are contained in an `if(State() == IClient::STATE_ONLINE)` branch and the state does not change while inside this branch, so these checks are unnecessary.
2024-04-13 11:10:25 +02:00
Robert Müller 507b097ad8 Remove unnecessary cleanup in CClient::LoadMap function
The number of received snapshots is already correctly reset in the `CClient::OnEnterGame` function for the main and dummy connections.
2024-04-13 11:07:19 +02:00
Robert Müller a743962b84 Pass CImageInfo by reference to IGraphics::LoadPng
For consistency with other graphics functions using `CImageInfo`.
2024-04-12 17:23:41 +02:00
Robert Müller 8f7055f694 Change PNG in function names to Png
- `LoadPNG` -> `LoadPng`
- `SavePNG` -> `SavePng`
- `LoadSkinPNG` -> `LoadSkinPng`
2024-04-12 17:23:18 +02:00
Robert Müller 5da64c54fd Fix tee briefly appearing at previous position when joining
Previously, when connecting to servers repeatedly, the local tee would appear at the position it had on the previous server for a short time when joining.

This (and potentially other bugs) are fixed by clearing all game related `CGameClient` member variables in the `OnReset` function. Additionally, the `OnReset` function is now used in the `OnInit` function to ensure everything is initialized correctly when starting the client and to avoid duplicating the code.

In particular, this bug was limited to use of `cl_predict 1`, because the predicted gameworlds were not being reset when disconnecting, causing the predicted world and character from the previous server to be used. This bug was introduced in version 15.6, which added the predicted gameworlds in #1620. Closes #4339.
2024-04-11 21:37:53 +02:00
Robert Müller e4fd16e6a5
Merge pull request #8200 from def-/pr-default-team0mode
Enable team0mode by default again
2024-04-11 18:21:26 +00:00
Dennis Felsing 1adae02291
Merge pull request #8199 from dobrykafe/pr-team0mode-fix
Prevent enabling `/team0mode` while practice mode is active
2024-04-11 16:45:22 +00:00
Dennis Felsing 387608a361 Enable team0mode by default again
Since we have https://github.com/ddnet/ddnet/pull/8199 now
2024-04-12 00:31:09 +08:00
dobrykafe 083f7ba7ab prevent enabling /team0mode while practice mode is active 2024-04-11 18:26:56 +02:00
Dennis Felsing e1ab2ea07e Add sv_team0mode 2024-04-12 00:15:38 +08:00
Robert Müller 01a995e5ec Track country/type filters separately for internet/favorites tabs
For the internet/favorite tabs, instead of combining the country/type filters of all communities in one view, track the country/type filters separately for these tabs using the new, reserved community name `all`. This should make the filters less confusing to use, as changing the country/type filters in one tab will not influence the other tabs anymore. Though the country/type filters of the internet and favorite tabs are still combined, as this is also the case for the community filter.

However, this made it possible to select country/type filters that exclude all servers, by first excluding some countries/types and then changing the selected communities so all selectable countries/types are excluded. To prevent this, the filters will now include all countries/types, if they would otherwise exclude all selectable countries/types.

To do this more efficiently, the community cache is moved from the menus to the engine serverbrowser. To avoid using the UI page in the engine serverbrowser, the serverbrowser type is instead used to detect if the community cache should be updated. This required additional changes in the menus to ensure that the UI page and the serverbrowser type stay in sync with each other, which would otherwise cause incorrect server entries to be shown for one frame when switching tabs. The serverbrowser type is now refreshed immediately when the menu page is changed with the `CMenus::SetMenuPage` function, which allowed removing duplicate code for the server browser tab buttons. The `CMenus::RefreshBrowserTab` function does not take the page to be refreshed as argument anymore, as it always was only used to refresh the current page. Instead, a `bool` argument is used to specify whether the refresh should be forced even if the server browser type has not changed.

Closes #8158.
2024-04-10 21:40:02 +02:00
Robert Müller 394ed87ac9 Avoid copy of CServerInfo in loop in IsRegistered 2024-04-10 21:08:29 +02:00
Dennis Felsing 67dfd7b434
Merge pull request #8193 from furo321/fix-typo
Fix typo in `/team0mode` description
2024-04-08 16:03:40 +00:00
furo 077d7c5afb Fix typo in /team0mode description 2024-04-08 17:01:15 +02:00
Dennis Felsing 8f58cbaea3
Merge pull request #8192 from dobrykafe/pr-conchain-bg-entities
Add console chain for `ClBackgroundEntities`
2024-04-08 12:39:00 +00:00
dobrykafe fd5d334cd1 add console chain for ClBackgroundEntities 2024-04-08 12:26:25 +02:00
furo 7fcac2adc2 Rename /flock to /team0mode 2024-04-07 18:48:39 +02:00
Dennis Felsing 3a75f838ac Address reviewer comment 2024-04-07 16:41:21 +08:00
dobrykafe 4c40e6c83f change /mode -> /flock 2024-04-07 16:39:27 +08:00
dobrykafe 672cfb6236 add /mode allowing teams to behave like team 0 2024-04-07 16:37:13 +08:00
Robert Müller 2e15b7d02f Let CUi::DoScrollbarOption return true if value changed
Reduce duplicate code when using the `CUi::DoScrollbarOption` function.
2024-04-04 21:00:26 +02:00
Dennis Felsing c20baa5035
Merge pull request #8186 from ChillerDragon/pr_optimize_demo_snap
Remove demo snap buffer and mem copy
2024-04-04 05:39:17 +00:00
ChillerDragon c5fb857893 Remove demo snap buffer and mem copy
Adding the snap to the demo is the last usage of `pTmpBuffer3`
all prior usages of it copy the data if needed.
So we can edit it in place. No need to copy it into a new buffer.
2024-04-04 07:38:52 +08:00
Robert Müller 3c6fce376d Remove unused CTextCursor variable 2024-04-03 22:01:10 +02:00
Dennis Felsing e263ce9bdc
Merge pull request #8181 from dobrykafe/pr-discord-activity
Show Discord activity when offline
2024-04-03 05:35:16 +00:00
Dennis Felsing 7286a05dd4
Merge pull request #8182 from furo321/ec-password
Specify that `ec_password` is required to be set for econ to be enabled
2024-04-03 05:34:40 +00:00
furo ff1b1ae7b0 Specify that ec_password is required to be set for econ to be enabled 2024-04-03 00:24:24 +02:00
dobrykafe 990bb9b1ef show discord activity when offline 2024-04-02 23:57:17 +02:00
Robert Müller 44cd59379d Improve layout of settings menus and restart message
Remove unnecessary, inconsistent margin at the top of all settings menus.

Reserve space for restart message and button only when necessary, so more height is available for settings menus per default.

Improve vertical alignment of restart message and button with settings menus.

Ensure consistent margin on all sides of settings menus.
2024-04-02 21:28:15 +02:00
Robert Müller 7727628eeb Improve layout of Appearance settings
Use consistent margins for all settings pages and titles.

Fix chat preview overlapping with the restart warning.

Simplify layout code. Remove array of `CButtonContainer`s with arbitrary size and use individual variables instead.
2024-04-02 21:28:15 +02:00
Robert Müller 1a9f15d11b Render loading popup also while loading demo files
As this can take a few seconds for large demos.
2024-04-01 16:44:10 +02:00
Zwelf 467a3187dc Simplify and fix HookBase calculation
Saw this while implementing TwGame. Increase teehistorian version_minor
to make replaying teehistorian files easier.
2024-04-01 12:58:41 +02:00
Dennis Felsing 9122080514
Merge pull request #8170 from Robyt3/Gameclient-Render-Checks
Improve performance when rendering menus
2024-04-01 03:58:07 +00:00
Dennis Felsing 295b095d29
Merge pull request #8167 from Robyt3/Client-Rcon-Username-State-Fix
Fix rcon username not reset when disconnecting while connecting
2024-04-01 03:06:10 +00:00
Dennis Felsing c9f0075330
Merge pull request #8166 from Robyt3/Browser-Favorite-Communities-Increase
Increase maximum number of favorite communities from 3 to 5
2024-04-01 03:00:26 +00:00
Robert Müller 2790530bbe Increase maximum number of favorite communities from 3 to 5
Simply hide the favorite community tabs in the offline server browser with screen resolutions where not enough width is available.

The ingame server browser can always show at least 5 favorite community tabs with all screen resolutions.
2024-03-31 20:17:51 +02:00
Robert Müller b730d9d890 Improve performance when rendering menus
Skip rendering various client components (players, ghosts, nameplates, HUD etc.) while not ingame to improve performance. This increases FPS when rendering the start menu by around 300-400 both in debug and release builds.

This also fixes potential crashes when components using the map data where rendered while the client is loading a new map.
2024-03-31 15:30:19 +02:00
Robert Müller a287669500 Reset tuning of dummy and main when disconnecting
Instead of only resetting the tuning for either one which is currently active.
2024-03-31 12:48:43 +02:00
Robert Müller 830e8fea8c Fix rcon username not reset when disconnecting while connecting
The rcon username requirement was not reset correctly when disconnecting from a server while connecting/loading, at which point the `NETMSG_RCONTYPE` message has already been received.

Closes #4170.
2024-03-31 11:17:29 +02:00
Edgar 8412d2be6e
Merge pull request #8160 from edg-l/incl_algo
include algorithm in jobs.cpp, try to fix #8159
2024-03-30 10:46:57 +00:00
murpii ed90392636 Refresh the jumps after teleporting 2024-03-29 13:40:45 +01:00
Edgar 78cb4d4373
include algorithm in jobs.cpp, try to fix #8159 2024-03-28 20:14:16 +01:00
Robert Müller 2b8af7f40f Pass arguments as CImageInfo to graphics functions
Pass `CImageInfo` arguments to various graphics and text render functions instead of passing the components (data pointer, width, height, format/pixel size) of the image info separately.

Pass texture/file name to loading functions when available to improve error/warning messages.
2024-03-27 21:12:02 +01:00
Robert Müller 8218dbb6f8 Add CImageInfo::DataSize convenience function
To calculate the size of the image data based on its width, height and pixel size.
2024-03-27 21:12:02 +01:00
Robert Müller b4a22e2fee Refactor client state handling in menus
Split menu rendering explicitly by client state. This makes the code more readable by not mixing code for rendering different states together as much and fixes issues where the menu was being rendered inconsistently for one frame when the state is changed, at the cost of some additional duplicated code.

The fullscreen popups shown when in the connecting and loading client states are now hard-coded for these states, instead of being mixed together with the other fullscreen popups, which can be shown when offline, ingame or during demo playback.

As a side effect of rendering the demo controls like the regular menu, the UI color will now also affect the demo controls menu background.

Move `CBackground::ChangePosition` calls inside functions to reduce duplicate code and improve readability.

Remove unnecessary `CMenus::m_ActivePage` variable.

Closes #7834.
2024-03-25 20:48:52 +01:00
Dennis Felsing 58ee780fa7
Merge pull request #8155 from ChillerDragon/pr_add_missing_includes
Add missing includes
2024-03-25 07:51:18 +00:00
ChillerDragon e4c136d324 Add missing includes 2024-03-25 14:24:08 +08:00
Robert Müller 015390a51e Fix recursive folder creation with mixed slashes and drive letters
The function `fs_makedir_rec_for` for recursively creating folders did not handle paths containing backslashes correctly and only created folders after every occurrence of a regular slash. This could cause the recursive folder creation to fail when a parent folder is not created before the child folder. For example when recursively creating folders for the path `D:\Games/DDNet\downloadedskins`, the `DDNet` folder was not being created because this path segment does not end in a forward slash. Now, backslashes are handled the same as regular slashes, which is consistent with the other filesystem functions.

Additionally, the function tried to create folders for drive letters on Windows (e.g. `C:` and `D:`). Trying to create a system drive as a folder will fail due to access being denied, whereas it seems to work for already existing non-system drives. For example when recursively creating folders for the path `C:/Games/DDNet/downloadedskins`, the `C:` "folder" could not be created which caused the entire operation to fail. Now, the function will not try to create folders for drive letters anymore, i.e. if the name of the to be created folder ends with `:`.

Closes #8148.
2024-03-24 12:33:56 +01:00
Dennis Felsing 7e8dc57194
Merge pull request #8150 from furo321/freezebar-fix
Fix freeze bar not being correct after returning from pause
2024-03-23 23:26:04 +00:00
Dennis Felsing a4aafb78bd
Merge pull request #8147 from dobrykafe/pr-fix-style
`fix_style.py`: check for newline at the end of source files
2024-03-23 23:24:02 +00:00
Dennis Felsing eefcb83a4f
Merge pull request #8144 from Robyt3/Client-Skin-Reset-Cleanup
Use `CTeeRenderInfo::Reset`
2024-03-23 23:22:44 +00:00
c0d3d3v ab3991f821 fix freeze bar not beeing correct after returning from pause
m_FreezeStart is now corrected by the ticks the character was paused
Possible physical changes: Until now it was possible if you sit inside freeze to re-freeze instant
after unpause. Now you re-freeze after the second that was dawned before
the pause. I do not excpect that this is used on any map, and it did not
bring any benifit.
2024-03-23 23:05:14 +01:00
dobrykafe 6175022e39 add missing newline at EOF 2024-03-23 16:01:16 +01:00
Robert Müller 134961015a Fix more variable names (GPU -> Gpu, ID -> Id) 2024-03-23 12:06:31 +01:00
Robert Müller 4d6a00d827 Use CTeeRenderInfo::Reset
To reduce duplicate code and ensure all members are reset.
2024-03-23 11:57:08 +01:00
ChillerDragon e2c02eaf7b Remove useless operation in CUIRect SplitMid 2024-03-22 15:50:38 +08:00
Robert Müller f05bbc226a Fix envelope points not clickable after opening bezier popup
Closes #8017.
2024-03-21 21:12:31 +01:00
Corantin H ad07be1492 Fix wrong array indexing in undo action label (fixes #8135)
`Result` was not the correct variable to use to index the operation names array, instead it should be what is returned from the selection popup.
2024-03-21 18:25:48 +01:00
Dennis Felsing 21d0d69bec
Merge pull request #8133 from dobrykafe/pr-more-settings
Include more options in appearance settings
2024-03-20 22:43:28 +00:00
dobrykafe 2a31ff1998 include more options in settings 2024-03-20 23:20:04 +01:00
Dennis Felsing f169899083 serverbrowser: communities->servers instead of communities->icon->servers 2024-03-20 12:28:41 +01:00
Robert Müller c9439eac36
Merge pull request #8102 from archimede67/editor-fix-save-missing-layers
Editor: allow saving empty quads & sounds layers
2024-03-18 22:13:34 +00:00
archimede67 95402b9559
Merge pull request #8126 from Robyt3/Engine-LineReader-UTF8-Check
Ensure line reader only returns lines which are valid UTF-8, refactoring
2024-03-18 21:19:37 +00:00
Corantin H a5a4d50237 Allow saving empty quads & sounds layers 2024-03-18 22:06:26 +01:00
Robert Müller 2a99c81721
Merge pull request #8123 from archimede67/editor-fix-autorules-crash
[Editor] Fix crash when trying to select autorule with arrow keys
2024-03-18 20:41:06 +00:00
Robert Müller 010d4dc673 Remove unnecessary UTF-8 check for config variables
Invalid UTF-8 will not be read from config files with `CLineReader` anymore and the local console never allowed entering invalid UTF-8, so this additional mangling of invalid UTF-8 string config variable values is unnecessary.
2024-03-18 21:29:43 +01:00
Robert Müller e0e6bbbbe2 Minor cleanup of CLineReader
- Use `nullptr` instead of `0`.
- Use `\0` instead of `0`.
- Move variable declaration.
2024-03-18 21:29:41 +01:00
Robert Müller 0f94d0d72c Ensure line reader only returns lines which are valid UTF-8
Skip lines containing invalid UTF-8 in `CLineReader::Get` function.
2024-03-18 21:29:34 +01:00
heinrich5991 3f70ae4b70
Merge pull request #8115 from Robyt3/Client-Mapimages-Refactoring
Various refactoring of `CMapImages`
2024-03-18 00:08:30 +00:00
Corantin H d506dc4fa9 Support navigating in selection popups with arrow keys 2024-03-17 19:44:12 +01:00
Corantin H 72029e4105 Prevent switching layer selection while popup is open 2024-03-17 15:35:32 +01:00
archimede67 47d77fad07
Merge pull request #8120 from Robyt3/UI-Color-Picker-Line-Improvement
Support clicking line color picker label to toggle checkbox
2024-03-17 10:56:31 +00:00
Robert Müller d7f3c4fb6d
Merge pull request #8118 from dobrykafe/pr-nameplates-strong
`ClNameplatesStrong` improvements
2024-03-17 10:43:24 +00:00
Robert Müller 67329acae9 Support clicking line color picker label to toggle checkbox
Closes #8117.
2024-03-17 11:37:40 +01:00
archimede67 d853a17f20
Merge pull request #8119 from Robyt3/UI-String-Fix
Fix replacement of `UI` with `Ui` in strings
2024-03-17 10:33:28 +00:00
Robert Müller bef399f296 Fix replacement of UI with Ui in strings 2024-03-17 11:16:14 +01:00
dobrykafe 19ea53998f show nameplates strong indicator from perspective of spectated player 2024-03-17 11:13:44 +01:00
dobrykafe 7f4974616a fix nameplates strong indicator 2024-03-17 11:11:51 +01:00
Robert Müller d57a2d490e Extract IsValidTile function 2024-03-17 10:48:08 +01:00
Dennis Felsing f3c246f622
Merge branch 'master' into pr_ddnet_http_age_crash 2024-03-16 23:23:35 +01:00
Robert Müller 033b659570 Avoid unnecessary calculations for invalid tiles
Only calculate offsets for valid tiles when the offsets will be used.
2024-03-16 22:33:58 +01:00
Robert Müller f1deec2c84 Rename variables i to ModType and n to LayerType 2024-03-16 22:33:58 +01:00
Robert Müller 29d924e061 Simplify handling of entities paths, remove unnecessary variables 2024-03-16 22:33:57 +01:00
Robert Müller c97c3ac7b1 Extract GetEntitiesModType function 2024-03-16 22:33:57 +01:00
Robert Müller 01daa919e8
Merge pull request #8113 from furo321/eye-emote
Remove `(until you die)` part from `/eyeemote off`
2024-03-16 20:46:43 +00:00
heinrich5991 790c73bffe
Merge pull request #8098 from Robyt3/Graphics-ImageInfo-Free
Replace `IGraphics::FreePNG` with `CImageInfo::Free`
2024-03-16 20:14:02 +00:00
heinrich5991 03aab986fe Fix crash when the serverlist request fails
We're not allowed to look at `ResultAgeSeconds` when the state is
`EHttpState::ERROR`.

Fixes #8107.
2024-03-16 21:12:47 +01:00
furo 7043a59bc3 Remove (until you die) part from /eyeemote off 2024-03-16 21:10:21 +01:00
Robert Müller 11aba0e38d Replace IGraphics::FreePNG with CImageInfo::Free
The engine graphics do not need to be involved with freeing image data.

The `Free` function now also ensures that all other member variables are cleared when freeing the image data.
2024-03-16 20:55:22 +01:00
Robert Müller 722b5f8d11 Comment out verbose serverbrowser HTTP log message
The `unknown address` log message got printed very often because many servers have 0.6 and 0.7 addresses but only 0.6 addresses are considered valid by the client.
2024-03-16 20:54:56 +01:00
Robert Müller 4f4284ba2a Fix typo in serverbrowser HTTP log context 2024-03-16 20:54:56 +01:00
Robert Müller 24caf08d84 Minor refactoring of net_addr_from_url
- Remove unnecessary branch and temporary variable usage at the end of the function.
- Move variable declarations closer to usages.
2024-03-15 18:40:03 +01:00
Robert Müller 6df1d251d7
Merge pull request #7947 from ChillerDragon/pr_coll_tele
Move tele vector init from gamecontroller to collision
2024-03-14 17:02:09 +00:00
Dennis Felsing 681b66b563 Version 18.1 2024-03-14 17:14:07 +01:00
heinrich5991 ff7b6ffe14 Take serverlist age into account when choosing master
Prefer masters with newer server lists, and try re-selecting the chosen
master if the result is older than 5 minutes.
2024-03-14 12:31:41 +01:00
heinrich5991 5603d284bf Parse Date and Last-Modified HTTP headers 2024-03-14 12:31:41 +01:00
heinrich5991 2d17097c91 Use log_* instead of Console()->Log() in HTTP serverbrowser 2024-03-14 11:19:32 +01:00
ChillerDragon 4da4ca5bdd Make tele getters const 2024-03-14 08:50:35 +08:00
ChillerDragon 552d466197 Move tele vector init from gamecontroller to collision 2024-03-14 08:46:22 +08:00
Robert Müller ae9a8fe3d4 Support overlapping scroll regions, always allow mouse scrolling
Support scrolling all scroll regions with the mouse wheel also while popup menus are open. Support overlapping scroll regions by always scrolling the top-most hovered scroll region on mouse wheel events.

The hot scroll region is now tracked separated by `CUi`, as tracking the IDs of all UI elements which are contained in scroll regions is not feasible. The separate active state for scroll regions is therefore unnecessary.

It's still necessary to disable `CListBox`es when popup menus are open, to ensure that only one list box consumes the key events.

Closes #8087. Supersedes #8090.
2024-03-12 22:15:20 +01:00
Robert Müller f291362d88 Revert name of enum literal Ui back to UI
This `enum` literal was accidentally included in the renaming of the `UI` function to `Ui`.
2024-03-12 21:49:00 +01:00
heinrich5991 8108cb04fd Inform HTTP map download of the map size 2024-03-11 17:50:51 +01:00
heinrich5991 dd5ddf07a4 Disconnect when we get map change with invalid parameters
This is the only sane thing we can do, the server will have changed its
map and we can't pretend to still be on the old one.
2024-03-11 17:50:12 +01:00
Dennis Felsing 3489131d78
Merge pull request #8085 from dobrykafe/pr-timecp
Improve `/timecp` chat command
2024-03-11 07:34:54 +00:00
Dennis Felsing 621b201acf
Merge pull request #8086 from furo321/browser-login-filter
Add a `No login required` filter
2024-03-11 07:33:21 +00:00
furo 40f641b0a6 Add a No login required filter 2024-03-11 02:09:16 +01:00
dobrykafe 35c45cf869 improve /timecp chat command 2024-03-11 00:36:07 +01:00
furo 1cee65a980 Document usage of ~ for /tpxy in help text. 2024-03-10 21:44:40 +01:00
heinrich5991 3805ffba86
Merge pull request #8073 from Robyt3/Gamecore-Str-Validation
Add validation for `StrToInts` and `IntsToStr`
2024-03-10 13:48:08 +00:00
Robert Müller 02f60421f9 Add validation for StrToInts and IntsToStr
Add strict validation for `StrToInts` function. Because this function should only be used with trusted internal strings, assertions are added to ensure that the string is not truncated. Some buffer sizes are adjusted accordingly, so truncation cannot happen.

Add less strict validation for `IntsToStr` function. An additional argument specifying the size of the output buffer is added to assert that the size of the output buffer is sufficient. However, because this function is used to decode data sent by the server and read from maps and ghosts, invalid input data should never result in crashes or invalid UTF-8 strings. The function will now unpack an empty string and return `false`, if the string contains invalid UTF-8.

The inline definition of the functions is not wanted, because it requires adding a `system.h` include in `gamecore.h`. Therefore the tools now have to depend on game-shared, which previously only worked because the functions were inline.

Tests are added to ensure the function still behaves the same as before for valid inputs and correctly handles invalid inputs.
2024-03-10 12:49:56 +01:00
Robert Müller bff5247746 Ensure commands executed via Econ are valid UTF-8
`CNetConsole` will now ignore received lines containing invalid UTF-8 codepoints. Previously, it was possible to crash the server on Windows with Econ commands like `exec <invalid UTF-8>`.
2024-03-10 11:23:42 +01:00
Robert Müller b67263107d Use uint8_t * consistently for raw image data
Previously, usage of `void *`, `unsigned char *` and `uint8_t *` was mixed in various places for pointers to raw image data and the pointers ended up being cast to `uint8_t *` at some point anyway. Now only `uint8_t *` is used consistently, which improves type safety and readability. Casts to `uint8_t *` are now only necessary when using `malloc` or when reading data from a map.
2024-03-09 13:31:53 +01:00
Robert Müller 3073934df1 Show completion options for bind key names in console
Show completion options for key names for all bind commands (`bind`, `binds`, `bind_reset`) in the local console.

At the moment this only works for completing the first key name but not for composite binds that use `+`, which would work differently than other console argument completion.

Unnamed keys (starting with `&`) are not shown as completion options.

Refactor console argument completion to reduce duplicate code.
2024-03-08 21:54:22 +01:00
heinrich5991 1afdf47362
Merge pull request #8072 from furo321/practice-helptext
List all practice commands when enabling `/practice`
2024-03-07 00:14:36 +00:00
furo 209df982f8 List all practice commands when enabling /practice 2024-03-07 00:57:21 +01:00
archimede67 de956c8db9
Merge pull request #8071 from dobrykafe/pr-popup-image-height
Editor: Make embedded image popup bigger at all times
2024-03-06 22:47:38 +00:00
dobrykafe 0b03bc7a16 make embedded image popup bigger at all times 2024-03-06 23:27:50 +01:00
Robert Müller 3656c95eca Ensure commands executed via FIFO are valid UTF-8 2024-03-06 22:01:10 +01:00
Dennis Felsing b6689bc012
Merge pull request #8068 from heinrich5991/pr_ddnet_job_atomics
Fix race conditions in job state handling
2024-03-05 21:57:11 +00:00
heinrich5991 e7717f2265 Fix race conditions in job state handling
We want to change the state of the job from `STATE_QUEUED` to
`STATE_RUNNING`, but not from `STATE_ABORTED`. Previously, the code
usedd `exchange` to change the state and compared non-atomically
afterwards. This led to `STATE_ABORTED` being replaced by
`STATE_RUNNING` in a race. With `compare_exchange_strong`, this can no
longer happen.

Fixes #8044.
2024-03-05 20:55:44 +01:00
Robert Müller 9323e18616 Fix HTTP client shutdown and deadlock on request error
Fix HTTP client effectively shutting down by entering the `ERROR` state when a request cannot be added. Now only the invalid request is aborted immediately. The `ERROR` state is now only entered when a curl function fails in a way where recovery is not possible.

Fix occasional deadlock when HTTP client is shutting down after entering the `ERROR` state, by also immediately aborting new requests when the HTTP client is already in the `ERROR` state.

Remove unused `CHttp::EState::STOPPING`.
2024-03-05 19:48:45 +01:00
Dennis Felsing f3de37d9d4
Merge pull request #8019 from heinrich5991/pr_ddnet_rename_variables
Rename all variables for strict camel-casing of abbreviations
2024-03-05 16:06:58 +00:00
heinrich5991 44bf0134f0
Merge pull request #8065 from dobrykafe/pr-solo-practice-bug
Fix practice mode not resetting after disconnect on solo servers
2024-03-05 15:20:34 +00:00
heinrich5991 17402cc43f Rename all variables for strict camel-casing of abbreviations
This is the strict version, ID → Id, UI → Ui, except DDNet which stays
DDNet.

This would fix #7750.

Done using a naive rename script (for bash, use `shopt -s globstar`):

```fish
sed -i \
	-e 's/\([a-z]_\?\)ID/\1Id/g' \
	-e 's/\([^ ]\)\<UI\>/\1Ui/g' \
	-e 's/UI()/Ui()/g' \
	-e 's/\<CUI\>/CUi/g' \
	-e 's/\([\ta-z.(&]\|[,=|] \)ID\>/\1Id/g' \
	-e 's/\<ID\>\([^ ").]\)/Id\1/g' \
	-e 's/\<ID\([0-9]\)/Id\1/g' \
	-e 's/\<ID\>\( [<=>:+*/-]\)/Id\1/g' \
	-e 's/int ID/int Id/g' \
	-e 's/\([a-z]_\?\)GPU/\1Gpu/g' \
	-e 's/\([a-z]_\?\)IP/\1Ip/g' \
	-e 's/\([a-z]_\?\)CID/\1Cid/g' \
	-e 's/\([a-z]_\?\)MySQL/\1Mysql/g' \
	-e 's/MySql/Mysql/g' \
	-e 's/\([a-xz]_\?\)SQL/\1Sql/g' \
	-e 's/DPMode/DpMode/g' \
	-e 's/TTWGraphics/TTwGraphics/g' \
	\
	-e 's/Ipointer/IPointer/g' \
	-e 's/\.vendorId/.vendorID/g' \
	-e 's/\.windowId/.windowID/g' \
	-e 's/SDL_GetWindowFromId/SDL_GetWindowFromID/g' \
	-e 's/SDL_AudioDeviceId/SDL_AudioDeviceID/g' \
	-e 's/SDL_JoystickId/SDL_JoystickID/g' \
	-e 's/SDL_JoystickInstanceId/SDL_JoystickInstanceID/g' \
	-e 's/AVCodecId/AVCodecID/g' \
	src/**/*.cpp src/**/*.h {datasrc,scripts}/**/*.py
git checkout -- src/engine/external
```

I like this option because it presents clear rules.

Still needs fixups because of the naive replacement, I'd do this if we
want this merged.
2024-03-05 15:44:09 +01:00
dobrykafe d94d020c25 fix practice mode not resetting after disconnect on solo servers 2024-03-05 14:08:30 +01:00
heinrich5991 c15733eda3
Merge pull request #8063 from heinrich5991/pr_ddnet_register_error
Show error from masterserver in console
2024-03-04 23:08:25 +00:00
heinrich5991 12409e545c Show error from masterserver in console
Allows people to see why masterserver registering failed.
2024-03-04 21:58:30 +01:00
Robert Müller dd94da67fb Hide tune_zone command in local console
Prevent the `tune_zone` command from being shown and used in the local console, which could cause issues with prediction, by only registering it as a game setting but not as a client command. The command callback is still correctly called when map settings are loaded in the `CGameClient::LoadMapSettings` function.
2024-03-04 21:26:47 +01:00
Robert Müller bfa5bc2b3c Remove remaining hard-coded server commands from client-side
Followup for #7919.
2024-03-04 21:26:41 +01:00
heinrich5991 e851c78e47 Don't show the git revision twice in server log
Previously:
```
2024-03-03 12:17:40 I git-revision: 885ae7ecae
2024-03-03 12:17:40 I server: version 18.0.3 on linux amd64
2024-03-03 12:17:40 I server: git revision hash: 885ae7ecae
```
2024-03-04 16:50:45 +01:00
Dennis Felsing 70eca3869a
Merge pull request #8051 from dobrykafe/pr-serverbrowser-friends-sort
Add sorting by number of friends to the server browser
2024-03-04 07:27:48 +00:00
Robert Müller 6b3e16ea82 Fix client crash due to truncated skin name 2024-03-03 18:18:49 +01:00
dobrykafe 13f324ccf4 add sort by number of friends to server browser 2024-03-03 02:01:28 +01:00
Dennis Felsing c0e4a4c3f2
Merge pull request #8002 from dobrykafe/pr-change-info-countdown
Show countdown message in player/tee settings for `sv_info_change_delay`
2024-03-02 13:02:06 +00:00
Dennis Felsing 968d08c716
Merge pull request #8026 from Robyt3/Base-Threading-Error-Handling
Add assertions to all thread and semaphore functions
2024-03-02 13:00:58 +00:00
Dennis Felsing 5d070ec5c3
Merge pull request #8043 from Robyt3/Editor-Envelope-Point-Color-Fix
Fix editor crash when right-clicking bezier control points
2024-03-02 12:50:42 +00:00
Robert Müller 350acae56b
Merge pull request #8041 from Jupeyy/pr_small_alloc_fix_vk
Search __most__ fitting allocation, not _first_ fitting
2024-03-02 12:36:48 +00:00
Robert Müller 6895cdc343 Fix editor crash when right-clicking bezier control points
The color selection should only be shown for normal envelope points but not for bezier control points, because it always changes the previously selected normal envelope point. This caused the client to crash when right-clicking a bezier control point when no normal envelope point was previously selected.

Closes #8020.
2024-03-02 13:16:26 +01:00
Jupeyy ec39742017 Search __most__ fitting allocation, not _first_ fitting 2024-03-02 13:12:58 +01:00
Robert Müller 209a367ab2 Fix editor color picker when Vulkan image blitting used
When image blitting is supported by the Vulkan backend, the color picker was reading incorrect pixel values, because the offset positions for the blitting region are the positions of the top-left and bottom-right corners, but instead the top-left offset and size (width, height) were passed as arguments.

Closes #8040.
2024-03-02 12:32:11 +01:00
Robert Müller 52da715858 Minor refactoring of CClient::SetState
- Rename parameter `s` to `State`.
- Only print debug message if new state is different from old state.
- Reduce indentation.
2024-03-01 18:58:41 +01:00
Robert Müller dd09834f32 Always build switch entities layers
Only building the switch entities layer when the current map has a switch layer (#8011) also does not work, because the entities textures are cached for each type and not reloaded unless the entities are changed manually. First joining a server with a map that does not have a switch layer will cause the textures for the type of that server to be built without the switch entities layer, so the switch entities texture will be missing when joining a server of that type with a map that does have a switch layer.

Instead, the switch entities layer textures are always built now, so the cached entities textures are can be used on all maps of the respective server type. This is expected to slightly increase the total memory usage after joining multiple servers of different types. As before, tiles which are unused are masked unless `m_DontMaskEntities` is set.
2024-02-29 21:45:53 +01:00
bencie 26cc7dde2f Refactor 2024-02-29 18:37:39 +01:00
bencie 2868b3cdf6 Let users pick background entities map without file extensions 2024-02-29 18:13:50 +01:00
Robert Müller be9411b262
Merge pull request #8031 from dobrykafe/pr-emotional-tees
fix incorrect usage of `SvEmotionalTees`
2024-02-29 16:06:43 +00:00
dobrykafe d2b2071bda fix incorrect usage of SvEmotionalTees 2024-02-29 16:47:58 +01:00
dobrykafe 720572ddda make chat command arguments case-insensitive when possible 2024-02-29 01:17:11 +01:00
heinrich5991 9620a9d3d9
Merge pull request #8029 from Robyt3/Menus-RenderPopupFullscreen-Function
Extract `CMenus::RenderPopupFullscreen` function
2024-02-28 22:39:29 +00:00
Robert Müller 6080cffcbb Extract CMenus::RenderPopupFullscreen function
Improve readability of the `CMenus::Render` function by extracting the code for rendering the fullscreen popups into a separate function.
2024-02-28 22:53:51 +01:00
Robert Müller 8d774fa48c Define Windows header macros only once in CMakeLists.txt
Instead of defining the macro `WIN32_LEAN_AND_MEAN` and sometimes also the macro `_WIN32_WINNT` in each file that directly or indirectly includes `<windows.h>`, only define these macros once consistently in `CMakeLists.txt`.

Also define `NTDDI_VERSION`, which is the new macro to specify the minimum Windows version starting with Windows Vista. This macro needs to be defined in addition to old `_WIN32_WINNT` macro, according to the documentation.

See https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers
2024-02-28 21:40:28 +01:00
Robert Müller 4ceb376969 Add assertions to all thread and semaphore functions
Assert on failures in all `thread_*` and `sphore_*` functions on all operating systems instead of only printing log messages on Unix, as these functions are only expected to fail when used with incorrect arguments or in some cases when a dead-lock is detected.

On macOS, `sphore_wait` was not correctly calling `sem_wait` in a loop to repeat the wait operation if it is interrupted by a signal.

On Windows, the AIO tests were failing with the additional assertions. The maximum count that semaphores on Windows could be incremented to was previously, arbitrarily limited to 10000, which was causing the `ReleaseSemaphore` call to fail as the AIO semaphore is signaled 65536 times (for each write operation) in multiple of the AIO tests.
2024-02-27 22:14:56 +01:00
Robert Müller ecfc18d129 Minor refactoring of bezier curve evaluation
- Remove `ValidateFCurve` function because it's small and only used once.
- Remove unnecessary checks in `SolveBezier`, as all of these conditions are already checked before the function is called.
- Remove unnecessary double negation of `InTang` to improve readability.
- Use `double` literals for `double` comparisons instead of `float` literals.
- Fix comments.
2024-02-26 20:43:35 +01:00
Robert Müller 47a8156ca8 Fix inaccurate evaluation of bezier curve envelopes
There is no need to divide the times by 1000 when evaluating bezier curves, as all times are relative and the division adds significant inaccuracy, to the point where evaluation of bezier curves goes completely wrong in some cases.

Closes #8005.
2024-02-26 20:43:21 +01:00
Robert Müller cc1d43e5a0 Fix division by zero when envelope point times overlap
Effectively skip envelope points whose start time is equal to the start time of the next envelope point.
2024-02-26 20:43:12 +01:00
Robert Müller 5aab9969ce Fix first envelope line segment not being rendered in editor
Rendering was started with the second line segment after one time step has already passed.
2024-02-26 20:42:58 +01:00
Robert Müller 7c4d51f111
Merge pull request #8016 from dobrykafe/pr-save-replay-improve
Improvements regarding `save_replay`
2024-02-26 18:39:20 +00:00
dobrykafe 91349e4cae add error handling for CDemoEdit job 2024-02-26 18:44:11 +01:00
dobrykafe 268b79cb61 handle invalid filename for save_replay 2024-02-26 18:43:51 +01:00
Robert Müller 2258cbca57
Merge pull request #8007 from heinrich5991/pr_ddnet_vital_ping
Respond to pings sent as vital messages with vital pongs
2024-02-26 12:22:46 +00:00
Robert Müller 6cdfa35727 Allow background jobs to be aborted, refactoring
Add `IJob::Abortable(bool)` function which jobs can call to specify whether they can be aborted. Jobs are not abortable per default. Abortable jobs may have their state set to `IJob::STATE_ABORTED` at any point if the job was aborted. The job state should be checked periodically in the `IJob::Run` function and the job should terminate at the earliest, safe opportunity when aborted. Scheduled jobs which are not abortable are guaranteed to fully complete before the job pool is shut down. However, if the job pool is already shutting down, no additional jobs will be enqueue anymore and abortable jobs will immediately be aborted.

In particular, the sound loading, community icon loading, master chooser and host lookup jobs are specified as being abortable. Conversely, the jobs saving replay demos, editor maps and screenshots are expected to finish before the client is shut down.

When the client is quitting/restarting, it will now disconnect from the current server first, before saving the config, to ensure that any actions that happen on disconnect (demo recorders being stopped etc.) happen first. The shutdown message is rendered before disconnecting and waiting for background jobs to finish.

The HTTP client is now initialized later during server launch, after the network initialization. Error handling is added and the server stops if the HTTP client could not be initialized, same as the client.

The `RunBlocking` functions are removed, as they are not used anymore after curl-multi was added.

The function `IJob::Status` is renamed to `State` and `IJob::STATE_PENDING` is renamed to `STATE_QUEUED` for consistency with naming of the HTTP client.

The member variables of the engine interface are encapsulated and the `jobs.h` include is removed from `engine.h`, which removes transitive includes of `system.h`.

Documentation for all job and job pool API is added.
2024-02-25 17:03:45 +01:00
Jupeyy 6bfd565a7c
Merge pull request #7995 from edg-l/some_updates
update ci actions, update rust edition to 2021 since our MSRV covers it
2024-02-25 15:11:54 +00:00
Edgar 0e0ebe9aea
update ci actions, update rust edition to 2021 since our MSRV covers it 2024-02-25 15:55:10 +01:00
archimede67 95e51db753
Merge pull request #8014 from furo321/case-insenstive-command-chat
Make chat commands completion case-insenstive
2024-02-24 18:30:43 +00:00
furo f3a277c365 Make chat commands completion case-insenstive 2024-02-24 18:11:26 +01:00
Dennis Felsing 59a734ce3f
Merge pull request #8010 from Robyt3/Map-Envelope-Render-Refactoring
Improve envelope evaluation and validation
2024-02-23 23:07:22 +00:00
Robert Müller 835001058b Always build switch entities layer when map has switch layer
Instead of only building the switch entities when the server uses the DDNet/DDrace type. Fix switch entities not being shown anymore on servers which do not mask entities. Regression from #7979.
2024-02-23 21:37:46 +01:00
Robert Müller ab3c6c4353 Improve envelope evaluation and validation
Call `EnvelopeEval` functions directly instead of passing them and their arguments to `CRenderTools::RenderTilemap` and `CRenderTools::RenderTileRectangle`.

Only evaluate color envelopes for tiles layers once instead of separately for the opaque and transparent passes.

Only evaluate relevant number of envelope channels instead of always evaluating all channels.

Avoid unnecessary calculations by only evaluating position envelopes for quads which are not fully transparent.

Fully ignore layer color and envelope color for entities layers, as these cannot be specified in the editor and should not be changeable.

Remove duplicate and insufficient checks for invalid envelope index before calling `EnvelopeEval`. Instead, set the correct default for all channels before calling `EnvelopeEval` and only change the result on success. Now, white color will consistently be assumed for invalid color envelopes, zero positions and rotations for invalid position envelopes, and full volume for invalid sound envelopes.

Validate number of envelope channels to prevent crashes. When loading maps containing envelopes with invalid number of channels (not equal to 1, 3 or 4), the number of channels of these envelopes is reset to 4 and an error message is displayed, so the mapper can examine all channels' data and transfer it to another envelope if necessary. Closes #7985.
2024-02-23 19:24:34 +01:00
Robert Müller 040d7673c6 Remove dead code 2024-02-23 18:21:18 +01:00
Robert Müller 73c3636f3b Add color4_base::Multiply function 2024-02-23 18:21:17 +01:00
Robert Müller 7d7a45663f Improve layout of General settings page, refactoring
Use consistent margins for all settings pages and titles (except the Appearance settings, which will be covered in the future).

Fix checkbox UI element ID variable `s_LowerRefreshRate` not being `static`.

Improve readability of layout code.
2024-02-22 22:14:54 +01:00
heinrich5991 e69ea46982 Respond to pings sent as vital messages with vital pongs
Matching the requester allows "reliable" and "unreliable" pings.
"Reliable" pings suffer from re-sends, thus might not accurately reflect
the latency, "unreliable" pings might not arrive at all.
2024-02-22 11:18:12 +01:00
Robert Müller e50f8cfaa0 Fix client crash if cl_race_ghost_save_best 1 deletes last ghost
If the own ghost is the last element in the vector and deleted due to using the `cl_race_ghost_save_best 1` setting then the following accesses with index `Own` were out-of-bounds. Closes #8003.
2024-02-21 23:38:43 +01:00
Dennis Felsing 99ee3f4fb9
Merge pull request #8004 from furo321/teamcolors-fixes
Small fixes to `cl_chat_teamcolors`
2024-02-21 11:29:34 +00:00
furo da02be4a9f Remove cl_chat_teamcolors check from info messages. 2024-02-21 12:03:42 +01:00
furo ba3a6b4262 Enable cl_chat_teamcolors by default 2024-02-21 12:02:51 +01:00
dobrykafe 40329b7d2e show countdown in player/tee settings for sv_info_change_delay 2024-02-20 21:41:20 +01:00
heinrich5991 87f3740a61
Merge pull request #8001 from Robyt3/Http-Android-Fix
Fix incorrect variable used in Android-specific code
2024-02-20 20:29:14 +00:00
Robert Müller aa7a614c36 Fix incorrect variable used in Android-specific code
The function `curl_easy_setopt` expects a `CURL *`, but `pHandle` is a `void *`.
2024-02-20 21:11:26 +01:00
Robert Müller 386b00f18d Add has_finishes attribute to community info
Add mandatory Boolean attribute `has_finishes` to every community info, which specifies whether finishes can be shown for the community, regardless of whether any finishes are currently available for the player.

The community info must be adjusted when/before merging this, by adding the attribute `has_finishes` to every community object, with the value `true` for DDNet and `false` for all other communities.

Closes #7957.
2024-02-20 20:34:21 +01:00
Dennis Felsing 99c982e3e0
Merge pull request #7998 from Robyt3/Client-Skin-Loading-Refactoring
Validate skin names when loading, refactor skin loading
2024-02-19 22:56:58 +00:00
heinrich5991 9a95f3b1fd Add return value docs to DoEditBox* 2024-02-19 22:51:55 +01:00
Robert Müller 8adfb2f2ec Fix unlikely cases of skin blood color being wrong
The check before calling `normalize` incorrectly excludes skins containing zero in any color component instead of excluding only skins with zero in all components. The check can be removed entirely, because it is already checked inside the `normalize` function whether the length of the `vec3` is zero, in which case a zero `vec3` will be returned.

For very large skins which use large color values in at least one component, the `int` used for calculating the blood color could overflow.
2024-02-19 22:09:59 +01:00
Robert Müller 4eb0ffd701 Validate skin names when loading, refactor loading
Prevent skins with invalid names from being loaded/downloaded.

Improve log messages when skins cannot be loaded.

Remove obsolete check for duplicate skins, as the storage handles duplicate files already.
2024-02-19 22:09:59 +01:00
Robert Müller 9a24cf4e10 Ensure placeholder skin always exists and has valid metrics
Instead of adding the placeholder skin to the list of skins only when no skins have been loaded, always create the placeholder skin and use it only when no other skin is available.

Use reasonable values for skin metrics of placeholder skin to improve its rendering.
2024-02-19 22:09:59 +01:00
heinrich5991 bf0f699b42 ClientEmptyClientSlotEmpty
Makes it clearer to me, didn't know what an empty client is supposed to
be.

CC #7968
2024-02-19 21:36:21 +01:00
bencie 2240380b0e Unfreeze on rcon undeep 2024-02-19 17:45:30 +01:00
archimede67 4760ff71c7
Merge pull request #7991 from Robyt3/Client-Loading-Indicators
Render loading message/indicator for vote options and rcon commands
2024-02-18 19:03:23 +00:00
archimede67 8a98e70172
Merge pull request #7992 from furo321/no-cmdlist-rcon
Don't tell user about `/cmdlist` in rcon when using an unknown command.
2024-02-18 18:15:02 +00:00
furo 19796cdce4 Don't tell user about /cmdlist in rcon when using an unknown command. 2024-02-18 18:42:22 +01:00
Robert Müller ce81f7b45f Render loading message/indicator when receiving rcon commands
Render a progress spinner and message in the remote console while receiving rcon commands.
2024-02-18 18:15:33 +01:00
Robert Müller 1d0bb0dfcf Render loading message/indicator when receiving vote options
Render a progress spinner and message on the "Change settings" tab while receiving vote options.
2024-02-18 18:11:58 +01:00
Edgar e041c0a870
Merge pull request #7977 from dobrykafe/pr-expire-invites
Expire team invites on player disconnect
2024-02-18 15:24:01 +00:00
Edgar ea0827b5bd
Merge pull request #7987 from dobrykafe/pr-showfps-render
Don't show fps during demo render
2024-02-18 15:23:16 +00:00
Edgar f7b3cc7179
Merge pull request #7988 from Robyt3/Editor-Button-Refactoring
Refactor editor button functions: replace/remove `DoButton_File`, `DoButton_ButtonDec/Inc` and `DoButton_Menu`
2024-02-18 15:22:08 +00:00
Robert Müller ca56aa0b4a Replace DoButton_Menu with DoButton_Ex
This adds highlighting color when hovering the main menu buttons (File, Tools, Settings), which was previously missing for these buttons. This also reduced duplicate code.

Extract font size for menu buttons into constant `MENU` in new namespace `EditorFontSizes`.
2024-02-18 15:56:19 +01:00
Robert Müller 0da1743143 Avoid while loop for calculating console Y offset 2024-02-18 13:14:02 +01:00
Robert Müller bb650b85c4 Minor refactoring of console rendering variables
Remove temporary variables. Mark variables as `const` when possible. Avoid duplicate calculations. Use `bool` instead of `int`.
2024-02-18 13:12:20 +01:00
Robert Müller af99f5ba57 Replace DoButton_ButtonDec/Inc with DoButton_FontIcon/Ex
Use `DoButton_FontIcon` with `FONT_ICON_MINUS`/`FONT_ICON_PLUS` consistently instead of using `DoButton_ButtonDec/Inc` with text labels `+`/`-`.

For yes/no buttons, use `DoButton_Ex` and specify the button corners explicitly instead of using `DoButton_ButtonDec/Inc`.
2024-02-18 12:32:51 +01:00
Robert Müller 929765e95e Remove unused DoButton_File 2024-02-18 12:32:46 +01:00
dobrykafe 3ad0e233ee dont show fps during demo render 2024-02-18 04:01:40 +01:00
Robert Müller aded3f70a2 Fix editor UI locking up when dragging groups/layers quickly
Reset dragging operation when the dragged button has been unset and reset dragged button when operation has been reset, to prevent the editor from being stuck in either of two inconsistent states. This could be reproduced easily by clicking very quickly while moving the mouse up and down over the groups/layers list.

Do not call `CheckActiveItem` on a UI element (the dragged button) which might not be in view, as this prevents the UI from detecting the invalid active item, when groups/layers are dragged very far and quickly outside the scrollregion.

Closes #6855.
2024-02-17 13:14:13 +01:00
Robert Müller 886b417ed4
Merge pull request #7983 from archimede67/editor-fix-quads-2
Editor: fix quad snapping when grid is enabled
2024-02-17 09:42:59 +00:00
Robert Müller a720bb0c29
Merge pull request #7976 from ChillerDragon/pr_ed_hover_tiles_vector
[vector] Move select layer to editor component
2024-02-17 09:34:28 +00:00
Corantin H 87155d4a82 Fix logic for preferring grid over quad snapping 2024-02-17 10:16:09 +01:00
ChillerDragon 9134e31800 Move select layer to editor component
closed #7943
closed #7612
2024-02-17 12:06:04 +08:00
Robert Müller c729ccad32 Abort new HTTP requests immediately when shutting down CHttp
Immediately cancel new HTTP requests instead of enqueuing them when already shutting down `CHttp`. Otherwise, `CChooseMaster` may wait forever for HTTP requests to be completed while the client is shutting down, if `CHttp` was shutdown while `CChooseMaster` is not waiting for an existing HTTP request.

Not directly caused by #7962, but it made it more likely to happen.

Closes #7980.
2024-02-16 17:33:50 +01:00
archimede67 aae674897a
Merge pull request #7975 from ChillerDragon/pr_ed_wasd_speed
[editor] Increase WASD pan speed when holding down shift
2024-02-16 12:50:10 +00:00
Robert Müller fdf427db15 Fix entities textures not being built for non-DDNet/DDRace types
The combined entities texture for all layers except the switch layer was only built when the gametype has a front, speedup, tele or tune layer, which is only the case for servers declaring DDNet or DDRace type in their gameinfo. Now this entities layer is always built, as the game layer is always present.
2024-02-15 21:51:53 +01:00
dobrykafe 5dc8fe81e3 expire team invites on player disconnect 2024-02-15 21:37:51 +01:00
Robert Müller ab3445967d Fix assertion due to double-free of transparent texture
The transparent texture is reused for multiple entity layers and should never be unloaded.
2024-02-15 20:49:55 +01:00
Robert Müller 0a776b9062 Cleanup select layer UI element handling
Expose UI element ID for the main map editor as member variable so the select layer by tile funtionality can correctly be enabled when the map editor is the hot item.
2024-02-14 22:03:25 +01:00
ChillerDragon 7ec182b498 Increase editor pan speed when holding down shift 2024-02-14 08:43:21 +08:00
Dennis Felsing 5cb37c2e4a
Merge pull request #7974 from Robyt3/Menus-Tabs-Tooltips
Add tooltips for all icon-based menu and browser tabs
2024-02-13 23:51:30 +00:00
Robert Müller 639a5879a6 Add tooltips for all icon-based menu and browser tabs 2024-02-13 22:26:28 +01:00
Robert Müller 6c27894a63
Merge pull request #7973 from ChillerDragon/pr_ed_igfx
Remove indirect Graphics() access in BrushSelecting()
2024-02-13 21:03:17 +00:00
ChillerDragon 2f2b8f32fa Remove indirect Graphics() access in BrushSelecting() 2024-02-13 16:01:18 +08:00
Robert Müller 73011529cd Document all shell, OS, secure random and related functions
Add/update doxygen comments for all `shell_*`, `os_*`, `secure_*`, `cmdline_*`, `windows_*` and related functions.

Move `open_link` and `open_file` declarations to shell group, to the same relative position as their function definitions.
2024-02-12 23:05:21 +01:00
bencie 997fe8fa3b Add /solo and /deep as practice commands 2024-02-12 17:17:55 +01:00
Dennis Felsing c85be52409
Merge pull request #7968 from Robyt3/Server-Mod-Message-Fix
Make it less likely that antibot message is sent from random tees
2024-02-11 21:58:01 +00:00
Robert Müller be98c17738 Make it less likely that antibot message is sent from random tees
Instead of sending the message from the first client which is not ingame, choose the first client which is fully empty, to make it less likely that the message is sent from a currently connecting client.
2024-02-11 22:12:15 +01:00
Robert Müller f0e71219a9 Add placeholder country/type for servers without community
Add a country "none" with tee flag (code `-1`) and a type "None" for all servers without community.

Previously, the country and type for these servers was unset and their handling special-cased, so any non-empty country/type filter would exclude servers without country/type information. Now individual countries/types can be excluded without also excluding all servers without community.

Closes #7961.
2024-02-11 17:55:53 +01:00
Robert Müller e4e4227709 Fix filter excluding all items when right-clicking the only entry
It was possible to create a community/country/type filter excluding all entries when the list only contains one entry and right-click is used to deselect it.
2024-02-11 17:41:15 +01:00
Dennis Felsing 6d3bd36877
Merge pull request #7964 from ChillerDragon/pr_doc_ui_doeditbox
Document `DoEditBox()`
2024-02-11 14:47:47 +00:00
Robert Müller 8e2195ce16
Merge pull request #7963 from bencie/flag-search
Add flag search
2024-02-11 14:43:47 +00:00
bencie b5960f3fc3 Track filtered flags directly instead of their indices 2024-02-11 15:16:40 +01:00
ChillerDragon 74a9c39650 Document DoEditBox() 2024-02-11 17:47:02 +08:00
bencie 206a36a02a Add searchbar to flags tab in settings 2024-02-11 04:05:35 +01:00
Robert Müller 9d1ebe726c Quit client faster by aborting HTTP requests earlier
Shutdown `CHttp`, i.e. abort all HTTP requests, as early as possible when quitting/restarting the client, after the config has been saved but before shutting down the gameclient. Previously, this was delayed until the engine shutdown, so the requests would often finish entirely instead of being aborted by the callback.

Previously, HTTP requests being aborted due to `CHttp` shutting down were considered `EHttpState::ERROR`, which sometimes causes deadlocks during engine shutdown or destruction of `CHttp`. The state is now set to `ABORTED` by passing `CURLE_ABORTED_BY_CALLBACK` to `OnCompletionInternal`. The otherwise unused handling of internal errors is removed.
2024-02-10 22:38:42 +01:00
Robert Müller b2041f5703 Fix assertion due to incorrect HTTP request state
Previously, it was assumed `ResultJson` would return `nullptr` for HTTP requests which have been aborted or failed with an error, which would trigger the newly added assertion error "Request not done".
2024-02-10 22:38:10 +01:00
Robert Müller 399ba63a2c Fix incorrect check for aborted server list GET request result
The HEAD request result has already been checked above.
2024-02-10 22:37:54 +01:00
Corantin H 93120b83cf Call FlagModified only when property can affect automapper (fixes #7959)
Handle more cases for undoing auto automap
2024-02-10 12:15:28 +01:00
Dennis Felsing a7bbcf00a6
Merge pull request #7956 from archimede67/editor-fix-quads
Editor: fix several quads related issues
2024-02-09 23:13:30 +00:00
Robert Müller fe5b9d2dc9 Encapsulate CInfoMessages members 2024-02-09 21:35:35 +01:00
Robert Müller dda86b4624 Refactor info message creation
Add `CInfoMessages::CreateInfoMsg` function to create fully initialized info messages, to reduce duplicate code when creating info messages.
2024-02-09 21:35:14 +01:00
Robert Müller 4be56bb87d Refactor info message rendering
Improve readability of flag rendering code.

Add `ROW_HEIGHT` and `FONT_SIZE` constants.
2024-02-09 21:35:07 +01:00
Robert Müller 9295993190 Remove redundant text width calculation
Directly use the bounding box which has already been calculated for the text containers, instead of calculating the text width again for every info message text.
2024-02-09 21:34:45 +01:00
Robert Müller ebe60738d9 Refactor CInfoMessages::AddInfoMsg usage
Reduce duplicate code by moving screen remapping and validation of the info message into the `AddInfoMsg` function.

Check for valid kill message before creating text containers, so they are not created and deleted unnecessarily.

Assign info message type directly instead of passing it as a separate parameter.
2024-02-09 21:33:47 +01:00
Robert Müller 109b6bfb8e Refactor info message text container creation
Combine `CreateNamesIfNotCreated` and `CreateFinishTextContainersIfNotCreated` functions to `CreateTextContainersIfNotCreated` function to reduce duplicate code on usage.

Extract duplicate code for determining name color in info messages as lambda function.
2024-02-09 21:33:27 +01:00
Robert Müller 1683304acd Ensure skin info of finish messages is valid 2024-02-09 21:33:14 +01:00