From 02a6d7307062f9466e6e5b69656377776f23f1f5 Mon Sep 17 00:00:00 2001 From: offtkp Date: Sat, 23 Dec 2023 22:55:55 +0200 Subject: [PATCH] No User-Agent attempt --- CMakeLists.txt | 8 ++++---- src/retro_achievements.cpp | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddfd7ea02..de0ee8131 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) option(ENABLE_RETRO_ACHIEVEMENTS "Enable Retro Achievements" ON) if (EMSCRIPTEN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 ") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 ") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 -s ASSERTIONS=1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 -s ASSERTIONS=1") endif () if (MSVC) # Perform extremely aggressive optimization on Release builds: @@ -61,8 +61,8 @@ if (NOT EMSCRIPTEN) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 ") set(UNICODE_GUI 1) else () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -DNDEBUG") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3 ") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 ") endif () if(IOS) set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum iOS deployment version" FORCE) diff --git a/src/retro_achievements.cpp b/src/retro_achievements.cpp index 06a7f380c..0d52bfeb0 100644 --- a/src/retro_achievements.cpp +++ b/src/retro_achievements.cpp @@ -40,11 +40,20 @@ static void server_callback(const rc_api_request_t* request, } else { type = http_request_e::POST; } + url += "?" + post_data; + + printf("[rcheevos]: %s %s\n", url.c_str(), content_type.c_str()); #ifndef EMSCRIPTEN std::thread thread([type, url, post_data, callback, callback_data](){ #endif - https_request(type, url, post_data, { {"User-Agent", "SkyEmu/4.0"} }, [callback, callback_data](const std::vector& result) { + std::vector> headers; + #ifndef EMSCRIPTEN + // TODO(paris): When setting User-Agent from browser side, it sends a CORS preflight request + // which is makes the request fail. + headers.push_back({"User-Agent", "SkyEmu/4.0"}); + #endif + https_request(type, url, {}, headers, [callback, callback_data](const std::vector& result) { if (result.empty()) { printf("[rcheevos]: empty response\n");