(cheevos) change expired token message from info to error; clear token (#18294)

This commit is contained in:
Jamiras 2025-10-06 09:16:28 -06:00 committed by GitHub
parent df1ccb9497
commit 8f73291977
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 6 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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"

View File

@ -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,