Skip to content

Commit

Permalink
do disconnected processing even when no game is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Apr 3, 2024
1 parent 8cb4e91 commit 6f00cf4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions cheevos/cheevos.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ static rcheevos_locals_t rcheevos_locals =
0, /* menuitem_count */
#endif
#ifdef HAVE_RC_CLIENT
true,/* hardcore_allowed */
true, /* hardcore_allowed */
false,/* is_disconnected */
#else
#ifdef HAVE_GFX_WIDGETS
0, /* active_lboard_trackers */
Expand Down Expand Up @@ -617,6 +618,7 @@ static void rcheevos_server_error(const char* api_name, const char* message)
static void rcheevos_server_disconnected(void)
{
CHEEVOS_LOG(RCHEEVOS_TAG "Unable to communicate with RetroAchievements server\n");
rcheevos_locals.is_disconnected = true;

/* always show message - even with widget. it helps the user understand what the widget is for */
{
Expand All @@ -634,6 +636,7 @@ static void rcheevos_server_disconnected(void)
static void rcheevos_server_reconnected(void)
{
CHEEVOS_LOG(RCHEEVOS_TAG "All pending requests synced to RetroAchievements server\n");
rcheevos_locals.is_disconnected = false;

{
const char* message = msg_hash_to_str(MENU_ENUM_LABEL_CHEEVOS_SERVER_RECONNECTED);
Expand Down Expand Up @@ -2442,7 +2445,9 @@ static void rcheevos_client_load_game_callback(int result,
char msg[256];

#if defined(HAVE_GFX_WIDGETS)
gfx_widget_set_cheevos_disconnect(false);
/* hide the loading widget if not in a disconnected state */
if (!rcheevos_locals.is_disconnected)
gfx_widget_set_cheevos_disconnect(false);
#endif

if (result != RC_OK || !game)
Expand Down
1 change: 1 addition & 0 deletions cheevos/cheevos_locals.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ typedef struct rcheevos_locals_t

#ifdef HAVE_RC_CLIENT
bool hardcore_allowed; /* prevents enabling hardcore if illegal settings detected */
bool is_disconnected; /* indicates there are pending requests */
#else

#ifdef HAVE_GFX_WIDGETS
Expand Down
4 changes: 4 additions & 0 deletions cheevos/cheevos_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ void rcheevos_menu_populate(void* data)
case RC_CLIENT_LOAD_GAME_STATE_STARTING_SESSION:
msg = MENU_ENUM_LABEL_VALUE_CHEEVOS_STARTING_SESSION;
break;
case RC_CLIENT_LOAD_GAME_STATE_NONE:
if (!rc_client_get_user_info(rcheevos_locals->client))
msg = MENU_ENUM_LABEL_VALUE_NOT_LOGGED_IN;
break;
}

menu_entries_append(info->list,
Expand Down
8 changes: 4 additions & 4 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -6983,6 +6983,10 @@ int runloop_iterate(void)
netplay_driver_ctl(RARCH_NETPLAY_CTL_PAUSE, NULL);
#endif
#endif
#ifdef HAVE_CHEEVOS
if (cheevos_enable)
rcheevos_idle();
#endif
#ifdef HAVE_MENU
/* Rely on vsync throttling unless VRR is enabled and menu throttle is disabled. */
if (vrr_runloop_enable && !settings->bools.menu_throttle_framerate)
Expand All @@ -6998,10 +7002,6 @@ int runloop_iterate(void)
: settings->floats.video_refresh_rate));
else
runloop_set_frame_limit(&video_st->av_info, settings->floats.fastforward_ratio);
#endif
#ifdef HAVE_CHEEVOS
if (cheevos_enable)
rcheevos_idle();
#endif
goto end;
case RUNLOOP_STATE_ITERATE:
Expand Down

0 comments on commit 6f00cf4

Please sign in to comment.