Skip to content

Commit

Permalink
Hopefully fix reset bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Aug 10, 2024
1 parent 3095152 commit 0df078e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/retro_achievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ ra_config_t* se_get_ra_config();
#include <atomic>
#include <cassert>
#include <chrono>
#include <condition_variable>
#include <cstdint>
#include <cstdio>
#include <cstring>
Expand Down Expand Up @@ -141,7 +140,6 @@ struct ra_game_state_t
ra_progress_indicator_t progress_indicator;
std::vector<ra_notification_t> notifications;
std::atomic_int outstanding_requests;
std::condition_variable cv;
std::mutex mutex;

void inc()
Expand All @@ -154,10 +152,6 @@ struct ra_game_state_t
{
outstanding_requests--;
printf("outstanding requests: %d\n", outstanding_requests.load());
if (outstanding_requests == 0)
{
cv.notify_all();
}
}
};

Expand Down Expand Up @@ -1071,6 +1065,15 @@ void retro_achievements_load_game()
if (!ra_state->emu_state->rom_loaded)
return;

const rc_client_user_t* user = rc_client_get_user_info(ra_state->rc_client);
if (!user)
return;

if (ra_state->game_state) {
// We need to wait for any requests to finish
while(ra_state->game_state->outstanding_requests.load() != 0) {}
}

// the old one will be destroyed when the last reference is gone
ra_state->game_state.reset(new ra_game_state_t());

Expand Down

0 comments on commit 0df078e

Please sign in to comment.