Commit graph

5417 commits

Author SHA1 Message Date
heinrich5991 77054c1134 Use Client()->PlayerName() for copied server info
Fixes #8554.

Alternative to #8555.
2024-07-03 14:22:15 +02:00
Dennis Felsing a0da2d0978 Support new UPNP API
See c0a50ce33e
2024-07-02 00:32:46 +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 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 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 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 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 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
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
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 24d12e4820 Consistently use str_copy instead of mem_copy for strings 2024-06-01 13:55:20 +02: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 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 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
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
Robert Müller dfae99da76 Fix unused variable Silent in client.cpp on Android 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
heinrich5991 392fc0ba9a str_from_intstr_format 2024-05-14 21:37:02 +02:00
ChillerDragon f3a686bc62 Show percentage of loaded rcon commands
closed #7769
2024-05-14 08:46:17 +08: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 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
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
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
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
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
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
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
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
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 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 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
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
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
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 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
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
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
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 29f6cc67db Add delta debug dump 2024-04-25 08:44:49 +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
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