Commit graph

5504 commits

Author SHA1 Message Date
Robert Müller dd44c6cd4d Minor improvement of dummy config variable descriptions 2024-01-28 20:12:22 +01:00
Learath 31b3ac71c2 Fix client/server updates 2024-01-28 19:34:30 +01:00
Dennis Felsing d60852a020
Merge pull request #7868 from Learath2/dd_pr_updater
Fix updater issue. Close #7867
2024-01-28 12:37:42 +00:00
Learath 2470e7489d Fix updater issue. Close #7867 2024-01-28 12:50:54 +01:00
heinrich5991 dcdc66d1df
Merge pull request #7869 from furo321/testcmds-error
Add a error message for when testing commands aren't allowed
2024-01-27 17:59:51 +00:00
furo 633330bcd8 Add a error message for when testing commands aren't allowed 2024-01-27 18:18:32 +01:00
Robert Müller 5d7f2c6e1b Show error messages in console when add_demomarker fails
When there are too many demo markers already or when the previous demo marker is too close.
2024-01-27 13:26:08 +01:00
Robert Müller d5c7488480 Ensure client window is maximized and active after restarting
Add parameter to `shell_execute` to either start the process in the foreground or background on Windows. Previously, all processes were started in the background, because this is desired when starting the server from the client. However, this causes the graphics initialization to fail when restarting the client after updating or with the `restart` command when using Vulkan with windowed and windowed fullscreen mode.

Closes #6578.
2024-01-25 20:52:17 +01:00
Robert Müller c4d512d86e
Merge pull request #7687 from archimede67/editor-better-map-settings
Editor: better map settings input (autocomplete, validation)
2024-01-24 18:17:19 +00:00
Corantin H 0cd002e08c Various fixes to map settings handling 2024-01-23 20:15:30 +01:00
Corantin H aca398f3c9 Added dialog to fix invalid map settings on load 2024-01-23 20:13:57 +01:00
Corantin H 9cc8a28305 Better map settings input (autocomplete, validation) 2024-01-23 20:13:56 +01:00
Robert Müller 9c66a6a147 Remove unused parameter of SetWindowParams function
The `bool AllowResizing` parameter is only passed to other `SetWindowParams` functions but never used in the end, as whether or not resizing is allowed is separately determined based on the value of the `int FullscreenMode` parameter.
2024-01-23 17:49:55 +01:00
Robert Müller 797db31aa1 Fix countries/types filters excluding all servers
Instead of cleaning the countries/types filters based on all available communities' countries/types, only consider the countries/types of currently selected communities. Ensure countries/types are always cleaned when updating the server browser filter in the UI. This fixes that countries/types which are not available for the selected communities were still affecting the server filtering, causing no servers to be shown in some cases.

Closes #7847.
2024-01-22 22:30:15 +01:00
Samuele Radici 79cf3b4e17
Update config_variables.h
text error
2024-01-22 01:33:44 +01:00
Dennis Felsing fca6e0abe3
Merge pull request #7837 from Robyt3/Demo-Recorder-Improvements
Refactor demo recorder usage
2024-01-21 22:39:46 +00:00
Alexander Akulich d0f5ced546 Make http states a enum class and use it across the codebase 2024-01-22 01:06:59 +03:00
Robert Müller 9150f48562 Refactor demo recorder usage
To simplify the usage of the demo recorder, parameters are added to the `IDemoRecorder::Stop` function to control whether the demo file is removed or renamed when stopping the recording.

Ensure demo files of the replay recorder are always removed (except on crashes). The temporary replay demos were previously not removed when being disconnected from a server.

Fix auto demos being stopped and restarted when enabling replays in the settings menu. Now only the replay recorder is stopped/started when necessary.

Fix replay recorder being restarted when setting `cl_replay` variable with console without changing the value.

Remove unnecessary `CClient::m_ButtonRender` variable. Demo rendering is already stopped correctly when reaching the end of the demo without this additional variable.

Remove unused `CDemoRecorder::m_pMapData` variable.
2024-01-21 22:21:56 +01:00
Robert Müller b89e4e8770 Finish CHttpRequest::OnCompletion before updating State()
Ensure that the `CHttpRequest::OnCompletion` function has finished before updating the state which is visible to other threads. Otherwise, threads may try to access the result of a completed HTTP request, before the result has been initialized/updated in the `OnCompletion` function.

Fixes warning due to invalid texture width/height being shown for downloaded skins, because the texture was loaded before the image data was initialized. Closes #7818.

Regression from #7683. Before this, the `OnCompletion` function could also modify the HTTP request's state, which was used to check if loading the skin PNG failed. Instead of doing this, a separate check is added for the skin download task to check that the PNG was loaded successfully.
2024-01-21 14:53:33 +01:00
ChillerDragon e59c9a6450 Only log http requests if `dbg_curl 1`
closed #7823
2024-01-19 12:38:53 +08:00
Robert Müller 4be76f0d08 Add time scale to debug graphs for constant scrolling speed
Store X value (time) for all graph entries in addition to the Y value (FPS, prediction margin etc.). The `CGraph::Add` function adds values to the graph at the current time. The `CGraph::InsertAt` function allows specifying arbitrary X values, as long as the values are inserted in increasing order.

The entries are kept in a ringbuffer and old entries are recycled when it's full. The size of the ringbuffer is configurable for each graph, as the FPS graph needs significantly more buffer because values are added more often.

The scrolling speed of the graphs is fixed by specifying the maximum size of the window of values which should be displayed. For this purpose, a parameter is added to the `CGraph::Scale` function to specify the size of the window which should be rendered in the `CGraph::Render` function. For the FPS graph only the last second is rendered, so small spikes are still noticeable. For prediction and gametime margin graphs the last five seconds are rendered, which should result in a similar scrolling speed as before this change. The debug tuning graph is a special case, where the X values set manually and fixed to 0-127, same as before, instead of being based on the current time.

The graph rendering is made much more efficient by precalculating when the vertex colors need to be updated, to avoid all unnecessary calls to `SetColorVertex`. Additionally, line items are bundled together in an array to avoid calling `LinesDraw` for every individual line item.
2024-01-17 20:43:19 +01:00
Robert Müller c90a52f51c Add CDynamicRingBuffer to avoid specifying size as template 2024-01-17 18:17:08 +01:00
heinrich5991 626b7ca805
Merge pull request #7795 from Robyt3/Menus-Browser-Tab-Icons
Use icons for Internet, LAN and Favorites server browser tabs, use star icon for favorite servers
2024-01-17 13:56:59 +00:00
Robert Müller 0512e65dbe Fix warning title being uninitialized in some cases
For some warnings a random title instead of the default title was shown because it was not initialized.
2024-01-16 20:12:25 +01:00
heinrich5991 bb3bd57c0e
Merge pull request #7683 from Learath2/dd_pr_curlmultifinal
Use curl-multi. Supersedes #5842
2024-01-15 21:54:24 +00:00
Learath2 f5910343e2 Fix CI 2024-01-14 15:37:44 +03:00
Dennis Felsing 8dee975d66
Merge pull request #7744 from Robyt3/Editor-Color-Palette-Pipette
Add color palette and pipette to editor
2024-01-13 22:55:16 +00:00
Robert Müller a873485643 Fix multi-line text selection not rendered correctly anymore
The `CTextCursor::m_LineCount` variable is only updated after the cursor is rendered. For calculating the selection quads we need to check `LineCount` instead, which is updated while the cursor is being rendered. Regression from #7733.
2024-01-13 23:21:13 +01:00
Learath2 bcf86d81f3 Fix CRegister 2024-01-13 15:28:53 +03:00
Robert Müller 89802396a7 Use icons for Internet, LAN and Favorites server browser tabs
Free up space for up to three more server browser tabs of the same size (on 5:4 resolutions), i.e. tabs for configurable communities.

Remove the additional server browser icon tab on the right side. Remove the purely visual Demo and News tabs which were only shown when the respective page is already active. Instead, always show all server browser tabs when offline.
2024-01-13 12:47:11 +01:00
Learath2 6eb51239c9 Fix some clang-tidy issues and UB 2024-01-12 23:27:49 +03:00
Learath2 32e968335b Fix lots of weirdness in updater 2024-01-12 23:19:47 +03:00
Robert Müller 5e510cdbf4 Include limits instead of climits
Consistently use `std::numeric_limits` instead of `INT_MIN` and `INT_MAX`.
2024-01-11 22:24:37 +01:00
Robert Müller 3eeba01578 Remove duplicate cleanup when connecting
The `IClient::Disconnect` function is always called at the beginning of the `IClient::Connect` function. The `IClient::Disconnect` function calls `IClient::DisconnectWithReason`, if the client is not already offline, which performs cleanup of temporary commands and demo recorders already, so the same cleanup in the `Connect` function is unnecessary. An assertion is added to ensure that the client was properly disconnected before connecting. Connecting while the client is already quitting or restarting is now prevented, as the client state cannot be changed once set to quitting or restarting.
2024-01-10 21:48:09 +01:00
heinrich5991 035cb6eab8
Merge pull request #7784 from ChillerDragon/pr_256_welcome
Increase sv_welcome to 256
2024-01-10 16:57:59 +00:00
ChillerDragon 21f6af9d38 Increase sv_welcome to 256 2024-01-10 17:39:24 +01:00
Robert Müller 80a52cae95 Avoid including zlib.h in header file
By adding `CDataFileWriter::ECompressionLevel` to replace usage of zlib internal compression levels in the `CDataFileWriter` API.

Use `std::numeric_limits<int>::max()` instead of `INT_MAX` in one case where the latter was only declared by the transitive zlib include. The `limits` header is already included and its use is more fitting for C++ code.
2024-01-09 19:36:41 +01:00
Dennis Felsing 0dc9495e80
Merge pull request #7781 from HiRavie/master
Improve text outlines
2024-01-09 10:58:08 +00:00
heinrich5991 9de11a5ecd
Merge pull request #7780 from Robyt3/Serverbrowser-Community-Update-Fix
Fix community not set for servers with missing server info
2024-01-08 21:26:34 +00:00
Robert Müller 6bdc73ad3d Fix community not set for servers with missing server info
The server community was only initialized when receiving server info. This caused servers for which no server info is received to be hidden when using the community filter. Now the community filter also works correctly for servers for which no ordinary server info is received, by initializing the community already when adding server entries to the list.

Closes #7776.
2024-01-08 22:07:24 +01:00
Ravie 2e44c02bbc Improve text outlines 2024-01-08 21:52:14 +01:00
Learath2 9b3ebf3f1b Remove debug statement, fix CI 2024-01-07 17:48:48 +03:00
Robert Müller a80d875e85 Improve error log messages when saving settings fails
Log separate messages for `io_sync` error, `io_close` error and general write errors.
2024-01-07 12:24:07 +01:00
Robert Müller 43b1e5cb1f Improve warning popup message when saving settings fails
The message was previously showing an incorrect filename.
2024-01-07 12:23:58 +01:00
Robert Müller 999119c60f Propagate unknown UUID-based map items in map tools
Adapt the `CDataFileReader::GetItem` function so it optionally also returns a `CUuid` for UUID-based map items, including for items with unknown UUIDs where the item type will be `-1`. Adapt the `CDataFileWriter::AddItem` function so it optionally also accepts a `CUuid` which will be used if the item type is `-1`.

The additional checks for invalid map item types in the map tools are removed again and instead the new UUID parameters are used so map items with unknown UUIDs are written back to maps correctly.

Closes #7701.
2024-01-06 21:25:15 +01:00
heinrich5991 c12835bc39 Group NETMSG_RCON_CMD_ADD 2024-01-05 18:10:57 +01:00
Dennis Felsing ca9c4f532a
Merge pull request #7757 from Robyt3/Graphics-LoadTexture-Move
Avoid copying texture memory when possible
2024-01-04 11:32:42 +00:00
Dennis Felsing 4f89a4d3fd
Merge pull request #7749 from archimede67/editor-fix-autosave-crash
Fix crash on editor autosave, add system method `timestamp_from_str`
2024-01-04 11:17:08 +00:00
Robert Müller abc7b602b2 Avoid copying texture memory when possible
Add separate `IGraphics::LoadTextureRawMove` function with non-`const` `void *pData` argument in addition to existing `LoadTextureRaw` function with `const void *pData` argument. The former function takes ownership of the data and avoids copying the texture data into an additional buffer, if the texture data is already in RGBA format. Non-RGBA texture data always needs to be converted and therefore also copied.

The `LoadTextureRaw` function is split into smaller functions to share common code with the `LoadTextureRawMove` function. Alternatively to this, a flag `TEXLOAD_MOVE_DATA` could have been added to the existing `LoadTextureRaw` function, which would have required the use of `const_cast` to free the texture data.
2024-01-03 23:03:04 +01:00
Corantin H 3c9294321e Fix crash on editor autosave
Add system method `timestamp_from_str` and add tests.
Replace `int64_t` with `time_t` to be more consistent.
2024-01-02 23:38:41 +01:00
Robert Müller e27bf7b6c1 Fix crash in assertion handler after client/graphics destroyed
Unset the assertion handler before shutting down the kernel (including graphics) and client. Otherwise the assertion handler itself crashes when assertion errors happen after the graphics/client have been destroyed.
2024-01-02 19:20:57 +01:00
Dennis Felsing 3defe8eb0e
Merge pull request #7703 from BlaiZephyr/fix-cmake-warning
change cast of pointer to uintptr_t
2023-12-30 23:11:53 +00:00
melon 5d35cd8a66 change cast of pointer to uintptr-t 2023-12-30 22:54:47 +01:00
Robert Müller f5e7fa24d6 Add color palette and pipette to editor
Add color palette with up to 8 colors to editor toolbar. The palette colors work like regular color picker buttons, so they open a color picker popup on click and the value can be copied and pasted with Ctrl+Right click and Ctrl+Left click respectively. Less palette colors are shown when not enough space is available (with 5:4 resolutions).

Add color pipette which allows selecting any color displayed on the screen. Selecting a color with the pipette adds the new color to the palette and shifts the other colors to the right. The selected color is also copied to the clipboard immediately. The hotkey Ctrl+Shift+C is added to toggle the color pipette, which allows using the color pipette in popups and dialogs.

The implement this, the function `IGraphics::ReadPixel` and the command `SCommand_TrySwapAndReadPixel` are added to read a specified pixel's color from the backbuffer. Like the screenshot command, this command also requires a swap operation to be performed before the correct pixel color can be read with the Vulkan backend. The `ReadPixel` function therefore accepts a pointer to a `ColorRGBA` that will be filled after the next swap operation.

Closes #7430.
2023-12-30 13:17:30 +01:00
Robert Müller 661339cc64 Optimize allocation of sound sample indices
Replace linear search for free sample index with free list. This brings sound sample index allocation down to constant complexity independent of the number of allocated sounds. On average the time to allocate sound samples is reduced by around 75% (843µs down to 223µs). For perspective, the time to load all default sounds on client launch is reduced by around 15ms (although this does not significantly affect launch time due to threaded loading).
2023-12-29 13:07:04 +01:00
Robert Müller 87191a380e Use sound lock when setting/getting current time of sample
The lock needs to be owned when accessing the sound voices. Calling `IsPlaying` is redundant, as the loops effectively check whether the sample is playing.
2023-12-29 12:35:45 +01:00
Robert Müller 7a84a746e0 Add CSample::TotalTime function 2023-12-29 12:25:39 +01:00
Dennis Felsing 0f1171a501
Merge pull request #7741 from furo321/translate-racefinish
Use 0.7 translation layer for `Sv_RaceFinish` netmessage.
2023-12-29 08:00:19 +00:00
furo 1a94aa6d8a Use 0.7 translation layer for Sv_RaceFinish netmessage. 2023-12-29 08:33:36 +01:00
Robert Müller c9640459e4 Improve editor toolbar anim and grid buttons, add dropdowns
Add dropdown menus for changing animation and grid settings (i.e. animation speed and grid size) instead of conditionally showing more buttons for this directly in the menu bar. This frees up space in the menu bar, which is currently full on 5:4 resolutions.

The icons previously used for the default animation/grid buttons are now used for the main buttons that toggle animation/grid instead of using text.

Support setting lower animation speeds with the plus and minus buttons by adjusting the step size when the animation speed is low.

Support setting arbitrary animation speed by text input.
2023-12-28 17:43:09 +01:00
Robert Müller 72019df288 More efficient text selection rendering
Render one quad for each line of the text selection instead of rendering one quad per selected character.

This increases the average FPS when the console is open and all text is selected by around 10% (from around 849 to around 943 FPS) (on my machine, in release mode).
2023-12-27 21:07:25 +01:00
Robert Müller 32373c0559 Fix color rendering being inconsistent with displayed color values
When normalizing color components in the engine graphics, round the components to the nearest integer instead of rounding down. Otherwise the color that is rendered in color pickers may be off by 1 in any of its RGB components from the color that the color picker displays as text (hex string and individual components). The slightly incorrect color can be confirmed by creating a screenshot or otherwise reading the backbuffer (planned editor pipette feature).

This should not change map rendering, since maps already store quantized RGBA values on which the rounding mode should have no effect. It may however slightly change appearance of colors in all other places (at most +1 in every RGB component).
2023-12-27 13:49:55 +01:00
Robert Müller 0a0e066535 Remove unused FlipImgData parameter from Vulkan backend
The parameter is always set to `false` so the code is unused.
2023-12-26 17:34:02 +01:00
Robert Müller c3689cd9b4 Remove unused VkBufferImageCopy Region variable
According to the Vulkan specification, the struct `VkBufferImageCopy` is used only for `vkCmdCopyBufferToImage` and `vkCmdCopyImageToBuffer`. The variable `Region` is only initialized but not passed to either of those functions.
2023-12-26 14:06:24 +01:00
Dennis Felsing a9c316055f
Merge pull request #7712 from furo321/rework-cfilecollection
Rework `CFileCollection`.
2023-12-26 08:02:40 +00:00
Dennis Felsing f12f789c3a
Merge pull request #7709 from furo321/server-demos-fixes
A few fixes and improvements to server-side auto demos.
2023-12-26 07:58:30 +00:00
furo 5b5ead8356 Rework CFileCollection.
- Use existing functions from `system.h`
- Use sorting from `<algorithm>`
- Don't recall `ListDirectory` for every removal, which caused the client to hang previously with a lot of files.
2023-12-26 03:31:06 +01:00
Robert Müller 4c223a0002 Improve text line spacing and console text selection
Consider line spacing to belong to the previous line when calculating and rendering text selection. Instead of handling spacing between entries separately in the console, also include line spacing for the last line in the height calculation. Pixel align the line spacing in addition to the font size, as previously some gaps between the entries were larger than others due to missing pixel alignment. This allows rendering the text selection in the console smoothly without any gaps between the console entries/lines.

Closes #7617.
2023-12-25 19:11:42 +01:00
furo b1f9137e34 Change path to demos/auto/server. Use same filename format as client. 2023-12-25 17:31:25 +01:00
furo 1c098c2941 Don't use the same demo recorder for auto and manual demos. 2023-12-25 17:29:39 +01:00
Robert Müller c31f82a9e9 Refactor graphics SetColor functions
Reduce duplicate code.

Replace `clampf` function with `NormalizeColorComponent` function that convert color component from `float` to `unsigned char`.

Use `size_t` instead of `int`.
2023-12-23 17:56:52 +01:00
Robert Müller 45ced1f499 Avoid duplicate calculation in QuadsTex3DDrawTL
Only calculate `CurIndex` value once outside of loop instead of calculating it every iteration.
2023-12-21 22:04:40 +01:00
Edgar 2b344f4a01
Merge pull request #7647 from Robyt3/Server-Votes-Config-Improvement
Improve vote config variable descriptions and value range
2023-12-20 10:41:17 +00:00
Learath 1f224344ec Format and bump fake curl 2023-12-18 23:02:00 +01:00
Learath d847b0f60c Fix double request, fix merge error 2023-12-18 22:42:25 +01:00
Learath 1dc8496470 Use curl-multi 2023-12-18 20:06:43 +01:00
Dennis Felsing 173345df74
Merge pull request #7673 from Jupeyy/pr_fix_ms_sample_accuracy
Fix multi sampling accuracy
2023-12-18 07:52:17 +00:00
Jupeyy caecb31751 Fix multi sampling accuracy 2023-12-17 10:39:28 +01:00
Dennis Felsing e689441d14
Merge pull request #7668 from Robyt3/Engine-Notifications-Interface
Add `INotifications` kernel interface
2023-12-16 23:17:18 +00:00
Dennis Felsing 0ce8413570
Merge pull request #7671 from Robyt3/Server-Config-Flags-Cleanup
Remove `CFGFLAG_SAVE` when `CFGFLAG_SERVER` used
2023-12-16 23:16:51 +00:00
Robert Müller eb222ae02a Remove CFGFLAG_SAVE when CFGFLAG_SERVER used
Server variables are currently not saved.
2023-12-16 21:21:03 +01:00
Robert Müller 5f9d6b208c
Merge pull request #7667 from furo321/rest-of-string
Use rest of string parameter for `save_replay`
2023-12-16 18:39:04 +00:00
furo d2efc936cf Use rest of string parameter for save_replay 2023-12-16 19:02:56 +01:00
Robert Müller 013b8dffa5 Add INotifications kernel interface
Add a proper kernel interface `INotifications` for the notifications component instead of using a C style interface.

Add parameter for the application name when initializing notifications to avoid hardcoding the application name.

The implementation for macOS is kept in Objective-C and a TODO is added, as the API we are currently using appears to be deprecated.
2023-12-16 18:15:43 +01:00
Robert Müller b067ccafc6 Improve vote config variable descriptions and value range
Closes #7584.
2023-12-16 18:01:06 +01:00
archimede67 5dbd5a1f49 Added quad alignment/snapping to other quads/points 2023-12-16 01:29:09 +01:00
Edgar 8be0ba3a84
Merge pull request #7655 from def-/pr-discord-build
Fix discord build
2023-12-15 09:32:28 +00:00
Edgar 726ffe35d0
Merge pull request #7654 from def-/pr-curlopt-share
Disable CURL_LOCK_DATA_CONNECT (fixes #7636)
2023-12-15 09:26:34 +00:00
Dennis Felsing 255cf408cd Fix discord build
/home/deen/isos/ddnet/ddnet-source/src/engine/client/discord.cpp: In member function ‘bool CDiscord::Init(FDiscordCreate)’:
/home/deen/isos/ddnet/ddnet-source/src/engine/client/discord.cpp:39:17: error: ‘mem_zero’ was not declared in this scope
   39 |                 mem_zero(&m_ActivityEvents, sizeof(m_ActivityEvents));
      |                 ^~~~~~~~
2023-12-15 00:55:26 +01:00
Dennis Felsing 5ff8697be1 Disable CURL_LOCK_DATA_CONNECT (fixes #7636) 2023-12-15 00:51:02 +01:00
Robert Müller 6a12e209b6 Fix readability-make-member-function-const 2023-12-14 23:38:03 +01:00
Corantin H af77ebac54 Added console search function 2023-12-14 21:58:27 +01:00
BlaiZephyr 6521344eca changed GFX → Gfx 2023-12-13 15:46:49 +01:00
Robert Müller 187120dd31 Ensure network log files are closed when shutting down engine
Previously, the network log files were not explicitly closed unless the `dbg_lognetwork` command is used again manually.
2023-12-12 20:00:52 +01:00
Robert Müller 10b486a6b0 Remove unnecessary use of GetCompletePath
The result `aFullPath` is unused.
2023-12-12 20:00:48 +01:00
heinrich5991 be53d83019 Remove #include <system.h> from one more header 2023-12-12 00:44:46 +01:00
Dennis Felsing 7813cfed6c
Merge pull request #7618 from heinrich5991/pr_ddnet_less_system_h
Make less headers depend on `<base/system.h>`
2023-12-11 23:08:59 +00:00
heinrich5991 05af24a052 Make less headers depend on <base/system.h>
Move a couple of trivial type definitions to `<base/types.h>` instead.
2023-12-11 23:52:23 +01:00
Robert Müller 140fcea667 Avoid using console to reset game settings
Prevent potential dead lock when using `/map` chat command in combination with Teehistorian. Closes #7619. I could not reproduce the issue on Windows though.

This also means resetting game settings should actually be efficient now, because it only involves iterating over all game settings and directly resetting their value.
2023-12-10 11:23:20 +01:00
Dennis Felsing addb3c6980
Merge pull request #7616 from Robyt3/Snapshot-Storage-Separate-Alloc
Separate snapshot storage holder and snap data allocations
2023-12-09 21:45:45 +00:00
Robert Müller 7ae7877248
Merge pull request #7593 from archimede67/console-scrolling
Add ability to scroll in console. Remove pages.
2023-12-09 18:26:32 +00:00
Robert Müller d3cc932a9b
Merge pull request #7393 from archimede67/editor-undo-redo-v2
Editor undo/redo v2
2023-12-09 18:17:38 +00:00
Robert Müller efc451324d Separate snapshot storage holder and snap data allocations
Previously, only one buffer was allocated to store each snapshot holder structure, the snapshot data and alternative snapshot data. This prevents tools like ASAN from detecting some invalid accesses, e.g. to the snapshot holder structure by underflowing the snapshot data pointer. Now three separate allocations are used instead. This hopefully helps debugging #2677.
2023-12-09 19:03:07 +01:00
furo e0b51c2aec Add ability to scroll in console. Remove pages. 2023-12-09 12:20:43 +01:00
heinrich5991 0c33be1692
Merge pull request #7604 from Robyt3/Endianness-Check
Add compile time errors for unsupported endianness
2023-12-08 16:13:17 +00:00
Robert Müller 30df38f926 Add compile time errors for unsupported endianness
We support little and big endian but not PDP endian (Middle-endian).

Define endianness as string `CONF_ARCH_ENDIAN_STRING` to avoid conditional compilation when printing endianness.
2023-12-08 16:57:01 +01:00
Robert Müller 6b547b1388 Fix incorrect map being loaded/downloaded
The `LoadMapSearch` function returns an error message or `nullptr` on success but the condition was incorrectly changed in #7580 so the opposite was checked instead.

Closes #7597.
2023-12-07 17:46:58 +01:00
heinrich5991 f52aa8a61c
Merge pull request #7592 from Robyt3/Protocol-VoteTime-Fix
Fix votes with timeout over 60 seconds not being shown in client
2023-12-05 19:34:41 +00:00
Robert Müller b738f5f9ce Fix votes with timeout over 60 seconds not being shown in client
Setting a vote timeout longer than 60 seconds with `sv_vote_time` caused the vote network messages to be discarded with the error message `weird message 'Sv_VoteSet' (15), failed on 'm_Timeout'` by the client, as the protocol did not allow longer vote timeouts.

This changes the protocol so the vote timeout can be any positive integer although for now the maximum `sv_vote_time` value is changed back to 60 again to preserve compatibility with old clients.

Closes #7583.
2023-12-05 20:12:15 +01:00
heinrich5991 801274ac63
Merge pull request #7580 from Robyt3/Message-Unpack-Check
Add missing unpacker error checks for server and client packets
2023-12-05 19:01:33 +00:00
Robert Müller 4ad0a48a48 Add missing unpacker error checks for server and client packets
Ensure all packets are unpacked correctly before using the unpacked data.

Ensure strings are valid UTF-8 in `CUnpacker::GetString`.
2023-12-05 19:40:27 +01:00
heinrich5991 3607e8e0f2
Merge pull request #7581 from Robyt3/Snapshot-Refactoring
Various minor refactoring of snapshot-related code
2023-12-05 00:36:40 +00:00
heinrich5991 da6dbc9da8
Merge pull request #7582 from Robyt3/Kernel-Refactoring
Support arbitrary number of kernel interfaces, assert on errors
2023-12-05 00:34:33 +00:00
Corantin H 96e4c5f7cd Add editor undo/redo feature 2023-12-04 22:44:20 +01:00
Robert Müller 0c6978f553 Support arbitrary number of kernel interfaces, assert on errors
Support registering arbitrary number of interfaces with `IKernel` instead at most 32.

Assert when incorrect arguments are passed to `IKernel` functions instead of returning a `bool`, which was not being handled in all cases. These functions are not expected to fail expect on programming errors.

Consistently order and format creation and registration of kernel interfaces in client and server.
2023-12-04 18:11:47 +01:00
Robert Müller 0ff2c5b772 Use size_t and add assertions for CSnapshotStorage::Add 2023-12-04 17:59:40 +01:00
Robert Müller f5ed4159b7 Mark functions and pointers as const 2023-12-04 17:59:40 +01:00
Robert Müller 0472808561 Add assertions for CSnapshotDelta::SetStaticsize parameters 2023-12-04 17:59:40 +01:00
Robert Müller 8f9a44514f Remove unnecessary RangeCheck function 2023-12-04 17:59:39 +01:00
heinrich5991 a0d8c6c3c6 Reintroduce m_HaveGlobalTcpAddr
CC #7575
2023-12-04 02:52:48 +01:00
Robert Müller 93d669143d Use nullptr instead of 0 and 0x0 2023-12-03 12:15:22 +01:00
Robert Müller 026ddc3f3a Extract common expression in variable pSnapshot 2023-12-03 12:15:22 +01:00
Robert Müller d70fc84e38 Properly initialize all CClient member variables
Additionally, ensure snapshots are cleared and dummy is disconnected when disconnecting programatically with `DisconnectWithReason`.

Add `NETADDR_ZEROED` and `UUID_ZEROED` for more convenient initialization without using `mem_zero`.
2023-12-02 18:33:46 +01:00
furo d9a726eb48 Stop all recording of server demos on shutdown. 2023-12-02 11:10:20 +01:00
Dennis Felsing 01847457a9
Merge pull request #7571 from BurnyLlama/fix-demo-record
Added check if demo recorder is already active.
2023-12-01 23:01:04 +00:00
Dennis Felsing d452372b13
Merge pull request #7567 from Robyt3/Windows-Ignore-Invalid-UTF16
Check for invalid unicode in filenames etc. on Windows
2023-12-01 23:00:00 +00:00
BurnyLlama 0e684e10d2 Added check if demo recorder is already active. Closes #7568. 2023-12-01 23:06:13 +01:00
Emir Marincic eba86204db
Merge pull request #7552 from Robyt3/Config-Refactoring
Refactor config manager, move config variable handling
2023-12-01 19:34:44 +00:00
Robert Müller 8b589f3c49 Check for invalid unicode in filenames etc. on Windows
Add stricter error handling when converting between UTF-16 (wide characters) and UTF-8 (multi-byte) on Windows.

The `windows_wide_to_utf8` function now returns an `std::optional`, which will be empty if the argument contains invalid UTF-16. Files/folders with names containing invalid UTF-16 are now ignored on Windows. It was previously not possible to use these files either, as converting their names to UTF-8 changed the invalid codepoints to unicode replacement characters.

The `windows_utf8_to_wide` function now fails with an assertion error if the argument contains invalid UTF-8, as this should never happen.

Closes #7486.
2023-12-01 20:27:03 +01:00
heinrich5991 21cfb01ec3
Merge pull request #7515 from furo321/racefinish-message
Add finish info messages from 0.7
2023-12-01 16:13:06 +00:00
Robert Müller 1d7c0fad49 Check SHA256 of downloaded maps and community icons
Add `CHttpRequest::ExpectSha256` function to specify expected SHA256 for HTTP downloads. If the download completes with a different SHA256 hash than expected, then the download fails and the file is deleted.

Closes #7485.
2023-11-30 21:31:48 +01:00
Robert Müller 159ddf5534 Refactor config manager, move config variable handling
Move all code for handling of config variables from console to config manager. The console no longer depends on the config manager, instead the config manager now depends on the console.

Add `struct`s to manage config variables of different types (int, color and string). The config manager now keeps a list of all config variables, so usage of the preprocessor can be avoided except for code to initially create all config variables. Additionally, a separate list of just the game config variables (config variables with `CFGFLAG_GAME`) is kept to optimize the `ResetGameSettings` function, as this function is called whenever connecting to a server and should be fast. Previously, this function was even less efficient because it preformed a linear search for every individual game config variable to find the respective command data.

Move console commands that opperate only on config variables (`reset`, `toggle` and `+toggle`) to config manager. Ensure that these commands only opperate on the desired config variables (client or server, respectively) by checking `IConsole::FlagMask`.

Add `IConfigManager::SetReadOnly` function to set/unset config variables as read-only instead of manually overriding the command handlers for the `sv_rescue` and `sv_test_cmds` config variables. This also fixes that read-only config variables could still be changed by using the `reset` command. A console message is now printed when trying to change a read-only config variable. Removing the special handling for these two config variables is additionally useful so the console does not need to keep a pointer to config values and manager.

Use a `CHeap` for the config variables, their help texts and the previous values of string config variables to avoid many separate allocations as well usage of static variables. Also use the heap to store the unknown commands instead of using `std::string`s.

Properly trigger command chain when resetting config variables with the `reset` command and when resetting game settings on map loading. Closes #7461.

Format default value for color variables as RGB/RGBA hex with dollar sign prefix. Closes #5523.

Add log message when using `reset` with a variable that does not exist. Use `log_error` instead of `dbg_msg` when saving config file fails.

Support unlimited number of config save callbacks instead of at most 16. The code also becomes more readable by using an `std::vector` instead of a fixed-size array and a separate num variable.

Consistently name `MACRO_CONFIG_*` parameters when declaring the macros.

Add `IConsole::CMDLINE_LENGTH` constant to represent the maximum length of the console input and thereby reduce usage of magic numbers for buffer sizes.
2023-11-30 20:26:00 +01:00
Robert Müller 1c2903b0b4 Remove unused enum literal MAX_PRINT_CB 2023-11-29 20:42:23 +01:00
Robert Müller 5aa9003180 Remove unused ver parameter of MACRO_INTERFACE 2023-11-28 21:46:03 +01:00
furo eff6361c38 Add settings for info messages 2023-11-26 17:30:49 +01:00
Dennis Felsing c90899cc29
Merge pull request #7549 from Robyt3/Memheap-Refactoring
Refactor `CHeap`
2023-11-26 13:36:30 +00:00
Robert Müller 591c08cf34 Use static_casts instead of C style, remove unnecessary casts 2023-11-26 13:40:01 +01:00
Robert Müller 7a142df580 Move variable declarations closer to usages 2023-11-26 13:29:02 +01:00
Robert Müller ec6d7b48bf Use nullptr instead of 0x0 2023-11-26 13:20:56 +01:00
Robert Müller 41d2c80f21 Add templated CHeap::Allocate function
Add a templated `CHeap::Allocate` function to simplify memory allocation of objects using `CHeap`. The function uses perfect forwarding to construct objects with the specified arguments.
2023-11-26 13:09:23 +01:00
Corantin H fee9b986fb Added possibility to edit chat size and width. Refactored chat preview code. 2023-11-26 12:27:56 +01:00
Dennis Felsing 3e2f8f8a44
Merge pull request #7543 from Robyt3/Console-Interface-Cleanup
Minor refactoring of `IConsole`
2023-11-25 22:21:40 +00:00
Dennis Felsing 0601794801
Merge pull request #7547 from Robyt3/Server-Nameban-Clan
Also apply name bans to clans, trim space from clans, refactor name bans, move code to separate class `CNameBans`
2023-11-25 22:18:46 +00:00
Robert Müller 794e6b750b Also apply name bans to clans, trim space from clans
Apply the name bans system also to player clans, meaning players joining with banned clan names are kicked and changing the clan to a banned name while ingame has no effect.

Additionally, trim UTF-8 whitespace from beginning and end of clan. This was already done for player names but not for clans.

Closes #7516.
2023-11-25 23:00:57 +01:00
Robert Müller 8156052cc1 Refactor name bans, move code to separate class CNameBans
Unify all code for name bans in new class `CNameBans` in the existing `name_ban.cpp/h` files. The previously global function `IsNameBanned` is now the member function `CNameBans::IsBanned`. The existing name ban tests are extended for the `CNameBans` class.

Move `CNameBan` constructor definition to source file to avoid including `system.h` in the header file. Use `bool` instead of `int` for `m_IsSubstring`. Reorder `CNameBan` constructor arguments and remove unnecessary default value.
2023-11-25 22:28:54 +01:00
Robert Müller 42b952bc6c Move config variables to config_variables.h, remove variables.h
The contents of `variables.h` are moved to `config_variables.h` instead of being included with the preprocessor. The file `variables.h` is removed, so all config variables can be found in a single file instead of being spread over two files without any clear structure. The original declaration order of config variables is preserved. The unnecessary header guard `GAME_VARIABLES_H` from `variables.h` is removed, as the comment `// This file can be included several times.` already serves the same purpose of silencing the header guard check.

A comment is added at the end of `config_variables.h` to mark the location where modders should ideally declare all of their own config variables to avoid merge conflicts with us in the future.

Closes #7472.
2023-11-25 16:40:55 +01:00
Robert Müller e410dd85f8 Replace IConsole::m_Cheated variable with Cheated getter
Interfaces should not have member variables, so the variable is moved to `CConsole`. Only a getter `IConsole::Cheated` is added because the cheated state of the console is never reset.
2023-11-25 11:43:42 +01:00
Robert Müller c216567431 Add IConsole::FlagMask getter function
So other interfaces/components can check which console commands are active. In particular this will be used to refactor the config manager. The respective setter function already exists.
2023-11-25 11:42:56 +01:00
furo 9627e7b3a8 Simplify TickSpeed getters 2023-11-23 15:33:30 +01:00
furo b9fd612ef5 Replace 50 with SERVER_TICK_SPEED or TickSpeed() 2023-11-23 14:42:30 +01:00
Robert Müller 61c201c37c Fix string game settings not being reset correctly
Due to swapped `str_copy` arguments, the old value for string game variables was being overridden by the current value instead of the other way around in `CConsole::ResetGameSettings`.

There are currently no string game settings affected by this.
2023-11-22 23:16:57 +01:00
Robert Müller d331bcb496 Fix color game settings not being reset correctly
Handling color settings the same as int settings in `CConsole::ResetGameSettings` is not correct, as this causes the color variable data to be cast to int variable data.

There are currently no color game settings affected by this.
2023-11-22 23:12:56 +01:00
Robert Müller 48bfecc0d3 Ensure debug dummies are not included in server info
Also fix normal clients being disconnected/controlled like debug dummies.

Closes #7523.
2023-11-22 19:23:38 +01:00
heinrich5991 f95b0f163f
Merge pull request #7520 from Robyt3/Packer-Improvements
Minor improvements to `CPacker` and `CUnpacker`
2023-11-22 16:44:30 +00:00
Robert Müller ab4e737a57 Fix misaligned int loads in CUnpacker::GetUncompressedInt
Use `mem_copy` instead of dereferencing potentially misaligned address as `int`.
2023-11-21 21:57:06 +01:00
Robert Müller 51e3c37c03 Use mem_copy instead of for-loop in CPacker::AddRaw
Using `memcpy` is faster, assuming the compiler doesn't already transform the loop to `memcpy` automatically.
2023-11-21 21:49:29 +01:00
Robert Müller 0d8a0d3b1d Dynamically connect/disconnect debug dummies, cleanup
Call expected server callback functions to simulate clients dynamically connecting and disconnecting when changing the `dbg_dummies` variable. This makes the debug dummies more useful for debugging. Previously, the debug dummies were considered invalid clients, whereas they are now considered to be ingame, so they should behave mostly like real clients being connected to the server. The debug dummies also have correct client names now, e.g. "Debug dummy 42".

The game server code is cleaned up by moving all special handling for debug dummies to the engine server function `CServer::UpdateDebugDummies`.

The left/right direction inputs for debug dummies are now properly added to the client input array, so their input handling should be consistent with normal clients, which fixes some inconsistent prediction with debug dummies.
2023-11-21 19:59:20 +01:00
Dennis Felsing 35f071b021
Merge pull request #7513 from Robyt3/ImageLoader-Greyscale-Fix
Handle all color channel counts in image loader, refactoring
2023-11-20 21:55:00 +00:00
Robert Müller 29a32b7acc Use const char * instead of char const * consistently
Both are equivalent. Seems to already be used consistently for all other types.
2023-11-20 22:26:19 +01:00
Robert Müller bcae7da6b4 Handle all color channel counts in image loader
Greyscale images with alpha channel (i.e. channel count = 2) were incorrectly handled as RGBA images, causing the client to crash when loading such images. Now the images can successfully be loaded with the image loader, but the client still only supports loading RGB and RGBA images like before.
2023-11-20 21:58:29 +01:00
Robert Müller f0a17435e6 Ensure freed image buffer is not propagated
The image data is freed when the image format is unsupported, but `CImageInfo::m_pData` would still point to the freed memory, so double-frees were possible.
2023-11-20 21:58:29 +01:00
Robert Müller 82b75ddfe0 Improve error log messages for PNG loading 2023-11-20 21:58:29 +01:00
Robert Müller 0427dfff2e Use bool instead of int 2023-11-20 21:58:29 +01:00
Robert Müller 15e4f9a886 Remove remaining obsolete // ignore_convention comments 2023-11-20 21:58:29 +01:00
Dennis Felsing d11a271f45
Merge pull request #7506 from trml/pr_predmargin_simplify
Make prediction margin take effect instantanously
2023-11-19 21:56:40 +00:00
dobrykafe 904abae6ac replace sizeof x with sizeof(x) 2023-11-19 22:36:47 +01:00
trml 717aad2677 Make prediction margin take effect immediately 2023-11-19 19:52:39 +01:00
heinrich5991 b4567d6e25
Merge pull request #7502 from Robyt3/Browser-CommunityFilter-Fixes
Prevent community filters excluding all elements, fix server browser update on community filter change via console
2023-11-19 16:24:52 +00:00
Robert Müller aba67f46ee Prevent community filters excluding all elements
Ensure that community/country/type filters do not exclude all allowed elements, which can happen when a previously selected community is not available anymore or when arbitrary community filter values are set with the console.
2023-11-19 15:34:33 +01:00
heinrich5991 a5b72fef42 Allow antibot to kick people 2023-11-19 14:59:14 +01:00
heinrich5991 28b00892f6 Allow more complex interaction with the antibot via the console
Allows the antibot to receive arbitrary console commands.
2023-11-19 04:41:56 +01:00
Dennis Felsing 97d64cdfea
Merge pull request #6256 from heinrich5991/pr_ddnet_typesafe_mem_zero
Typesafe `mem_zero` function
2023-11-18 23:00:48 +00:00
heinrich5991 b951734c03 Don't allow mem_zero for nontrivial types
Initialize nontrivial types with a constructor instead. Make the
compiler aware that some of our constructors are indeed trivial.

This allows `mem_zero` calls to actually always zero the memory.
2023-11-18 22:55:17 +01:00
Robert Müller ddf935795d Fix inverted community parsing conditions 2023-11-18 22:55:08 +01:00
Chairn 6e629e1deb Type safe mem_zero function (fixes #5228)
Partially replaces #5690.
POD types are just memset. Other types are either destructed if not
trivial and/or constructed if not trivial. Types need to have a default
constructor.
Virtual classes can be mem_zeroed only if they already have been
constructed, otherwise it is UB.
2023-11-18 22:47:22 +01:00
Robert Müller ee04cd4dda
Merge pull request #7459 from heinrich5991/pr_ddnet_community_json
Add icon URL, remove `servers-key`/`ranks-key` from community JSON
2023-11-18 21:08:23 +00:00
heinrich5991 c7cd281aff Add icon URL, remove servers-key/ranks-key from community JSON
Previously:

```json
{
  "ddnet": {
    "name": "DDraceNetwork",
    "servers-key": "servers",
    "ranks-key": "maps",
    "icon-sha256": "162313eeb954e34495ad03066fee1418ed3c963e76cc83dff993e1c7856c742b"
  }
}
```

Now:
```json
[
  {
    "id": "ddnet",
    "name": "DDraceNetwork",
    "icon": {
      "sha256": "162313eeb954e34495ad03066fee1418ed3c963e76cc83dff993e1c7856c742b",
      "url": "https://info.ddnet.org/icons/ddnet.png"
    },
    "ranks": [
      …
    ],
    "servers": {
      …
    }
  }
]
```

Special case `ddnet` to look for the `servers`, `maps` in the top-level
and `kog` to look for `servers-kog` in the top-level.
2023-11-18 21:52:51 +01:00
Robert Müller fcddc165b2 Remove unnecessary mem_zero of ringbuffer memory
Zeroing the entire ringbuffer memory is unnecessary and inefficient. Only the first item in the ringbuffer has to be initialized properly.

It's unlikely that existing code depends on allocated memory being zeroed, as recycled ringbuffer items where never zeroed.
2023-11-18 17:40:36 +01:00
Robert Müller 5c7bb58457 Ensure filenames are valid UTF-8 on Unix
On Unix, the encoding of filenames is unspecified, although UTF-8 is likely used in most cases. Detecting and converting from several possible encodings to UTF-8 would be too much effort, considering that most systems already use UTF-8 per default. Therefore, any filenames which are not valid UTF-8 will be ignored when listing directories with `fs_listdir(_fileinfo)`, `fs_storage_path` will fail if the storage location is not valid UTF-8 and `fs_getcwd` will fail if the current working directory is not valid UTF-8. Paths specified in `storage.cfg` must also be valid UTF-8.

On Windows, we already ensure that all filenames are converted to UTF-8.
2023-11-17 18:55:28 +01:00
ChillerDragon 9e27a5a107 Fix unused variabled m_WasRecording 2023-11-15 12:11:58 +01:00
Dennis Felsing e74e6770c3
Merge pull request #7325 from Robyt3/Browser-Community-Filter
Add community server filter and icons, remove DDNet and KoG tabs
2023-11-12 00:00:05 +00:00
Dennis Felsing d716210e31
Merge pull request #7408 from Jupeyy/pr_tile_border_shader
Switch to a fragment shader solution for border tile rendering
2023-11-11 23:02:34 +00:00
Dennis Felsing aefa52c6b9
Merge pull request #7432 from Robyt3/Base-Standard-Mutex-Wrapper
Add `CLock` wrapper for `std::mutex` to replace `lock_*` functions, use `CLock` instead of `std::mutex`, add thread-safety annotations
2023-11-11 22:07:02 +00:00
furo 6599b7e14b Save unknown commands from settings_ddnet.cfg 2023-11-11 19:09:13 +01:00
Robert Müller 10470046b7 Use CLock instead of std::mutex, add thread-safety annotations
Use `CLock` and `CLockScope` instead of `std::mutex` and add clang thread-safety analysis annotations everywhere except for usages in engine graphics and video, as those usages also involve `std::condition_variable`.

Fix lock not being unlocked on all code paths in `CFutureLogger::Log`, which is caught by the static analysis.
2023-11-11 00:09:17 +01:00
Robert Müller 3d858c28ee Add CLock wrapper for std::mutex to replace lock_* functions
Replace usages of platform specific `lock_*` functions with `std::mutex` through the wrapper class `CLock`. Move lock classes to `base/lock.h`.

The `CLock` wrapper class is only necessary because the clang thread-safety attributes are not available for `std::mutex` except when explicitly using libc++.
2023-11-11 00:04:57 +01:00
Robert Müller b4423551d4 Fix client not quitting after graphics assertion
After the error message popup is shown for graphics assertions, the client window was destroyed but the process was not terminated properly. Now the graphics assertion error is handled like a normal assertion error, as those are also shown in an error message popup and correctly cause the client to break into the debugger or terminate.

However, calling `dbg_assert` while already owning the lock that `WaitForIdle` waits on will cause a deadlock, so error handling must be delayed until after the lock is released.

The buffer size for assertion messages is increased, as it was not sufficient for some graphics assertions.

The `ICommandProcessor::GetError` and `ICommandProcessor::GetWarning` functions are marked as `const`.
2023-11-06 23:34:05 +01:00
Robert Müller 3e5a2888bc Support writing maps with more items/data
Previously, the client would crash with an assertion when writing more than 1024 items, 1024 data items or 64 extended item types to a map file. This arbitrary limitation is removed by using `std::vector`s, so much larger maps can be written. This was only a limitation when writing map files. Old clients can correctly read the map files having more items/data but will crash when the map is saved in the editor.
2023-11-04 22:54:18 +01:00
Robert Müller d39247f726 Add community server filter and icons, remove DDNet and KoG tabs
Remove the DDNet and KoG tabs and replace them with a community filter, which works like the country and type filters. Community information (ID, name, icon SHA256, countries, types, servers, ranked maps) is loaded dynamically from the DDNet info json.

The official checkmark icon is replaced with community icons. The icons are downloaded to the `communityicons` folder in the config directory from a URL specified in the DDNet info json. The icons are only re-downloaded when their SHA256 has changed.

Per default, the Internet tab with all communities is selected. When starting the client for the first time, only the DDNet community is selected. The community, country and type filters can also be used on the Favorites tab now. The LAN tab remains unchanged.

The country and type filters are refactored. Previously, using these filters changed the total number of servers and players that were displayed, as the filter was implemented as a separate step. Now the community, country and type filters work like the other browser filters. This also has the benefit that the server list and DDNet info json are not reloaded each time these filters are changed, as updating the local filtering/sorting is enough now.

The check for finished maps is made more efficient by using an `std::unordered_set` instead of linear search.

Closes #5654.
2023-11-04 15:32:27 +01:00
Robert Müller 7f694e8fc9 Add IStorage::CalculateHashes
To conveniently calculate the SHA256 and CRC32 hashes of a file without reading the entire file into memory at once.
2023-11-04 15:24:44 +01:00
Jupeyy 639a8c3c8b Switch to a fragment shader solution for border tile rendering 2023-11-04 14:51:39 +01:00
Robert Müller 367c7ba4e7 Fix some textures being loaded without mipmaps
Some calls to `LoadTextureRaw` where passing the image format also in place of the texture load flags. Since the image format would be RGBA most of the time, this was interpreted as the flag `IGraphics::TEXLOAD_NOMIPMAPS` causing various textures (all sprites textures, assets when shown in menus, menu images, menu theme icons) to be loaded without mipmaps.

This is fixed by passing `0` as the texture load flags and by replacing uses of `LoadPNG` and `LoadTextureRaw` with `LoadTexture`.
2023-11-04 12:54:09 +01:00
Robert Müller 82ba8e0bb8 Add CTextureHandle::IsNullTexture, rename InvalidTexture
Rename `InvalidTexture` to `NullTexture` to avoid confusion because the null texture is not invalid. The function `CTextureHandle::IsNullTexture` is added to make it easier to check the result of using `IGraphics::LoadTexture`, which returns the null texture on error instead of an invalid texture handle. An assertion is added to ensure that `IsNullTexture` works correctly.
2023-11-04 12:54:08 +01:00
Robert Müller fdaa343219 Fix check for invalid texture after LoadTextureRaw
The handle returned by `LoadTextureRaw` is either valid or invalid (i.e. `-1`) but never the invalid texture itself.

Additionally, ensure that the `LoadTexture` function returns the invalid texture also when `LoadTextureRaw` fails.
2023-11-04 12:54:08 +01:00
Dennis Felsing 80c4940b7f
Merge pull request #7403 from Robyt3/Datafile-Writer-Refactoring
Add more assertions to datafile writer, refactoring
2023-11-01 22:02:45 +00:00
Robert Müller ebe2ddea9f Add gameclient warnings to queue instead of overriding others
Using `CMenus::PopupWarning` will immediately set the popup and override the current warning, which can hide warnings when multiple are shown at the same time. Now all warnings are added to the queue with `IClient::AddWarning`.
2023-11-01 22:17:01 +01:00
Robert Müller 9b8eb9d6fc Use for- instead of while-loop, improve comments 2023-11-01 14:07:36 +01:00
Robert Müller 7343ca224c Add CDatafileHeader::SizeOffset to replace magic 16 2023-11-01 14:07:36 +01:00
Robert Müller 64716075f9 Add assertion to ensure correct item IDs are written 2023-11-01 14:07:36 +01:00
Robert Müller 284390cc75 Add assertions to ensure correct map item/data sizes are written
Add assertions to prevent map items and data that are too large to be represented by the map format from being written to maps. Additionally, ensure that the size of the whole map file is not too large to be represented by the map header.

Prevent `malloc` of size 0, which is implementation defined and should be avoided, when adding items without data, which happens for example when adding an empty array of envelope points.
2023-11-01 14:06:28 +01:00
Robert Müller f7722eb016 Remove separate CDataFileWriter::Init/OpenFile functions
Simplify usage of datafile writer by removing duplicate functions for opening file.
2023-11-01 12:54:38 +01:00
BurnyLlama c76352cb9f Altered snd_buffer_size description. Fixes #7229 2023-10-29 19:57:03 +01:00
furo e61ed1c3b4 Small fixes for cl_race_ghost_strict_map
- Better description
- Remove redudant map check
2023-10-28 14:54:35 +02:00
Dennis Felsing 28f4739e46
Merge pull request #7375 from furo321/improve-ghosts
Various improvements to ghosts
2023-10-27 22:06:00 +00:00
furo dadb142f4e Add cl_race_ghost_alpha, add title for ghost settings. 2023-10-27 20:56:57 +02:00
furo b90995da06 Add option to always save ghosts, not only personal bests. 2023-10-27 20:55:35 +02:00
furo c79e4c2de5 Add option to disable ghost map hash check. 2023-10-27 20:51:17 +02:00
Dennis Felsing 80cccaaae9
Merge pull request #7362 from furo321/SvRegionalRankings
Add option to disable printing of regional rankings.
2023-10-27 16:42:23 +00:00
Robert Müller 4845639a00 Fix use of closed demo file when playback stopped due to error
Check whether the demo file has been closed due to a playback error when calling `DoTick` in loops, to prevent crashes on operating systems with assertions for correct C library usage. On Windows, `warning: Invalid parameter passed to C runtime function` was printed to the debug console in this case.
2023-10-25 20:10:15 +02:00
Robert Müller a0d154a841 Bump maximum server password length from 128 to 256
Ensure server password can fit username and password separated by colon, so there is no discrepancy where some passwords work in rcon but not for reserved slots.
2023-10-24 21:44:53 +02:00
Robert Müller 3116fb4bcf Fix ec_output_level default/min/max values, update description
To ensure that all `*_output_level` variables have the same default, minimum and maximum values.
2023-10-24 20:17:09 +02:00
Robert Müller f1e8d4bae3 Remove length limitation when packing server/rcon password
There is no need to limit the length of server password, rcon username, rcon password and rcon commands when packing them into their respective messages. The source buffers for these strings are already limited in length and the message packer ensures that the maximum packet size is not exceeded.
2023-10-24 20:10:42 +02:00
Robert Müller bade6f78fb Reduce duplicate code for sending messages for dummy
Add parameter `int Conn` to `SendInfo` and `SendReady` functions and use existing `SendEnterGame` function to reduce duplicate code for sending the same messages for main and dummy connections.
2023-10-24 20:10:18 +02:00
Robert Müller fec7e89b00
Merge pull request #7356 from dobrykafe/pr-editor-stop-sound-preview
Editor: stop/pause sound previews
2023-10-23 16:52:32 +00:00
furo bf98eec518 Add option to disable regional rankings.
Set config to true in tests

Add test for `´sv_regional_rankings`
2023-10-23 14:02:22 +02:00
dobrykafe c304b3eef8 extract CEditor::OnDialogClose 2023-10-23 12:48:53 +02:00
Robert Müller bea7aea431 Encapsulate CHostLookup member variables
The host lookup job is currently only used for the DNSBL lookup on the server-side and in tests.
2023-10-22 13:38:56 +02:00
Robert Müller f8af7542c6 Move CHostLookup to separate compilation unit
The host lookup job and the engine interface are independent so they are moved to separate files.

The include of `engine.h` in `client.h` is therefore unnecessary and other includes also had to be adjusted because of this.

The variable `m_VersionServeraddr` is unused and therefore removed. The host lookup job is currently not used on the client-side.
2023-10-22 13:38:35 +02:00
Robert Müller 0e4f174f78 Check for all file errors in demo player, show demo error popup
Handle the return values of all uses of the `io_read`, `io_skip` and `io_tell` functions in `CDemoPlayer`, to handle truncated demo files and other unexpected file reading and seeking errors during demo playback.

Show more detailed error message popups when demos cannot be loaded due to errors and when demo playback is stopped unexpectedly due to errors. Previously, only a generic message "Error loading demo" was shown when loading failed and no error message was shown when demo playback is stopped due to errors.
2023-10-19 21:48:04 +02:00
Robert Müller 92e2e17f0f Validate ticks when reading demo chunk headers
Add checks to ensure that the ticks read from demo chunk headers are in the valid range (cf. `MIN_TICK` and `MAX_TICK` constants). Playing demos with invalid ticks is prevented entirely, as the invalid ticks would cause issues in other places. The server never uses ticks outside the valid range, so invalid ticks should never occur in correctly recorded demos.

Additionally, checks are added to detect if a tickmarker chunk with a tick delta occurs before a tickmarker chunk defining an initial tick. The tick delta is only meaningful when an initial tick has already been defined, so if this is not the case the demo is also considered invalid.
2023-10-19 21:41:20 +02:00
Robert Müller 6951795619 Add title to engine warnings and make auto-hiding optional
Make the title of warnings adjustable, with the default title being "Warning" to preserve existing code.

Make auto-hiding configurable, so the automatic closing of warning popups after 10 seconds can be toggled.
2023-10-19 21:40:55 +02:00
dobrykafe aafee689ca stop/pause sound previews 2023-10-18 13:27:31 +02:00
Robert Müller 8fea5998aa Mark functions as const when possible 2023-10-17 20:27:58 +02:00
Robert Müller 59b5fd2793 Fix graphs initially rendering incorrect values
Ensure only valid graph entries are used to render curve line segments.
2023-10-17 20:27:31 +02:00
Robert Müller 11423b88b1 Use full graph width for rendering curve
Previously, roughly one percent of the graph width was not used for the curve values.
2023-10-17 20:25:35 +02:00
Robert Müller 1a01d7657f Remove unused m_Graph member of CSmoothTime 2023-10-17 20:25:32 +02:00
Robert Müller e187bda620 Use bool instead of int 2023-10-17 20:24:45 +02:00
Robert Müller d92b7b5c5f Add enum for CSmoothTime adjust direction 2023-10-17 20:24:38 +02:00
Robert Müller fb96217147 Fix first value in graphs being incorrect
As the index was incremented before setting the value, the value at index 0 was not set correctly until the ringbuffer wraps around.
2023-10-17 20:23:35 +02:00
Robert Müller dc7fa1fbb2 Use ColorRGBA for CGraph entry color 2023-10-17 20:23:16 +02:00
Robert Müller 912355f9ec Move CSmoothTime class to separate compilation unit 2023-10-17 20:23:07 +02:00
Robert Müller ee51cac9e6 Move CGraph class to separate compilation unit 2023-10-17 20:22:48 +02:00
Robert Müller f1e74c12e9 Remove unused IDemoPlayer::GetDemoType and enum literals
We only show the string value directly in the UI instead of using the demotype enum literals. There also should not be any reason to change any logic depending on whether the current demo is a server- or client-demo.
2023-10-16 22:06:28 +02:00
Robert Müller af4b1c9c97 Remove tick error debug message
This is shown every time demo playback ends when reaching the end of the file and it does not really help debugging.
2023-10-16 22:06:19 +02:00
Robert Müller ed92a9e8c7 Remove redundant checks for missing SHA256 when recording demo
The SHA256 was effectively not optional anymore when recording demos, as it and the SHA256 extension UUID were always written to the demo file without checking for `nullptr`. Therefore the SHA256 is now passed by const reference instead of by pointer and redundant checks for `nullptr` are removed.
2023-10-16 21:53:37 +02:00
Robert Müller f7b8738f91 Remove obsolete TODO about improving demo player map checking
We already use `CClient::LoadMapSearch` to load maps for demo playback, so maps in the `maps` folder are already considered. Using the map CRC is deprecated, we do not want to check it.
2023-10-16 21:53:37 +02:00
Robert Müller dbbae72ca7 Move variable declarations closer to usages 2023-10-16 21:53:37 +02:00
Robert Müller 9b68b9deef Use bool instead of int 2023-10-16 21:53:36 +02:00
Robert Müller 1333ac34f4 Use nullptr instead of 0 and NULL 2023-10-16 21:53:36 +02:00
Robert Müller 568177114f Remove unnecessary parentheses 2023-10-16 21:53:36 +02:00
Robert Müller 82d94faf28 Refactor GetDemoName using IStorage::StripPathAndExtension
The functions were effectively identical already.
2023-10-16 21:53:32 +02:00
Robert Müller c3b8c94212 Use std::vector for demo player keyframes
Using an `std::vector` is simpler and more readable than first allocating a linked list on a heap and later copying the list to an array.

The variable `m_SeekablePoints` is removed from `CPlaybackInfo`, as it does not need to be exposed outside of `CDemoPlayer` and can be replaced with the size of the vector.
2023-10-16 21:53:29 +02:00
Robert Müller cd4a13e74c Remove unnecessary check for open file in ReadChunkHeader
The function is only used internally and never called when the file is not open.
2023-10-16 20:50:43 +02:00
Dennis Felsing 042a04d610
Merge pull request #7353 from Robyt3/Engine-Jobpool-Refactoring
Minor refactoring of engine jobpool
2023-10-15 22:29:33 +00:00
Robert Müller 22352316d8 Give jobpool worker threads different names based on index 2023-10-15 22:10:50 +02:00
Robert Müller ba5a974353 Increase jobpool thread count based on hardware concurrency
The client/server jobpools were previously only using a fixed number of 2 threads. Now the pools use `2 * hardware-concurrency + 2` threads, which should provide better performance overall, as we expect threads to often wait on I/O.
2023-10-15 22:10:49 +02:00
Robert Müller 2dcec6496f Use std::vector for jobpool threads
To simplify the usage and to support an arbitrary number of threads.
2023-10-15 22:00:25 +02:00
Robert Müller 9cbbc0aca6 Replace static variables in MouseRelative with member variable
Avoid using a global variable for last mouse position on Android.
2023-10-15 20:36:59 +02:00
Robert Müller d00283e885 Enable use of video recording for each demo player individually
Previously all demo players checked `IVideo::Current` to render a video, which would cause issues when rendering a demo while a demo slicing background job is running. Now video rendering can be toggled for each demo player individually and is only enabled for the main demo player.
2023-10-14 10:52:24 +02:00
Robert Müller 668e6fb14e Use member variables for demo player snapshot data
Use member instead of static variables for demo player snapshot data. The static variables would otherwise cause issues when multiple demo players are playing at the same time, especially demo players used in background jobs for replay demo slicing. This hopefully closes #7068.
2023-10-14 10:51:45 +02:00
Robert Müller 3af7de307a Preserve demo type when slicing
Previously all sliced demos used type "client", even if the original demo had type "server". Now the type of the original demo is copied when slicing.
2023-10-13 22:11:49 +02:00
Robert Müller 9030c5b155 Refactor CDemoEditor, fix clang-tidy NOLINT
Use composition instead of inheritance for demo player listener to avoid temporarily storing a pointer to a local variable in a member variable.

Fix demo player file not being closed when demo recorder file cannot be opened during demo slicing.
2023-10-13 20:46:08 +02:00
Robert Müller a0b708a0b2 Assert that demo recording/playback are properly started/stopped
Add assertions to check that demo recording/playback is not started when already running.

Add assertions to check that demo recording/playback is stopped before the respective demo recorder/player is destroyed.
2023-10-13 20:45:22 +02:00
Robert Müller 543e63ee71 Use IO_MAX_PATH_LENGTH for demo recorder/player filenames 2023-10-13 20:45:07 +02:00
Robert Müller 7a624d7911 Ensure demo player listener is initialized
Using `SetListener` is optional.
2023-10-13 20:02:13 +02:00
Robert Müller a19c51f545 Remove unused CHUNKFLAG_BIGSIZE 2023-10-13 20:02:13 +02:00
heinrich5991 5fbf02ae91
Merge pull request #7333 from Robyt3/Clang-Tidy-Remove-Nolint
Remove obsolete clang-tidy `NOLINT` comments
2023-10-11 15:49:46 +00:00
Robert Müller aa03aa0f60 Remove obsolete clang-tidy NOLINT comments
The TODO in the `Dilate` function is removed, as the code already appears to be safe without additional checks. The variable `k` is at most `(w * h - 1) * BPP`, as `ix` and `iy` are clamped to maximum `w - 1` and `h - 1` respectively. Because `p < BPP - 1` the index `k + p` is therefore always valid for the buffers. (The caller must ensure that the source and destination buffers are of size `w * h * BPP`.)
2023-10-11 17:22:59 +02:00
Dennis Felsing 60fa51ff13
Merge pull request #7309 from infclass/kaffeine/merge-client-data-structs
Extract client 'six' data types and use them for 'seven' data
2023-10-10 21:55:55 +00:00
Dennis Felsing 1fb0235f4b
Merge pull request #7327 from furo321/correct-max-length
Show correct max length in help text for `MACRO_CONFIG_STR`
2023-10-09 06:52:43 +00:00
furo f39792f330 Show correct max length in help text for MACRO_CONFIG_STR 2023-10-09 00:53:28 +02:00
Dennis Felsing 1f5a764cf5 Make sure notification object exists 2023-10-08 14:01:02 +02:00
Robert Müller d4fed2360e
Merge pull request #7208 from dobrykafe/pr-editor-toolbar-sounds
Enhance editor toolbar sounds
2023-10-08 09:06:15 +00:00
furo e1979d9c9b Use icons for editor mode switching.
Make the icons bigger.

Make it the same size as "group"
2023-10-08 01:17:20 +02:00
dobrykafe 8adbbc433c fix requested changes 2023-10-07 14:49:51 +02:00
Robert Müller 076a902684 Overhaul demo browser UI
Improve layout of demo browser buttons, search and checkbox. Use icons for most buttons. Decrease size of UI elements.

Move demo details from below the file browser to a side panel on the right, which is the same size as the server browser side panel. Use ellipsis to truncate the SHA256 instead of rendering only half of it with reduced font size. Show "map not included" instead of "0.00 KiB" for the map size of demos that don't include a map.

Remove the "Markers" column, as it is not very useful to see for all demos and sort by.

Closes #7275.
2023-10-06 21:46:13 +02:00
Alexander Akulich b6470e5a43 Use client 'six' data structs for client 'seven' data 2023-10-06 18:14:38 +03:00
dobrykafe 6e2ddfbeaf use nullptr instead of 0, add missing return statement 2023-10-06 17:09:20 +02:00
dobrykafe ca517f27b8 enhance editor toolbar sounds 2023-10-06 17:09:19 +02:00
Robert Müller fb7669ebb0 Fix clang-tidy modernize-use-override 2023-10-06 14:06:52 +02:00
Robert Müller b81fb37f82 Fix clang-tidy modernize-use-emplace 2023-10-06 14:06:20 +02:00
Edgar f5f57ee24c
Merge pull request #7283 from Robyt3/ImageLoader-Indexed-Fix
Fix images using indexed color palette not being loadable
2023-10-04 13:55:21 +00:00
Dennis Felsing 2e5ee8287e
Merge pull request #7008 from Robyt3/Datafile-String-Util
Add functions for reading/writing strings from/to datafile, minor refactoring of datafile/map reader
2023-10-03 20:54:40 +00:00
Robert Müller 6f1e08b6f4 Encapsulate/move IClient member variables 2023-10-03 17:56:17 +02:00
Robert Müller 7acf2c1573 Add functions for reading/writing strings from/to datafile
Simplify the usage of datafile reader and writer by adding utility functions to read and write zero-terminated UTF-8 strings.

Improve validation of string data read from datafiles. It is ensure that string data is null-terminated, has no internal NUL-characters and is valid UTF-8.

Fix loading of external sounds in the editor. The wrong path variable was being used, so the sound files would not be loaded from correct folder.

Add tests for new datafile reader/writer functions.
2023-10-03 16:07:15 +02:00
Robert Müller 106b04ee79 Add assertion for Index argument of ReplaceData function 2023-10-03 15:58:58 +02:00
Robert Müller 4716791c6d Add missing IMap::FindItemIndex delegate function 2023-10-03 15:58:58 +02:00
Robert Müller 6a5752d71e Use bool instead of int for Swap parameter 2023-10-03 15:58:58 +02:00
Robert Müller e68caafc07 Consistently order CDataFileReader and IMap functions 2023-10-03 15:58:58 +02:00
Dennis Felsing dbd9da3c7b
Merge pull request #7289 from Robyt3/Map-Version-Check
Ensure current map is not corrupted when loading another fails
2023-10-03 13:17:03 +00:00
Robert Müller 9096b089b9 Ensure current map is not corrupted when loading another fails
When `IMap::Load` fails, other components will continue to use the old map. However, if `IMap::Load` failed after the map was already successfully read with the datafile reader then other components kept their pointers to the old, invalid datafile reader items and data, causing random crashes in collision code. This is fixed by using a separate datafile reader to read the new map and only applying the datafile reader globally when loading was entirely successfully.

An error message is added for the case that a map has an unsupported version, which is currently the only case where a map can fail to load after the datafile was read successfully.

In particular, the block maps `blmapPepe`, `blmapV5` and `blmapDT-UPTU` did not have a version map item and were fixed separately.

Closes #7218. Regression from #5737.
2023-10-03 14:27:11 +02:00
Robert Müller b7e1e61988 Remove redundant argument of Dilate function
The pixel size (bytes per pixel) always has to be 4 for the `Dilate` function to work correctly. This is already checked before calling the function, so the redundant argument which is always `4` can be removed.
2023-10-03 13:52:37 +02:00
Robert Müller dab88177dd Fix images using indexed color palette not being loadable
The wrong color channel count was being used for loading images that use an indexed color palette, which was causing the loading to fail with the error "bytes in row incorrect". Now the correct color channel count is retrieved using the libpng API.

Closes #7157.
2023-10-02 12:21:20 +02:00
Robert Müller b1d90aaaf2 Store number of filtered players when filtering
Only update total number of filtered players when the filter is updated instead of calculating it every frame.
2023-10-01 20:53:29 +02:00
Dennis Felsing e0d906d9e1
Merge pull request #7272 from furo321/afk-optional2
Don't run `GET_INT` on afk attribute in `ProcessServerInfo`
2023-09-30 20:43:37 +00:00
furo a3064ae105 Don't run GET_INT on afk attribute in ProcessServerInfo 2023-09-30 20:51:20 +02:00
Dennis Felsing c8401aa38f
Merge pull request #7271 from furo321/afk-optional
Make IsAfk attribute optional
2023-09-30 18:22:09 +00:00
furo 3b2389daa4 Make IsAfk attribute optional 2023-09-30 19:56:01 +02:00
Robert Müller cf35594fa4 Extract UpdateServerFriends function, cache friends on server
Calculate the number of friends on each server when refreshing the friend state of the server info instead of every time the server entry is rendered.
2023-09-30 13:32:36 +02:00
Robert Müller 7e8442d394 Move and rename UpdateFilteredPlayers function, mark as const 2023-09-30 13:29:28 +02:00
Robert Müller 28d4451057 Add local variable Info to reduce duplicate code 2023-09-30 13:29:28 +02:00
Robert Müller 034962ae24 Add enum ERankState to replace magic numbers 2023-09-30 13:29:28 +02:00
Robert Müller dcff6d92f0 Add name for enum EClientScoreKind 2023-09-30 13:29:28 +02:00
Robert Müller 721a55c603 Remove game menus includes in engine
Use config manager to reset `ui_page` to the default, instead of using `CMenus::PAGE_DDNET` directly (which is the default).

Check current type of serverbrowser instead of checking the current `ui_page` against `CMenus::PAGE_DDNET` and `CMenus::PAGE_KOG`.
2023-09-30 13:29:28 +02:00
Robert Müller 6753e37772 Move function definitions to remove and organize includes 2023-09-30 13:29:27 +02:00
Robert Müller e78305e1cd Remove unused m_aFilter(Gametype)String variables 2023-09-30 13:29:27 +02:00
Dennis Felsing 3e2893e638
Merge pull request #7182 from dobrykafe/pr-show-direction
Ability to show local keypresses only
2023-09-30 09:35:20 +00:00
Robert Müller c64ec0f677 Limit effects of dbg_stress to features useful for debugging
Using `dbg_stress 1` now only does the following (in debug build):

- Randomly send inputs.
- Randomly send chat messages.
- Randomly connect/disconnect to server configured with `dbg_stress_server` (`localhost` by default).

Previously it also did the following, which is not useful for this debugging feature and only complicates the code unnecessarily:

- Cause images and sounds not to be loaded.
- Render only every tenth frame.
- Always use inactive graphics refresh rate.
2023-09-28 20:14:54 +02:00
Robert Müller 06948ddecd Remove remains of dbg_stress from server
Using `dbg_stress 1` on a server made clients always auto-join team 0 and nothing else, which is not useful on its own for stress testing.
2023-09-28 20:14:23 +02:00
Robert Müller 247ce38094 Remove unused variables m_RenderFrameTimeLow/High 2023-09-28 20:12:55 +02:00
Robert Müller 74192b9051 Add CSnapshot::EmptySnapshot, mark pointer arguments as const
Instead of keeping track of a permanently empty `CSnapshot` object in client and server separately, add `CSnapshot::EmptySnapshot` to access a singleton empty `CSnapshot`.

Mark pointer parameters of snapshot functions as `const` when possible.
2023-09-26 20:13:27 +02:00
Jupeyy 958676ae84
Merge pull request #7251 from Robyt3/Graphics-Texture-Index-DoubleFree-Assertion
Add assertion when double-freeing texture index, ensure OpenGL texture vectors are large enough
2023-09-25 18:51:04 +00:00
furo 25101d2cb0 Add missing descriptions of commands. 2023-09-24 23:21:10 +02:00
Robert Müller 96a68455ca Ensure OpenGL texture vectors are large enough
In the unlikely case that the wanted texture slot is larger than twice the size of the original texture vector.
2023-09-24 22:27:16 +02:00
Robert Müller 99cee23de4 Add assertion when double-freeing texture index
Simplify the handling of free texture indices by using `-1` only for indices which are currently in use, whereas the size of the vector is now used to indicate the last free index. Otherwise the assertions incorrectly detect the last texture index always being in use because `-1` was used for both states.
2023-09-24 22:24:51 +02:00
Robert Müller 9933c1350d
Merge pull request #7246 from furo321/register_conchain
Configs used in Register OnConfigChange should have Conchain
2023-09-24 17:54:31 +00:00
furo 4476dfacde Configs used in OnConfigChange should trigger Conchain 2023-09-24 15:31:43 +02:00
Dennis Felsing 5d220e337c
Merge pull request #7244 from furo321/suicide-penalty
Remove unused config, `sv_suicide_penalty`
2023-09-23 22:17:43 +00:00
furo 436c977f7e Remove unused config, sv_suicide_penalty 2023-09-23 23:51:16 +02:00
Robert Müller 2d4bac8c0c Ensure strings in demo header are zero-terminated and valid UTF-8
Previously, if the demo header strings did not contain zero-termination, the client would render the strings and any following non-zero memory from the demo header.

Now, demos will not be loaded, if any string in the header is not zero-terminated or not valid UTF-8.
2023-09-23 22:14:34 +02:00
VoxelDoesCode c4d325e09b Show if your friend is AFK through friends list
resolve mege conflict

AFK -> Afk (for consistency)
2023-09-23 00:54:13 +02:00
Robert Müller 1d711d6cf0 Correctly update auth keys when using auth_remove
When using `auth_remove`, the key indices for the default helper, mod and admin passwords were not properly adjusted, causing the wrong passwords to be used for the username-less logins.

The key indices for connected clients were also not properly adjusted, causing the wrong identity to be shown for currently authenticated clients when using the `status` command.

Closes #6427.
2023-09-22 21:12:20 +02:00
Dennis Felsing c042835c1d
Merge pull request #7234 from Robyt3/Input-PumpEvents
Fix double-click handling with `gfx_asyncrender_old 0`
2023-09-22 15:38:17 +00:00
Robert Müller 98bfed7859 Fix double-click handling with gfx_asyncrender_old 0
We need to call `SDL_PumpEvents()` to ensure that we have the latest keyboard, mouse and joystick state before we use it.

See:
- https://wiki.libsdl.org/SDL2/SDL_GetKeyboardState
- https://wiki.libsdl.org/SDL3/SDL_GetMouseState#code-examples

Closes #7052.
2023-09-22 17:09:39 +02:00
Robert Müller b9951dd411 Refactor and reorder RateConvert, DecodeOpus, DecodeWV
Pass sample by reference instead of by index, as the functions are only used internally and a valid sample is assured.
2023-09-21 23:52:44 +02:00
Robert Müller 7fe854d861 Reduce indentation, rename variables in Mix function 2023-09-21 23:52:40 +02:00
Robert Müller 07e18ebecb Replace most global variables in engine sound with member variables
Most variables used in the sound engine were static globals, as they are used in the static sound mixing function. The global variables are replaced by member variables, by passing the sound interface as user-data for the SDL mixing callback. The `Mix` function is made a public member function of `ISound` instead of being exposed using `ISoundMixFunc GetSoundMixFunc()`.

This allows to remove the direct dependency of the engine sound on the engine video, by instead passing the sound mixing function as a lambda to the engine video in the engine client.

The old WavPack reader function interface does support passing a user-data pointer to the callback function, so global variables are still used here.
2023-09-21 23:52:13 +02:00
Robert Müller a2de08a8db Add UpdateVolume function, remove unnecessary lock usage
Using the lock is not necessary, as the volume is already an atomic variable.
2023-09-21 23:44:59 +02:00
Robert Müller beaf263f3d Reorder SetChannel and SetListenerPos functions 2023-09-21 23:44:58 +02:00
Robert Müller b0356aea13 Rename argument, reduce indentation of SetVoiceTimeOffset 2023-09-21 23:44:58 +02:00
Robert Müller f169ce1c8c Use nullptr instead of 0, 0x0 and NULL 2023-09-21 23:44:58 +02:00
dobrykafe 7c710ddb96 add another value instead of new variable 2023-09-20 22:47:09 +02:00
Robert Müller 61a9095fc3 Remove unused IServerBrowser::TYPE_NONE, add NUM_TYPES 2023-09-20 17:03:24 +02:00
Dennis Felsing 60de0f191e
Merge pull request #7217 from furo321/gfx-screen-conchain
Add console chain for screen resolution commands.
2023-09-20 09:25:14 +00:00
furo 597350010f Add console chain for screen resolution commands. 2023-09-20 11:01:43 +02:00
Jupeyy fcbe429d4c Decrease descriptor pool's current size when descriptor is freed 2023-09-19 18:28:48 +02:00
Robert Müller ce65d57f2e Support dynamic list of "communities" in engine serverbrowser
Replace existing hard-coded support for two "networks" with support for a dynamic list of "communities" which are indexed by a string-ID, though right now the DDNet and KoG communities are still hard-coded. The communities now also support an arbitrary number of associated countries, types and servers. This is a refactoring to prepare for getting the list of communities dynamically from the server and removing the DDNet and KoG tabs from the serverbrowser.
2023-09-18 19:37:04 +02:00
Robert Müller 2973eee036 Refactor json parser usage in CServerInfo2::FromJsonRaw 2023-09-18 17:37:21 +02:00
Robert Müller ca1bec5bac Refactor json parser usage in CServerBrowser::LoadDDNetRanks 2023-09-18 17:37:15 +02:00
Robert Müller e82e197109 Use NUM_LOCS as static assertion for array size 2023-09-18 17:29:43 +02:00
Dennis Felsing a706074c82
Merge pull request #7203 from Robyt3/Serverbrowser-Memory-Leak
Fix memory leak of server browser entry UI elements
2023-09-17 20:13:01 +00:00
Robert Müller 816f1a5a01 Fix memory leak of server browser entry UI elements
New UI elements were being created for every server info after refreshing the server list. At the same time, old UI elements were not being deleted when the server info objects are deleted. The use of `mutable` for this purpose was also rather unclean.

Now, a separate `std::vector` of UI elements is kept for all server browser entries, instead of associating the UI elements directly with the server info.
2023-09-17 21:37:36 +02:00
Robert Müller 8dfa0b2198 Rename UpdateFilteredPlayers, remove mutable variable 2023-09-17 21:37:32 +02:00
Dennis Felsing e33b747a4c Increase password size limit from 32 to 128 2023-09-17 14:32:23 +02:00
Robert Müller 0b57d56f48 Overhaul server browser filter, details and friends tabs
Move the "Filter", "Info" and "Friends" tabs to the top, above the tab content. Use icons instead of text for the tabs. Use animator to animate the tabs on mouse-over. Closes #6613.

Make spacings, corners and font sizes used in the filter, details and friends tabs more consistent.

Remove some unnecessary dark UI rect backgrounds.

Improve alignment of the number of friends with the heart icon for entries in the server list.

Improve layout of countries and types filters. Make the filters scrollable when there are many entries.

Refactor most of the server browser in preparation for replacing the DDNet and KoG tabs with a community filter, which will work like the countries and types filters. Split rendering of different server browser sections into multiple functions to improve readability. Reduce duplicate code for the countries and types filters.
2023-09-16 13:45:52 +02:00
dobrykafe 74567a1a62 ability to show local keypresses only 2023-09-15 20:34:23 +02:00
Robert Müller 0ea4d6540a Overhaul demo player skipping UI and UX
Make the skipping duration adjustable with a dropdown menu. The dropdown menu includes the durations 1s, 5s, 10s, 30s, 1m, 5m and 10m. The default duration is 5s. Skipping durations longer than the current demo are not shown. The dropdown menu is only shown if two or more durations would be shown.

Add buttons for skipping the duration, which was previously only possible with the hotkeys.

Add Ctrl+Left/Right hotkeys for skipping to chapters.

Add Shift+Left/Right hotkeys for adjusting the skipping time.

The Left/Right arrow keys and the J/L keys work identically for all hotkeys now.

Ignore ctrl, shift and alt keys for demo speed changes with the mouse wheel, to better support actions like zooming being bound to alt+mousewheel etc.

Also handle keypad enter key for play/pause like the normal return key.

Use arrow up/down icon for speed adjustment buttons, so that the "backward/forward" icons can be used for duration skipping instead.

Closes #7064.
2023-09-13 21:03:04 +02:00
Jupeyy ca2926335b Disable scissor for clearing the framebuffer 2023-09-10 09:44:32 +02:00
Alexander Akulich 1074a5ff56 CMake: Use DDNet_VERSION to construct DDNET_VERSION_NUMBER 2023-09-08 23:13:00 +03:00
Dennis Felsing ee1b8baab5
Merge pull request #7145 from infclass/for-ddnet4
Cleanup CMake, adjust the version variables
2023-09-08 08:09:56 +00:00
Alexander Akulich d0ecb5f8dd CMake: Rework the versioning 2023-09-08 00:10:48 +03:00
heinrich5991 2bf2850b20
Merge pull request #7128 from ChillerDragon/pr_sixup_slot_info
Fix 0.7 clients not being able to join after slot change
2023-09-06 23:15:43 +00:00
Robert Müller dd8b2cd88a Fix incorrect text height when maximum number of lines specified
Check if maximum number of lines has been reached before starting a new line, to prevent the text cursor from reporting the wrong number of lines and text height in that case.
2023-09-06 19:16:42 +02:00
Robert Müller fe95919f63 Support longer lines being rendered in console
Don't truncate console lines at 255 bytes anymore. Especially lines containing many Unicode characters would be adversely affected by this limitation.

Instead, truncate console lines after 10 wrapped lines are rendered. Rendering too many lines at once currently breaks the console scrolling. Rendering an ellipsis is currently not possible when rendering text with a maximum line count.

Increase buffer sizes to handle long (esp. invalid) command inputs.

Closes #7132.
2023-09-06 19:16:00 +02:00
ChillerDragon 5a8e67b323 Fix 0.7 clients not being able to join after slot change
If the player slots update the 0.7 clients have to be informed
about it. Otherwise the client can block the join button
if the outdated playerslots are filled already.
2023-09-06 12:50:16 +02:00
heinrich5991 d2a12e01c1
Merge pull request #7126 from Robyt3/Graphics-Format-PixelSize
Add `CImageInfo::PixelSize` function, use `enum EImageFormat`
2023-09-06 09:57:59 +00:00
heinrich5991 86e0e9539d
Merge pull request #7135 from Moiman/typos
Fix typos
2023-09-05 21:04:33 +00:00
Harri Nieminen 4d9ff1d904 Fix typos
Found by codespell
2023-09-05 22:32:09 +03:00
Robert Müller 1604784669 Improve Windows pipe (FIFO) support
Use `WaitForPipeDrain` to deterministically wait for the pipe to drain instead of using `Start-Sleep`.

Use `Dispose` instead of `Close` to properly flush and close the pipe stream.

Add error handling for connection timeout and I/O errors.

Handle `ERROR_BROKEN_PIPE` separately when peeking at pipe, as this happens when the pipe is disconnected immediately after connecting it or after reading the previous message.

Don't ignore `ERROR_BAD_PIPE` anymore, as the pipe should never be in a disconnected (i.e. bad) state at this point of the function.
2023-09-05 19:15:09 +02:00
Robert Müller dde45f7a40 Add CImageInfo::PixelSize function, use enum EImageFormat
Use `enum EImageFormat` type for image format literals and variables.

Add `PixelSize` function to get the number of bytes/color channels per pixel for a specified image format.

Remove unused store format argument of texture loading functions. All textures are automatically being stored as RGBA, so the argument was unused. Also remove the therefore unused `FORMAT_AUTO`.

Rename variables consistently to `PixelSize` and use `size_t`, instead of mixing different names like `BPP` and `ColorChannelCount`.

Validate image format loaded from maps using `CImageInfo::ImageFormatFromInt`. Add `FORMAT_ERROR` to represent invalid formats.

Remove redundant `PixelSize` parameter from graphics backends and commands, which can be derived from the texture format.

Fix memory leak when RGB image data is being converted to RGBA format when saving map in editor.
2023-09-03 20:40:28 +02:00
Robert Müller ab6262d7ce Use nullptr instead of NULL 2023-09-02 12:07:46 +02:00
Robert Müller 872d6c9e5e Move variable declarations closer to usage/definition 2023-09-02 12:05:31 +02:00
Robert Müller ead33ba05a Add debug messages for all error cases in LoadPNG 2023-09-02 12:01:06 +02:00
Robert Müller 1ebd209f90
Merge pull request #7095 from Marmare314/refactor-a1
Refactor editor mapitems
2023-09-01 18:47:51 +00:00
marmare314 12d0608dfd let CEditorImage inherit CEditorComponent 2023-09-01 18:57:35 +02:00
Jupeyy 16115c204e
Merge pull request #7094 from Robyt3/Variable-Desc-Fixes
Remove `gfx_finish` config variable, remove `dbg_hitch` config variable, improve config variable descriptions, add missing descriptions
2023-08-30 18:28:25 +00:00
Robert Müller 98b3fe460a Fix typo in internal name of cl_assets_entities config variable
The name used in config is unchanged.
2023-08-30 20:07:12 +02:00
Robert Müller 943f98dc92 Improve config variable descriptions, add missing descriptions 2023-08-30 20:07:11 +02:00
Robert Müller 1028cedee3 Remove dbg_hitch config variable
This config variable was only settable in the server console but only read in the client, so it was effectively unusable. It also has no use case right now.
2023-08-30 20:07:11 +02:00
Robert Müller 31a80c976b Remove gfx_finish config variable
This config variable does not have any use case right now and only causes the rendering to be slowed down.
2023-08-30 20:07:11 +02:00
Robert Müller 0a290bc501 Remove unused enum literals 2023-08-30 17:58:21 +02:00
Robert Müller 95b1c7dc2b Hide client is not online log message except when using record
The log message is otherwise shown multiple times when starting the client.

Now it's only shown when the `record` command is used manually, i.e. not for automatically recorded demos anymore.
2023-08-29 22:05:16 +02:00
heinrich5991 ee32ceb1da
Merge pull request #7092 from furo321/pr_fix_ipv4only_registering
Don't register to ipv6 when sv_ipv4only is enabled. (fixes #7091)
2023-08-28 21:09:59 +00:00
furo b24b11f48e Move sv_ipv4only check to OnConfigChange 2023-08-28 22:45:53 +02:00
Dennis Felsing ff1a2a44d3
Merge pull request #7076 from dobrykafe/pr-fix-map-drag-and-drop
Add warning for unsaved editor changes when dragging a map file into the game
2023-08-28 13:49:58 +00:00
furo 8f73a9ea8c Fix style 2023-08-27 21:40:32 +02:00
furo 2b07832b9e Don't register to ipv6 when ipv4only is enabled. 2023-08-27 21:23:55 +02:00
heinrich5991 330d1ebaf6 Add possibility to persist game data past map changes 2023-08-27 16:11:45 +02:00
dobrykafe cb29ad2b4f dont switch to editor if loading fails 2023-08-26 22:13:13 +02:00
dobrykafe 5e923adcc9 fix map drag and drop 2023-08-26 18:14:13 +02:00
Dennis Felsing 23ed630a4e
Merge pull request #7065 from heinrich5991/pr_ddnet_teehistorian_antibot
Allow antibot to record data into teehistorian
2023-08-25 15:08:35 +00:00
heinrich5991 84948adad1 Allow antibot to record data into teehistorian 2023-08-25 14:26:09 +02:00
heinrich5991 548f2f6021
Merge pull request #7058 from Robyt3/Demo-Player-Pause-Indicator
Show indicator when pausing/unpausing in demo player
2023-08-25 11:55:03 +00:00
Robert Müller ec0522d58f Show indicator when pausing/unpausing in demo player
Render a pause/play icon in the center of the screen when pausing/unpausing while the menu is not active.

The icon fades in and out over 0.5 seconds and slightly increases in size over that time.

When starting demo rendering with initial pause, the pause indicator is rendered continuous until playback is first started, to ensure that the initial pause state is communicated clearly to the user. The initial pause indicator is not included in the rendered demo, but pausing and unpausing later during demo rendering will cause it to be included in the video, same as other UI elements. Closes #7044.

The config variable `cl_demo_show_pause` (`0/1`, default `1`) is added to hide the pause indicator entirely, for example to render a demo with multiple pauses without the indicator.

The pause indicator and also the existing speed indicator are not rendered (anymore) while the menu is active, as the menu already contains this information.
2023-08-25 13:29:17 +02:00
heinrich5991 b739c18a86
Merge pull request #7056 from Robyt3/Base-Number-Format-Optimization
Add `str_from_int` function
2023-08-25 11:16:00 +00:00
heinrich5991 1f13a693a5
Merge pull request #6744 from Zwelf/pr-fix-teehistorian-mapchange
Fix JoinVer and Join teehistorian chunks missing in some conditions
2023-08-25 11:15:43 +00:00
Zwelf 3c2d8afff6 Create new teehistorian event for player rejoin 2023-08-25 00:42:54 +02:00
Robert Müller d2c9750c65 Add str_from_int function
Add more efficient function for formatting integer values as strings.

A benchmark shows that using this function is significantly faster than using `str_format`. It is faster by a factor of 220 with Clang 15.0 O2 (https://quick-bench.com/q/BlNoLnlyqxipf4jvsFTUxKMHDJU) and by a factor of 11 with GCC 12.2 O2 (https://quick-bench.com/q/Fxf9lDCTqXBF4pIa_IyZ5R0IqYg).

This increases FPS in the editor by ~25% when many numbers are rendered for switch/tele/speedup/tune layers or with "Show Info" being enabled.

The additional static analysis for `std::to_chars` revealed that the wrong size was used in `CHud` for `aScoreTeam[TEAM_RED]` and `aScoreTeam[TEAM_BLUE]`.

This requires incrementing the macOS deployment target from 10.13 to 10.15.
2023-08-24 20:54:17 +02:00
heinrich5991 1c8a67f6f9
Merge pull request #7049 from Robyt3/Sqlite-Error-Assertion
Fix assertion failure when SQLite connection fails, Remove unused `IDbConnection::Copy`
2023-08-23 15:38:39 +00:00
Robert Müller 040731095e Fix assertion failure when SQLite connection fails
When connecting to the SQLite database fails, e.g. because the `.sqlite` file is corrupted, the server would crash with the assertion "Tried connecting while the connection is in use" when a player joins and performs any action.

This is fixed by resetting the use-flag when connecting to the SQLite database fails, which is the same behavior as for the MySQL database connection.
2023-08-22 20:40:36 +02:00
Robert Müller bb147328c2 Remove unused IDbConnection::Copy 2023-08-22 20:40:36 +02:00
ChillerDragon 796d79ad5b Replace 0.7 serverinfo magic number with enum 2023-08-22 13:53:08 +02:00
Dennis Felsing 55789819a3
Merge pull request #7026 from ChillerDragon/pr_auth_unused
NETMSG_AUTH_CHALLENGE is not used in 0.6 or 0.7
2023-08-22 09:59:58 +00:00
ChillerDragon 87640d7857 NETMSG_AUTH_CHALLENGE is not used in 0.6 or 0.7 2023-08-22 10:31:16 +02:00
Robert Müller 7c1a667486
Merge pull request #7046 from infclass/kaffeine/drop-rendering-paused-by-default
Remove cl_video_pause_on_start; reset the pause option on popup opened
2023-08-19 11:42:54 +00:00
Alexander Akulich 29688fb499 Remove cl_video_pause_on_start; reset the pause option on popup opened 2023-08-19 13:51:38 +03:00
Robert Müller bfe1175558 Save console output variables again, improve descriptions
As #6451 was partially reverted by #5434.
2023-08-19 10:53:47 +02:00
Dennis Felsing a44bd9d3e1 Shut down db connection pool (fixes #7036) 2023-08-17 14:35:58 +02:00
Dennis Felsing b52fa5e910
Merge pull request #7028 from Robyt3/Base-Str-Utf8-Offset-Functions
Add utility functions for converting UTF-8 bytes ↔ chars offsets
2023-08-15 21:10:38 +00:00
Zwelf d7164211e6 Rename OnClientEngineJoin and OnClientEngineDrop to make the name fit its usage 2023-08-15 22:22:42 +02:00
Zwelf b9458150e0 Fix JoinVer and Join teehistorian chunks missing in some conditions
vanilla 0.6 joins weren't recorded. Also after map change, for the
existing players these Join chunks were missing.  Just add these
message for existing players now and add OnClientEngineJoin in all
code paths with clients connecting.
2023-08-15 22:22:42 +02:00
Robert Müller af3870a64d Add utility functions for converting UTF-8 bytes ↔ chars offsets
Add `str_utf8_offset_bytes_to_chars` and `str_utf8_offset_chars_to_bytes` functions to base system to convert between byte and UTF-8 character offsets in UTF-8 strings.

Previously, this was separately implemented in the textrender and in the lineinput helper.

These textrender functions are entirely replaced by the new functions:

- `ITextRender::SelectionToUTF8OffSets` (by `str_utf8_offset_chars_to_bytes`)
- `ITextRender::UTF8OffToDecodedOff` (by `str_utf8_offset_bytes_to_chars`)
- `ITextRender::DecodedOffToUTF8Off` (by `str_utf8_offset_chars_to_bytes`)

These lineinput helper functions are reimplemented using the new functions:

- `CLineInput::OffsetFromActualToDisplay` (uses `str_utf8_offset_bytes_to_chars`)
- `CLineInput::OffsetFromDisplayToActual` (uses `str_utf8_offset_chars_to_bytes`)
2023-08-15 22:11:25 +02:00
Robert Müller 7168fb15d2 Move OnWindowResize listener to engine, handle editor
Register the `OnWindowResize` listener in the engine client instead of the game client and properly dispatch the event also to the editor, so text containers in the editor are cleared when the window is resized.

Closes #7018.
2023-08-15 20:17:27 +02:00
Robert Müller 5567c56d3a Reorder CClient interface pointers alphabetically 2023-08-15 19:47:52 +02:00
Robert Müller 15be3c3944 Remove unused m_DebugSoundIndex variable 2023-08-15 19:47:52 +02:00
Robert Müller f90e908c9d Reset text containers on language change
Fix text containers rendering broken text after the language is changed, as this cleared the glyph atlas without clearing the references to the glyph positions in the text containers. Now `OnWindowResize` is also called on language change to reset all text containers.

However, the glyph atlas is not cleared on normal window resize anymore, because this seems to be unnecessary.
2023-08-14 23:04:55 +02:00
Samuele Radici 5e1ef437d8
Update connection_pool.cpp 2023-08-12 18:40:33 +02:00
Robert Müller b98d519744 Use textrender for graphs, refactor CGraph::Render
Use textrender for rendering debug graph labels instead of using the debugging font and quad text.
2023-08-08 20:31:47 +02:00
Robert Müller be83d44470 Refactor CClient::DebugRender
Fix names of static variables. Remove dead code.
2023-08-08 20:31:47 +02:00
Robert Müller 0e161cf4d9 Fix textrender variables being uninitialized
Regression from #6952.
2023-08-07 17:53:54 +02:00