mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
use case-corrected username for server calls
This commit is contained in:
parent
7aca71e625
commit
46ffe5f4b2
@ -98,7 +98,8 @@ static rcheevos_locals_t rcheevos_locals =
|
||||
NULL, /* task_lock */
|
||||
CMD_EVENT_NONE, /* queued_command */
|
||||
#endif
|
||||
{0}, /* token */
|
||||
"", /* username */
|
||||
"", /* token */
|
||||
"N/A",/* hash */
|
||||
"", /* user_agent_prefix */
|
||||
"", /* user_agent_core */
|
||||
@ -1532,7 +1533,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
|
||||
|
||||
CORO_GOSUB(RCHEEVOS_LOGIN);
|
||||
|
||||
ret = rc_url_get_patch(coro->url, sizeof(coro->url), coro->settings->arrays.cheevos_username, rcheevos_locals.token, coro->gameid);
|
||||
ret = rc_url_get_patch(coro->url, sizeof(coro->url), rcheevos_locals.username, rcheevos_locals.token, coro->gameid);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -1750,7 +1751,9 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
|
||||
CORO_STOP();
|
||||
}
|
||||
|
||||
ret = rcheevos_get_token(coro->json, tok, sizeof(tok));
|
||||
ret = rcheevos_get_token(coro->json,
|
||||
rcheevos_locals.username, sizeof(rcheevos_locals.username),
|
||||
tok, sizeof(tok));
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
@ -1773,12 +1776,12 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
|
||||
char msg[256];
|
||||
snprintf(msg, sizeof(msg),
|
||||
"RetroAchievements: Logged in as \"%s\".",
|
||||
coro->settings->arrays.cheevos_username);
|
||||
rcheevos_locals.username);
|
||||
msg[sizeof(msg) - 1] = 0;
|
||||
runloop_msg_queue_push(msg, 0, 2 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "logged in successfully\n");
|
||||
CHEEVOS_LOG(RCHEEVOS_TAG "%s logged in successfully\n", rcheevos_locals.username);
|
||||
strlcpy(rcheevos_locals.token, tok,
|
||||
sizeof(rcheevos_locals.token));
|
||||
|
||||
@ -1906,7 +1909,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
|
||||
for (coro->i = 0; coro->i < 2; coro->i++)
|
||||
{
|
||||
ret = rc_url_get_unlock_list(coro->url, sizeof(coro->url),
|
||||
coro->settings->arrays.cheevos_username,
|
||||
rcheevos_locals.username,
|
||||
rcheevos_locals.token, coro->gameid, coro->i);
|
||||
|
||||
if (ret < 0)
|
||||
@ -1941,7 +1944,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
|
||||
|
||||
{
|
||||
int ret = rc_url_post_playing(coro->url, sizeof(coro->url),
|
||||
coro->settings->arrays.cheevos_username,
|
||||
rcheevos_locals.username,
|
||||
rcheevos_locals.token, coro->gameid);
|
||||
|
||||
if (ret < 0)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2021-2021 - Brian Weiss
|
||||
* Copyright (C) 2019-2021 - Brian Weiss
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
@ -371,9 +371,9 @@ static void rcheevos_async_http_task_callback(
|
||||
/* Call appropriate handler to process the response */
|
||||
if (request->handler)
|
||||
{
|
||||
/* NOTE: data->data is not null-terminated. Assume response is
|
||||
* properly formatted or will encounter a parse failure before
|
||||
* reading past the end of the data */
|
||||
/* NOTE: data->data is not null-terminated. Most handlers assume the
|
||||
* response is properly formatted or will encounter a parse failure
|
||||
* before reading past the end of the data */
|
||||
request->handler(request->id, data, buffer, sizeof(buffer));
|
||||
}
|
||||
}
|
||||
@ -422,12 +422,12 @@ static void rcheevos_async_begin_request(rcheevos_async_io_request* request,
|
||||
rcheevos_async_handler handler, char type, int id,
|
||||
const char* success_message, const char* failure_message)
|
||||
{
|
||||
request->type = type;
|
||||
request->handler = handler;
|
||||
request->id = id;
|
||||
request->handler = handler;
|
||||
request->type = type;
|
||||
request->id = id;
|
||||
request->success_message = success_message;
|
||||
request->failure_message = failure_message;
|
||||
request->attempt_count = 0;
|
||||
request->attempt_count = 0;
|
||||
|
||||
if (!request->user_agent)
|
||||
request->user_agent = get_rcheevos_locals()->user_agent_core;
|
||||
@ -501,13 +501,13 @@ static retro_time_t rcheevos_client_prepare_ping(rcheevos_async_io_request* requ
|
||||
{
|
||||
const rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
|
||||
const settings_t *settings = config_get_ptr();
|
||||
rc_api_ping_request_t api_params;
|
||||
char buffer[256] = "";
|
||||
const bool cheevos_richpresence_enable =
|
||||
settings->bools.cheevos_richpresence_enable;
|
||||
rc_api_ping_request_t api_params;
|
||||
char buffer[256] = "";
|
||||
|
||||
memset(&api_params, 0, sizeof(api_params));
|
||||
api_params.username = settings->arrays.cheevos_username;
|
||||
api_params.username = rcheevos_locals->username;
|
||||
api_params.api_token = rcheevos_locals->token;
|
||||
api_params.game_id = request->id;
|
||||
|
||||
@ -575,11 +575,10 @@ void rcheevos_client_award_achievement(unsigned achievement_id)
|
||||
else
|
||||
{
|
||||
const rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
|
||||
const settings_t *settings = config_get_ptr();
|
||||
rc_api_award_achievement_request_t api_params;
|
||||
|
||||
memset(&api_params, 0, sizeof(api_params));
|
||||
api_params.username = settings->arrays.cheevos_username;
|
||||
api_params.username = rcheevos_locals->username;
|
||||
api_params.api_token = rcheevos_locals->token;
|
||||
api_params.achievement_id = achievement_id;
|
||||
api_params.hardcore = rcheevos_locals->hardcore_active ? 1 : 0;
|
||||
@ -627,11 +626,10 @@ void rcheevos_client_submit_lboard_entry(unsigned leaderboard_id, int value)
|
||||
else
|
||||
{
|
||||
const rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
|
||||
const settings_t *settings = config_get_ptr();
|
||||
rc_api_submit_lboard_entry_request_t api_params;
|
||||
|
||||
memset(&api_params, 0, sizeof(api_params));
|
||||
api_params.username = settings->arrays.cheevos_username;
|
||||
api_params.username = rcheevos_locals->username;
|
||||
api_params.api_token = rcheevos_locals->token;
|
||||
api_params.leaderboard_id = leaderboard_id;
|
||||
api_params.score = value;
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2015-2018 - Andre Leiradella
|
||||
* Copyright (C) 2019-2021 - Brian Weiss
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
|
@ -133,6 +133,7 @@ typedef struct rcheevos_locals_t
|
||||
enum event_command queued_command; /* action queued by background thread to be run on main thread */
|
||||
#endif
|
||||
|
||||
char username[32]; /* case-corrected username */
|
||||
char token[32]; /* user's session token */
|
||||
char hash[33]; /* retroachievements hash for current content */
|
||||
char user_agent_prefix[128]; /* RetroArch/OS version information */
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define CHEEVOS_JSON_KEY_BADGENAME 0x887685d9U
|
||||
#define CHEEVOS_JSON_KEY_CONSOLE_ID 0x071656e5U
|
||||
#define CHEEVOS_JSON_KEY_TOKEN 0x0e2dbd26U
|
||||
#define CHEEVOS_JSON_KEY_USERNAME 0x7c8da264U
|
||||
#define CHEEVOS_JSON_KEY_FLAGS 0x0d2e96b2U
|
||||
#define CHEEVOS_JSON_KEY_LEADERBOARDS 0xf1247d2dU
|
||||
#define CHEEVOS_JSON_KEY_RICHPRESENCE 0xf18dd230U
|
||||
@ -149,14 +150,16 @@ static int rcheevos_get_value(const char* json, unsigned key_hash,
|
||||
Returns the token or the error message
|
||||
*****************************************************************************/
|
||||
|
||||
int rcheevos_get_token(const char* json, char* token, size_t length)
|
||||
int rcheevos_get_token(const char* json, char* username, size_t username_length,
|
||||
char* token, size_t length)
|
||||
{
|
||||
rcheevos_get_value(json, CHEEVOS_JSON_KEY_ERROR, token, length);
|
||||
|
||||
if (!string_is_empty(token))
|
||||
return -1;
|
||||
|
||||
return rcheevos_get_value(json, CHEEVOS_JSON_KEY_TOKEN, token, length);
|
||||
return rcheevos_get_value(json, CHEEVOS_JSON_KEY_TOKEN, token, length) +
|
||||
rcheevos_get_value(json, CHEEVOS_JSON_KEY_USERNAME, username, username_length);
|
||||
}
|
||||
|
||||
int rcheevos_get_json_error(const char* json, char* token, size_t length)
|
||||
|
@ -23,7 +23,9 @@ RETRO_BEGIN_DECLS
|
||||
typedef void (*rcheevos_unlock_cb_t)(unsigned id, void* userdata);
|
||||
|
||||
int rcheevos_get_json_error(const char* json, char* token, size_t length);
|
||||
int rcheevos_get_token(const char* json, char* token, size_t length);
|
||||
|
||||
int rcheevos_get_token(const char* json, char* username, size_t username_length,
|
||||
char* token, size_t length);
|
||||
|
||||
int rcheevos_get_patchdata(const char* json, rcheevos_rapatchdata_t* patchdata);
|
||||
void rcheevos_free_patchdata(rcheevos_rapatchdata_t* patchdata);
|
||||
|
Loading…
Reference in New Issue
Block a user