mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
(cheevos) Backport 'moved cheevos configuration to the config file'
This commit is contained in:
parent
41b27ad242
commit
f48771ea42
49
cheevos.c
49
cheevos.c
@ -19,6 +19,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <configuration.h>
|
||||||
#include <formats/jsonsax.h>
|
#include <formats/jsonsax.h>
|
||||||
#include <net/net_http.h>
|
#include <net/net_http.h>
|
||||||
#include <rhash.h>
|
#include <rhash.h>
|
||||||
@ -145,19 +146,11 @@ typedef struct
|
|||||||
unsigned count;
|
unsigned count;
|
||||||
} cheevoset_t;
|
} cheevoset_t;
|
||||||
|
|
||||||
cheevos_config_t cheevos_config =
|
|
||||||
{
|
|
||||||
/* enable */ 1,
|
|
||||||
/* test_unofficial */ 0,
|
|
||||||
/* username */ "libretro",
|
|
||||||
/* password */ "l1br3tro3456",
|
|
||||||
/* token */ { 0 },
|
|
||||||
/* game_id */ 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
static cheevoset_t core_cheevos = { NULL, 0 };
|
static cheevoset_t core_cheevos = { NULL, 0 };
|
||||||
static cheevoset_t unofficial_cheevos = { NULL, 0 };
|
static cheevoset_t unofficial_cheevos = { NULL, 0 };
|
||||||
|
|
||||||
|
static char token[ 32 ] = { 0 };
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
Supporting functions.
|
Supporting functions.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -1030,11 +1023,16 @@ static void test_cheevo_set( const cheevoset_t* set )
|
|||||||
|
|
||||||
void cheevos_test(void)
|
void cheevos_test(void)
|
||||||
{
|
{
|
||||||
if ( cheevos_config.enable )
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
if (!settings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( settings->cheevos.enable )
|
||||||
{
|
{
|
||||||
test_cheevo_set( &core_cheevos );
|
test_cheevo_set( &core_cheevos );
|
||||||
|
|
||||||
if ( cheevos_config.test_unofficial )
|
if ( settings->cheevos.test_unofficial )
|
||||||
test_cheevo_set( &unofficial_cheevos );
|
test_cheevo_set( &unofficial_cheevos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1242,14 +1240,17 @@ static int cheevos_login(void)
|
|||||||
cheevo_getvalueud_t ud;
|
cheevo_getvalueud_t ud;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if ( cheevos_config.token[ 0 ] == 0 )
|
if ( token[ 0 ] == 0 )
|
||||||
{
|
{
|
||||||
cheevos_config.token[ 0 ] = 0;
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
if (!settings)
|
||||||
|
return -1;
|
||||||
|
|
||||||
snprintf(
|
snprintf(
|
||||||
request, sizeof( request ),
|
request, sizeof( request ),
|
||||||
"http://retroachievements.org/dorequest.php?r=login&u=%s&p=%s",
|
"http://retroachievements.org/dorequest.php?r=login&u=%s&p=%s",
|
||||||
cheevos_config.username, cheevos_config.password
|
settings->cheevos.username, settings->cheevos.password
|
||||||
);
|
);
|
||||||
|
|
||||||
request[ sizeof( request ) - 1 ] = 0;
|
request[ sizeof( request ) - 1 ] = 0;
|
||||||
@ -1259,23 +1260,27 @@ static int cheevos_login(void)
|
|||||||
if ( !json )
|
if ( !json )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
res = cheevos_get_value( json, 0x0e2dbd26U /* Token */, cheevos_config.token, sizeof( cheevos_config.token ) );
|
res = cheevos_get_value( json, 0x0e2dbd26U /* Token */, token, sizeof( token ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
RARCH_LOG( "CHEEVOS user token is %s\n", cheevos_config.token );
|
RARCH_LOG( "CHEEVOS user token is %s\n", token );
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cheevos_get_by_game_id( const char** json, unsigned game_id )
|
int cheevos_get_by_game_id( const char** json, unsigned game_id )
|
||||||
{
|
{
|
||||||
char request[ 256 ];
|
char request[ 256 ];
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
if (!settings)
|
||||||
|
return -1;
|
||||||
|
|
||||||
cheevos_login();
|
cheevos_login();
|
||||||
|
|
||||||
snprintf(
|
snprintf(
|
||||||
request, sizeof( request ),
|
request, sizeof( request ),
|
||||||
"http://retroachievements.org/dorequest.php?r=patch&u=%s&g=%u&f=3&l=1&t=%s",
|
"http://retroachievements.org/dorequest.php?r=patch&u=%s&g=%u&f=3&l=1&t=%s",
|
||||||
cheevos_config.username, game_id, cheevos_config.token
|
settings->cheevos.username, game_id, settings->cheevos.token
|
||||||
);
|
);
|
||||||
|
|
||||||
request[ sizeof( request ) - 1 ] = 0;
|
request[ sizeof( request ) - 1 ] = 0;
|
||||||
@ -1291,15 +1296,19 @@ int cheevos_get_by_game_id( const char** json, unsigned game_id )
|
|||||||
static unsigned cheevos_get_game_id( unsigned char* hash )
|
static unsigned cheevos_get_game_id( unsigned char* hash )
|
||||||
{
|
{
|
||||||
MD5_CTX ctx;
|
MD5_CTX ctx;
|
||||||
char request[ 256 ];
|
|
||||||
const char* json;
|
const char* json;
|
||||||
|
char request[ 256 ];
|
||||||
char game_id[ 16 ];
|
char game_id[ 16 ];
|
||||||
int res;
|
int res;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
if (!settings)
|
||||||
|
return -1;
|
||||||
|
|
||||||
snprintf(
|
snprintf(
|
||||||
request, sizeof( request ),
|
request, sizeof( request ),
|
||||||
"http://retroachievements.org/dorequest.php?r=gameid&u=%s&m=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
"http://retroachievements.org/dorequest.php?r=gameid&u=%s&m=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
|
||||||
cheevos_config.username,
|
settings->cheevos.username,
|
||||||
hash[ 0 ], hash[ 1 ], hash[ 2 ], hash[ 3 ],
|
hash[ 0 ], hash[ 1 ], hash[ 2 ], hash[ 3 ],
|
||||||
hash[ 4 ], hash[ 5 ], hash[ 6 ], hash[ 7 ],
|
hash[ 4 ], hash[ 5 ], hash[ 6 ], hash[ 7 ],
|
||||||
hash[ 8 ], hash[ 9 ], hash[ 10 ], hash[ 11 ],
|
hash[ 8 ], hash[ 9 ], hash[ 10 ], hash[ 11 ],
|
||||||
|
17
cheevos.h
17
cheevos.h
@ -17,27 +17,14 @@
|
|||||||
#ifndef __RARCH_CHEEVOS_H
|
#ifndef __RARCH_CHEEVOS_H
|
||||||
#define __RARCH_CHEEVOS_H
|
#define __RARCH_CHEEVOS_H
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned char enable;
|
|
||||||
unsigned char test_unofficial;
|
|
||||||
const char* username;
|
|
||||||
const char* password;
|
|
||||||
/* These are used by the implementation, do not touch. */
|
|
||||||
char token[ 20 ];
|
|
||||||
unsigned game_id;
|
|
||||||
} cheevos_config_t;
|
|
||||||
|
|
||||||
extern cheevos_config_t cheevos_config;
|
|
||||||
|
|
||||||
int cheevos_load(const char* json);
|
int cheevos_load(const char* json);
|
||||||
|
|
||||||
void cheevos_test(void);
|
void cheevos_test(void);
|
||||||
|
|
||||||
void cheevos_unload(void);
|
void cheevos_unload(void);
|
||||||
|
|
||||||
int cheevos_get_by_game_id( const char** json, unsigned game_id );
|
int cheevos_get_by_game_id( const char **json, unsigned game_id );
|
||||||
|
|
||||||
int cheevos_get_by_content( const char** json, const void* data, size_t size );
|
int cheevos_get_by_content( const char **json, const void *data, size_t size );
|
||||||
|
|
||||||
#endif /* __RARCH_CHEEVOS_H */
|
#endif /* __RARCH_CHEEVOS_H */
|
||||||
|
@ -595,6 +595,13 @@ static void config_set_defaults(void)
|
|||||||
settings->location.allow = false;
|
settings->location.allow = false;
|
||||||
settings->camera.allow = false;
|
settings->camera.allow = false;
|
||||||
|
|
||||||
|
#ifdef HAVE_CHEEVOS
|
||||||
|
settings->cheevos.enable = true;
|
||||||
|
settings->cheevos.test_unofficial = false;
|
||||||
|
*settings->cheevos.user_name = '\0';
|
||||||
|
*settings->cheevos.password = '\0';
|
||||||
|
#endif
|
||||||
|
|
||||||
settings->input.autoconfig_descriptor_label_show = true;
|
settings->input.autoconfig_descriptor_label_show = true;
|
||||||
settings->input.back_as_menu_toggle_enable = true;
|
settings->input.back_as_menu_toggle_enable = true;
|
||||||
settings->input.input_descriptor_label_show = input_descriptor_label_show;
|
settings->input.input_descriptor_label_show = input_descriptor_label_show;
|
||||||
@ -1460,6 +1467,13 @@ static bool config_load_file(const char *path, bool set_defaults)
|
|||||||
CONFIG_GET_STRING_BASE(conf, settings, camera.device, "camera_device");
|
CONFIG_GET_STRING_BASE(conf, settings, camera.device, "camera_device");
|
||||||
CONFIG_GET_BOOL_BASE(conf, settings, camera.allow, "camera_allow");
|
CONFIG_GET_BOOL_BASE(conf, settings, camera.allow, "camera_allow");
|
||||||
|
|
||||||
|
#ifdef HAVE_CHEEVOS
|
||||||
|
CONFIG_GET_BOOL_BASE(conf, settings, cheevos.enable, "cheevos_enable");
|
||||||
|
CONFIG_GET_BOOL_BASE(conf, settings, cheevos.test_unofficial, "cheevos_test_unofficial");
|
||||||
|
CONFIG_GET_STRING_BASE(conf, settings, cheevos.user_name, "cheevos_user_name");
|
||||||
|
CONFIG_GET_STRING_BASE(conf, settings, cheevos.password, "cheevos_password");
|
||||||
|
#endif
|
||||||
|
|
||||||
CONFIG_GET_BOOL_BASE(conf, settings, location.allow, "location_allow");
|
CONFIG_GET_BOOL_BASE(conf, settings, location.allow, "location_allow");
|
||||||
CONFIG_GET_STRING_BASE(conf, settings, video.driver, "video_driver");
|
CONFIG_GET_STRING_BASE(conf, settings, video.driver, "video_driver");
|
||||||
CONFIG_GET_STRING_BASE(conf, settings, record.driver, "record_driver");
|
CONFIG_GET_STRING_BASE(conf, settings, record.driver, "record_driver");
|
||||||
@ -2541,6 +2555,14 @@ bool config_save_file(const char *path)
|
|||||||
settings->network.buildbot_auto_extract_archive);
|
settings->network.buildbot_auto_extract_archive);
|
||||||
config_set_string(conf, "camera_device", settings->camera.device);
|
config_set_string(conf, "camera_device", settings->camera.device);
|
||||||
config_set_bool(conf, "camera_allow", settings->camera.allow);
|
config_set_bool(conf, "camera_allow", settings->camera.allow);
|
||||||
|
|
||||||
|
#ifdef HAVE_CHEEVOS
|
||||||
|
config_set_bool(conf, "cheevos_enable", settings->cheevos.enable);
|
||||||
|
config_set_bool(conf, "cheevos_test_unofficial", settings->cheevos.test_unofficial);
|
||||||
|
config_set_string(conf, "cheevos_user_name", settings->cheevos.user_name);
|
||||||
|
config_set_string(conf, "cheevos_password", settings->cheevos.password);
|
||||||
|
#endif
|
||||||
|
|
||||||
config_set_bool(conf, "audio_rate_control", settings->audio.rate_control);
|
config_set_bool(conf, "audio_rate_control", settings->audio.rate_control);
|
||||||
config_set_float(conf, "audio_rate_control_delta",
|
config_set_float(conf, "audio_rate_control_delta",
|
||||||
settings->audio.rate_control_delta);
|
settings->audio.rate_control_delta);
|
||||||
|
@ -282,6 +282,16 @@ typedef struct settings
|
|||||||
bool builtin_imageviewer_enable;
|
bool builtin_imageviewer_enable;
|
||||||
} multimedia;
|
} multimedia;
|
||||||
|
|
||||||
|
#ifdef HAVE_CHEEVOS
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool enable;
|
||||||
|
bool test_unofficial;
|
||||||
|
char user_name[32];
|
||||||
|
char password[32];
|
||||||
|
} cheevos;
|
||||||
|
#endif
|
||||||
|
|
||||||
int state_slot;
|
int state_slot;
|
||||||
|
|
||||||
bool bundle_assets_extract_enable;
|
bool bundle_assets_extract_enable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user