diff --git a/src/services/AchievementRuntime.cpp b/src/services/AchievementRuntime.cpp index c6e589d2..11c1ae62 100644 --- a/src/services/AchievementRuntime.cpp +++ b/src/services/AchievementRuntime.cpp @@ -17,6 +17,7 @@ #include "services\IAudioSystem.hh" #include "services\IConfiguration.hh" #include "services\IFileSystem.hh" +#include "services\IHttpRequester.hh" #include "services\ILocalStorage.hh" #include "services\ServiceLocator.hh" #include "services\impl\JsonFileConfiguration.hh" @@ -193,12 +194,23 @@ uint32_t AchievementRuntime::ReadMemory(uint32_t nAddress, uint8_t* pBuffer, uin } static void ConvertHttpResponseToApiServerResponse(rc_api_server_response_t& pResponse, - const ra::services::Http::Response& httpResponse) noexcept + const ra::services::Http::Response& httpResponse, + std::string& sErrorBuffer) { memset(&pResponse, 0, sizeof(pResponse)); pResponse.http_status_code = ra::etoi(httpResponse.StatusCode()); pResponse.body = httpResponse.Content().c_str(); pResponse.body_length = httpResponse.Content().length(); + + if (pResponse.http_status_code > 599 || pResponse.body_length == 0) + { + const auto& pHttpRequestService = ra::services::ServiceLocator::Get(); + sErrorBuffer = pHttpRequestService.GetStatusCodeText(pResponse.http_status_code); + pResponse.body = sErrorBuffer.c_str(); + pResponse.body_length = sErrorBuffer.length(); + pResponse.http_status_code = pHttpRequestService.IsRetryable(pResponse.http_status_code) ? + RC_API_SERVER_RESPONSE_RETRYABLE_CLIENT_ERROR : RC_API_SERVER_RESPONSE_CLIENT_ERROR; + } } void AchievementRuntime::ServerCallAsync(const rc_api_request_t* pRequest, rc_client_server_callback_t fCallback, @@ -253,7 +265,8 @@ void AchievementRuntime::ServerCallAsync(const rc_api_request_t* pRequest, rc_cl httpRequest.CallAsync([fCallback, pCallbackData, sApi](const ra::services::Http::Response& httpResponse) { rc_api_server_response_t pResponse; - ConvertHttpResponseToApiServerResponse(pResponse, httpResponse); + std::string sErrorBuffer; + ConvertHttpResponseToApiServerResponse(pResponse, httpResponse, sErrorBuffer); RA_LOG_INFO("<< %s response (%d): %s", sApi.c_str(), ra::etoi(httpResponse.StatusCode()), httpResponse.Content().c_str()); diff --git a/src/ui/win32/OverlayWindow.cpp b/src/ui/win32/OverlayWindow.cpp index 93f65988..9380a846 100644 --- a/src/ui/win32/OverlayWindow.cpp +++ b/src/ui/win32/OverlayWindow.cpp @@ -57,14 +57,15 @@ void OverlayWindow::CreateOverlayWindow(HWND hWnd) if (m_hOverlayWnd && IsWindow(m_hOverlayWnd)) { - // overlay window exists, just update the parent (if necessary) + // overlay window already exists, destroy before creating a new one if (m_hWnd != hWnd) { - m_hWnd = hWnd; - SetParent(m_hOverlayWnd, hWnd); - UpdateOverlayPosition(); + DestroyOverlayWindow(); + } + else + { + return; } - return; } // overlay window does not exist, create it @@ -197,8 +198,13 @@ void OverlayWindow::CreateOverlayWindow() }); } -void OverlayWindow::DestroyOverlayWindow() noexcept +void OverlayWindow::DestroyOverlayWindow() { + + //clear current popups so they don't interfere with creation of a new overlay + auto& pOverlayManager = ra::services::ServiceLocator::GetMutable(); + pOverlayManager.ClearPopups(); + if (m_hEventHook) { UnhookWinEvent(m_hEventHook); diff --git a/src/ui/win32/OverlayWindow.hh b/src/ui/win32/OverlayWindow.hh index 5c503371..0830c4a6 100644 --- a/src/ui/win32/OverlayWindow.hh +++ b/src/ui/win32/OverlayWindow.hh @@ -13,7 +13,7 @@ class OverlayWindow { public: void CreateOverlayWindow(HWND hWnd); - void DestroyOverlayWindow() noexcept; + void DestroyOverlayWindow(); void OnOverlayMoved() noexcept;