This commit is contained in:
twinaphex 2017-05-06 17:23:19 +02:00
parent 75c45c4f2b
commit 881b18a965

View File

@ -365,6 +365,18 @@ static INLINE const char *cheevos_dupstr(const cheevos_field_t *field)
return string;
}
static uint32_t cheevos_djb2(const char* str, size_t length)
{
const unsigned char *aux = (const unsigned char*)str;
const unsigned char *end = aux + length;
uint32_t hash = 5381;
while (aux < end)
hash = (hash << 5) + hash + *aux++;
return hash;
}
/*****************************************************************************
Supporting functions.
*****************************************************************************/
@ -710,18 +722,6 @@ static void cheevos_log_lboard(const cheevos_leaderboard_t* lb)
}
#endif
static uint32_t cheevos_djb2(const char* str, size_t length)
{
const unsigned char *aux = (const unsigned char*)str;
const unsigned char *end = aux + length;
uint32_t hash = 5381;
while (aux < end)
hash = (hash << 5) + hash + *aux++;
return hash;
}
static int cheevos_http_get(const char **result, size_t *size,
const char *url, retro_time_t *timeout)
{
@ -1385,9 +1385,7 @@ static void cheevos_free_condition(cheevos_condition_t* condition)
if (condition->condsets)
{
for (i = 0; i < condition->count; i++)
{
free((void*)condition->condsets[i].conds);
}
free((void*)condition->condsets);
}
@ -1407,9 +1405,7 @@ static int cheevos_parse_expression(cheevos_expr_t *expr, const char* mem)
expr->count = 1;
for (aux = mem; *aux != '"'; aux++)
{
expr->count += *aux == '_';
}
expr->terms = (cheevos_term_t*)calloc(expr->count, sizeof(cheevos_term_t));
@ -1735,7 +1731,8 @@ static int cheevos_parse(const char *json)
calloc(lboard_count, sizeof(cheevos_leaderboard_t));
cheevos_locals.lboard_count = lboard_count;
if ( !cheevos_locals.core.cheevos || !cheevos_locals.unofficial.cheevos
if ( !cheevos_locals.core.cheevos
|| !cheevos_locals.unofficial.cheevos
|| !cheevos_locals.leaderboards)
{
free((void*)cheevos_locals.core.cheevos);
@ -1773,24 +1770,23 @@ Test all the achievements (call once per frame).
uint8_t *cheevos_get_memory(const cheevos_var_t *var)
{
uint8_t *memory = NULL;
if (var->bank_id >= 0)
{
rarch_system_info_t *system = runloop_get_system_info();
uint8_t *memory = (uint8_t *)cheevos_locals.meminfo[var->bank_id].data;
if (system->mmaps.num_descriptors != 0)
memory = (uint8_t *)system->mmaps.descriptors[var->bank_id].core.ptr;
else
memory = (uint8_t *)cheevos_locals.meminfo[var->bank_id].data;
if (memory)
memory += var->value;
}
return memory;
}
return NULL;
}
static unsigned cheevos_get_var_value(cheevos_var_t *var)
{
if (var->type == CHEEVOS_VAR_TYPE_VALUE_COMP)