From a5acd559d67b36fd5f086fc870c1b25dec6e1ade Mon Sep 17 00:00:00 2001 From: meleu Date: Sat, 16 Mar 2019 22:13:57 -0300 Subject: [PATCH] namespace both cheevos implementations & add a runtime setting to allow debugging --- Makefile.common | 126 +++++++++++++++----------------- cheevos-new/cheevos.c | 118 +++++++++++++++--------------- cheevos-new/cheevos.h | 44 +++++------ cheevos-new/fixup.c | 12 +-- cheevos-new/fixup.h | 8 +- cheevos-new/util.h | 4 +- cheevos/cheevos.h | 2 +- command.c | 114 ++++++++++++++++++----------- configuration.c | 2 + configuration.h | 1 + discord/discord.c | 1 + dynamic.c | 4 +- griffin/griffin.c | 15 ---- managers/cheat_manager.c | 6 +- menu/cbs/menu_cbs_ok.c | 1 + menu/cbs/menu_cbs_sublabel.c | 5 +- menu/menu_displaylist.c | 18 +++-- menu/menu_setting.c | 4 +- menu/widgets/menu_dialog.c | 13 +++- network/httpserver/httpserver.c | 1 + retroarch.c | 22 +++--- tasks/task_content.c | 7 +- 22 files changed, 286 insertions(+), 242 deletions(-) diff --git a/Makefile.common b/Makefile.common index 88e4439225..0b487d01b0 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1688,76 +1688,70 @@ ifeq ($(HAVE_NETWORKING), 1) # RetroAchievements ifeq ($(HAVE_CHEEVOS), 1) - DEFINES += -DHAVE_CHEEVOS + DEFINES += -DHAVE_CHEEVOS \ + -Ideps/rcheevos/include - ifeq ($(HAVE_NEW_CHEEVOS), 1) - DEFINES += -DHAVE_NEW_CHEEVOS \ - -Ideps/rcheevos/include - OBJ += cheevos-new/cheevos.o \ - cheevos-new/badges.o \ - cheevos-new/fixup.o \ - cheevos-new/parser.o \ - cheevos-new/hash.o \ - deps/rcheevos/src/rcheevos/trigger.o \ - deps/rcheevos/src/rcheevos/condset.o \ - deps/rcheevos/src/rcheevos/condition.o \ - deps/rcheevos/src/rcheevos/operand.o \ - deps/rcheevos/src/rcheevos/term.o \ - deps/rcheevos/src/rcheevos/expression.o \ - deps/rcheevos/src/rcheevos/value.o \ - deps/rcheevos/src/rcheevos/lboard.o \ - deps/rcheevos/src/rcheevos/alloc.o \ - deps/rcheevos/src/rcheevos/format.o \ - deps/rcheevos/src/rurl/url.o + OBJ += cheevos/cheevos.o \ + cheevos/badges.o \ + cheevos/var.o \ + cheevos/cond.o \ + cheevos-new/cheevos.o \ + cheevos-new/fixup.o \ + cheevos-new/parser.o \ + cheevos-new/hash.o \ + deps/rcheevos/src/rcheevos/trigger.o \ + deps/rcheevos/src/rcheevos/condset.o \ + deps/rcheevos/src/rcheevos/condition.o \ + deps/rcheevos/src/rcheevos/operand.o \ + deps/rcheevos/src/rcheevos/term.o \ + deps/rcheevos/src/rcheevos/expression.o \ + deps/rcheevos/src/rcheevos/value.o \ + deps/rcheevos/src/rcheevos/lboard.o \ + deps/rcheevos/src/rcheevos/alloc.o \ + deps/rcheevos/src/rcheevos/format.o \ + deps/rcheevos/src/rurl/url.o - ifeq ($(HAVE_LUA), 1) - DEFINES += -DHAVE_LUA \ - -DLUA_32BITS \ - -Ideps/lua/src - OBJ += deps/lua/src/lapi.o \ - deps/lua/src/lcode.o \ - deps/lua/src/lctype.o \ - deps/lua/src/ldebug.o \ - deps/lua/src/ldo.o \ - deps/lua/src/ldump.o \ - deps/lua/src/lfunc.o \ - deps/lua/src/lgc.o \ - deps/lua/src/llex.o \ - deps/lua/src/lmem.o \ - deps/lua/src/lobject.o \ - deps/lua/src/lopcodes.o \ - deps/lua/src/lparser.o \ - deps/lua/src/lstate.o \ - deps/lua/src/lstring.o \ - deps/lua/src/ltable.o \ - deps/lua/src/ltm.o \ - deps/lua/src/lundump.o \ - deps/lua/src/lvm.o \ - deps/lua/src/lzio.o \ - deps/lua/src/lauxlib.o \ - deps/lua/src/lbaselib.o \ - deps/lua/src/lbitlib.o \ - deps/lua/src/lcorolib.o \ - deps/lua/src/ldblib.o \ - deps/lua/src/liolib.o \ - deps/lua/src/lmathlib.o \ - deps/lua/src/loslib.o \ - deps/lua/src/lstrlib.o \ - deps/lua/src/ltablib.o \ - deps/lua/src/lutf8lib.o \ - deps/lua/src/loadlib.o \ - deps/lua/src/linit.o - else - DEFINES += -DRC_DISABLE_LUA - endif - - # if not HAVE_NEW_CHEEVOS + ifeq ($(HAVE_LUA), 1) + DEFINES += -DHAVE_LUA \ + -DLUA_32BITS \ + -Ideps/lua/src + OBJ += deps/lua/src/lapi.o \ + deps/lua/src/lcode.o \ + deps/lua/src/lctype.o \ + deps/lua/src/ldebug.o \ + deps/lua/src/ldo.o \ + deps/lua/src/ldump.o \ + deps/lua/src/lfunc.o \ + deps/lua/src/lgc.o \ + deps/lua/src/llex.o \ + deps/lua/src/lmem.o \ + deps/lua/src/lobject.o \ + deps/lua/src/lopcodes.o \ + deps/lua/src/lparser.o \ + deps/lua/src/lstate.o \ + deps/lua/src/lstring.o \ + deps/lua/src/ltable.o \ + deps/lua/src/ltm.o \ + deps/lua/src/lundump.o \ + deps/lua/src/lvm.o \ + deps/lua/src/lzio.o \ + deps/lua/src/lauxlib.o \ + deps/lua/src/lbaselib.o \ + deps/lua/src/lbitlib.o \ + deps/lua/src/lcorolib.o \ + deps/lua/src/ldblib.o \ + deps/lua/src/liolib.o \ + deps/lua/src/lmathlib.o \ + deps/lua/src/loslib.o \ + deps/lua/src/lstrlib.o \ + deps/lua/src/ltablib.o \ + deps/lua/src/lutf8lib.o \ + deps/lua/src/loadlib.o \ + deps/lua/src/linit.o else - OBJ += cheevos/cheevos.o \ - cheevos/badges.o \ - cheevos/var.o \ - cheevos/cond.o + DEFINES += -DRC_DISABLE_LUA endif + endif ifeq ($(HAVE_DISCORD), 1) diff --git a/cheevos-new/cheevos.c b/cheevos-new/cheevos.c index 435a154f08..c37a9e68f6 100644 --- a/cheevos-new/cheevos.c +++ b/cheevos-new/cheevos.c @@ -41,7 +41,7 @@ #include #endif -#include "badges.h" +#include "../cheevos/badges.h" /* RCHEEVOS TODO: fix path */ #include "cheevos.h" #include "fixup.h" #include "parser.h" @@ -159,12 +159,12 @@ static cheevos_locals_t cheevos_locals = {0}, /* token */ }; -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; +bool rcheevos_loaded = false; +bool rcheevos_hardcore_active = false; +bool rcheevos_hardcore_paused = false; +bool rcheevos_state_loaded_flag = false; +int rcheevos_cheats_are_enabled = 0; +int rcheevos_cheats_were_enabled = 0; #ifdef HAVE_THREADS #define CHEEVOS_LOCK(l) do { slock_lock(l); } while (0) @@ -288,7 +288,7 @@ static int cheevos_parse(const char* json) cheevos_lboard_t* lboard = NULL; cheevos_racheevo_t* rac = NULL; - cheevos_fixup_init(&cheevos_locals.fixups); + rcheevos_fixup_init(&cheevos_locals.fixups); res = cheevos_get_patchdata(json, &cheevos_locals.patchdata); @@ -364,7 +364,7 @@ static int cheevos_parse(const char* json) } rc_parse_trigger(cheevo->trigger, cheevo->info->memaddr, NULL, 0); - cheevo->active = CHEEVOS_ACTIVE_SOFTCORE | CHEEVOS_ACTIVE_HARDCORE; + cheevo->active = RCHEEVOS_ACTIVE_SOFTCORE | RCHEEVOS_ACTIVE_HARDCORE; cheevo->last = 1; } } @@ -406,7 +406,7 @@ error: CHEEVOS_FREE(cheevos_locals.unofficial); CHEEVOS_FREE(cheevos_locals.lboards); cheevos_free_patchdata(&cheevos_locals.patchdata); - cheevos_fixup_destroy(&cheevos_locals.fixups); + rcheevos_fixup_destroy(&cheevos_locals.fixups); return -1; } @@ -488,8 +488,8 @@ static void cheevos_award(cheevos_cheevo_t* cheevo, int mode) /* Deactivates the cheevo. */ cheevo->active &= ~mode; - if (mode == CHEEVOS_ACTIVE_HARDCORE) - cheevo->active &= ~CHEEVOS_ACTIVE_SOFTCORE; + if (mode == RCHEEVOS_ACTIVE_HARDCORE) + cheevo->active &= ~RCHEEVOS_ACTIVE_SOFTCORE; /* Show the OSD message. */ snprintf(buffer, sizeof(buffer), "Achievement Unlocked: %s", cheevo->info->title); @@ -497,7 +497,7 @@ static void cheevos_award(cheevos_cheevo_t* cheevo, int mode) runloop_msg_queue_push(cheevo->info->description, 0, 3 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); /* Start the award task. */ - if ((mode & CHEEVOS_ACTIVE_HARDCORE) != 0) + if ((mode & RCHEEVOS_ACTIVE_HARDCORE) != 0) cheevos_award_task_hardcore(NULL, NULL, cheevo, ""); else cheevos_award_task_softcore(NULL, NULL, cheevo, ""); @@ -523,7 +523,7 @@ static void cheevos_award(cheevos_cheevo_t* cheevo, int mode) static unsigned cheevos_peek(unsigned address, unsigned num_bytes, void* ud) { - const uint8_t* data = cheevos_fixup_find(&cheevos_locals.fixups, + const uint8_t* data = rcheevos_fixup_find(&cheevos_locals.fixups, address, cheevos_locals.patchdata.console_id); unsigned value = 0; @@ -540,12 +540,12 @@ static unsigned cheevos_peek(unsigned address, unsigned num_bytes, void* ud) static void cheevos_test_cheevo_set(bool official) { settings_t *settings = config_get_ptr(); - int mode = CHEEVOS_ACTIVE_SOFTCORE; + int mode = RCHEEVOS_ACTIVE_SOFTCORE; cheevos_cheevo_t* cheevo; int i, count; - if (settings && settings->bools.cheevos_hardcore_mode_enable && !cheevos_hardcore_paused) - mode = CHEEVOS_ACTIVE_HARDCORE; + if (settings && settings->bools.cheevos_hardcore_mode_enable && !rcheevos_hardcore_paused) + mode = RCHEEVOS_ACTIVE_HARDCORE; if (official) { @@ -696,7 +696,7 @@ static void cheevos_test_leaderboards(void) } } -void cheevos_reset_game(void) +void rcheevos_reset_game(void) { cheevos_cheevo_t* cheevo; cheevos_lboard_t* lboard; @@ -721,7 +721,7 @@ void cheevos_reset_game(void) } } -void cheevos_populate_menu(void* data) +void rcheevos_populate_menu(void* data) { #ifdef HAVE_MENU int i = 0; @@ -732,9 +732,9 @@ void cheevos_populate_menu(void* data) if ( settings->bools.cheevos_enable && settings->bools.cheevos_hardcore_mode_enable - && cheevos_loaded) + && rcheevos_loaded) { - if (!cheevos_hardcore_paused) + if (!rcheevos_hardcore_paused) menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_PAUSE), msg_hash_to_str(MENU_ENUM_LABEL_ACHIEVEMENT_PAUSE), @@ -752,7 +752,7 @@ void cheevos_populate_menu(void* data) for (i = 0, count = cheevos_locals.patchdata.core_count; i < count; i++, cheevo++) { - if (!(cheevo->active & CHEEVOS_ACTIVE_HARDCORE)) + if (!(cheevo->active & RCHEEVOS_ACTIVE_HARDCORE)) { menu_entries_append_enum(info->list, cheevo->info->title, cheevo->info->description, @@ -760,9 +760,9 @@ void cheevos_populate_menu(void* data) MENU_SETTINGS_CHEEVOS_START + i, 0, 0); set_badge_info(&badges_ctx, i, cheevo->info->badge, - (cheevo->active & CHEEVOS_ACTIVE_HARDCORE)); + (cheevo->active & RCHEEVOS_ACTIVE_HARDCORE)); } - else if (!(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)) + else if (!(cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE)) { menu_entries_append_enum(info->list, cheevo->info->title, cheevo->info->description, @@ -770,7 +770,7 @@ void cheevos_populate_menu(void* data) MENU_SETTINGS_CHEEVOS_START + i, 0, 0); set_badge_info(&badges_ctx, i, cheevo->info->badge, - (cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)); + (cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE)); } else { @@ -780,7 +780,7 @@ void cheevos_populate_menu(void* data) MENU_SETTINGS_CHEEVOS_START + i, 0, 0); set_badge_info(&badges_ctx, i, cheevo->info->badge, - (cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)); + (cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE)); } } @@ -790,7 +790,7 @@ void cheevos_populate_menu(void* data) for (i = 0, count = cheevos_locals.patchdata.unofficial_count; i < count; i++, cheevo++) { - if (!(cheevo->active & CHEEVOS_ACTIVE_HARDCORE)) + if (!(cheevo->active & RCHEEVOS_ACTIVE_HARDCORE)) { menu_entries_append_enum(info->list, cheevo->info->title, cheevo->info->description, @@ -798,9 +798,9 @@ void cheevos_populate_menu(void* data) MENU_SETTINGS_CHEEVOS_START + i, 0, 0); set_badge_info(&badges_ctx, i, cheevo->info->badge, - (cheevo->active & CHEEVOS_ACTIVE_HARDCORE)); + (cheevo->active & RCHEEVOS_ACTIVE_HARDCORE)); } - else if (!(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)) + else if (!(cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE)) { menu_entries_append_enum(info->list, cheevo->info->title, cheevo->info->description, @@ -808,7 +808,7 @@ void cheevos_populate_menu(void* data) MENU_SETTINGS_CHEEVOS_START + i, 0, 0); set_badge_info(&badges_ctx, i, cheevo->info->badge, - (cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)); + (cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE)); } else { @@ -818,7 +818,7 @@ void cheevos_populate_menu(void* data) MENU_SETTINGS_CHEEVOS_START + i, 0, 0); set_badge_info(&badges_ctx, i, cheevo->info->badge, - (cheevo->active & CHEEVOS_ACTIVE_SOFTCORE)); + (cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE)); } } } @@ -839,7 +839,7 @@ void cheevos_populate_menu(void* data) #endif } -bool cheevos_get_description(cheevos_ctx_desc_t* desc) +bool rcheevos_get_description(rcheevos_ctx_desc_t* desc) { unsigned idx; const cheevos_cheevo_t* cheevo; @@ -849,7 +849,7 @@ bool cheevos_get_description(cheevos_ctx_desc_t* desc) *desc->s = 0; - if (cheevos_loaded) + if (rcheevos_loaded) { idx = desc->idx; @@ -871,15 +871,15 @@ bool cheevos_get_description(cheevos_ctx_desc_t* desc) return true; } -bool cheevos_apply_cheats(bool* data_bool) +bool rcheevos_apply_cheats(bool* data_bool) { - cheats_are_enabled = *data_bool; - cheats_were_enabled |= cheats_are_enabled; + rcheevos_cheats_are_enabled = *data_bool; + rcheevos_cheats_were_enabled |= rcheevos_cheats_are_enabled; return true; } -bool cheevos_unload(void) +bool rcheevos_unload(void) { bool running = false; unsigned i = 0, count = 0; @@ -904,7 +904,7 @@ bool cheevos_unload(void) #endif } - if (cheevos_loaded) + if (rcheevos_loaded) { for (i = 0, count = cheevos_locals.patchdata.core_count; i < count; i++) { @@ -925,20 +925,20 @@ bool cheevos_unload(void) CHEEVOS_FREE(cheevos_locals.unofficial); CHEEVOS_FREE(cheevos_locals.lboards); cheevos_free_patchdata(&cheevos_locals.patchdata); - cheevos_fixup_destroy(&cheevos_locals.fixups); + rcheevos_fixup_destroy(&cheevos_locals.fixups); cheevos_locals.core = NULL; cheevos_locals.unofficial = NULL; cheevos_locals.lboards = NULL; - cheevos_loaded = false; - cheevos_hardcore_paused = false; + rcheevos_loaded = false; + rcheevos_hardcore_paused = false; } return true; } -bool cheevos_toggle_hardcore_mode(void) +bool rcheevos_toggle_hardcore_mode(void) { settings_t *settings = config_get_ptr(); @@ -947,13 +947,13 @@ bool cheevos_toggle_hardcore_mode(void) /* reset and deinit rewind to avoid cheat the score */ if ( settings->bools.cheevos_hardcore_mode_enable - && !cheevos_hardcore_paused) + && !rcheevos_hardcore_paused) { const char *msg = msg_hash_to_str( MSG_CHEEVOS_HARDCORE_MODE_ENABLE); /* reset the state loaded flag in case it was set */ - cheevos_state_loaded_flag = false; + rcheevos_state_loaded_flag = false; /* send reset core cmd to avoid any user * savestate previusly loaded. */ @@ -974,7 +974,7 @@ bool cheevos_toggle_hardcore_mode(void) return true; } -void cheevos_test(void) +void rcheevos_test(void) { settings_t *settings = config_get_ptr(); @@ -987,28 +987,28 @@ void cheevos_test(void) if (settings->bools.cheevos_hardcore_mode_enable && settings->bools.cheevos_leaderboards_enable && - !cheevos_hardcore_paused) + !rcheevos_hardcore_paused) cheevos_test_leaderboards(); } } -bool cheevos_set_cheats(void) +bool rcheevos_set_cheats(void) { - cheats_were_enabled = cheats_are_enabled; + rcheevos_cheats_were_enabled = rcheevos_cheats_are_enabled; return true; } -void cheevos_set_support_cheevos(bool state) +void rcheevos_set_support_cheevos(bool state) { cheevos_locals.core_supports = state; } -bool cheevos_get_support_cheevos(void) +bool rcheevos_get_support_cheevos(void) { return cheevos_locals.core_supports; } -int cheevos_get_console(void) +int rcheevos_get_console(void) { return cheevos_locals.patchdata.console_id; } @@ -1365,7 +1365,7 @@ found: CORO_STOP(); } - cheevos_loaded = true; + rcheevos_loaded = true; /* * Inputs: CHEEVOS_VAR_GAMEID @@ -1382,13 +1382,13 @@ found: if (coro->settings->bools.cheevos_verbose_enable && cheevos_locals.patchdata.core_count > 0) { char msg[256]; - int mode = CHEEVOS_ACTIVE_SOFTCORE; + int mode = RCHEEVOS_ACTIVE_SOFTCORE; const cheevos_cheevo_t* cheevo = cheevos_locals.core; const cheevos_cheevo_t* end = cheevo + cheevos_locals.patchdata.core_count; int number_of_unlocked = cheevos_locals.patchdata.core_count; - if (coro->settings->bools.cheevos_hardcore_mode_enable && !cheevos_hardcore_paused) - mode = CHEEVOS_ACTIVE_HARDCORE; + if (coro->settings->bools.cheevos_hardcore_mode_enable && !rcheevos_hardcore_paused) + mode = RCHEEVOS_ACTIVE_HARDCORE; for (; cheevo < end; cheevo++) if (cheevo->active & mode) @@ -1961,7 +1961,7 @@ found: if (coro->json) { - mode = coro->i == 0 ? CHEEVOS_ACTIVE_SOFTCORE : CHEEVOS_ACTIVE_HARDCORE; + mode = coro->i == 0 ? RCHEEVOS_ACTIVE_SOFTCORE : RCHEEVOS_ACTIVE_HARDCORE; cheevos_deactivate_unlocks(coro->json, cheevos_unlock_cb, &mode); CHEEVOS_FREE(coro->json); } @@ -2035,14 +2035,14 @@ static void cheevos_task_handler(retro_task_t *task) } } -bool cheevos_load(const void *data) +bool rcheevos_load(const void *data) { retro_task_t *task; const struct retro_game_info *info = NULL; coro_t *coro = NULL; - cheevos_loaded = false; - cheevos_hardcore_paused = false; + rcheevos_loaded = false; + rcheevos_hardcore_paused = false; if (!cheevos_locals.core_supports || !data) return false; diff --git a/cheevos-new/cheevos.h b/cheevos-new/cheevos.h index 65aaabc31b..fce51e482c 100644 --- a/cheevos-new/cheevos.h +++ b/cheevos-new/cheevos.h @@ -27,49 +27,49 @@ RETRO_BEGIN_DECLS -typedef struct cheevos_ctx_desc +typedef struct rcheevos_ctx_desc { unsigned idx; char *s; size_t len; -} cheevos_ctx_desc_t; +} rcheevos_ctx_desc_t; enum { - CHEEVOS_ACTIVE_SOFTCORE = 1 << 0, - CHEEVOS_ACTIVE_HARDCORE = 1 << 1 + RCHEEVOS_ACTIVE_SOFTCORE = 1 << 0, + RCHEEVOS_ACTIVE_HARDCORE = 1 << 1 }; -bool cheevos_load(const void *data); +bool rcheevos_load(const void *data); -void cheevos_reset_game(void); +void rcheevos_reset_game(void); -void cheevos_populate_menu(void *data); +void rcheevos_populate_menu(void *data); -bool cheevos_get_description(cheevos_ctx_desc_t *desc); +bool rcheevos_get_description(rcheevos_ctx_desc_t *desc); -bool cheevos_apply_cheats(bool *data_bool); +bool rcheevos_apply_cheats(bool *data_bool); -bool cheevos_unload(void); +bool rcheevos_unload(void); -bool cheevos_toggle_hardcore_mode(void); +bool rcheevos_toggle_hardcore_mode(void); -void cheevos_test(void); +void rcheevos_test(void); -bool cheevos_set_cheats(void); +bool rcheevos_set_cheats(void); -void cheevos_set_support_cheevos(bool state); +void rcheevos_set_support_cheevos(bool state); -bool cheevos_get_support_cheevos(void); +bool rcheevos_get_support_cheevos(void); -int cheevos_get_console(void); +int rcheevos_get_console(void); -extern bool cheevos_loaded; -extern bool cheevos_hardcore_active; -extern bool cheevos_hardcore_paused; -extern bool cheevos_state_loaded_flag; -extern int cheats_are_enabled; -extern int cheats_were_enabled; +extern bool rcheevos_loaded; +extern bool rcheevos_hardcore_active; +extern bool rcheevos_hardcore_paused; +extern bool rcheevos_state_loaded_flag; +extern int rcheevos_cheats_are_enabled; +extern int rcheevos_cheats_were_enabled; RETRO_END_DECLS diff --git a/cheevos-new/fixup.c b/cheevos-new/fixup.c index 56e0436cb6..a81e90d1a1 100644 --- a/cheevos-new/fixup.c +++ b/cheevos-new/fixup.c @@ -64,20 +64,20 @@ static size_t cheevos_var_highest_bit(size_t n) return n ^ (n >> 1); } -void cheevos_fixup_init(cheevos_fixups_t* fixups) +void rcheevos_fixup_init(cheevos_fixups_t* fixups) { fixups->elements = NULL; fixups->capacity = fixups->count = 0; fixups->dirty = false; } -void cheevos_fixup_destroy(cheevos_fixups_t* fixups) +void rcheevos_fixup_destroy(cheevos_fixups_t* fixups) { CHEEVOS_FREE(fixups->elements); - cheevos_fixup_init(fixups); + rcheevos_fixup_init(fixups); } -const uint8_t* cheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, int console) +const uint8_t* rcheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, int console) { cheevos_fixup_t key; cheevos_fixup_t* found; @@ -114,13 +114,13 @@ const uint8_t* cheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, in fixups->elements[fixups->count].address = address; fixups->elements[fixups->count++].location = location = - cheevos_patch_address(address, console); + rcheevos_patch_address(address, console); fixups->dirty = true; return location; } -const uint8_t* cheevos_patch_address(unsigned address, int console) +const uint8_t* rcheevos_patch_address(unsigned address, int console) { rarch_system_info_t* system = runloop_get_system_info(); const void* pointer = NULL; diff --git a/cheevos-new/fixup.h b/cheevos-new/fixup.h index 41893a0ba8..e2b9946a0d 100644 --- a/cheevos-new/fixup.h +++ b/cheevos-new/fixup.h @@ -36,12 +36,12 @@ typedef struct bool dirty; } cheevos_fixups_t; -void cheevos_fixup_init(cheevos_fixups_t* fixups); -void cheevos_fixup_destroy(cheevos_fixups_t* fixups); +void rcheevos_fixup_init(cheevos_fixups_t* fixups); +void rcheevos_fixup_destroy(cheevos_fixups_t* fixups); -const uint8_t* cheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, int console); +const uint8_t* rcheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, int console); -const uint8_t* cheevos_patch_address(unsigned address, int console); +const uint8_t* rcheevos_patch_address(unsigned address, int console); RETRO_END_DECLS diff --git a/cheevos-new/util.h b/cheevos-new/util.h index 4e389cf404..ac556bf681 100644 --- a/cheevos-new/util.h +++ b/cheevos-new/util.h @@ -25,13 +25,13 @@ Setup - mainly for debugging *****************************************************************************/ /* Define this macro to get extra-verbose log for cheevos. */ -#undef CHEEVOS_VERBOSE +#define CHEEVOS_VERBOSE /***************************************************************************** End of setup *****************************************************************************/ -#define CHEEVOS_TAG "[CHEEVOS]: " +#define CHEEVOS_TAG "[RCHEEVOS]: " #define CHEEVOS_FREE(p) do { void* q = (void*)p; if (q != NULL) free(q); } while (0) #ifdef CHEEVOS_VERBOSE diff --git a/cheevos/cheevos.h b/cheevos/cheevos.h index c65c2afbc9..14c91380eb 100644 --- a/cheevos/cheevos.h +++ b/cheevos/cheevos.h @@ -34,7 +34,7 @@ Setup - mainly for debugging *****************************************************************************/ /* Define this macro to get extra-verbose log for cheevos. */ -#undef CHEEVOS_VERBOSE +#define CHEEVOS_VERBOSE /***************************************************************************** End of setup diff --git a/command.c b/command.c index aefc2fe531..b061525f6a 100755 --- a/command.c +++ b/command.c @@ -41,11 +41,9 @@ #ifdef HAVE_CHEEVOS #include "cheevos/cheevos.h" -#ifdef HAVE_NEW_CHEEVOS -#include "cheevos-new/fixup.h" -#else #include "cheevos/var.h" -#endif +#include "cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove lines */ +#include "cheevos-new/fixup.h" #endif #ifdef HAVE_DISCORD @@ -276,9 +274,10 @@ bool command_set_shader(const char *arg) #define SMY_CMD_STR "READ_CORE_RAM" static bool command_read_ram(const char *arg) { -#if !defined(HAVE_NEW_CHEEVOS) + /* RCHEEVOS TODO: remove settings init and test */ + settings_t *settings = config_get_ptr(); cheevos_var_t var; -#endif + unsigned i; char *reply = NULL; const uint8_t *data = NULL; @@ -294,13 +293,18 @@ static bool command_read_ram(const char *arg) reply[0] = '\0'; reply_at = reply + snprintf(reply, alloc_size - 1, SMY_CMD_STR " %x", addr); -#if defined(HAVE_NEW_CHEEVOS) - data = cheevos_patch_address(addr, cheevos_get_console()); -#else - var.value = addr; - cheevos_var_patch_addr(&var, cheevos_get_console()); - data = cheevos_var_get_memory(&var); -#endif + /* RCHEEVOS TODO: remove if condition below */ + if (settings->bools.cheevos_rcheevos_enable) + { + data = rcheevos_patch_address(addr, rcheevos_get_console()); + } + /* RCHEEVOS TODO: remove whole else block below */ + else + { + var.value = addr; + cheevos_var_patch_addr(&var, cheevos_get_console()); + data = cheevos_var_get_memory(&var); + } if (data) { @@ -321,19 +325,28 @@ static bool command_read_ram(const char *arg) static bool command_write_ram(const char *arg) { - unsigned nbytes = 0; -#if defined(HAVE_NEW_CHEEVOS) - unsigned int addr = strtoul(arg, (char**)&arg, 16); - uint8_t *data = (uint8_t *)cheevos_patch_address(addr, cheevos_get_console()); -#else - cheevos_var_t var; - uint8_t *data = NULL; + unsigned nbytes = 0; + uint8_t *data = NULL; + unsigned int addr = 0; - var.value = strtoul(arg, (char**)&arg, 16); - cheevos_var_patch_addr(&var, cheevos_get_console()); + /* RCHEEVOS TODO: remove settings init and test */ + settings_t *settings = config_get_ptr(); - data = cheevos_var_get_memory(&var); -#endif + if (settings->bools.cheevos_rcheevos_enable) + { + addr = strtoul(arg, (char**)&arg, 16); + data = (uint8_t *)rcheevos_patch_address(addr, rcheevos_get_console()); + } + /* RCHEEVOS TODO: remove the whole else block below */ + else + { + cheevos_var_t var; + + var.value = strtoul(arg, (char**)&arg, 16); + cheevos_var_patch_addr(&var, cheevos_get_console()); + + data = cheevos_var_get_memory(&var); + } if (data) { @@ -1089,7 +1102,9 @@ static void command_event_init_controllers(void) static void command_event_deinit_core(bool reinit) { #ifdef HAVE_CHEEVOS - cheevos_unload(); + /* RCHEEVOS TODO: remove settings init and test */ + settings_t *settings = config_get_ptr(); + settings->bools.cheevos_rcheevos_enable ? rcheevos_unload() : cheevos_unload(); #endif RARCH_LOG("Unloading game..\n"); @@ -1144,7 +1159,8 @@ static void command_event_load_auto_state(void) #endif #ifdef HAVE_CHEEVOS - if (cheevos_hardcore_active) + /* RCHEEVOS TODO: remove OR below */ + if (cheevos_hardcore_active || rcheevos_hardcore_active) goto error; #endif @@ -1395,7 +1411,8 @@ static bool command_event_save_auto_state(void) goto error; #ifdef HAVE_CHEEVOS - if (cheevos_hardcore_active) + /* RCHEEVOS TODO: remove OR below */ + if (cheevos_hardcore_active || rcheevos_hardcore_active) goto error; #endif @@ -1695,7 +1712,8 @@ static bool command_event_main_state(unsigned cmd) if (content_load_state(state_path, false, false)) { #ifdef HAVE_CHEEVOS - cheevos_state_loaded_flag = true; + /* RCHEEVOS TODO: remove duplication below */ + rcheevos_state_loaded_flag = cheevos_state_loaded_flag = true; #endif ret = true; #ifdef HAVE_NETWORKING @@ -1842,7 +1860,8 @@ bool command_event(enum event_command cmd, void *data) return false; #ifdef HAVE_CHEEVOS - if (cheevos_hardcore_active) + /* RCHEEVOS TODO: remove OR below */ + if (cheevos_hardcore_active || rcheevos_hardcore_active) return false; #endif if (!command_event_main_state(cmd)) @@ -1872,29 +1891,34 @@ bool command_event(enum event_command cmd, void *data) command_event_init_controllers(); break; case CMD_EVENT_RESET: + /* RCHEEVOS TODO: remove starting block bracket, settings init and tests */ + { #ifdef HAVE_CHEEVOS - cheevos_state_loaded_flag = false; - cheevos_hardcore_paused = false; + settings_t *settings = config_get_ptr(); + rcheevos_state_loaded_flag = cheevos_state_loaded_flag = false; + rcheevos_hardcore_paused = cheevos_hardcore_paused = false; #endif - RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET)); - runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET)); + runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); #ifdef HAVE_CHEEVOS - cheevos_set_cheats(); + settings->bools.cheevos_rcheevos_enable ? rcheevos_set_cheats() : cheevos_set_cheats(); #endif - core_reset(); + core_reset(); #ifdef HAVE_CHEEVOS - cheevos_reset_game(); + settings->bools.cheevos_rcheevos_enable ? rcheevos_reset_game() : cheevos_reset_game(); #endif #if HAVE_NETWORKING - netplay_driver_ctl(RARCH_NETPLAY_CTL_RESET, NULL); + netplay_driver_ctl(RARCH_NETPLAY_CTL_RESET, NULL); #endif - return false; + return false; + } case CMD_EVENT_SAVE_STATE: { settings_t *settings = config_get_ptr(); #ifdef HAVE_CHEEVOS - if (cheevos_hardcore_active) + /* RCHEEVOS TODO: remove OR below */ + if (cheevos_hardcore_active || rcheevos_hardcore_active) return false; #endif @@ -1976,7 +2000,11 @@ bool command_event(enum event_command cmd, void *data) break; case CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE: #ifdef HAVE_CHEEVOS - cheevos_toggle_hardcore_mode(); + /* RCHEEVOS TODO: remove starting block bracket, settings init and test */ + { + settings_t *settings = config_get_ptr(); + settings->bools.cheevos_rcheevos_enable ? rcheevos_toggle_hardcore_mode() : cheevos_toggle_hardcore_mode(); + } #endif break; /* this fallthrough is on purpose, it should do @@ -2017,7 +2045,8 @@ bool command_event(enum event_command cmd, void *data) break; case CMD_EVENT_REWIND_DEINIT: #ifdef HAVE_CHEEVOS - if (cheevos_hardcore_active) + /* RCHEEVOS TODO: remove OR below */ + if (cheevos_hardcore_active || rcheevos_hardcore_active) return false; #endif state_manager_event_deinit(); @@ -2026,7 +2055,8 @@ bool command_event(enum event_command cmd, void *data) { settings_t *settings = config_get_ptr(); #ifdef HAVE_CHEEVOS - if (cheevos_hardcore_active) + /* RCHEEVOS TODO: remove OR below */ + if (cheevos_hardcore_active || rcheevos_hardcore_active) return false; #endif if (settings->bools.rewind_enable) diff --git a/configuration.c b/configuration.c index 8aecd689c3..d06da91870 100644 --- a/configuration.c +++ b/configuration.c @@ -1521,6 +1521,8 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("cheevos_leaderboards_enable", &settings->bools.cheevos_leaderboards_enable, true, false, false); SETTING_BOOL("cheevos_verbose_enable", &settings->bools.cheevos_verbose_enable, true, false, false); SETTING_BOOL("cheevos_auto_screenshot", &settings->bools.cheevos_auto_screenshot, true, false, false); + SETTING_BOOL("cheevos_rcheevos_enable", &settings->bools.cheevos_rcheevos_enable, true, false, false); + /* RCHEEVOS TODO: remove line above */ #ifdef HAVE_XMB SETTING_BOOL("cheevos_badges_enable", &settings->bools.cheevos_badges_enable, true, false, false); #endif diff --git a/configuration.h b/configuration.h index f1ea2f6b3b..029c1fade3 100644 --- a/configuration.h +++ b/configuration.h @@ -237,6 +237,7 @@ typedef struct settings bool cheevos_badges_enable; bool cheevos_verbose_enable; bool cheevos_auto_screenshot; + bool cheevos_rcheevos_enable; /* RCHEEVOS TODO: remove line */ /* Camera */ bool camera_allow; diff --git a/discord/discord.c b/discord/discord.c index 8e8f339709..af36ee22b9 100644 --- a/discord/discord.c +++ b/discord/discord.c @@ -41,6 +41,7 @@ #ifdef HAVE_CHEEVOS #include "../cheevos/cheevos.h" +#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #ifdef HAVE_MENU diff --git a/dynamic.c b/dynamic.c index 0cf7bd830c..3b0f4ee49b 100644 --- a/dynamic.c +++ b/dynamic.c @@ -37,6 +37,7 @@ #ifdef HAVE_CHEEVOS #include "cheevos/cheevos.h" +#include "cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #ifdef HAVE_OPENGL @@ -1924,7 +1925,8 @@ bool rarch_environment_cb(unsigned cmd, void *data) { bool state = *(const bool*)data; RARCH_LOG("Environ SET_SUPPORT_ACHIEVEMENTS: %s.\n", state ? "yes" : "no"); - cheevos_set_support_cheevos(state); + /* RCHEEVOS TODO: remove settings test */ + settings->bools.cheevos_rcheevos_enable ? rcheevos_set_support_cheevos(state) : cheevos_set_support_cheevos(state); } #endif break; diff --git a/griffin/griffin.c b/griffin/griffin.c index 4c7deb0202..6a629b413b 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -158,30 +158,15 @@ ACHIEVEMENTS #include "../libretro-common/formats/json/jsonsax.c" #include "../network/net_http_special.c" -#ifdef HAVE_NEW_CHEEVOS #include "../cheevos-new/cheevos.c" -#include "../cheevos-new/badges.c" #include "../cheevos-new/fixup.c" #include "../cheevos-new/hash.c" #include "../cheevos-new/parser.c" -#include "../deps/rcheevos/src/rcheevos/alloc.c" -#include "../deps/rcheevos/src/rcheevos/condition.c" -#include "../deps/rcheevos/src/rcheevos/condset.c" -#include "../deps/rcheevos/src/rcheevos/expression.c" -#include "../deps/rcheevos/src/rcheevos/format.c" -#include "../deps/rcheevos/src/rcheevos/lboard.c" -#include "../deps/rcheevos/src/rcheevos/operand.c" -#include "../deps/rcheevos/src/rcheevos/term.c" -#include "../deps/rcheevos/src/rcheevos/trigger.c" -#include "../deps/rcheevos/src/rcheevos/value.c" -#include "../deps/rcheevos/src/rurl/url.c" -#else #include "../cheevos/cheevos.c" #include "../cheevos/badges.c" #include "../cheevos/cond.c" #include "../cheevos/var.c" -#endif #endif diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index 9dec2d8ac0..7f14060c6a 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -41,6 +41,7 @@ #ifdef HAVE_CHEEVOS #include "../cheevos/cheevos.h" +#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #include "cheat_manager.h" @@ -68,6 +69,8 @@ unsigned cheat_manager_get_size(void) void cheat_manager_apply_cheats(void) { #ifdef HAVE_CHEEVOS + /* RCHEEVOS TODO: remove settings init */ + settings_t *settings = config_get_ptr(); bool data_bool = false; #endif unsigned i, idx = 0; @@ -100,7 +103,8 @@ void cheat_manager_apply_cheats(void) #ifdef HAVE_CHEEVOS data_bool = idx != 0; - cheevos_apply_cheats(&data_bool); + /* RCHEEVOS TODO: remove settings test */ + settings->bools.cheevos_rcheevos_enable ? rcheevos_apply_cheats(&data_bool) : cheevos_apply_cheats(&data_bool); #endif } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 6e83490a12..4cf1ec542c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -78,6 +78,7 @@ #ifdef HAVE_CHEEVOS #include "../cheevos/cheevos.h" +#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #include "../../record/record_driver.h" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 108446b63c..9b446e85a3 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -21,6 +21,7 @@ #ifdef HAVE_CHEEVOS #include "../../cheevos/cheevos.h" +#include "../../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #include "../../verbosity.h" @@ -572,12 +573,14 @@ static int action_bind_sublabel_cheevos_entry( char *s, size_t len) { #ifdef HAVE_CHEEVOS + settings_t *settings = config_get_ptr(); /* RCHEEVOS TODO: remove line */ cheevos_ctx_desc_t desc_info; unsigned new_id = type - MENU_SETTINGS_CHEEVOS_START; desc_info.idx = new_id; desc_info.s = s; desc_info.len = len; - cheevos_get_description(&desc_info); + /* RCHEEVOS TODO: remove test */ + settings->bools.cheevos_rcheevos_enable ? rcheevos_get_description((rcheevos_ctx_desc_t*) &desc_info) : cheevos_get_description(&desc_info); strlcpy(s, desc_info.s, len); #endif diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 7d3f2b7652..8f48e54846 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -39,6 +39,7 @@ #ifdef HAVE_CHEEVOS #include "../cheevos/cheevos.h" +#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #ifdef HAVE_NETWORKING @@ -2686,7 +2687,8 @@ static int menu_displaylist_parse_load_content_settings( if (settings->bools.quick_menu_show_save_load_state #ifdef HAVE_CHEEVOS - && !cheevos_hardcore_active + /* RCHEEVOS TODO: remove 'rcheevos_*' below */ + && !(rcheevos_hardcore_active || cheevos_hardcore_active) #endif ) { @@ -2709,7 +2711,8 @@ static int menu_displaylist_parse_load_content_settings( if (settings->bools.quick_menu_show_save_load_state && settings->bools.quick_menu_show_undo_save_load_state #ifdef HAVE_CHEEVOS - && !cheevos_hardcore_active + /* RCHEEVOS TODO: remove 'rcheevos_*' below */ + && !(rcheevos_hardcore_active || cheevos_hardcore_active) #endif ) { @@ -5040,10 +5043,13 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist break; case DISPLAYLIST_ACHIEVEMENT_LIST: #ifdef HAVE_CHEEVOS - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - cheevos_populate_menu(info); - info->need_push = true; - info->need_refresh = true; + { /* RCHEEVOS TODO: remove brackets, settings and settings test */ + settings_t *settings = config_get_ptr(); + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); + settings->bools.cheevos_rcheevos_enable ? rcheevos_populate_menu(info) : cheevos_populate_menu(info); + info->need_push = true; + info->need_refresh = true; + } #endif break; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 2bad35bb7d..2c14999471 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -50,6 +50,7 @@ #ifdef HAVE_CHEEVOS #include "../cheevos/cheevos.h" +#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #include "../frontend/frontend_driver.h" @@ -3465,7 +3466,8 @@ static void achievement_hardcore_mode_write_handler(rarch_setting_t *setting) if (settings && settings->bools.cheevos_enable && settings->bools.cheevos_hardcore_mode_enable) { - cheevos_toggle_hardcore_mode(); + /* RCHEEVOS TODO: remove settings test */ + settings->bools.cheevos_rcheevos_enable ? rcheevos_toggle_hardcore_mode() : cheevos_toggle_hardcore_mode(); command_event(CMD_EVENT_RESET, NULL); return; } diff --git a/menu/widgets/menu_dialog.c b/menu/widgets/menu_dialog.c index 2fbd65d0b0..5fd0a35c0a 100644 --- a/menu/widgets/menu_dialog.c +++ b/menu/widgets/menu_dialog.c @@ -23,6 +23,7 @@ #ifdef HAVE_CHEEVOS #include "../../cheevos/cheevos.h" +#include "../../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #include "menu_dialog.h" @@ -173,10 +174,14 @@ int menu_dialog_iterate(char *s, size_t len, const char *label) #ifdef HAVE_CHEEVOS case MENU_DIALOG_HELP_CHEEVOS_DESCRIPTION: - desc_info.idx = menu_dialog_current_id; - desc_info.s = s; - desc_info.len = len; - cheevos_get_description(&desc_info); + { /* RCHEEVOS TODO: remove brackets, settings and settings test */ + settings_t *settings = config_get_ptr(); + desc_info.idx = menu_dialog_current_id; + desc_info.s = s; + desc_info.len = len; + settings->bools.cheevos_rcheevos_enable ? rcheevos_get_description((rcheevos_ctx_desc_t*) &desc_info) : cheevos_get_description(&desc_info); + + } break; #endif diff --git a/network/httpserver/httpserver.c b/network/httpserver/httpserver.c index 607c340511..8831bbf3ae 100644 --- a/network/httpserver/httpserver.c +++ b/network/httpserver/httpserver.c @@ -30,6 +30,7 @@ #include "../../gfx/video_driver.h" #include "../../managers/core_option_manager.h" #include "../../cheevos/cheevos.h" +#include "../../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #include "../../content.h" #define BASIC_INFO "info" diff --git a/retroarch.c b/retroarch.c index e7afc9bfff..91347ea49a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -78,6 +78,7 @@ #ifdef HAVE_CHEEVOS #include "cheevos/cheevos.h" +#include "cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #ifdef HAVE_DISCORD @@ -3231,7 +3232,8 @@ bool runloop_msg_queue_pull(const char **ret) */ #define time_to_exit(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !is_alive || bsv_movie_is_end_of_file() || ((runloop_max_frames != 0) && (frame_count >= runloop_max_frames)) || runloop_exec) -#define runloop_check_cheevos() (settings->bools.cheevos_enable && cheevos_loaded && (!cheats_are_enabled && !cheats_were_enabled)) +/* RCHEEVOS TODO: remove 'rcheevos_*' tests below */ +#define runloop_check_cheevos() (settings->bools.cheevos_enable && (rcheevos_loaded || cheevos_loaded) && (!(rcheevos_cheats_are_enabled || cheats_are_enabled) && !(rcheevos_cheats_were_enabled || cheats_were_enabled))) #ifdef HAVE_NETWORKING /* FIXME: This is an ugly way to tell Netplay this... */ @@ -4118,17 +4120,18 @@ static enum runloop_state runloop_check_state( } #ifdef HAVE_CHEEVOS - cheevos_hardcore_active = settings->bools.cheevos_enable + /* RCHEEVOS TODO: remove the 'rcheevos_*' below */ + rcheevos_hardcore_active = cheevos_hardcore_active = settings->bools.cheevos_enable && settings->bools.cheevos_hardcore_mode_enable - && cheevos_loaded && !cheevos_hardcore_paused; + && (rcheevos_loaded || cheevos_loaded) && !(rcheevos_hardcore_paused || cheevos_hardcore_paused); - if (cheevos_hardcore_active && cheevos_state_loaded_flag) + if ((rcheevos_hardcore_active || cheevos_hardcore_active) && (rcheevos_state_loaded_flag || cheevos_state_loaded_flag)) { - cheevos_hardcore_paused = true; + rcheevos_hardcore_paused = cheevos_hardcore_paused = true; runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED), 0, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); } - if (!cheevos_hardcore_active) + if (!(rcheevos_hardcore_active || cheevos_hardcore_active)) #endif { char s[128]; @@ -4144,7 +4147,8 @@ static enum runloop_state runloop_check_state( /* Checks if slowmotion toggle/hold was being pressed and/or held. */ #ifdef HAVE_CHEEVOS - if (!cheevos_hardcore_active) + /* RCHEEVOS TODO: remove the 'rcheevos_*' below */ + if (!(rcheevos_hardcore_active || cheevos_hardcore_active)) #endif { static bool old_slowmotion_button_state = false; @@ -4493,8 +4497,8 @@ int runloop_iterate(unsigned *sleep_ms) rarch_core_runtime_tick(); #ifdef HAVE_CHEEVOS - if (runloop_check_cheevos()) - cheevos_test(); + if (runloop_check_cheevos()) /* RCHEEVOS TODO: remove settings test */ + settings->bools.cheevos_rcheevos_enable ? rcheevos_test() : cheevos_test(); #endif cheat_manager_apply_retro_cheats(); diff --git a/tasks/task_content.c b/tasks/task_content.c index ec809fa14f..6cc586c5c0 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -71,6 +71,7 @@ #ifdef HAVE_CHEEVOS #include "../cheevos/cheevos.h" +#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */ #endif #include "task_content.h" @@ -738,13 +739,15 @@ static bool content_file_load( #ifdef HAVE_CHEEVOS if (!special) { + /* RCHEEVOS TODO: remove settings and settings tests */ + settings_t *settings = config_get_ptr(); const char *content_path = content->elems[0].data; enum rarch_content_type type = path_is_media_type(content_path); - cheevos_set_cheats(); + settings->bools.cheevos_rcheevos_enable ? rcheevos_set_cheats() : cheevos_set_cheats(); if (type == RARCH_CONTENT_NONE && !string_is_empty(content_path)) - cheevos_load(info); + settings->bools.cheevos_rcheevos_enable ? rcheevos_load(info) : cheevos_load(info); } #endif