From e981c2b317a5e838811d0748905f7b97a8de218f Mon Sep 17 00:00:00 2001 From: golova Date: Mon, 8 Jan 2024 21:06:48 +0100 Subject: [PATCH] Added posting practice replays --- include/Core/ReplayRecorder.hpp | 11 +++++++---- src/Core/ReplayRecorder.cpp | 4 ++-- src/Utils/ReplayManager.cpp | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/Core/ReplayRecorder.hpp b/include/Core/ReplayRecorder.hpp index 1744b39..183258a 100644 --- a/include/Core/ReplayRecorder.hpp +++ b/include/Core/ReplayRecorder.hpp @@ -16,13 +16,14 @@ enum class LevelEndType { Clear = 1, Fail = 2, Restart = 3, - Quit = 4 + Quit = 4, + Practice = 5 }; class PlayEndData { public: - PlayEndData(const GlobalNamespace::LevelCompletionResults* results) - : _endType(ToLevelEndAction(results)), + PlayEndData(const GlobalNamespace::LevelCompletionResults* results, float speed) + : _endType(ToLevelEndAction(results, speed)), _time(results->endSongTime) {} @@ -54,7 +55,9 @@ class PlayEndData { { { LevelEndStateType::Cleared , LevelEndAction::None }, LevelEndType::Clear } }; - LevelEndType ToLevelEndAction(const GlobalNamespace::LevelCompletionResults* results) { + LevelEndType ToLevelEndAction(const GlobalNamespace::LevelCompletionResults* results, float speed) { + if (speed != 0) return LevelEndType::Practice; + LevelEndStateType levelEndStateType = results->levelEndStateType; LevelEndAction levelEndAction = results->levelEndAction; diff --git a/src/Core/ReplayRecorder.cpp b/src/Core/ReplayRecorder.cpp index 2b6dbf9..440fb9a 100644 --- a/src/Core/ReplayRecorder.cpp +++ b/src/Core/ReplayRecorder.cpp @@ -204,7 +204,7 @@ namespace ReplayRecorder { mapEnhancer.energy = levelCompletionResults->energy; mapEnhancer.Enhance(replay.value()); - auto playEndData = PlayEndData(levelCompletionResults); + auto playEndData = PlayEndData(levelCompletionResults, replay->info.speed); if (playEndData.GetEndType() == LevelEndType::Fail) { replay->info.failTime = audioTimeSyncController->songTime; @@ -230,7 +230,7 @@ namespace ReplayRecorder { { case MultiplayerLevelCompletionResults::MultiplayerPlayerLevelEndReason::Cleared: auto results = levelCompletionResults->localPlayerResultData->multiplayerLevelCompletionResults->levelCompletionResults; - auto playEndData = PlayEndData(results); + auto playEndData = PlayEndData(results, replay->info.speed); replay->info.score = results->multipliedScore; diff --git a/src/Utils/ReplayManager.cpp b/src/Utils/ReplayManager.cpp index 0472667..e10c0be 100644 --- a/src/Utils/ReplayManager.cpp +++ b/src/Utils/ReplayManager.cpp @@ -54,7 +54,7 @@ void ReplayManager::TryPostReplay(string name, PlayEndData status, int tryIndex, FILE *replayFile = fopen(name.data(), "rb"); chrono::steady_clock::time_point replayPostStart = chrono::steady_clock::now(); - WebUtils::PostFileAsync(WebUtils::API_URL + "replayoculus" + status.ToQueryString(), replayFile, (long)file_info.st_size, [name, tryIndex, finished, replayFile, replayPostStart](long statusCode, string result, string headers) { + WebUtils::PostFileAsync(WebUtils::API_URL + "replayoculus" + status.ToQueryString(), replayFile, (long)file_info.st_size, [name, tryIndex, finished, replayFile, replayPostStart, runCallback, status](long statusCode, string result, string headers) { fclose(replayFile); if (statusCode >= 450 && tryIndex < 2) { getLogger().info("%s", ("Retrying posting replay after " + to_string(statusCode) + " #" + to_string(tryIndex) + " " + std::string(result)).c_str());