Skip to content

Commit

Permalink
Added posting practice replays
Browse files Browse the repository at this point in the history
  • Loading branch information
NSGolova committed Jan 8, 2024
1 parent b040615 commit e981c2b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions include/Core/ReplayRecorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{}

Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/Core/ReplayRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ReplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit e981c2b

Please sign in to comment.