RetroArch
Classes | Macros | Enumerations | Functions | Variables
cheevos.c File Reference
#include <string.h>
#include <ctype.h>
#include <file/file_path.h>
#include <string/stdstring.h>
#include <formats/jsonsax.h>
#include <streams/interface_stream.h>
#include <streams/file_stream.h>
#include <features/features_cpu.h>
#include <compat/strl.h>
#include <rhash.h>
#include <retro_miscellaneous.h>
#include <retro_math.h>
#include <net/net_http.h>
#include <libretro.h>
#include "badges.h"
#include "cheevos.h"
#include "var.h"
#include "cond.h"
#include "../file_path_special.h"
#include "../paths.h"
#include "../command.h"
#include "../dynamic.h"
#include "../configuration.h"
#include "../performance_counters.h"
#include "../msg_hash.h"
#include "../retroarch.h"
#include "../core.h"
#include "../network/net_http_special.h"
#include "../tasks/tasks_internal.h"
#include "../verbosity.h"
#include "coro.h"
Include dependency graph for cheevos.c:

Classes

struct  cheevos_condset_t
 
struct  cheevos_condition_t
 
struct  cheevo_t
 
struct  cheevoset_t
 
struct  cheevos_deactivate_t
 
struct  cheevos_getvalueud_t
 
struct  cheevos_countud_t
 
struct  cheevos_field_t
 
struct  cheevos_readud_t
 
struct  cheevos_finder_t
 
struct  cheevos_term_t
 
struct  cheevos_expr_t
 
struct  cheevos_leaderboard_t
 
struct  cheevos_locals_t
 
struct  cheevos_nes_header_t
 
struct  coro_t
 

Macros

#define CHEEVOS_JSON_KEY_GAMEID   0xb4960eecU
 
#define CHEEVOS_JSON_KEY_ACHIEVEMENTS   0x69749ae1U
 
#define CHEEVOS_JSON_KEY_ID   0x005973f2U
 
#define CHEEVOS_JSON_KEY_MEMADDR   0x1e76b53fU
 
#define CHEEVOS_JSON_KEY_TITLE   0x0e2a9a07U
 
#define CHEEVOS_JSON_KEY_DESCRIPTION   0xe61a1f69U
 
#define CHEEVOS_JSON_KEY_POINTS   0xca8fce22U
 
#define CHEEVOS_JSON_KEY_AUTHOR   0xa804edb8U
 
#define CHEEVOS_JSON_KEY_MODIFIED   0xdcea4fe6U
 
#define CHEEVOS_JSON_KEY_CREATED   0x3a84721dU
 
#define CHEEVOS_JSON_KEY_BADGENAME   0x887685d9U
 
#define CHEEVOS_JSON_KEY_CONSOLE_ID   0x071656e5U
 
#define CHEEVOS_JSON_KEY_TOKEN   0x0e2dbd26U
 
#define CHEEVOS_JSON_KEY_FLAGS   0x0d2e96b2U
 
#define CHEEVOS_JSON_KEY_LEADERBOARDS   0xf1247d2dU
 
#define CHEEVOS_JSON_KEY_MEM   0x0b8807e4U
 
#define CHEEVOS_JSON_KEY_FORMAT   0xb341208eU
 
#define CHEEVOS_JSON_KEY_SUCCESS   0x110461deU
 
#define CHEEVOS_JSON_KEY_ERROR   0x0d2011cfU
 
#define CHEEVOS_LOCK(l)
 
#define CHEEVOS_UNLOCK(l)
 

Enumerations

enum  {
  SNES_MD5 = -1, GENESIS_MD5 = -2, LYNX_MD5 = -3, NES_MD5 = -4,
  GENERIC_MD5 = -5, FILENAME_MD5 = -6, EVAL_MD5 = -7, FILL_MD5 = -8,
  GET_GAMEID = -9, GET_CHEEVOS = -10, GET_BADGES = -11, LOGIN = -12,
  HTTP_GET = -13, DEACTIVATE = -14, PLAYING = -15, DELAY = -16
}
 

Functions

void cheevos_log (const char *fmt,...)
 
static unsigned size_in_megabytes (unsigned val)
 
static uint32_t cheevos_djb2 (const char *str, size_t length)
 
static int cheevos_getvalue__json_key (void *userdata, const char *name, size_t length)
 
static int cheevos_getvalue__json_string (void *userdata, const char *string, size_t length)
 
static int cheevos_getvalue__json_boolean (void *userdata, int istrue)
 
static int cheevos_getvalue__json_null (void *userdata)
 
static int cheevos_get_value (const char *json, unsigned key_hash, char *value, size_t length)
 
static int cheevos_count__json_end_array (void *userdata)
 
static int cheevos_count__json_key (void *userdata, const char *name, size_t length)
 
static int cheevos_count__json_number (void *userdata, const char *number, size_t length)
 
static int cheevos_count_cheevos (const char *json, unsigned *core_count, unsigned *unofficial_count, unsigned *lboard_count)
 
static unsigned cheevos_count_cond_sets (const char *memaddr)
 
static int cheevos_parse_condition (cheevos_condition_t *condition, const char *memaddr)
 
static void cheevos_free_condition (cheevos_condition_t *condition)
 
static int cheevos_parse_expression (cheevos_expr_t *expr, const char *mem)
 
static int cheevos_parse_mem (cheevos_leaderboard_t *lb, const char *mem)
 
static INLINE const char * cheevos_dupstr (const cheevos_field_t *field)
 
static int cheevos_new_cheevo (cheevos_readud_t *ud)
 
static void cheevos_format_value (const unsigned value, const unsigned type, char *formatted_value, size_t formatted_size)
 
unsigned cheevos_parse_format (cheevos_field_t *format)
 
static int cheevos_new_lboard (cheevos_readud_t *ud)
 
static int cheevos_read__json_key (void *userdata, const char *name, size_t length)
 
static int cheevos_read__json_string (void *userdata, const char *string, size_t length)
 
static int cheevos_read__json_number (void *userdata, const char *number, size_t length)
 
static int cheevos_read__json_end_object (void *userdata)
 
static int cheevos_read__json_end_array (void *userdata)
 
static int cheevos_parse (const char *json)
 
static int cheevos_test_condition (cheevos_cond_t *cond)
 
static int cheevos_test_pause_cond_set (const cheevos_condset_t *condset, int *dirty_conds, int *reset_conds, int process_pause)
 
static int cheevos_test_cond_set (const cheevos_condset_t *condset, int *dirty_conds, int *reset_conds)
 
static int cheevos_reset_cond_set (cheevos_condset_t *condset, int deltas)
 
static int cheevos_test_cheevo (cheevo_t *cheevo)
 
static void cheevos_url_encode (const char *str, char *encoded, size_t len)
 
static void cheevos_make_unlock_url (const cheevo_t *cheevo, char *url, size_t url_size)
 
static void cheevos_unlocked (void *task_data, void *user_data, const char *error)
 
static void cheevos_test_cheevo_set (const cheevoset_t *set)
 
static int cheevos_test_lboard_condition (const cheevos_condition_t *condition)
 
static int cheevos_expr_value (cheevos_expr_t *expr)
 
static void cheevos_make_lboard_url (const cheevos_leaderboard_t *lboard, char *url, size_t url_size)
 
static void cheevos_lboard_submit (void *task_data, void *user_data, const char *error)
 
static void cheevos_test_leaderboards (void)
 
static void cheevos_free_condset (const cheevos_condset_t *set)
 
static void cheevos_free_cheevo (const cheevo_t *cheevo)
 
static void cheevos_free_cheevo_set (const cheevoset_t *set)
 
static int cheevos_deactivate__json_index (void *userdata, unsigned int index)
 
static int cheevos_deactivate__json_number (void *userdata, const char *number, size_t length)
 
static int cheevos_deactivate_unlocks (const char *json, unsigned mode)
 
void cheevos_reset_game (void)
 
void cheevos_populate_menu (void *data)
 
bool cheevos_get_description (cheevos_ctx_desc_t *desc)
 
bool cheevos_apply_cheats (bool *data_bool)
 
bool cheevos_unload (void)
 
bool cheevos_toggle_hardcore_mode (void)
 
static void cheevos_patch_addresses (cheevoset_t *set)
 
static void cheevos_patch_lb_conditions (cheevos_condition_t *condition)
 
static void cheevos_patch_lb_expressions (cheevos_expr_t *expression)
 
static void cheevos_patch_lbs (cheevos_leaderboard_t *leaderboard)
 
void cheevos_test (void)
 
bool cheevos_set_cheats (void)
 
void cheevos_set_support_cheevos (bool state)
 
bool cheevos_get_support_cheevos (void)
 
cheevos_console_t cheevos_get_console (void)
 
static int cheevos_iterate (coro_t *coro)
 
static void cheevos_task_handler (retro_task_t *task)
 
bool cheevos_load (const void *data)
 

Variables

static cheevos_locals_t cheevos_locals
 
bool cheevos_loaded = false
 
bool cheevos_hardcore_active = false
 
bool cheevos_hardcore_paused = false
 
bool cheevos_state_loaded_flag = false
 
int cheats_are_enabled = 0
 
int cheats_were_enabled = 0
 

Macro Definition Documentation

◆ CHEEVOS_JSON_KEY_ACHIEVEMENTS

#define CHEEVOS_JSON_KEY_ACHIEVEMENTS   0x69749ae1U

◆ CHEEVOS_JSON_KEY_AUTHOR

#define CHEEVOS_JSON_KEY_AUTHOR   0xa804edb8U

◆ CHEEVOS_JSON_KEY_BADGENAME

#define CHEEVOS_JSON_KEY_BADGENAME   0x887685d9U

◆ CHEEVOS_JSON_KEY_CONSOLE_ID

#define CHEEVOS_JSON_KEY_CONSOLE_ID   0x071656e5U

◆ CHEEVOS_JSON_KEY_CREATED

#define CHEEVOS_JSON_KEY_CREATED   0x3a84721dU

◆ CHEEVOS_JSON_KEY_DESCRIPTION

#define CHEEVOS_JSON_KEY_DESCRIPTION   0xe61a1f69U

◆ CHEEVOS_JSON_KEY_ERROR

#define CHEEVOS_JSON_KEY_ERROR   0x0d2011cfU

◆ CHEEVOS_JSON_KEY_FLAGS

#define CHEEVOS_JSON_KEY_FLAGS   0x0d2e96b2U

◆ CHEEVOS_JSON_KEY_FORMAT

#define CHEEVOS_JSON_KEY_FORMAT   0xb341208eU

◆ CHEEVOS_JSON_KEY_GAMEID

#define CHEEVOS_JSON_KEY_GAMEID   0xb4960eecU

◆ CHEEVOS_JSON_KEY_ID

#define CHEEVOS_JSON_KEY_ID   0x005973f2U

◆ CHEEVOS_JSON_KEY_LEADERBOARDS

#define CHEEVOS_JSON_KEY_LEADERBOARDS   0xf1247d2dU

◆ CHEEVOS_JSON_KEY_MEM

#define CHEEVOS_JSON_KEY_MEM   0x0b8807e4U

◆ CHEEVOS_JSON_KEY_MEMADDR

#define CHEEVOS_JSON_KEY_MEMADDR   0x1e76b53fU

◆ CHEEVOS_JSON_KEY_MODIFIED

#define CHEEVOS_JSON_KEY_MODIFIED   0xdcea4fe6U

◆ CHEEVOS_JSON_KEY_POINTS

#define CHEEVOS_JSON_KEY_POINTS   0xca8fce22U

◆ CHEEVOS_JSON_KEY_SUCCESS

#define CHEEVOS_JSON_KEY_SUCCESS   0x110461deU

◆ CHEEVOS_JSON_KEY_TITLE

#define CHEEVOS_JSON_KEY_TITLE   0x0e2a9a07U

◆ CHEEVOS_JSON_KEY_TOKEN

#define CHEEVOS_JSON_KEY_TOKEN   0x0e2dbd26U

◆ CHEEVOS_LOCK

#define CHEEVOS_LOCK (   l)

◆ CHEEVOS_UNLOCK

#define CHEEVOS_UNLOCK (   l)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SNES_MD5 
GENESIS_MD5 
LYNX_MD5 
NES_MD5 
GENERIC_MD5 
FILENAME_MD5 
EVAL_MD5 
FILL_MD5 
GET_GAMEID 
GET_CHEEVOS 
GET_BADGES 
LOGIN 
HTTP_GET 
DEACTIVATE 
PLAYING 
DELAY 

Function Documentation

◆ cheevos_apply_cheats()

bool cheevos_apply_cheats ( bool data_bool)
Here is the caller graph for this function:

◆ cheevos_count__json_end_array()

static int cheevos_count__json_end_array ( void userdata)
static
Here is the caller graph for this function:

◆ cheevos_count__json_key()

static int cheevos_count__json_key ( void userdata,
const char *  name,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_count__json_number()

static int cheevos_count__json_number ( void userdata,
const char *  number,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_count_cheevos()

static int cheevos_count_cheevos ( const char *  json,
unsigned *  core_count,
unsigned *  unofficial_count,
unsigned *  lboard_count 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_count_cond_sets()

static unsigned cheevos_count_cond_sets ( const char *  memaddr)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_deactivate__json_index()

static int cheevos_deactivate__json_index ( void userdata,
unsigned int  index 
)
static
Here is the caller graph for this function:

◆ cheevos_deactivate__json_number()

static int cheevos_deactivate__json_number ( void userdata,
const char *  number,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_deactivate_unlocks()

static int cheevos_deactivate_unlocks ( const char *  json,
unsigned  mode 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_djb2()

static uint32_t cheevos_djb2 ( const char *  str,
size_t  length 
)
static
Here is the caller graph for this function:

◆ cheevos_dupstr()

static INLINE const char* cheevos_dupstr ( const cheevos_field_t field)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_expr_value()

static int cheevos_expr_value ( cheevos_expr_t expr)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_format_value()

static void cheevos_format_value ( const unsigned  value,
const unsigned  type,
char *  formatted_value,
size_t  formatted_size 
)
static
Here is the caller graph for this function:

◆ cheevos_free_cheevo()

static void cheevos_free_cheevo ( const cheevo_t cheevo)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_free_cheevo_set()

static void cheevos_free_cheevo_set ( const cheevoset_t set)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_free_condition()

static void cheevos_free_condition ( cheevos_condition_t condition)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_free_condset()

static void cheevos_free_condset ( const cheevos_condset_t set)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_get_console()

cheevos_console_t cheevos_get_console ( void  )

◆ cheevos_get_description()

bool cheevos_get_description ( cheevos_ctx_desc_t desc)
Here is the caller graph for this function:

◆ cheevos_get_support_cheevos()

bool cheevos_get_support_cheevos ( void  )
Here is the caller graph for this function:

◆ cheevos_get_value()

static int cheevos_get_value ( const char *  json,
unsigned  key_hash,
char *  value,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_getvalue__json_boolean()

static int cheevos_getvalue__json_boolean ( void userdata,
int  istrue 
)
static
Here is the caller graph for this function:

◆ cheevos_getvalue__json_key()

static int cheevos_getvalue__json_key ( void userdata,
const char *  name,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_getvalue__json_null()

static int cheevos_getvalue__json_null ( void userdata)
static
Here is the caller graph for this function:

◆ cheevos_getvalue__json_string()

static int cheevos_getvalue__json_string ( void userdata,
const char *  string,
size_t  length 
)
static
Here is the caller graph for this function:

◆ cheevos_iterate()

static int cheevos_iterate ( coro_t coro)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_lboard_submit()

static void cheevos_lboard_submit ( void task_data,
void user_data,
const char *  error 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_load()

bool cheevos_load ( const void data)
Here is the caller graph for this function:

◆ cheevos_log()

void cheevos_log ( const char *  fmt,
  ... 
)

◆ cheevos_make_lboard_url()

static void cheevos_make_lboard_url ( const cheevos_leaderboard_t lboard,
char *  url,
size_t  url_size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_make_unlock_url()

static void cheevos_make_unlock_url ( const cheevo_t cheevo,
char *  url,
size_t  url_size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_new_cheevo()

static int cheevos_new_cheevo ( cheevos_readud_t ud)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_new_lboard()

static int cheevos_new_lboard ( cheevos_readud_t ud)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_parse()

static int cheevos_parse ( const char *  json)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_parse_condition()

static int cheevos_parse_condition ( cheevos_condition_t condition,
const char *  memaddr 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_parse_expression()

static int cheevos_parse_expression ( cheevos_expr_t expr,
const char *  mem 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_parse_format()

unsigned cheevos_parse_format ( cheevos_field_t format)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_parse_mem()

static int cheevos_parse_mem ( cheevos_leaderboard_t lb,
const char *  mem 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_patch_addresses()

static void cheevos_patch_addresses ( cheevoset_t set)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_patch_lb_conditions()

static void cheevos_patch_lb_conditions ( cheevos_condition_t condition)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_patch_lb_expressions()

static void cheevos_patch_lb_expressions ( cheevos_expr_t expression)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_patch_lbs()

static void cheevos_patch_lbs ( cheevos_leaderboard_t leaderboard)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_populate_menu()

void cheevos_populate_menu ( void data)
Here is the caller graph for this function:

◆ cheevos_read__json_end_array()

static int cheevos_read__json_end_array ( void userdata)
static
Here is the caller graph for this function:

◆ cheevos_read__json_end_object()

static int cheevos_read__json_end_object ( void userdata)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_read__json_key()

static int cheevos_read__json_key ( void userdata,
const char *  name,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_read__json_number()

static int cheevos_read__json_number ( void userdata,
const char *  number,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_read__json_string()

static int cheevos_read__json_string ( void userdata,
const char *  string,
size_t  length 
)
static
Here is the caller graph for this function:

◆ cheevos_reset_cond_set()

static int cheevos_reset_cond_set ( cheevos_condset_t condset,
int  deltas 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_reset_game()

void cheevos_reset_game ( void  )
Here is the caller graph for this function:

◆ cheevos_set_cheats()

bool cheevos_set_cheats ( void  )
Here is the caller graph for this function:

◆ cheevos_set_support_cheevos()

void cheevos_set_support_cheevos ( bool  state)
Here is the caller graph for this function:

◆ cheevos_task_handler()

static void cheevos_task_handler ( retro_task_t task)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_test()

void cheevos_test ( void  )
Here is the caller graph for this function:

◆ cheevos_test_cheevo()

static int cheevos_test_cheevo ( cheevo_t cheevo)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_test_cheevo_set()

static void cheevos_test_cheevo_set ( const cheevoset_t set)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_test_cond_set()

static int cheevos_test_cond_set ( const cheevos_condset_t condset,
int *  dirty_conds,
int *  reset_conds 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_test_condition()

static int cheevos_test_condition ( cheevos_cond_t cond)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_test_lboard_condition()

static int cheevos_test_lboard_condition ( const cheevos_condition_t condition)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_test_leaderboards()

static void cheevos_test_leaderboards ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_test_pause_cond_set()

static int cheevos_test_pause_cond_set ( const cheevos_condset_t condset,
int *  dirty_conds,
int *  reset_conds,
int  process_pause 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_toggle_hardcore_mode()

bool cheevos_toggle_hardcore_mode ( void  )
Here is the caller graph for this function:

◆ cheevos_unload()

bool cheevos_unload ( void  )
Here is the caller graph for this function:

◆ cheevos_unlocked()

static void cheevos_unlocked ( void task_data,
void user_data,
const char *  error 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cheevos_url_encode()

static void cheevos_url_encode ( const char *  str,
char *  encoded,
size_t  len 
)
static
Here is the caller graph for this function:

◆ size_in_megabytes()

static unsigned size_in_megabytes ( unsigned  val)
static
Here is the caller graph for this function:

Variable Documentation

◆ cheats_are_enabled

int cheats_are_enabled = 0

◆ cheats_were_enabled

int cheats_were_enabled = 0

◆ cheevos_hardcore_active

bool cheevos_hardcore_active = false

◆ cheevos_hardcore_paused

bool cheevos_hardcore_paused = false

◆ cheevos_loaded

bool cheevos_loaded = false

◆ cheevos_locals

cheevos_locals_t cheevos_locals
static
Initial value:
=
{
true,
false,
0,
0,
{NULL, 0},
{NULL, 0},
0,
{0},
{
{NULL, 0, 0},
{NULL, 0, 0},
{NULL, 0, 0},
{NULL, 0, 0}
}
}
#define NULL
Pointer to 0.
Definition: gctypes.h:65
Definition: cheevos.h:68

◆ cheevos_state_loaded_flag

bool cheevos_state_loaded_flag = false