Commit graph

15006 commits

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