Complete rework of the ghost and race recorder#869
Conversation
|
So we get a new ghost format here and a new demo format from heinrich? To me this change sounds great. Anyone up for a review? |
|
I hope to find some time for this. |
|
Learath2
left a comment
There was a problem hiding this comment.
Just style issues now, will give it another look tomorrow.
src/engine/shared/ghost.cpp
Outdated
There was a problem hiding this comment.
Should also clean up the file from trailing whitespaces
src/engine/client/client.h
Outdated
There was a problem hiding this comment.
Don't think we do underscores in function names but should check with @heinrich5991 on that :)
There was a problem hiding this comment.
seems pretty common:
https://github.com/Redix/ddnet/blob/master/src/engine/client/client.h#L356
and the following lines
|
|
2 Doesn't work if I compile this PR |
|
2 I can't reproduce this. When restarting is on, the ghost starts immediately. When it is off, for me the ghost starts when the center of the tee does not touch the start line anymore. 4 Disabling the timer during a race should not be a problem right now. For activating I could add a check if gametick and race start-tick match (or are at least close to each other). When the gametick is significantly higher than the start-tick (maybe one second), the timer has been activated and the ghost won't restart. |
Improve ghost file handling
…save the tick This makes the ghosts more resistant against lags
…e start line again
|
Short update: |
|
Interesting that you cannot reproduce 2. I just build it and join a map where I have a ghost on, sit on the start line and watch my ghost go race. |
|
Just to make sure that I understand you correctly... Timer was on or off? |
|
Non-solo map, tee is inside the start line, as soon as I leave the start line the ghost weirdly teleports back and goes where it's supposed to be. I think until you leave the start line the ghost should be paused at the 0 mark. Timer on, official server. |
|
I still cannot reproduce it... The problem is, that until we receive the snapshot with the race-timer flag set, the client does not know whether the timer is active or not. So until this snapshot arrives, the client has to check for the start itself, based on predicted values. The transition between the local and the server-side starting behavior might cause some problems. When the problem only occurs one time after you joined a map, the client cannot identify the server as non-solo. But I could not imagine why this would fail. It is directly linked to the team visualization in the scoreboard. Someone would probably have noticed if this feature was buggy. |
|
All maps affected, It behaves a little different now but still wrong. Now when you go in the start line the first time it doesn't start as expected, but leave the start line and go back on it and the ghost won't disappear. Causing it to re-sync onto you when you leave the line again. |
|
Actually this was needed to have a smooth transition from local to server-side ghost control. But I found a solution, so that the ghost is now disabled while you touch the start line. |
|
So, ready to merge? Sounds like something that would be a good addition for DDNet 11. |
|
Behaviour is fine now \o/ I'll give the code one last look and merge in an hour or so. |
Learath2
left a comment
There was a problem hiding this comment.
Can you join Discord or IRC and answer some questions? I really can't seem to understand some of this.
src/engine/client/client.cpp
Outdated
|
|
||
| void CClient::GhostRecorder_Start(const char *pFilename, const char *pPlayerName) | ||
| { | ||
| m_GhostRecorder.Start(Storage(), m_pConsole, pFilename, m_aCurrentMap, m_pMap->Crc(), pPlayerName); |
There was a problem hiding this comment.
IGhostRecorder and IGhostLoader are kernel interfaces, they can request IStorage and IConsole from the kernel.
src/engine/client/client.cpp
Outdated
| return m_DemoRecorder[RECORDER_RACE].IsRecording(); | ||
| } | ||
|
|
||
| void CClient::GhostRecorder_Start(const char *pFilename, const char *pPlayerName) |
There was a problem hiding this comment.
If IGhostLoader and IGhostRecorder are kernel interfaces, what is the point of having these functions?
|
The things we talked about are fixed now. |
|
Thanks :) |
869: Complete rework of the ghost and race recorder r=Learath2 a=Redix This PR fixes a lot of issues with the ghost and race recorder, introduces a new ghost file format and implements some pretty useful features. **A quick overview:** - When you cross the start line multiple times, both (ghost and recorder) will only restart if it is a non-solo server - If available, both will use the race timer to recognize the start instead of searching for the start line - Fastcap support for both - The recorder immediately starts when the Tee spawns, so the preparation steps (which are quite important for speedruns) will be included in the demo. If you do not cross the start-line within 20 seconds, it will stop the demo until you really start. - Better ghost menu (colors, reloading, deleting and saving ghosts) - The ghosts are more resistant against lags (old ones were sometimes completely useless due to small lags) - New ghosts files are significantly smaller - Cleanup, bugfixes.. **About the new ghost format (version 4/5):** This format is used by Teerace for over a year now. The code for handling the binary files was moved to the engine. It includes an auto updater which creates a backup of all ghosts and converts them to the new format afterwards. The major differences from the format used by DDNet right now (version 2), are the ability to store multiple types of data, the usage of delta-encoding and a more portable header. For whatever reason, the ghost stores values for every predicted tick, but without tick information, so lost snapshots can make them unusable. The new code uses the original values from the snapshots including ticks but it can also handle the old ones without. Since hardly any server uses the high bandwidth option this practically reduces the file size. Like the demo recorder the ghost recorder directly stores the data to a file (every 50 snapshots) instead of writing the whole file at the end of the race. Indeed this can be changed with only a few lines if the old behavior is preferred. The updater can handle version 2 (DDNet) and 3 (old teerace format, only slightly different from version 2) files. The updating already happens when the files are scanned for generating the list in the menu and not only when you activate them. The change from version 4 to 5 was only needed due to a bug in the implementation, the ghost loader can read both. Some numbers about the file size: (map: hotrun, both about 30 seconds) - Old ghost: 30.4 kB (converted: 10.7 kB) - New ghost: 5.4 kB **One thing about the race recorder:** The old implementation compared the new file only with the first file it found for the particular map. The new one compares with all related demos and deletes them possibly, so that only the best demo is left. Since DDNet can also store the demos without name, this might also delete demos from other players, that you might have in your directory. To prevent this I at least check whether the demo contains the player name if `cl_demo_name` is on. In my opinion the better solution would be to remove `cl_demo_name` and always use the player name.
This PR fixes a lot of issues with the ghost and race recorder, introduces a new ghost file format and implements some pretty useful features.
A quick overview:
About the new ghost format (version 4/5):
This format is used by Teerace for over a year now. The code for handling the binary files was moved to the engine. It includes an auto updater which creates a backup of all ghosts and converts them to the new format afterwards. The major differences from the format used by DDNet right now (version 2), are the ability to store multiple types of data, the usage of delta-encoding and a more portable header.
For whatever reason, the ghost stores values for every predicted tick, but without tick information, so lost snapshots can make them unusable. The new code uses the original values from the snapshots including ticks but it can also handle the old ones without. Since hardly any server uses the high bandwidth option this practically reduces the file size.
Like the demo recorder the ghost recorder directly stores the data to a file (every 50 snapshots) instead of writing the whole file at the end of the race. Indeed this can be changed with only a few lines if the old behavior is preferred.
The updater can handle version 2 (DDNet) and 3 (old teerace format, only slightly different from version 2) files. The updating already happens when the files are scanned for generating the list in the menu and not only when you activate them. The change from version 4 to 5 was only needed due to a bug in the implementation, the ghost loader can read both.
Some numbers about the file size: (map: hotrun, both about 30 seconds)
One thing about the race recorder:
The old implementation compared the new file only with the first file it found for the particular map. The new one compares with all related demos and deletes them possibly, so that only the best demo is left. Since DDNet can also store the demos without name, this might also delete demos from other players, that you might have in your directory.
To prevent this I at least check whether the demo contains the player name if
cl_demo_nameis on.In my opinion the better solution would be to remove
cl_demo_nameand always use the player name.