Skip to content

Commit

Permalink
Fixed crash on song restart with dynamic height enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
NSGolova committed Apr 17, 2024
1 parent cca8d4a commit c5d2aad
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/Core/ReplayRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,6 @@ namespace ReplayRecorder {
automaticPlayerHeight = gameplayCoreSceneSetupData->playerSpecificSettings->automaticPlayerHeight;
}

void OnPlayerHeightChange(float height)
{
if (audioTimeSyncController && automaticPlayerHeight && replay != nullopt) {
replay->heights.emplace_back(height, audioTimeSyncController->songTime);
}
}

void startReplay() {
std::string timeStamp(std::to_string(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()));

Expand All @@ -162,7 +155,7 @@ namespace ReplayRecorder {
replay.emplace(ReplayInfo(modInfo.version, UnityEngine::Application::get_version(), timeStamp));

userEnhancer.Enhance(replay.value());

audioTimeSyncController = nullptr;
}

MAKE_HOOK_MATCH(SinglePlayerInstallBindings, &GameplayCoreInstaller::InstallBindings, void, GameplayCoreInstaller* self) {
Expand All @@ -177,13 +170,12 @@ namespace ReplayRecorder {
startReplay();
}

MAKE_HOOK_MATCH(PlayerHeightDetectorStart, &PlayerHeightDetector::Start, void, PlayerHeightDetector* self) {
PlayerHeightDetectorStart(self);
MAKE_HOOK_MATCH(PlayerHeightDetectorLateUpdate, &PlayerHeightDetector::LateUpdate, void, PlayerHeightDetector* self) {
PlayerHeightDetectorLateUpdate(self);

if (replay == nullopt) return;

_heightEvent = custom_types::MakeDelegate<System::Action_1<float>*>((std::function<void(float)>)OnPlayerHeightChange);
self->add_playerHeightDidChangeEvent(_heightEvent);
if (audioTimeSyncController && automaticPlayerHeight && replay != nullopt) {
replay->heights.emplace_back(self->_lastReportedHeight, audioTimeSyncController->songTime);
}
}

void processResults(LevelCompletionResults* levelCompletionResults, bool skipUpload) {
Expand Down Expand Up @@ -551,7 +543,7 @@ namespace ReplayRecorder {
INSTALL_HOOK(BeatLeaderLogger, Tick);
INSTALL_HOOK(BeatLeaderLogger, ComputeSwingRating);
INSTALL_HOOK(BeatLeaderLogger, ProcessNewSwingData);
INSTALL_HOOK(BeatLeaderLogger, PlayerHeightDetectorStart);
INSTALL_HOOK(BeatLeaderLogger, PlayerHeightDetectorLateUpdate);
INSTALL_HOOK(BeatLeaderLogger, ScoreControllerStart);
INSTALL_HOOK(BeatLeaderLogger, ScoreControllerLateUpdate);
INSTALL_HOOK(BeatLeaderLogger, ProcessResultsMultiplayer);
Expand Down

0 comments on commit c5d2aad

Please sign in to comment.