From 8225c90ddbd89f094ad851d847d958a62ea02b57 Mon Sep 17 00:00:00 2001 From: offtkp Date: Fri, 3 May 2024 13:25:38 +0300 Subject: [PATCH] Fixes for web --- src/main.c | 4 ++-- src/retro_achievements.cpp | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index c124a9185..370679c9b 100644 --- a/src/main.c +++ b/src/main.c @@ -521,7 +521,7 @@ void se_reset_save_states(); void se_reset_cheats(); void se_set_new_controller(se_controller_state_t* cont, int index); bool se_run_ar_cheat(const uint32_t* buffer, uint32_t size); -static void se_emscripten_flush_fs(); +void se_emscripten_flush_fs(); static uint32_t se_save_best_effort_state(se_core_state_t* state); static bool se_load_best_effort_state(se_core_state_t* state,uint8_t *save_state_data, uint32_t size, uint32_t bess_offset); static size_t se_get_core_size(); @@ -1354,7 +1354,7 @@ double se_fps_counter(int tick){ return 1.0/fps; } -static void se_emscripten_flush_fs(){ +void se_emscripten_flush_fs(){ #if defined(EMSCRIPTEN) EM_ASM( FS.syncfs(function (err) {});); #endif diff --git a/src/retro_achievements.cpp b/src/retro_achievements.cpp index 8dcd2828c..ff8f4f6e6 100644 --- a/src/retro_achievements.cpp +++ b/src/retro_achievements.cpp @@ -14,6 +14,7 @@ void se_boxed_image_dual_label(const char* title, const char* description, const bool se_button(const char* label, ImVec2 size); const char* se_localize_and_cache(const char* input_str); ImFont* se_get_mono_font(); +void se_emscripten_flush_fs(); #include "retro_achievements.h" ra_config_t* se_get_ra_config(); } @@ -395,15 +396,13 @@ namespace uint32_t id = rc_achievement->id; uint8_t bucket = rc_achievement->bucket; std::unique_lock lock(game_state->mutex); - ra_state->download(game_state, url, [game_state, notification, url, id, bucket]() { - ra_achievement_t* achievement = - retro_achievements_move_bucket(game_state, id, bucket); - + ra_achievement_t* achievement = retro_achievements_move_bucket(game_state, id, bucket); + game_state->notifications.push_back(*notification); + ra_state->download(game_state, url, [game_state, notification, url, id, bucket, achievement]() { if (achievement) { achievement->tile = &game_state->image_cache[url]; notification->tile = achievement->tile; - game_state->notifications.push_back(*notification); } }); } @@ -503,9 +502,7 @@ namespace sb_save_file_data(path.c_str(), (const uint8_t*)data.data(), data.size()); retro_achievements_load_game(); -#if defined(SE_PLATFORM_WEB) - EM_ASM( FS.syncfs(function (err) {});); -#endif + se_emscripten_flush_fs(); } state->pending_login = false;