From d255d6609b21de7880c8e724ae9f96ba90f8fe18 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 13 Feb 2016 06:06:51 +0100 Subject: [PATCH] Create cheevos_ctl --- cheevos.c | 29 ++++++++++++++++++++++------- cheevos.h | 8 +++++++- content.c | 7 ++++++- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/cheevos.c b/cheevos.c index d40a4a07fe..59e87df1c1 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1933,7 +1933,7 @@ static unsigned cheevos_find_game_id_nes( } -int cheevos_load(const void *data) +static bool cheevos_load(const void *data) { retro_ctx_memory_info_t mem_info; @@ -1986,11 +1986,11 @@ int cheevos_load(const void *data) /* Just return OK if cheevos are disabled. */ if (!settings->cheevos.enable) - return 0; + return true; /* Also return OK if there's no content. */ if (!info) - return 0; + return true; mem_info.data = NULL; mem_info.size = 0; @@ -2028,7 +2028,7 @@ int cheevos_load(const void *data) { runloop_msg_queue_push("This core doesn't support achievements", 0, 5 * 60, false); RARCH_LOG("This core doesn't support achievements\n"); - return -1; + return false; } /* The the supported extensions as a hint to what method we should use. */ @@ -2092,7 +2092,7 @@ int cheevos_load(const void *data) runloop_msg_queue_push("This game doesn't feature achievements", 0, 5 * 60, false); - return -1; + return false; found: @@ -2105,14 +2105,14 @@ int cheevos_load(const void *data) cheevos_locals.loaded = 1; rarch_main_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id); - return 0; + return true; } free((void*)json); } runloop_msg_queue_push("Error loading achievements", 0, 5 * 60, false); - return -1; + return false; } #ifdef HAVE_MENU @@ -2209,3 +2209,18 @@ void cheevos_apply_cheats(bool enable) cheevos_globals.cheats_are_enabled = enable; cheevos_globals.cheats_were_enabled |= cheevos_globals.cheats_are_enabled; } + +bool cheevos_ctl(enum cheevos_ctl_state state, void *data) +{ + switch (state) + { + case CHEEVOS_CTL_LOAD: + if (!cheevos_load((const void*)data)) + return false; + break; + case CHEEVOS_CTL_NONE: + default: + break; + } + return true; +} diff --git a/cheevos.h b/cheevos.h index 677b52d558..b03ae66b62 100644 --- a/cheevos.h +++ b/cheevos.h @@ -19,7 +19,11 @@ #include #include -int cheevos_load(const void *data); +enum cheevos_ctl_state +{ + CHEEVOS_CTL_NONE = 0, + CHEEVOS_CTL_LOAD +}; #ifdef HAVE_MENU void cheevos_populate_menu(void *data); @@ -35,4 +39,6 @@ void cheevos_test(void); void cheevos_unload(void); +bool cheevos_ctl(enum cheevos_ctl_state state, void *data); + #endif /* __RARCH_CHEEVOS_H */ diff --git a/content.c b/content.c index acbb0fc0c4..3968dcd469 100644 --- a/content.c +++ b/content.c @@ -584,9 +584,14 @@ static bool load_content( #ifdef HAVE_CHEEVOS if (!special) { + const void *load_data = NULL; + /* Load the achievements into memory if the game has content. */ cheevos_set_cheats(); - cheevos_load(*content->elems[0].data ? info : NULL); + + if (*content->elems[0].data) + load_data = info; + cheevos_ctl(CHEEVOS_CTL_LOAD, (void*)load_data); } #endif