diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 7f314a9b70..fdede5e681 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1340,13 +1340,28 @@ static void rcheevos_client_login_callback(int result, if (result != RC_OK) { + settings_t* settings = config_get_ptr(); char msg[256]; size_t _len = strlcpy(msg, "RetroAchievements login failed: ", sizeof(msg)); _len += strlcpy(msg + _len, error_message, sizeof(msg) - _len); CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", msg); + + if (result == RC_EXPIRED_TOKEN || /* token expired */ + (result == RC_INVALID_CREDENTIALS && settings->arrays.cheevos_token[0])) /* token invalid */ + { + /* expired token, clear it out */ + settings->arrays.cheevos_token[0] = '\0'; + + /* the server message says to log in again. RetroArch doesn't really + have a login form, so use a custom message (that's translated) to + tell them to re-enter their password and restart the game. */ + _len = strlcpy(msg, msg_hash_to_str(MSG_CHEEVOS_LOGIN_TOKEN_EXPIRED), + sizeof(msg)); + } + runloop_msg_queue_push(msg, _len, 0, 2 * 60, false, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR); return; } @@ -1444,18 +1459,29 @@ static void rcheevos_client_load_game_callback(int result, return; _len = strlcpy(msg, msg_hash_to_str(MSG_CHEEVOS_GAME_NOT_IDENTIFIED), sizeof(msg)); + + runloop_msg_queue_push(msg, _len, 0, 2 * 60, false, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } else { if (!error_message) error_message = "Unknown error"; - _len = snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEEVOS_GAME_LOAD_FAILED), error_message); CHEEVOS_LOG(RCHEEVOS_TAG "Game load failed: %s\n", error_message); + + if (result == RC_LOGIN_REQUIRED) + { + /* assume error already reported by rcheevos_client_login_callback */ + } + else + { + _len = snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEEVOS_GAME_LOAD_FAILED), error_message); + runloop_msg_queue_push(msg, _len, 0, 2 * 60, false, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR); + } } - runloop_msg_queue_push(msg, _len, 0, 2 * 60, false, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); return; } diff --git a/cheevos/cheevos_client.c b/cheevos/cheevos_client.c index 35cfa5b25e..d9aa337569 100644 --- a/cheevos/cheevos_client.c +++ b/cheevos/cheevos_client.c @@ -248,12 +248,12 @@ static void rcheevos_client_http_task_callback(retro_task_t* task, if (!http_data) { - CHEEVOS_LOG(RCHEEVOS_TAG "http_task returned null"); + CHEEVOS_LOG(RCHEEVOS_TAG "http_task returned null\n"); callback_data->callback(&server_response, callback_data->callback_data); } else if (http_data->status < 0) { - CHEEVOS_LOG(RCHEEVOS_TAG "http_task returned %d", http_data->status); + CHEEVOS_LOG(RCHEEVOS_TAG "http_task returned %d\n", http_data->status); callback_data->callback(&server_response, callback_data->callback_data); } else diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 00e16cf50c..e0c6c7b38c 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -15894,6 +15894,10 @@ MSG_HASH( MSG_CHEEVOS_CHANGE_MEDIA_FAILED, "RetroAchievements change media failed: %s" ) +MSG_HASH( + MSG_CHEEVOS_LOGIN_TOKEN_EXPIRED, + "RetroAchievements login expired. Please re-enter your password and reload the game." + ) MSG_HASH( MSG_RESAMPLER_QUALITY_LOWEST, "Lowest" diff --git a/msg_hash.h b/msg_hash.h index 9b68db031c..519520e5d8 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -4154,6 +4154,7 @@ enum msg_hash_enums MSG_CHEEVOS_GAME_NOT_IDENTIFIED, MSG_CHEEVOS_GAME_LOAD_FAILED, MSG_CHEEVOS_CHANGE_MEDIA_FAILED, + MSG_CHEEVOS_LOGIN_TOKEN_EXPIRED, MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS, MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM, MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD,