Commit graph

18154 commits

Author SHA1 Message Date
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
Robert Müller 60807b5de9 Fix io_skip return type and documentation
The function returns 0 on success and -1 on error, as it delegates to `io_seek`, instead of returning the number of bytes skipped, which the documentation previously suggested. The return type is changed from `unsigned` to `int`, as this is also the type of `io_seek` and this better handles -1 as a return value.
2023-10-19 21:40:35 +02:00
Dennis Felsing dad2c14abb
Merge pull request #7355 from Robyt3/Client-Graph-SmoothTime-Refactoring
Refactor `CGraph` and `CSmoothTime`, move to separate compilation units, minor fixes to graph rendering
2023-10-17 20:56:05 +00: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 a0c0d7efba Fix incorrect minimum value of dbg_tuning velramp graph
This was causing the curve to clip outside the graph area.
2023-10-17 20:24:47 +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
Dennis Felsing f06f65d753
Merge pull request #7354 from Robyt3/Engine-Demo-Refactoring
Refactor engine demo player and recorder
2023-10-16 22:04:42 +00: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 a60eb31ede
Merge pull request #7351 from Robyt3/Client-Snap-PlayerInfo-Crash-Fix
Fix client crash on player info snapshot item with invalid ID
2023-10-15 22:30:02 +00: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
Dennis Felsing 0666646f40
Merge pull request #7352 from Robyt3/Engine-Input-Antistatic
Replace static variables in `MouseRelative` with member variable
2023-10-15 22:29:14 +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 97c1046104 Add assertions to ensure that thread_init is successful
Ensure that `pthread_create`/`CreateThread` are successful.
2023-10-15 21:59:42 +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 1a83a17db8 Fix client crash on player info snapshot item with invalid ID
The player info snapshot item (`CNetObj_PlayerInfo`) has its own `m_ClientID` member variable in addition to the generic snapshot item ID. The snapshot item ID was only used to set `m_Snap.m_LocalClientID` but without being checked for invalid values. Now it is checked that both IDs are identical and only `m_ClientID` is used consistently.
2023-10-15 17:06:12 +02:00
heinrich5991 788a2ad1ff
Merge pull request #7348 from Robyt3/Tools-Map-Version-Check
Fix map version checks in map_diff and map_extract tools
2023-10-14 16:16:11 +00:00
Robert Müller 60bb48c725 Fix map version checks in map_diff and map_extract tools
The map version was only checked if the version item is present, which is different from how client and editor load maps. Now a missing version item is considered an unsupported version. Additional log messages are also added to the tools.
2023-10-14 17:03:48 +02:00
heinrich5991 575fc6c27c
Merge pull request #7346 from Robyt3/Scripts-Check-Unused-Header-Python
Rewrite unused header style check shell script in Python
2023-10-14 14:42:07 +00:00
Robert Müller db17539652 Rewrite unused header style check shell script in Python
As the shell script is pretty slow, taking roughly 84 seconds in the CI, whereas the equivalent Python script takes only 1 second.
2023-10-14 15:21:28 +02:00
Dennis Felsing 46c7229a22
Merge pull request #7345 from Robyt3/Tests-Swap-Endian
Add tests and documentation for `swap_endian` function
2023-10-14 12:02:30 +00:00
Robert Müller d9a7df0f92 Add tests and documentation for swap_endian function 2023-10-14 13:29:24 +02:00
Dennis Felsing 2ddde45f62
Merge pull request #7344 from Robyt3/Engine-Demo-Antistatic
Use member variables for demo player snapshot data, enable use of video recording for each demo player individually
2023-10-14 11:04:10 +00: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
Dennis Felsing 90466689d3
Merge pull request #7343 from Robyt3/Engine-Demo-Editor-Type-Preservation
Preserve demo type when slicing
2023-10-13 21:58:20 +00:00
Dennis Felsing c4a6955fb1
Merge pull request #7342 from Robyt3/Demo-Render-Slice-Disable
Disable demo slice button while demo is being rendered
2023-10-13 21:58:19 +00: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 172f316a40 Disable demo slice button while demo is being rendered
There is no reason to slice a demo while currently rendering it and it may cause issues because multiple demo players would access the same `IVideo` instance.
2023-10-13 22:06:17 +02:00