From bb6911077a584fbdd0121e7fea20c610162b1b6f Mon Sep 17 00:00:00 2001 From: Jamiras Date: Fri, 30 Jul 2021 11:16:12 -0600 Subject: [PATCH] add messages for unknown game and network error --- cheevos/cheevos.c | 10 ++++++++++ cheevos/cheevos_locals.h | 1 + cheevos/cheevos_menu.c | 16 ++++++++++++++++ intl/msg_hash_us.h | 8 ++++++++ msg_hash.h | 3 +++ 5 files changed, 38 insertions(+) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index cd0b7f36c8..d368d81d6a 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -111,6 +111,7 @@ static rcheevos_locals_t rcheevos_locals = false,/* hardcore_active */ false,/* loaded */ true, /* core_supports */ + false,/* network_error */ false,/* leaderboards_enabled */ false,/* leaderboard_notifications */ false /* leaderboard_trackers */ @@ -1271,6 +1272,11 @@ static int rcheevos_iterate(rcheevos_coro_t* coro) if (!coro->settings->bools.cheevos_enable) CORO_STOP(); + /* reset the network error flag */ + rcheevos_locals.network_error = false; + /* reset the identified game id */ + rcheevos_locals.patchdata.game_id = 0; + /* iterate over the possible hashes for the file being loaded */ rc_hash_initialize_iterator(&coro->iterator, coro->path, (uint8_t*)coro->data, coro->len); #ifdef CHEEVOS_TIME_HASH @@ -1300,6 +1306,9 @@ static int rcheevos_iterate(rcheevos_coro_t* coro) CORO_STOP(); } + /* capture the identified game id in case we bail before fetching the patch data (not logged in) */ + rcheevos_locals.patchdata.game_id = coro->gameid; + #ifdef CHEEVOS_JSON_OVERRIDE { size_t size = 0; @@ -1890,6 +1899,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro) } CHEEVOS_LOG(RCHEEVOS_TAG "Couldn't connect to server after 5 tries\n"); + rcheevos_locals.network_error = true; CORO_RET(); diff --git a/cheevos/cheevos_locals.h b/cheevos/cheevos_locals.h index a42e80ff3c..ffce11d19d 100644 --- a/cheevos/cheevos_locals.h +++ b/cheevos/cheevos_locals.h @@ -148,6 +148,7 @@ typedef struct rcheevos_locals_t bool hardcore_active; /* hardcore functionality is active */ bool loaded; /* load task has completed */ bool core_supports; /* false if core explicitly disables achievements */ + bool network_error; /* hash lookup or login failed with network error */ bool leaderboards_enabled; /* leaderboards are enabled */ bool leaderboard_notifications; /* leaderboard notifications are enabled */ bool leaderboard_trackers; /* leaderboard trackers are enabled */ diff --git a/cheevos/cheevos_menu.c b/cheevos/cheevos_menu.c index 504e09c889..0667087e45 100644 --- a/cheevos/cheevos_menu.c +++ b/cheevos/cheevos_menu.c @@ -662,6 +662,22 @@ void rcheevos_menu_populate(void* data) MENU_ENUM_LABEL_CANNOT_ACTIVATE_ACHIEVEMENTS_WITH_THIS_CORE, FILE_TYPE_NONE, 0, 0); } + else if (rcheevos_locals->network_error) + { + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETWORK_ERROR), + msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_ERROR), + MENU_ENUM_LABEL_NETWORK_ERROR, + FILE_TYPE_NONE, 0, 0); + } + else if (!rcheevos_locals->patchdata.game_id) + { + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_UNKNOWN_GAME), + msg_hash_to_str(MENU_ENUM_LABEL_UNKNOWN_GAME), + MENU_ENUM_LABEL_UNKNOWN_GAME, + FILE_TYPE_NONE, 0, 0); + } else if (!rcheevos_locals->token[0]) { menu_entries_append_enum(info->list, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 66c7fa1631..89e25f1743 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7184,6 +7184,14 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NOT_LOGGED_IN, "Not logged in" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETWORK_ERROR, + "Network Error" +) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_UNKNOWN_GAME, + "Unknown Game" +) MSG_HASH( MENU_ENUM_LABEL_VALUE_CANNOT_ACTIVATE_ACHIEVEMENTS_WITH_THIS_CORE, "Cannot activate achievements using this core" diff --git a/msg_hash.h b/msg_hash.h index 5547f45272..95bf05956c 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1330,8 +1330,11 @@ enum msg_hash_enums MENU_LABEL(SET_CORE_ASSOCIATION), MENU_LABEL(RESET_CORE_ASSOCIATION), MENU_LABEL(MENU_THROTTLE_FRAMERATE), + MENU_LABEL(NO_ACHIEVEMENTS_TO_DISPLAY), MENU_LABEL(NOT_LOGGED_IN), + MENU_LABEL(NETWORK_ERROR), + MENU_LABEL(UNKNOWN_GAME), MENU_LABEL(CANNOT_ACTIVATE_ACHIEVEMENTS_WITH_THIS_CORE), MENU_LABEL(NO_ENTRIES_TO_DISPLAY), MENU_LABEL(DOWNLOAD_PL_ENTRY_THUMBNAILS),