Create CHEEVOS_CTL_UNLOAD

This commit is contained in:
twinaphex 2016-02-13 06:11:17 +01:00
parent a36382b938
commit fc6d22d47b
3 changed files with 13 additions and 15 deletions

View File

@ -964,7 +964,7 @@ static int cheevos_parse(const char *json)
if (jsonsax_parse(json, &handlers, (void*)&ud) != JSONSAX_OK) if (jsonsax_parse(json, &handlers, (void*)&ud) != JSONSAX_OK)
{ {
cheevos_unload(); cheevos_ctl(CHEEVOS_CTL_UNLOAD, NULL);
return -1; return -1;
} }
@ -1446,16 +1446,6 @@ static void cheevos_free_cheevo_set(const cheevoset_t *set)
free((void*)set->cheevos); free((void*)set->cheevos);
} }
void cheevos_unload(void)
{
if (cheevos_locals.loaded)
{
cheevos_free_cheevo_set(&cheevos_locals.core);
cheevos_free_cheevo_set(&cheevos_locals.unofficial);
cheevos_locals.loaded = 0;
}
}
/***************************************************************************** /*****************************************************************************
Load achievements from retroachievements.org. Load achievements from retroachievements.org.
@ -2200,6 +2190,15 @@ bool cheevos_ctl(enum cheevos_ctl_state state, void *data)
if (!cheevos_load((const void*)data)) if (!cheevos_load((const void*)data))
return false; return false;
break; break;
case CHEEVOS_CTL_UNLOAD:
if (!cheevos_locals.loaded)
return false;
cheevos_free_cheevo_set(&cheevos_locals.core);
cheevos_free_cheevo_set(&cheevos_locals.unofficial);
cheevos_locals.loaded = 0;
break;
case CHEEVOS_CTL_TEST: case CHEEVOS_CTL_TEST:
if (!cheevos_locals.loaded) if (!cheevos_locals.loaded)
return false; return false;

View File

@ -23,7 +23,8 @@ enum cheevos_ctl_state
{ {
CHEEVOS_CTL_NONE = 0, CHEEVOS_CTL_NONE = 0,
CHEEVOS_CTL_TEST, CHEEVOS_CTL_TEST,
CHEEVOS_CTL_LOAD CHEEVOS_CTL_LOAD,
CHEEVOS_CTL_UNLOAD
}; };
#ifdef HAVE_MENU #ifdef HAVE_MENU
@ -36,8 +37,6 @@ void cheevos_set_cheats(void);
void cheevos_apply_cheats(bool enable); void cheevos_apply_cheats(bool enable);
void cheevos_unload(void);
bool cheevos_ctl(enum cheevos_ctl_state state, void *data); bool cheevos_ctl(enum cheevos_ctl_state state, void *data);
#endif /* __RARCH_CHEEVOS_H */ #endif /* __RARCH_CHEEVOS_H */

View File

@ -396,7 +396,7 @@ static void event_deinit_core(bool reinit)
{ {
#ifdef HAVE_CHEEVOS #ifdef HAVE_CHEEVOS
/* Unload the achievements from memory. */ /* Unload the achievements from memory. */
cheevos_unload(); cheevos_ctl(CHEEVOS_CTL_UNLOAD, NULL);
#endif #endif
core_ctl(CORE_CTL_RETRO_UNLOAD_GAME, NULL); core_ctl(CORE_CTL_RETRO_UNLOAD_GAME, NULL);