Skip to content

Commit

Permalink
Add bxt_on_tas_playback_stopped()
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Jun 24, 2023
1 parent 9b01101 commit 0c9deb3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ struct on_tas_playback_frame_data {
// Change the variable name if you change the parameters!
// This way outdated bxt-rs will be unable to find the variable, instead of crashing due to mismatching parameters.
extern "C" {
// Return value != 0 means stop TAS playback.
// BXT will call this right before running HLStrafe for every played back frame of a TAS.
//
// Return value != 0 will cause BXT to stop TAS playback.
DLLEXPORT int (*bxt_on_tas_playback_frame)(on_tas_playback_frame_data data);

// BXT will call this when the TAS playback stops.
DLLEXPORT void (*bxt_on_tas_playback_stopped)();
}

// Linux hooks.
Expand Down Expand Up @@ -2390,8 +2395,16 @@ int HwDLL::CallOnTASPlaybackFrame() {
});
}

void HwDLL::CallOnTASPlaybackStopped() {
if (bxt_on_tas_playback_stopped) {
bxt_on_tas_playback_stopped();
}
}

void HwDLL::ResetTASPlaybackState()
{
CallOnTASPlaybackStopped();

// Disable the input editor.
SetTASEditorMode(TASEditorMode::DISABLED);

Expand Down Expand Up @@ -4967,6 +4980,7 @@ void HwDLL::SetTASEditorMode(TASEditorMode mode)
input.RemoveFrame(currentFramebulk);
}

CallOnTASPlaybackStopped();
runningFrames = false;
ORIG_Cbuf_InsertText("host_framerate 0;_bxt_norefresh 0;_bxt_min_frametime 0;bxt_taslog 0\n");

Expand Down Expand Up @@ -5882,6 +5896,7 @@ void HwDLL::InsertCommands()

// Ran through all frames.
if (currentFramebulk >= totalFramebulks) {
CallOnTASPlaybackStopped();
runningFrames = false;

if (!exportFilename.empty()) {
Expand Down
1 change: 1 addition & 0 deletions BunnymodXT/modules/HwDLL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ class HwDLL : public IHookableNameFilterOrdered
bool is_cof_steam = false; // Cry of Fear-specific

int CallOnTASPlaybackFrame();
void CallOnTASPlaybackStopped();
void ResetTASPlaybackState();
void StartTASPlayback();

Expand Down

0 comments on commit 0c9deb3

Please sign in to comment.