Commit graph

4919 commits

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