Commit graph

15134 commits

Author SHA1 Message Date
Robert Müller 3eb8122eea Support composite binds with + commands
Previously, binding `+` commands like `+hook` to composite keys like `shift+x` or `ctrl+alt+mouse1` was not possible, as it would lead to stuck inputs when one of the modifiers is released first before the primary key. When binding `+` commands to composite binds the modifier was instead ignored to prevent this.

Now, binding `+` commands to composite keys is also possible. Active binds (key, modifier) are stored and when a modifier key is released all binds using that modifier are also released.

Closes #8314.
2024-08-04 22:23:30 +02:00
Robert Müller dc1a483b53 Make handling of F1-F24 keys binds consistent with regular binds
The handling of F1-F24 keys in `CBindsSpecial` was not correct for composite binds, leading to stuck inputs if modifier keys are released first. Now, the `CBindsSpecial::OnInput` function simply delegates to `CBinds::OnInput` for F-key presses/releases so the behavior is consistent with regular binds.
2024-08-04 22:10:15 +02:00
Robert Müller 12e5f7f1d3 Various minor refactoring of CBinds
- Use `UnbindAll` function in destructor to reduce duplicate code.
- Use appropriate constants instead of magic number `0`.
- Remove redundant comments.
- Remove redundant `else if` condition.
- Rename generic loop variables `i` and `j` to `Modifier` and `Key` for clarity.
2024-08-04 22:09:52 +02:00
Robert Müller 9f6cb92cb9 Add assertions to CBinds::Bind and Get functions 2024-08-04 22:09:47 +02:00
Robert Müller 8fd40efe36 Fix key names for composite binds with multiple modifiers
This was only affecting the key names displayed in the voting HUD, e.g. with `bind "ctrl+alt+f3" "vote yes"` the voting HUD previously showed `+f3` as the key name.
2024-08-04 22:09:29 +02:00
Robert Müller d2222f55e7 Add CBindSlot as return value for GetBindSlot function 2024-08-04 22:05:50 +02:00
Robert Müller b28bac89d4 Move CBinds::GetKeyId function to IInput::FindKeyByName 2024-08-04 22:05:34 +02:00
Corantin H 79ff930aaa Fix invalid team count in scoreboard for split teams
Refactor state variables into `CScoreboardRenderState`
2024-08-04 17:20:56 +02:00
Robert Müller 924f8f582b Remove unused TEXLOAD_NOMIPMAPS and TEXLOAD_NO_COMPRESSION
The flag `TEXLOAD_NO_COMPRESSION` is entirely unused.

The flag `TEXLOAD_NOMIPMAPS` is unused and only the respective `CCommandBuffer::TEXFLAG_NOMIPMAPS` is used internally, so the former flag does not need to be exposed to users of `IGraphics`.
2024-08-02 18:16:26 +02:00
Robert Müller 273f3e5bfa Remove unused return value of IGraphics::UnloadTexture function 2024-08-02 18:16:15 +02:00
Robert Müller da8ec6bed9 Remove unused LoadTextureRawSub and CMD_TEXTURE_UPDATE
The `IGraphics::LoadTextureRawSub` function and the respective `CMD_TEXTURE_UPDATE` command are unused. Only text textures are updated after having been uploaded, but there is a separate `CMD_TEXT_TEXTURE_UPDATE` for that.
2024-08-02 18:15:55 +02:00
Robert Müller 9110d393dd Remove unused IGraphics::NullTexture function
It should not be necessary to access the null-texture directly. The `CTextureHandle::IsNullTexture` function can be used to check if a texture handle is the null-texture.
2024-08-02 18:15:34 +02:00
Robert Müller 7930eb9b79 Use != instead of < to future-proof sv_team
Assume that this branch should apply to all team modes except `SV_TEAM_FORCED_SOLO` also when new team modes would get added after `SV_TEAM_FORCED_SOLO` in the future, as the values will never be changed and there is no relation between the order of the numeric values and the behavior.
2024-08-01 21:33:53 +02:00
Robert Müller f676a8b9ad Add error message when trying to /swap on forced solo server
Previously, swapping on forced solo servers was already impossible, as this would require two players to join the same team, so it would always fail with the error `Player is on a different team` (or earlier). The check `g_Config.m_SvTeam != 3` was never reached. Also, this check was not using the constant `SV_TEAM_FORCED_SOLO`. Now, an earlier check is added to show a more specific error message when trying to use `/swap` on a forced solo server.
2024-08-01 21:33:48 +02:00
ChillerDragon ef1d5fa78c Fix first typo 2024-08-01 11:47:46 +08:00
Dennis Felsing 2c61177745
Merge pull request #8669 from Robyt3/Client-Damageind-Refactoring
Refactor and optimize damage indicators, reset damage indicators when skipping in demo
2024-07-31 21:48:00 +00:00
Robert Müller fd1cc863b4 Remove unused code for saving embedded RGB map images
Only embedded images in RGBA format are loaded anymore, so the additional code for converting RGB to RGBA image data is not necessary.
2024-07-31 22:13:08 +02:00
Robert Müller 12aa79d6f8 Avoid duplicate calculation of damage indicator life
Only calculate the passed time once to adjust damage indicators' remaining life instead calculating the time separately for each damage indicator.
2024-07-31 20:36:48 +02:00
Robert Müller 782c9a54bf Remove separate CreateI and DestroyI functions
Improve readability by removing the indirection when creating and removing damage indicators.
2024-07-31 20:36:48 +02:00
Robert Müller 90562b5157 Make CDamageInd::OnReset function more efficient
There is no need to copy the items if we only want to delete all of them.
2024-07-31 20:36:47 +02:00
Robert Müller 690590ca03 Remove unnecessary m_StartAlpha variable
The `m_Color` variable already stores the initial alpha value and should not be modified, so the separate `m_StartAlpha` variable is unnecessary.
2024-07-31 20:36:47 +02:00
Robert Müller df0a9811d9 Remove unused m_Lastupdate variable 2024-07-31 20:36:47 +02:00
Robert Müller f14f00da09 Reset damage indicators when skipping in demo
Prevent old damage indicators still persisting in demo player after skipping.
2024-07-31 20:36:47 +02:00
Robert Müller cd2a20f1f4 Use OnReset function to reset damage indicators
The additional indirection with the `CEffects::ResetDamageIndicator` and `CDamageInd::Reset` functions to reset damage indicators is confusing and unnecessary. Always reset the damage indicators when disconnecting (in `OnReset`) instead of when entering the next game.
2024-07-31 20:36:47 +02:00
Robert Müller 7f59a159e4 Refactor, rename IGraphics::IsImageFormatRGBA
Rename `IGraphics::IsImageFormatRGBA` function to `IsImageFormatRgba`.

Rename parameter `pFileName` to `pContextName`, as this name does not necessarily describe a file.

Remove unnecessary check for parameter `pFileName` (now `pContextName`) being unset, which is and should never be the case.

Rename parameter `Img` to `Image` for consistency.
2024-07-30 19:58:53 +02:00
Robert Müller 82bf71e780 Refactor IGraphics::CheckImageDivisibility
Put the context name in quotation marks in the warning message.

Rename parameter `pFileName` to `pContextName`, as this name does not necessarily describe a file.

Rename parameter `Img` to `Image` for consistency.
2024-07-30 19:58:53 +02:00
Robert Müller 92b0b90b29 Remove unused CClient::DirectInput function
The function is unused and because the message is not flushed it would also not have worked correctly. The `NETMSG_INPUT` message is already packed and flushed in the `CClient::SendInput` function.

Closes #8408.
2024-07-29 21:43:50 +02:00
Robert Müller 5bd0b06c52 Fix menu checker background on wide resolutions and optimize it
The maximum width and height were swapped as the loop bounds, so the menu checker background did not have the correct width on very wide resolutions.

This was not noticed on common resolutions because twice as many quads as necessary were also being rendered for each row of the background. The bounds of the inner loop are adjusted and only every second x-value is iterated, which reduced the total number of quads for the checker background rendering by more than half.
2024-07-28 20:49:09 +02:00
Robert Müller 23fb01f9dd Smoother menu checker background scrolling on loading screens
Update global time also while rendering loading screens and shift the menu checker background based on the global time so it's smoother while loading.
2024-07-28 20:38:51 +02:00
Dennis Felsing 1d92b5acd6
Merge pull request #8658 from Robyt3/Client-Image-Non-Rgba-Leak
Fix memory leak of non-RGBA image data, clear all image info
2024-07-27 22:12:42 +00:00
Dennis Felsing 6911944c57
Merge pull request #8659 from Robyt3/Client-Dummy-Connecting-Improvement
Improve dummy connecting button and error handling
2024-07-27 22:11:47 +00:00
Robert Müller b61005d3e7 Improve dummy connecting button and error handling
Track whether the dummy is currently connecting separately so the dummy being disconnected due to errors can be detected. Show an error message as echo in the chat when the dummy could not be connected, e.g. when the server is full.

Use the global time for limiting the dummy connecting delay instead of using game ticks, so the delay also works correctly when having connection problems (i.e., when ticks do not advance). Handle the dummy connecting being delayed separately from the dummy currently connecting.

Add tooltips for the "Connect dummy"-button when it's disable due to dummy not being allow on the server or when connecting is delayed.

Add console error messages for `dummy_connect` command.
2024-07-27 22:44:15 +02:00
Robert Müller fb832b482c Fix memory leak of non-RGBA image data, clear all image info
The image data was not being freed when `IGraphics::LoadTextureRawMove` is used with images that are not in RGBA format as this falls back to using `IGraphics::LoadTextureRaw` which requires manually freeing the image data.

Also consistently clear all image info in `LoadTextureRawMove`. This makes it necessary to store the size of the preview image in the editor separately, as previously the width and height of the unloaded image info were being used to render the preview image.
2024-07-27 21:24:32 +02:00
Robert Müller 8a3929d48c Support IME composition strings of arbitrary length
Previously, IME composition strings were limited to at most 32 bytes, e.g. 10 Hiragana characters. Now, `SDL_TextEditingExtEvent` (`SDL_TEXTEDITING_EXT`) is supported, which uses heap-allocated composition strings of arbitrary length.

On the other hand, the buffer for input event text was larger than necessary, as SDL text events only contain at most 32 bytes (`SDL_TEXTINPUTEVENT_TEXT_SIZE` is not used directly to avoid the include). With the hint for extended IME handling enabled, long composition text will be sent as multiple text events (without breaking UTF-8).
2024-07-27 17:32:41 +02:00
ChillerDragon 3c5320aa90 Rename editor component Init to OnInit
This matches the naming convention used for client components and the
`GameServer()->OnInit()`
2024-07-27 22:07:56 +08:00
Robert Müller f79ea492fa Minor refactoring of ResizeImage and related functions
Avoid duplicate code by using arrays and loops.

Move local variable declarations closer to their usages.

Use `mem_copy` instead of for-loops.
2024-07-26 21:10:05 +02:00
Robert Müller bfc4902910 Minor refactoring of DilateImage and related functions
Add constants for BPP and alpha threshold during Dilate, as dilating only works for RGBA images and we only use a fixed alpha threshold.

Move local variable declarations closer to their usages.

Use `mem_copy` instead of for-loop.

Use `nullptr` instead of `NULL`.
2024-07-26 21:10:05 +02:00
archimede67 08f955bff0
Merge pull request #8651 from Robyt3/Client-Saves-File-Header-Fix
Fix CSV header being written multiple times to `ddnet-saves.txt`
2024-07-25 22:02:06 +00:00
Robert Müller 5e655615cb Fix CSV header being written multiple times to ddnet-saves.txt
It is implementation-defined whether the file position returned by `ftell` denotes the beginning or the end of the file when opening in append-mode. This was causing the condition `io_tell(File) == 0` to always be true, so the CSV header was also written to `ddnet-saves.txt` every time that a new save code is written. Now, we check if the file already exists before appending and only write the CSV header once when the file does not exist yet.
2024-07-25 20:27:09 +02:00
furo 8f96584f40 Remove servers_legacy support 2024-07-25 17:24:39 +02:00
Dennis Felsing cd81b1f253
Merge pull request #8645 from Robyt3/Client-HUD-Score-Team-Colors
Use same Red/Blue team colors for score HUD as for scoreboard
2024-07-24 16:46:53 +00:00
Robert Müller fddba0cc76
Merge pull request #8641 from def-/pr-formatting
Also trim search strings in highlights
2024-07-24 16:31:02 +00:00
Robert Müller eb956e72d1 Use same Red/Blue team colors for score HUD as for scoreboard 2024-07-24 18:29:00 +02:00
Learath2 90c4a552ed Try fix issue with savegames 2024-07-24 17:36:12 +02:00
Dennis Felsing 1c2d7262d0 Also trim search strings in highlights 2024-07-24 15:23:05 +02:00
Dennis Felsing a84a53c5fe
Merge pull request #8640 from Robyt3/Server-DNSBL-Ban-Only-New
Only apply DNSBL bans once when player joins
2024-07-24 11:08:40 +00:00
Robert Müller 7f2908d822 Only apply DNSBL bans once when player joins
Only ban DNSBL blacklisted players once when joining immediately after the DNSBL result is available, to prevent current players from having their runs ended when the `sv_dnsbl_ban` setting is enabled.

Note that enabling `sv_dnsbl` and `sv_dnsbl_ban` at the same time will still cause the players to be banned immediately. To prevent this, first enable `sv_dnsbl` for at least one tick, then enable `sv_dnsbl_ban`.

Closes #2640.
2024-07-24 12:50:06 +02:00
DynamoFox 9365e1453f Fix 'auto' GPU identification and display
* Refactors the previous code segment
* Fixes 'auto' GPU identification and display in DDNet Graphics tab of
  the settings. The 'auto' GPU is the best one encountered in the VK
  physical device enumeration array until we encounter one that is
  at least "integrated" when accessing them in increasing order
* Selects the first GPU that matches a name when using one by user
  specified name
2024-07-23 21:31:32 +02:00
Robert Müller 8b3e686fdb Fix text input rapidly activated/deactivated when closing console
Fixes virtual keyboard on Android flashing rapidly when the console is closed.
2024-07-23 12:51:36 +02:00
Corantin H 5f8e2742a6 Fix team number and team size rendering
Fix team number and team size rendering outside of the scoreboard when the team is rendered on both sides
Fix team number and team size alignment
2024-07-23 10:10:43 +02:00