Skip to content

Fix many issues with input-demoseeking.cfg

This fixes a number of problems with the input-demoseeking.cfg script and adds some new features. It's become a lot larger and complicated, but at least I changed some alias names and added comments to make understanding the script easier. The existing usages stay the same.

Short summary of the changes:

  • Fix "defer clear" commands breaking seekdemo.
  • Fix repeated seekdemo commands often breaking the seek.
  • Handle failed playdemo command cleanly.
  • Introduce maximum playback speed to avoid freezes for long seeks.
  • Introduce option to disable default bindings.
  • Introduce hooks for demo playback start and seek end.
  • Introduce alias for retrieving seek target or demo playback time from scripts.
  • Introduce vars to provide information about demo playback.
  • Prevent interrupting the game and loading the last viewed demo when accidentally running seekdemo command during an actual game (cl_hook_gamestart_all setup needed).
  • Reduce screen flashes by disabling r_render only for long seeks where the performance is needed.
  • Disable more options to improve performance and reduce particles and effects accumulating during the seek.

Stability: I've done the main changes more than a year ago and have been using it extensively all the time, and it's very reliable in both 0.8.2 and current autobuild.

The problem with non-stopping seeks: In the old version the seek tended to miss its target and forward at high speed until the end of the demo. Perhaps worse, because the cleanup alias wouldn't run, any modified options were not reset to their original values. I found that some component ran defer clear commands during playback, which breaks the defer … … loops this script uses. As far as I could tell it's caused by csprogs and differs between csprogs versions. My solution is to hook into the defer command, exactly like the script already did for the playdemo command: defining an alias for an existing command causes that alias to be run after the command, with the same arguments. When the first argument is clear, and a seek is in progress, the alias restores the seekdemo state by restarting the defer loop. I'm interested in alternatives, but this seems to work perfectly fine--as long as no one else tries to hook into defer the same way and overwrites the alias.

Speed cap: Another issue was that long seeks would set the slowmo cvar to a very high value, resulting in a long freeze before any input is handled again. This was easy to fix by introducing a maximum. 200 should be a safe value. I made it configurable to allow higher values for users with more powerful machines.

Prevent leaving game when accidentally hitting a seekdemo key: I wanted to prevent seekdemo reloading the demo outside of demo playback, because in the old version a seekdemo command during a game could reload the last demo and exit the current game. My fix requires hooking into cl_hook_gamestart_all to clear the last demo variables, because I couldn't find any other cvars that could have helped with this. The downside is that users need to manually add this to their autoexec. This fix does not apply if the hook is not added, but other parts of the script work fine.

Pauses: The duration of a pause of a game is forwarded relatively slowly for some reason. This happened in the old and this new version, and I don't know what could be done about that. The effect is worse in 0.8.2, but at least in autobuild it's reasonably fast.

Scripting: I added hooks and aliases that can be used for scripting. I'm already using those in my autoexec for demo-specific options and other scripts.

Merge request reports