From dd4018cb0a6927e6c56dbe38832a8e8175bc9d28 Mon Sep 17 00:00:00 2001 From: R2DLiu Date: Tue, 1 Aug 2023 16:12:18 -0400 Subject: [PATCH] pull in bf0c0764a2905f91bb69c8aa273677b012fa89f0 --- Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp | 3 +++ .../Core/Core/Slippi/SlippiGameReporter.cpp | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp index 8ebdb0d783..7f17aff19a 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp @@ -969,6 +969,9 @@ void CEXISlippi::prepareFrameData(u8* payload) return; } + // Hides frame index message on waiting for game screen + // OSD::AddTypedMessage(OSD::MessageType::FrameIndex, "", 0, OSD::Color::CYAN); + // If a new replay should be played, terminate the current game auto isNewReplay = g_replayComm->isNewReplay(); if (isNewReplay) diff --git a/Source/Core/Core/Slippi/SlippiGameReporter.cpp b/Source/Core/Core/Slippi/SlippiGameReporter.cpp index 714b13acf9..c5ede4d4cb 100644 --- a/Source/Core/Core/Slippi/SlippiGameReporter.cpp +++ b/Source/Core/Core/Slippi/SlippiGameReporter.cpp @@ -99,11 +99,19 @@ SlippiGameReporter::SlippiGameReporter(SlippiUser* user, const std::string curre m_user = user; + run_thread = true; + reporting_thread = std::thread(&SlippiGameReporter::ReportThreadHandler, this); + static const mbedtls_md_info_t* s_md5_info = mbedtls_md_info_from_type(MBEDTLS_MD_MD5); m_md5_thread = std::thread([this, current_file_name]() { + if (!run_thread) + return; + std::array md5_array; mbedtls_md_file(s_md5_info, current_file_name.c_str(), md5_array.data()); this->m_iso_hash = std::string(md5_array.begin(), md5_array.end()); + if (!run_thread) + return; if (known_desync_isos.find(this->m_iso_hash) != known_desync_isos.end() && known_desync_isos.at(this->m_iso_hash)) @@ -127,6 +135,9 @@ SlippiGameReporter::~SlippiGameReporter() if (reporting_thread.joinable()) reporting_thread.join(); + if (m_md5_thread.joinable()) + m_md5_thread.join(); + if (m_curl) { curl_slist_free_all(m_curl_header_list); @@ -282,6 +293,12 @@ void SlippiGameReporter::ReportThreadHandler() // Parse the response auto r = json::parse(resp); + if (!r.is_object()) + { + ERROR_LOG_FMT(SLIPPI, "JSON was not an object. {}", resp); + Common::SleepCurrentThread(errorSleepMs); + continue; + } bool success = r.value("success", false); if (!success) { @@ -368,8 +385,8 @@ void SlippiGameReporter::ReportCompletion(std::string matchId, u8 endMode) if (res != 0) { ERROR_LOG_FMT(SLIPPI_ONLINE, - "[GameReport] Got error executing completion request. Err code: {}", - static_cast(res)); + "[GameReport] Got error executing completion request. Err code: {}. Msg: {}", + static_cast(res), m_curl_err_buf); } }