Skip to content

Commit 8f73291

Browse files
authored
(cheevos) change expired token message from info to error; clear token (#18294)
1 parent df1ccb9 commit 8f73291

4 files changed

Lines changed: 37 additions & 6 deletions

File tree

cheevos/cheevos.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,13 +1340,28 @@ static void rcheevos_client_login_callback(int result,
13401340

13411341
if (result != RC_OK)
13421342
{
1343+
settings_t* settings = config_get_ptr();
13431344
char msg[256];
13441345
size_t _len = strlcpy(msg, "RetroAchievements login failed: ",
13451346
sizeof(msg));
13461347
_len += strlcpy(msg + _len, error_message, sizeof(msg) - _len);
13471348
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", msg);
1349+
1350+
if (result == RC_EXPIRED_TOKEN || /* token expired */
1351+
(result == RC_INVALID_CREDENTIALS && settings->arrays.cheevos_token[0])) /* token invalid */
1352+
{
1353+
/* expired token, clear it out */
1354+
settings->arrays.cheevos_token[0] = '\0';
1355+
1356+
/* the server message says to log in again. RetroArch doesn't really
1357+
have a login form, so use a custom message (that's translated) to
1358+
tell them to re-enter their password and restart the game. */
1359+
_len = strlcpy(msg, msg_hash_to_str(MSG_CHEEVOS_LOGIN_TOKEN_EXPIRED),
1360+
sizeof(msg));
1361+
}
1362+
13481363
runloop_msg_queue_push(msg, _len, 0, 2 * 60, false, NULL,
1349-
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
1364+
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
13501365
return;
13511366
}
13521367

@@ -1444,18 +1459,29 @@ static void rcheevos_client_load_game_callback(int result,
14441459
return;
14451460

14461461
_len = strlcpy(msg, msg_hash_to_str(MSG_CHEEVOS_GAME_NOT_IDENTIFIED), sizeof(msg));
1462+
1463+
runloop_msg_queue_push(msg, _len, 0, 2 * 60, false, NULL,
1464+
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
14471465
}
14481466
else
14491467
{
14501468
if (!error_message)
14511469
error_message = "Unknown error";
14521470

1453-
_len = snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEEVOS_GAME_LOAD_FAILED), error_message);
14541471
CHEEVOS_LOG(RCHEEVOS_TAG "Game load failed: %s\n", error_message);
1472+
1473+
if (result == RC_LOGIN_REQUIRED)
1474+
{
1475+
/* assume error already reported by rcheevos_client_login_callback */
1476+
}
1477+
else
1478+
{
1479+
_len = snprintf(msg, sizeof(msg), msg_hash_to_str(MSG_CHEEVOS_GAME_LOAD_FAILED), error_message);
1480+
runloop_msg_queue_push(msg, _len, 0, 2 * 60, false, NULL,
1481+
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
1482+
}
14551483
}
14561484

1457-
runloop_msg_queue_push(msg, _len, 0, 2 * 60, false, NULL,
1458-
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
14591485
return;
14601486
}
14611487

cheevos/cheevos_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,12 @@ static void rcheevos_client_http_task_callback(retro_task_t* task,
248248

249249
if (!http_data)
250250
{
251-
CHEEVOS_LOG(RCHEEVOS_TAG "http_task returned null");
251+
CHEEVOS_LOG(RCHEEVOS_TAG "http_task returned null\n");
252252
callback_data->callback(&server_response, callback_data->callback_data);
253253
}
254254
else if (http_data->status < 0)
255255
{
256-
CHEEVOS_LOG(RCHEEVOS_TAG "http_task returned %d", http_data->status);
256+
CHEEVOS_LOG(RCHEEVOS_TAG "http_task returned %d\n", http_data->status);
257257
callback_data->callback(&server_response, callback_data->callback_data);
258258
}
259259
else

intl/msg_hash_us.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15894,6 +15894,10 @@ MSG_HASH(
1589415894
MSG_CHEEVOS_CHANGE_MEDIA_FAILED,
1589515895
"RetroAchievements change media failed: %s"
1589615896
)
15897+
MSG_HASH(
15898+
MSG_CHEEVOS_LOGIN_TOKEN_EXPIRED,
15899+
"RetroAchievements login expired. Please re-enter your password and reload the game."
15900+
)
1589715901
MSG_HASH(
1589815902
MSG_RESAMPLER_QUALITY_LOWEST,
1589915903
"Lowest"

msg_hash.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4154,6 +4154,7 @@ enum msg_hash_enums
41544154
MSG_CHEEVOS_GAME_NOT_IDENTIFIED,
41554155
MSG_CHEEVOS_GAME_LOAD_FAILED,
41564156
MSG_CHEEVOS_CHANGE_MEDIA_FAILED,
4157+
MSG_CHEEVOS_LOGIN_TOKEN_EXPIRED,
41574158
MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS,
41584159
MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM,
41594160
MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD,

0 commit comments

Comments
 (0)