Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix capture skip non gameplay frame #94

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/modules/capture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ pub enum SoundCaptureMode {
}

#[allow(clippy::large_enum_variant)]
enum State {
pub enum State {
Idle,
Starting(String),
Recording(Recorder),
}

static STATE: MainThreadRefCell<State> = MainThreadRefCell::new(State::Idle);
pub static STATE: MainThreadRefCell<State> = MainThreadRefCell::new(State::Idle);

static BXT_CAP_START: Command = Command::new(
b"bxt_cap_start\0",
Expand Down
13 changes: 10 additions & 3 deletions src/modules/capture_skip_non_gameplay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,29 @@ pub unsafe fn should_record_current_frame(marker: MainThreadMarker) -> bool {
return true;
}

if !matches!(
*capture::STATE.borrow_mut(marker),
capture::State::Recording(_)
) {
return false;
};

let skip_frames = BXT_CAP_SKIP_NON_GAMEPLAY_FRAMES.as_u64(marker);

if skip_frames == 0 {
return true;
}

if (&*engine::cls.get(marker)).state != 5 {
if (*engine::cls.get(marker)).state != 5 {
// If state is not 5, skip frame.
// State 4 is still loading.
return false;
}

// demoplayback is updated to 1 after state 4 is done.
// The current implementation will skip all the frames until some viewmodel values are set.
if (&*engine::cls_demos.get(marker)).demoplayback == 1 {
// For some reasons, the "true" first frame will be catched in this condition
if (*engine::cls_demos.get(marker)).demoplayback == 1 {
// For some reasons, the "true" first frame will be caught in this condition
// despite having no viewmodel shown in demo.
// So it does technically capture all non-loading frames.
if (*engine::cl_stats.get(marker))[2] == 0 {
Expand Down
Loading