Commit graph

15529 commits

Author SHA1 Message Date
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
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