Commit graph

15425 commits

Author SHA1 Message Date
Dennis Felsing b05ffeae3b
Merge pull request #8762 from ChillerDragon/pr_fix_dummy7_marking_alpha
Fix 0.7 dummy marking alpha being reset
2024-08-18 06:34:56 +00:00
Dennis Felsing 9fe2203a24
Merge pull request #8754 from ChillerDragon/pr_fix_06_demo_cutting
Fix cutting 0.6 demos
2024-08-18 06:29:33 +00:00
ChillerDragon 99fe6b09ed Fix 0.7 dummy marking alpha being reset
Closed #8757
2024-08-18 11:06:40 +08:00
ChillerDragon fa1ee98f1e Fix race 0.7 check null pointer dereference
Found by @fokkonaut in https://github.com/ddnet/ddnet/pull/8707

Co-authored-by: fokkonaut <35420825+fokkonaut@users.noreply.github.com>
2024-08-18 10:57:56 +08:00
ChillerDragon 64c7ab677d Color speed in hud based on increase or decrease 2024-08-18 10:32:00 +08:00
ChillerDragon 8d7c99fb96 Implement 0.7 delete skin button
See #8750
2024-08-18 10:17:13 +08:00
ChillerDragon e8fbb440b9 Fix cutting 0.6 demos
Closed #8748
2024-08-18 10:05:58 +08:00
Dennis Felsing b16bc401a8
Merge pull request #8716 from ChillerDragon/pr_hide_url_for_06
Hide address url for 0.6 ips (Closed #8712)
2024-08-17 17:42:30 +00:00
ChillerDragon 933a43bd0f Make render m_Sixup an array for dummy 2024-08-16 22:32:03 +08:00
ChillerDragon 7cffdf40b6 Make gameclient m_Sixup an array for dummy 2024-08-16 22:30:58 +08:00
heinrich5991 f057898ce0
Merge pull request #8745 from ChillerDragon/pr_07_hook_coll
Fix hook coll on vanilla 0.7 servers
2024-08-16 12:56:24 +00:00
ChillerDragon fac02650f1 Fix hook coll on vanilla 0.7 servers
Thanks to @fokkonaut for this F-Client commit

8ecd8c7f0a

Closed #8742
2024-08-16 19:12:42 +08:00
heinrich5991 aaf69542b6
Merge pull request #8739 from ChillerDragon/pr_log_error_crc
Use error log level for snap crc errors
2024-08-16 08:21:30 +00:00
Dennis Felsing 8d024be37c
Merge pull request #8738 from ChillerDragon/pr_increase_max_tmp_cmd_len
Increase max temp cmp length
2024-08-16 07:50:40 +00:00
Chiller Dragon 87aa664899
Lower the cmd length to 64
Co-authored-by: Dennis Felsing <dennis@felsing.org>
2024-08-16 15:32:53 +08:00
Dennis Felsing 6a4a70fddd
Merge pull request #8736 from ChillerDragon/pr_fix_06_chat_skins
Fix old 0.7 skins overwriting 0.6 skins in chat
2024-08-16 06:49:48 +00:00
Dennis Felsing de206b27d1
Merge pull request #8737 from ChillerDragon/pr_rm_setdtile
Remove unused function declaration SetDTile
2024-08-16 06:49:34 +00:00
ChillerDragon 1f0467b545 Use error log level for snap crc errors
A snapshot crc error should not happen.
If it does happen it will cause lags and it means something is really wrong.
2024-08-16 13:34:38 +08:00
ChillerDragon 04c141828f Increase max temp cmp length
Fixes long rcon commands being cut off on custom servers.
2024-08-16 13:01:35 +08:00
ChillerDragon a77895711b Remove unused function declaration SetDTile 2024-08-16 12:48:01 +08:00
ChillerDragon 81de29565d Fix old 0.7 skins overwriting 0.6 skins in chat
Closed #8731
2024-08-16 12:37:05 +08:00
Robert Müller 595f537625 Fix asset images not being freed if they fail ratio/format check 2024-08-15 21:44:07 +02:00
heinrich5991 438e04f785 Complain on higher log level that 0.7 support was disabled
Not sure why it was on debug level before.
2024-08-15 14:47:40 +02:00
heinrich5991 6754b5ff45
Merge pull request #8728 from Robyt3/Tools-Demo-Extract-Chat-Time
Print chat/broadcast times in `demo_extract_chat` tool
2024-08-14 17:49:47 +00:00
Robert Müller b4bd13c3aa
Merge pull request #8721 from Rei-Tw/improve-bans
Improve bans rcon command pagination
2024-08-14 17:29:31 +00:00
Robert Müller 17f13b9f97 Print chat/broadcast times in demo_extract_chat tool
This makes it easier to find the times of specific chat messages and broadcasts in demos.
2024-08-14 19:23:18 +02:00
Rei-Tw 035b4a1447 Make bans command better
Update src/engine/shared/netban.cpp

Remove the word "currently" for the empty ban list message.

Co-authored-by: Dennis Felsing <dennis@felsing.org>

Update src/engine/shared/netban.cpp

Text format refactor, adding "currently"

Co-authored-by: Dennis Felsing <dennis@felsing.org>
2024-08-14 15:29:42 +02:00
Jupeyy e3622f3532
Fix debug hud units 2024-08-14 14:11:04 +02:00
ChillerDragon 7fa2306138 Hide address url for 0.6 ips (Closed #8712) 2024-08-14 18:25:10 +08:00
heinrich5991 a48f502618
Merge pull request #8723 from Bamcane/map-sound
Add support for server play map sound
2024-08-14 09:27:12 +00:00
Bamcane 12057d9f6d Add map sound
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2024-08-14 16:48:22 +08:00
heinrich5991 1a0f28c5bd
Merge pull request #8568 from def-/pr-whispers
Add option to disable whispers
2024-08-14 08:21:57 +00:00
heinrich5991 e4bc5bde5d
Merge pull request #8682 from Robyt3/Client-RaceHelper-Refactoring
Refactor `CRaceHelper`, mark `CCollision` functions as `const` and add tile getters
2024-08-14 08:09:05 +00:00
heinrich5991 7de9242cb5
Merge pull request #8624 from Robyt3/Client-Nameplates-Refactoring
Refactor nameplate rendering, slightly improve performance
2024-08-14 08:08:03 +00:00
Dennis Felsing f14ae6bf13
Merge pull request #8725 from ChillerDragon/pr_fix_06_register
Fix 0.6 master server register (closed #8722)
2024-08-14 07:04:38 +00:00
ChillerDragon c16a38b4fa Fix 0.6 master server register (closed #8722) 2024-08-14 12:11:04 +08:00
Robert Müller 19105e224b Make CRaceHelper a member of CGameClient
Avoid static functions and global static variables for flag indices.

Avoid passing pointer to `CGameClient` separately to `IsStart` function.
2024-08-13 21:56:58 +02:00
Robert Müller 5ac3bb506c Mark CCollision functions const, add const tile getters
Mark remaining `CCollision` functions as `const` when possible.

Add remaining getter functions for all tile data and mark all tile getter functions as `const`.
2024-08-13 21:52:25 +02:00
Robert Müller 6dba8851a5 Refactor CRaceHelper::IsStart function
Avoid duplicate calculation by extraction result of `GetPureMapIndex` in variable.

Rename variable `Indices` to `Index`.

Include `vector` instead of `list`, as the former is used but the latter is not.
2024-08-13 21:50:25 +02:00
Dennis Felsing 171d5523de Add option to disable whispers
Since it's easy to abuse and impossible to moderate
2024-08-13 13:37:13 +02:00
Jupeyy b998937e91
Remove "Player Options"
See screenshots
2024-08-13 13:02:32 +02:00
heinrich5991 4cbdf2069c
Merge pull request #8577 from gerdoe-jr/scoreboard-spectator-clans
Scoreboard spectator clans
2024-08-13 10:19:14 +00:00
gerdoe-jr ae364942c8 Add spectator clans rendering in scoreboard
Show client ID before spectator clan
2024-08-13 12:00:57 +02:00
heinrich5991 4f09d3f7d4
Merge pull request #8701 from Robyt3/Client-Spectate-ClientIds
Improve `cl_show_ids`: support spectator menu, optimize, refactor
2024-08-13 09:50:12 +00:00
heinrich5991 585a36dd9d Distinguish birthday from finish events
This allows us to give birthdays a different effect in the future if we
want to.
2024-08-13 11:02:25 +02:00
heinrich5991 c0ec918721 Remove comments that just describe the next line 2024-08-13 11:01:06 +02:00
Dennis Felsing ef6fd80bc5
Merge pull request #8715 from furo321/birthday-confetti
Spawn a confetti when connecting on your DDNet birthday
2024-08-13 08:22:59 +00:00
Dennis Felsing a8219530b1
Merge pull request #8714 from def-/pr-spec-auth
server: Disallow moving authed players to spec
2024-08-12 21:39:53 +00:00
furo 1563b4a56a Spawn a confetti when connecting on your DDNet birthday 2024-08-12 23:14:07 +02:00
Robert Müller 594968fe07 Improve cl_show_ids: support spectator menu, optimize, refactor
Also show client IDs in the spectator menu when `cl_show_ids` is enabled. Previously, this setting applied to scoreboard and chat, although the setting and config variable descriptions were only mentioning the scoreboard.

Extract client ID formatting in `CGameClient::FormatClientId` function to reduce duplicate code and ensure it is consistent.

Correctly indent client IDs also when largest client ID is 100 or larger. Fix scoreboard spectator client ID buffer not being large enough for IDs 100 and larger.

Make client ID formatting more efficient by avoiding `str_format` except for formatting the number itself and appending text directly to the text cursor when possible.
2024-08-12 22:59:32 +02:00
Dennis Felsing 608fba82e0 server: Disallow moving authed players to spec 2024-08-12 19:33:50 +02:00
Dennis Felsing 043480b06e server: Handle dnsbl and other non-critical stuff only on new ticks
Less risk of causing microlags then, I think once per second is often enough since it has to iterate through all players
2024-08-12 18:49:17 +02:00
Dennis Felsing 96881defdf Show game menu buttons again, even in 5:4 2024-08-12 14:35:49 +02:00
Dennis Felsing bd92dbddf2
Merge pull request #8706 from Robyt3/Client-Skins7-Loading-Refactoring
Various refactoring of 0.7 skin loading
2024-08-11 22:12:35 +00:00
Dennis Felsing 960d2853bc
Merge pull request #8708 from ChillerDragon/pr_07_modern_is_ddnet_msg
Send the new is ddnet message in 0.7 connections
2024-08-11 22:12:00 +00:00
Robert Müller 570c2c857a Fix UDP socket creation/cleanup if opening IPv6 socket fails
Previously, the `net_udp_create` function returned whether the IPv6 socket in particular was created successfully. If an IPv4 socket or Websocket was created successfully before this, it was not used and also not closed properly, if the IPv6 socket could not be created.

Now, the `net_udp_create` function succeeds if the socket for at least one network type (IPv4, IPv6 or Websocket) could be created successfully.

Avoid reusing local variables and remove redundant comments. Also apply the same refactoring to `net_tcp_create`, which already has the behavior of succeeding if the socket for any network type (IPv4 or IPv6) was created successfully.
2024-08-11 17:09:09 +02:00
ChillerDragon 21507b51f1 Send the new is ddnet message in 0.7 connections
We already sent the legacy is ddnet message and so far the ddnet
protocol over 0.7 seems to work fine.

But for completeness and correctness it is now also sending the new
ddnet version net message.
2024-08-11 09:25:18 +08:00
Robert Müller 38b60b1d51 Various refactoring of 0.7 skin loading
- Only log successful log messages when `debug` is enabled, consistent with logging for regular skins.
- Use `IsImageFormatRgba` to check for RGBA image format, so this also shows a warning popup.
- Remove redundant logic for non-RGBA image data.
- Use `CheckImageDivisibility` instead of enforcing exact size of xmas hat and bot decoration images to allow higher resolution images.
- Fix image data not being freed if it has the wrong format or ratio.
- Fix potential integer overflow when calculating skin part blood color (same as for regular skins).
- Extract `LoadXmasHat` and `LoadBotDecoration` functions for readability.
2024-08-10 17:55:11 +02:00
ChillerDragon e0bc98e79a Add alpha support for 0.7 skins 2024-08-10 14:50:43 +02:00
ChillerDragon 53b01862d4 Remove netversion from demo editor init 2024-08-10 14:50:43 +02:00
ChillerDragon 399075c339 Display 0.7 skins in chat 2024-08-10 14:50:43 +02:00
ChillerDragon 8903f49716 Render skins in 0.7 demos 2024-08-10 14:50:43 +02:00
ChillerDragon be67622544 Resend 0.7 skin change if it got filtered by the server 2024-08-10 14:50:43 +02:00
Alexander Akulich fe99a346dd Improve 0.7 skins
skins7: Extract the skins dir to a macro
skins7: Look for the skins at 'skins7' dir
Data: Add 0.7 skins (diliated)
CMenus::RenderSkinSelection7: Fix the skins number (use 0.7 getter)
CSkins7::GetColorV3: Fix missing UnclampLighting
CRenderTools: Use stronger type for 0.7 colors
CSkins7::RandomizeSkin: Use enum value instead of hardcode+comment
CMenus::RenderSettingsTee7: Enable team skins validation
system: Add str_utf8_copy_num()
GameClient: Extract ApplySkin7InfoFromGameMsg()
GameClient: Add skin7 to CClientData (also process and validate it)
2024-08-10 14:50:43 +02:00
ChillerDragon bae37ab7df Add 0.7 client support
While keeping 0.6 fully working and untouched
This adds the option to connect via 0.7

0.7 servers are now mixed into the server browser list.
And users can also manually connect via 0.7
using a connection url like so:

    ./DDNet "connect tw-0.7+udp://127.0.0.1:8303"

This also adds a "Tee 0.7" section in the menu to pick a 0.7 skin.
The config variables are prefixed with player7_ like for example
player7_color_body
2024-08-10 14:50:42 +02:00
Robert Müller 2fa4c1f603 Remove clang-tidy static variable name exceptions
- Remove `readability-identifier-naming.StaticVariableIgnoredRegexp`.
- Mark `static` variables as `const` and use `UPPER_CASE` for names when possible.
- Use local variables instead of `static` variables when possible.
- Use member variables with correct name instead of `static` variables.
- Pass output buffer for `static` function `GetKeyBindModifiersName` by argument instead of returning pointer to `static` buffer.
2024-08-10 13:27:55 +02:00
Robert Müller 323ccf5a22 Show warning when connect address cannot be resolved
Show warning and disconnect instead of falling back to connecting to `localhost` when the connect address cannot be resolved.
2024-08-09 20:22:00 +02:00
Dennis Felsing 00586a0c4a Revert "Faster /rank, fixes test result"
This reverts commit c2a3444f87.
2024-08-08 18:59:20 +02:00
Dennis Felsing e3dd2895dd Revert "Fix /rank"
This reverts commit 49bef9c453.
2024-08-08 18:59:20 +02:00
Robert Müller 645a00551b Fix binds not being repeated when key held down
Closes #8699. Regression from #8685.
2024-08-08 18:14:59 +02:00
Dennis Felsing 49bef9c453 Fix /rank
minTime being NULL means no rank
2024-08-08 17:13:47 +02:00
Dennis Felsing 647abbd801
Merge pull request #8693 from def-/pr-optimize-query
Faster /rank, fixes test result
2024-08-08 14:39:13 +00:00
Dennis Felsing 9be9a902e7
Merge pull request #8697 from heinrich5991/pr_ddnet_to_ipv4_mapped
Use `Ipv6::to_ipv4_mapped` in mastersrv
2024-08-07 22:19:45 +00:00
heinrich5991 83a90c9a06
Merge pull request #8676 from Robyt3/Client-LineInput-Event-Handling-Consistency
Consistently return `true` from `OnInput` function for used events
2024-08-07 22:07:49 +00:00
heinrich5991 d42ae75a9e Use Ipv6::to_ipv4_mapped in mastersrv
Needs Rust 1.63.0, should be old enough at this point.
2024-08-08 00:00:41 +02:00
Robert Müller 2c7c391ff0 Only activate double-clicks with left mouse button again
Double-clicks could also be activated with other mouse buttons on some UI elements, which was unintentionally added by #8489.
2024-08-07 20:59:45 +02:00
Dennis Felsing c2a3444f87 Faster /rank, fixes test result 2024-08-07 18:10:36 +02:00
heinrich5991 e97b8e1818
Merge pull request #8690 from def-/pr-dnsbl-info
More dnsbl printing
2024-08-06 16:53:17 +00:00
Dennis Felsing 922e32be0c More dnsbl printing 2024-08-06 17:21:24 +02:00
Dennis Felsing 082580f586 Don't show ban time for vpn bans 2024-08-05 20:27:16 +02:00
heinrich5991 75ec6ed304
Merge pull request #8652 from def-/pr-vpn-ban-1min
Only ban VPNs for a minute
2024-08-05 16:19:50 +00:00
-StormAx 52a6b4d69f Fix https://github.com/ddnet/ddnet/issues/8668 2024-08-05 06:22:16 +03:00
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 bdd7784bbb Consistently return true from OnInput function for used events
The `OnInput` function should return `true` exactly for events that were handled. In case of line inputs, the function returned `true` when then line input was changed instead. For the consoles, the function did not return `true` for some events that were handled.
2024-08-03 11:58:15 +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
DynamoFox a013372be4 Fix game launch on Wayland-only systems with SDL2.30+ 2024-08-01 16:36:44 +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
Dennis Felsing 36b8d81d1a Only ban VPNs for a minute 2024-07-26 17:23:04 +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
Dennis Felsing 712aed780f Version 18.4 2024-07-22 17:56:21 +02:00
Dennis Felsing d8cee35f73
Merge pull request #8628 from Jupeyy/pr_gpu_if
Check API version before adding GPU to GPU list
2024-07-21 12:55:31 +00:00
Robert Müller 606212f2d0
Merge pull request #8629 from MilkeeyCat/pr_refactor_text_alignment_of_movement_information
Use text containers to render movement information
2024-07-21 12:05:59 +00:00
MilkeeyCat ec37efdcfd refactor: use text containers to render movement information
closes #8622
2024-07-21 14:43:22 +03:00
Jupeyy e96275943b
Check API version before adding GPU to GPU list
Signed-off-by: Jupeyy <jupjopjap@gmail.com>
2024-07-21 13:29:49 +02:00
Robert Müller 74426b05a3 Avoid copies of server info in CGameClient::OnNewSnapshot
Only copy the server info with the `GetServerInfo` function once, as it should not change within a call of the `CGameClient::OnNewSnapshot` function.
2024-07-21 12:53:29 +02:00
Robert Müller 3d804910e6 Minor refactoring of RenderNameplate
- Reduce duplicate code and dead stores for color and input data.
- Move variable declarations closer to their usages.
- Remove unnecessary `Graphics()->TextureClear` before `Graphics()->TextureSet`.
- Mark variables `const` and remove unnecessary temporary variables.
- Remove unnecessary default arguments of `Text` and `TextWidth` functions.
- Use `WithAlpha` for colors.
2024-07-20 13:32:14 +02:00
Robert Müller 3afdc20df2 Rename clan related variables, removing Name from name 2024-07-20 13:19:03 +02:00
Robert Müller 0222e4ae96 Avoid duplicate calculations of nameplate text width
Get name/clan bounding box size from the text container index instead of calculating it twice.
2024-07-20 13:18:41 +02:00
Robert Müller b30dde56b6 Extract variables to improve readability and reduce duplicate code 2024-07-20 13:18:17 +02:00
Robert Müller f0fb1fd196 Avoid using pointer for vec2, use in_range function 2024-07-20 13:18:02 +02:00
Robert Müller c24d0c0ace Remove unnecessary CNamePlates::RenderNameplate function
The client ID of `CNetObj_PlayerInfo` objects is validated prior to calling the `CNamePlates::RenderNameplate` function, so the additional checks and arguments to handle the client ID not being valid where never used.

Rename existing `RenderNameplatePos` function to `RenderNameplate`.
2024-07-20 13:17:49 +02:00
Robert Müller 36f19f491e Support touch input in engine, UI and console
Add support for touch input to the engine, UI and console. Ingame touch controls require more discussion and will be delivered separately based on this engine implementation.

Engine
------

The state of all currently pressed touch fingers is aggregated based on the SDL touch events and can be retrieved with the `IInput::TouchFingerStates` function. This design is less complex than an event-based system where the touch events are delivered to the individual client components, as each system would then have to keep track of the finger states individually. However, this means that only one component can handle touch fingers at any given time, which seems like a reasonable assumption for our use cases.

Obsolete code for relative mouse handling on Android is removed. Connecting a mouse to an Android device should now also work as expected, as more recent SDL/Android versions support relative mouse input natively.

User Interface
--------------

Support absolute mouse positioning and clicking in the user interfaces (menus, editor, demo player) with touch presses.

Support right clicking by pressing and holding one finger at roughly the same position for 0.5 seconds.

Support scrolling scroll regions up and down with a two finger swiping gesture. Fast scrolling via a two finger flinging gesture is not yet supported and would be a useful future extension.

The menus and demo player are fully usable with touch inputs. The editor is only fully usable with an external keyboard and/or mouse, as panning the map is not currently possible with only touch inputs, which is also left as a possible future extension.

Console
-------

The touch input logic for the user interface is reused for the console. Thereby, text selection in the console with touch input works, although the text can only be copied by pressing Ctrl+C with an external keyboard at the moment. In the future, we could add buttons to the console to activate the search and copy functionalities with touch inputs.

Support scrolling the console history up and down with a two finger swiping gesture.

The local/remote consoles can currently only be opened with an external keyboard. The ingame touch controls will also include buttons to open the consoles.
2024-07-19 13:36:04 +02:00
Dennis Felsing e74f17c939
Merge pull request #8614 from Robyt3/Video-Removed-Property-Fix
Fix assertion when rendering demo with updated ffmpeg library
2024-07-18 15:59:33 +00:00
Robert Müller c30a35a493 Fix assertion when rendering demo with updated ffmpeg library
The `in_channel_count` and `out_channel_count` properties of the `SwrContext` were already deprecated and have been removed in the most recent ffmpeg library version, hence rendering demos was causing an assertion error when these properties were set.

For newer ffmpeg versions, we now set the channel layout with the `in_chlayout` and `out_chlayout` properties instead of setting the number of channels.
2024-07-18 17:23:16 +02:00
Robert Müller ac95d73e31 Slightly increase size for score in scoreboard again
Did not consider in #8591 that the team and size would also need this space.
2024-07-17 20:23:04 +02:00
heinrich5991 f9a94fb5e0
Merge pull request #8609 from Robyt3/Android-No-Process-No-Server
Disable "Run server" button and process functions on Android
2024-07-17 15:46:56 +00:00
heinrich5991 f9c5d008ca
Merge pull request #8591 from Robyt3/Client-Scoreboard-Spectate-128
Add basic support for 128 players in scoreboard and spectator UI
2024-07-17 15:29:26 +00:00
Robert Müller 45f9161d43 Disable "Run server" button and process functions on Android
Starting the server on Android is currently not possible because a) the server executable is currently not compiled for Android b) launching the server executable with `fork` and `exec` is not supported on Android and may result in strange bugs like broken networking.

Running the server in a background service or in a separate process by using `Runtime.getRuntime().exec` from Java code might be feasible, but this is currently too much effort and may be done in the future.

For now, the "Run server" button as well as the process related system functions are disabled via conditional compilation on Android, to prevent the networking bug that would otherwise be triggered by pressing the "Run server" button.
2024-07-17 16:48:17 +02:00
MilkeeyCat 784333b2aa refactor: remove multi line chat support 2024-07-17 14:13:13 +03:00
Robert Müller 90c63746b4 Show skin name as tooltip in ingame player list 2024-07-16 20:38:47 +02:00
Dennis Felsing 3229a19fd5
Merge pull request #8601 from Robyt3/Client-Camera-ZoomAllowed-Function
Extract `CCamera::ZoomAllowed` function to reduce duplicate code
2024-07-16 16:49:40 +00:00
Dennis Felsing 7197b815a1
Merge pull request #8599 from Robyt3/Spectate-UI-Input-Refactoring
Refactor spectator UI input handling
2024-07-16 16:29:07 +00:00
Robert Müller f574f759d4 Extract CCamera::ZoomAllowed function to reduce duplicate code 2024-07-16 18:06:22 +02:00
Robert Müller 088f963c0d Readd separate localization strings for Red/blue team wins! 2024-07-16 17:40:57 +02:00
Robert Müller ed53b1c6dc Refactor spectator UI input handling
Use `IInput::KeyPress` instead of event callback for mouse presses. Remove subsequently unnecessary `m_Clicked` variable.
2024-07-16 17:12:58 +02:00
Robert Müller 846775c6b7 Avoid reusing Selected variable for different buttons 2024-07-16 17:12:48 +02:00
Robert Müller e8eb79e7fb Remove unused m_OldMouseX and m_OldMouseY variables 2024-07-16 17:12:45 +02:00
Robert Müller d4f47c2a55 Implement client restarting on Android
Restarting the client previously did not work, as the `shell_execute` function on Android uses `fork` which is not supported.

Now, the client is restarted by using an Android intent to restart the main activity. This is triggered by sending a user-defined message from the native code to the SDL main activity thread.
2024-07-16 12:52:19 +02:00
Robert Müller 78da9689f5 Add basic support for 128 players in scoreboard and spectator UI
Support showing up to 128 players in the scoreboard and the spectator UI. The 128 players are rendered in 3 columns of 43 players in the scoreboard and in 4 columns of 32 players in the spectator UI. Other lists like the server info (ingame and in the server browser) and the voting list already support showing any number of players.
2024-07-15 23:41:33 +02:00
Robert Müller 37756aa389 Ensure that sv_max_clients can only be set when starting server
Changing the `sv_max_clients` config variable while the server is running does not change the maximum number of clients that can connect, as this is determined only once when the `CNetServer` is initialized. The reserved slot check and the calculation of the number of player slots for the `protocol7::CNetMsg_Sv_ServerSettings` message were using the `sv_max_clients` config variable directly, which was causing them to be out-of-sync with the real number of maximum clients.

Existing uses of the `sv_max_clients` config variable, except for the `CNetServer` initialization, are replaced with `MaxClients()`. The config variable `sv_max_clients` is now marked as read-only after reading the initial config and command line argument, so changing it via the remote console is not possible and shows an error message. The unnecessary conchain for `sv_max_clients` is removed.
2024-07-15 14:37:11 +02:00
Robert Müller 325e22d2de Fix crashes with dbg_dummies and sv_max_clients
Use the real number of maximum clients returned by the `MaxClients()` function instead of the `MAX_CLIENTS` constant to calculate the debug dummy client IDs to fix a crash when `sv_max_clients` is below `MAX_CLIENTS`.

Ensure the `dbg_dummies` value does not exceed the maximum number of clients.
2024-07-15 14:36:50 +02:00
Dennis Felsing b0f0292fc9
Merge pull request #8588 from Robyt3/Snapshot-Usage-Cleanup
Simplify usage of `IClient::SnapGetItem` function, remove unnecessary `IClient::SnapGetItem` function
2024-07-14 12:49:07 +00:00
Learath ebd266c419 Reset and regenerate m_aPeerAddrStr appropriately
Hopefully fixes #8587
2024-07-14 14:11:19 +02:00
Robert Müller 2f6c3abc90 Remove unnecessary IClient::SnapItemSize function
The item data size is already returned by the `IClient::SnapGetItem` function and getting only the size is not currently useful, so the additional `IClient::SnapItemSize` function is unnecessary.
2024-07-14 13:18:30 +02:00
Robert Müller e9646ba157 Simplify usage of IClient::SnapGetItem function
Let the `IClient::SnapGetItem` function return an `IClient::CSnapItem` directly instead of passing it as a pointer. Add the item data pointer as a member variable to `IClient::CSnapItem` instead of returning it separately. Therefore, the separate data pointer of the class `CSnapEntities` is also not necessary anymore.

Consistently mark the snapshot items and data as `const`. The C-style cast to `void *` in the `IClient::SnapGetItem` function was previously implicitly casting away the `const` of the snapshot pointers.
2024-07-14 13:15:44 +02:00
Robert Müller a31d6a571a Cleanup snapshot member variables in demo_extract_chat tool
Using `CSnapshotStorage::CHolder`s in the `demo_extract_chat` tool is not necessary, as only the member variable `m_pAltSnap` is being used in this tool. The regular snapshot data was copied into `m_pSnap` but never read. The other member variables were initialized but never read.
2024-07-13 22:51:31 +02:00
Robert Müller e277131cf8 Fix incorrect scoreboard size if blue team used without teams flag
When `GAMEFLAG_TEAMS` is not set, only the players of the red team are rendered in the scoreboard, but the size of the scoreboard was incorrectly calculated based on the size of the larger team (red or blue), which should only be done when `GAMEFLAG_TEAMS` is set.
2024-07-12 21:44:16 +02:00
Robert Müller 7cbfe1623d Avoid duplicate distance calculation
Add variable `NewVelLength` to avoid calculating `length(NewVel)` twice.
2024-07-11 18:02:51 +02:00
Robert Müller 660c1de8f2 Remove unnecessary use of this
The same variable `m_HookHitDisabled` is also being accessed without `this`.
2024-07-11 18:02:24 +02:00
Robert Müller 998adfcefc Remove redundant distance checks
The check `Distance > 0.0f` is redundant because the same check already exists in the outer if-statement and the variable `Distance` is never modified.

The check `D >= 0.0f` is redundant because mathematically any distance is greater or equal to zero.
2024-07-11 17:54:51 +02:00
Robert Müller aeee2f561d Remove dead code and obsolete TODO
It seems unlikely we that would want to introduce a variable to tweak the hook behavior at this point, so the TODO is removed.
2024-07-11 17:54:41 +02:00
Robert Müller 8e83049054
Merge pull request #8352 from ChillerDragon/pr_multi_cmd_helptext
Show help text when chaining multiple commands
2024-07-10 16:46:47 +00:00
Dennis Felsing 108d0dc715 Make FillAntibot faster 2024-07-10 15:06:16 +02:00
Learath 7fa0ef56f3 Include port 2024-07-09 20:27:40 +02:00
Learath 3cb390c6e6 net_addr_str only once 2024-07-09 20:17:34 +02:00
Robert Müller 350a57df60 Fix multiple redirected clients not dropped in the same tick
Closes #8551.
2024-07-09 18:10:42 +02:00
ChillerDragon 7b540ddb16 Remove support for space separation 2024-07-09 08:30:59 +08:00
Dennis Felsing 9143f2eac7
Merge pull request #8571 from Robyt3/Tools-Map-Extract-Refactoring
Improve `map_extract` tool: fix crash when opus file cannot be opened, improve logging, refactoring
2024-07-08 21:44:05 +00:00
Robert Müller 526251293c Use static_cast and const pointers for map items 2024-07-08 22:21:51 +02:00
Robert Müller 4c702395db Split map_extract tool into separate functions
Improve readability by splitting the `map_extract` tool into multiple functions.
2024-07-08 22:21:28 +02:00
Robert Müller b81ac61556 Unload image and sound data in map_extract tool sooner
Reduce the memory footprint of the tool by unloading the map data as soon as possible instead of only implicitly when the `CDataFileReader` is destructed.
2024-07-08 22:21:14 +02:00
Robert Müller c9467454d3 Improve logging of map_extract tool
Use `log_info` and `log_error` instead of `dbg_msg`.

Add error messages when output files cannot be opened for writing.

Move log messages regarding files being written so they are only printed when the files are actually being written.
2024-07-08 22:20:57 +02:00
Robert Müller 4c4b2e9edc Fix map_extract tool crashing if opus file cannot be opened 2024-07-08 22:20:51 +02:00
Robert Müller 1b4e8ce3d3
Merge pull request #8553 from art0007i/test
add "/setjumps" practice command and "setjumps" rcon command
2024-07-07 15:07:28 +00:00
art0007i 03f934c81e add "/setjumps" practice command and "setjumps" rcon command 2024-07-07 16:43:02 +02:00
Robert Müller dc73da4514
Merge pull request #8497 from archimede67/teamcount-sb
Add team size indicator
2024-07-07 10:30:28 +00:00
Corantin H 816c64235c Add team size indicator in scoreboard and through /team 2024-07-07 11:26:01 +02:00
Corantin H 698603d63c Fix various automapper issues
Fix invalid logic for skipping empty tiles in automapper
Fix partial default rule search
Fix reading from wrong layer when proceeding
2024-07-06 16:22:48 +02:00
Robert Müller 60ab717f03
Merge pull request #8564 from ChillerDragon/pr_clang_editor
Fix some clang warnings in the editor
2024-07-06 10:51:04 +00:00
ChillerDragon d6cf127056 Fix some clang warnings in the editor 2024-07-06 17:53:10 +08:00
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