Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
khanghugo committed Feb 18, 2023
1 parent ec6807c commit b363826
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
3 changes: 0 additions & 3 deletions src/hooks/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1668,8 +1668,6 @@ use exported::*;
pub mod exported {
#![allow(clippy::missing_safety_doc)]

use std::ffi::CStr;

use super::*;

#[export_name = "Memory_Init"]
Expand Down Expand Up @@ -2123,7 +2121,6 @@ pub mod exported {
pub unsafe extern "C" fn my_CL_PlayDemo_f() {
abort_on_panic(move || {
let marker = MainThreadMarker::new();

capture_video_per_demo::on_before_cl_playdemo_f(marker);
CL_PlayDemo_f.get(marker)();
capture_video_per_demo::on_after_cl_playdemo_f(marker);
Expand Down
19 changes: 6 additions & 13 deletions src/modules/capture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ Especially useful for TASes.",
);
static BXT_CAP_SKIP_NON_GAMEPLAY_FRAMES: CVar = CVar::new(
b"_bxt_cap_skip_non_gameplay_frames\0",
b"2\0",
b"0\0",
"\
Skipping recording non-gameplay frames such as main menu, loading screen, or demo load.
Set to `0` to disable. Set to `1` to enable. Default is `2`. \
Any values higher than `1` will be the extra 'gameplay' frames being skipped. \
For example, `2` means one extra gameplay frame skipped during capture.",
For example, `2` means ''1'' extra gameplay frame skipped during capture.",
);
static BXT_CAP_SAMPLING_MIN_FPS: CVar = CVar::new(
b"_bxt_cap_sampling_min_fps\0",
Expand Down Expand Up @@ -226,7 +226,7 @@ fn cap_start(marker: MainThreadMarker) {
cap_start_with_filename(marker, "output.mp4".to_string());
}

fn cap_start_with_filename(marker: MainThreadMarker, filename: String) {
pub fn cap_start_with_filename(marker: MainThreadMarker, filename: String) {
if !Capture.is_enabled(marker) {
return;
}
Expand Down Expand Up @@ -536,20 +536,14 @@ pub unsafe fn time_passed(marker: MainThreadMarker) {

if BXT_CAP_SKIP_NON_GAMEPLAY_FRAMES.as_bool(marker) {
if (&*engine::cls.get(marker)).state != 5 {
// ca_dedicated=0,
// ca_disconnected=1,
// ca_connecting=2,
// ca_connected=3,
// ca_uninitialized=4,
// ca_active=5
return;
}
// 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 is in this true condition...
// That's a good thing because it technically captures all non-loading frames.
// Broken frames before that in a demo are counted as normal frames.
// For some reasons, the "true" first frame will be catched 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 {
// Fallback when there is no viewmodel assigned ever. Happens when no weapons are picked up.
// Frame 7 is guaranteed to be the "start" frame most of the time.
Expand All @@ -558,7 +552,6 @@ pub unsafe fn time_passed(marker: MainThreadMarker) {
}
}
// Alternative use of the cvar.
// Recording FPS must not be below demo FPS so the skip can work properly. Eg: recording 60fps of 250fps demo will be iffy.
if FRAME_SKIP.get(marker) + 1 < BXT_CAP_SKIP_NON_GAMEPLAY_FRAMES.as_f32(marker) as u32 {
FRAME_SKIP.set(marker, FRAME_SKIP.get(marker) + 1);
return;
Expand Down

0 comments on commit b363826

Please sign in to comment.