Skip to content

Enable free roaming in demos while paused#1956

Open
sm90x wants to merge 7 commits intoNeotokyoRebuild:masterfrom
sm90x:feat/paused-demo-roaming
Open

Enable free roaming in demos while paused#1956
sm90x wants to merge 7 commits intoNeotokyoRebuild:masterfrom
sm90x:feat/paused-demo-roaming

Conversation

@sm90x
Copy link
Copy Markdown
Contributor

@sm90x sm90x commented May 1, 2026

Description

Enables moving around with roaming view in paused demos.

The two impediments to do this were 1) the movement using frametime, which I guess stops when the engine pauses the game, and 2) when paused the engine stops processing in-game inputs so pressing to move forward would do nothing.

Changed the roaming view to use realtime instead of frametime, and added a hacky way to detect movement button presses while paused using vgui.

Toolchain

  • Linux GCC 10 Sniper 3.0

@sm90x sm90x force-pushed the feat/paused-demo-roaming branch from 740ffd7 to 4cb3b8a Compare May 1, 2026 19:32
@AdamTadeusz
Copy link
Copy Markdown
Contributor

AdamTadeusz commented May 1, 2026

I'm impressed, there are some issues with the demo playback but I would have to double check whether that's a fault with this pr or if it is on master, I'm heading to bed so i will just jot some things down here for myself to check later.

Bots (and most likely players too) repeatedly make footstep noises while the server demo is paused. an early return in CBaseEntity::EmitSound fixes the footstep noises, would need this everywhere where there is a call to g_SoundEmitterSystem.EmitSound( at least I guess, also check if there are any other ways to emit sounds that we want to pause when a demo is paused.

Bots (and most likely players too) teleport to the exact position at the given tick when a demo is paused, instead of remaining in the interpolated position they were in just before the pause. This can be fixed in C_BaseEntity::InterpolateServerEntities() by removing the engine->IsPaused() check. The check is there for a reason, probably so when watching demos we can see exactly where any given player was at any given time, might be worth keeping this functionality and adding some kind of cvar to disable it by default? Would need further discussion.

The "drone movement" relies on the walk key being pressed. Since user input isn't dealt with when a demo is paused like you said, the player will be stuck in drone movement if they had the walk key pressed while pausing the demo, or stuck outside of drone movement if they didn't, with no way to switch between the two while paused. bDroneMove should ignore m_lastCmd.buttons and instead check if the key assigned to +walk is pressed. You might want to also deal with whether the player is using toggle or hold to walk, as that makes a difference when the demo isn't paused.

I'm not suggesting you implement these right away, more testing needs to be done still.

(Edit) also the +speed command is used in spectate to slow the spectator down, also not handled when paused

(Edit 2) also in drone movement the swim up and down commands are used to move the camera up and down when in drone movement

@AdamTadeusz
Copy link
Copy Markdown
Contributor

wrt interpolation, we could just always interpolate during a paused demo, and if someone wants to see the exact position they can toggle cl_interpolate themselves

Copy link
Copy Markdown
Contributor

@AdamTadeusz AdamTadeusz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking into the code further, I think you can drop all the vgui stuff. We have a class CInput that keeps track of what buttons the user is pressing even when a demo is paused. You could create a third CreateMove function in CInput that instead takes a CUserCmd created in C_HLTVCamera, like the dummy command in the CInput ::ExtraMouseSample function, populates the command and returns it to be used in place of m_LastCmd in C_HLTVCamera. this should handle all user input regardless of if the player is using a mouse and keyboard or controller or whatever, and means you need very few changes in C_HLTVCamera

slow (+sprint) movement, handle vertical (+moveup +movedown) movement,
calc proper velocity by using cl_ speed values
@sm90x
Copy link
Copy Markdown
Contributor Author

sm90x commented May 2, 2026

I am probably not getting what you mean, but C_HLTVCamera::CreateMove and CInput::CreateMove don't get called when paused.

The sound looping issue is present in master.

Another issue already in master, is the menu and console key becoming unresponsive. I am not sure how to reproduce, maybe pausing and unpausing, it doesn't happen every time though.

@AdamTadeusz
Copy link
Copy Markdown
Contributor

@sm90x are you happy with me opening up a PR to your branch? I can implement my suggestion and you can merge it if you're happy with it

@sm90x
Copy link
Copy Markdown
Contributor Author

sm90x commented May 2, 2026

Sure.

@AdamTadeusz
Copy link
Copy Markdown
Contributor

@sm90x I opened sm90x#1

@sm90x
Copy link
Copy Markdown
Contributor Author

sm90x commented May 3, 2026

Looks clean now, thanks. My assumption on not processing inputs was wrong.

Comment thread src/game/client/hltvcamera.cpp
Comment thread src/game/client/hltvcamera.cpp Outdated
@AdamTadeusz AdamTadeusz self-requested a review May 3, 2026 09:27
@AdamTadeusz AdamTadeusz requested a review from a team May 3, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants