From 6946f878ef7d08f465ded5bd26c03e6444f5b70e Mon Sep 17 00:00:00 2001 From: Jamiras Date: Sat, 16 May 2020 08:01:24 -0600 Subject: [PATCH] disable hardcore when cheats are enabled --- cheevos-new/cheevos.c | 15 ++------------- cheevos-new/cheevos.h | 6 +----- intl/msg_hash_us.h | 6 +++++- managers/cheat_manager.c | 28 ++++++++++++++++++++++------ msg_hash.h | 1 + retroarch.c | 8 +------- tasks/task_content.c | 2 -- 7 files changed, 32 insertions(+), 34 deletions(-) diff --git a/cheevos-new/cheevos.c b/cheevos-new/cheevos.c index 51c076a582..0b5d7d836f 100644 --- a/cheevos-new/cheevos.c +++ b/cheevos-new/cheevos.c @@ -207,8 +207,6 @@ 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; char rcheevos_user_agent_prefix[128] = ""; #ifdef HAVE_THREADS @@ -1269,12 +1267,9 @@ bool rcheevos_get_description(rcheevos_ctx_desc_t* desc) return true; } -bool rcheevos_apply_cheats(bool* data_bool) +void rcheevos_pause_hardcore() { - rcheevos_cheats_are_enabled = *data_bool; - rcheevos_cheats_were_enabled |= rcheevos_cheats_are_enabled; - - return true; + rcheevos_hardcore_paused = true; } bool rcheevos_unload(void) @@ -1398,12 +1393,6 @@ void rcheevos_test(void) } } -bool rcheevos_set_cheats(void) -{ - rcheevos_cheats_were_enabled = rcheevos_cheats_are_enabled; - return true; -} - void rcheevos_set_support_cheevos(bool state) { rcheevos_locals.core_supports = state; diff --git a/cheevos-new/cheevos.h b/cheevos-new/cheevos.h index 952a760436..b1096be9a5 100644 --- a/cheevos-new/cheevos.h +++ b/cheevos-new/cheevos.h @@ -49,7 +49,7 @@ void rcheevos_get_achievement_state(unsigned index, char* buffer, size_t buffer_ bool rcheevos_get_description(rcheevos_ctx_desc_t *desc); -bool rcheevos_apply_cheats(bool *data_bool); +void rcheevos_pause_hardcore(); bool rcheevos_unload(void); @@ -57,8 +57,6 @@ bool rcheevos_toggle_hardcore_mode(void); void rcheevos_test(void); -bool rcheevos_set_cheats(void); - void rcheevos_set_support_cheevos(bool state); bool rcheevos_get_support_cheevos(void); @@ -73,8 +71,6 @@ 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/intl/msg_hash_us.h b/intl/msg_hash_us.h index 422999fc8d..201866f33d 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -10583,7 +10583,11 @@ MSG_HASH( ) MSG_HASH( MSG_CHEEVOS_HARDCORE_MODE_DISABLED, - "A save state was loaded, Achievements Hardcore Mode disabled for the current session. Restart to enable hardcore mode." + "A save state was loaded. Achievements Hardcore Mode disabled for the current session. Restart to enable hardcore mode." + ) +MSG_HASH( + MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, + "A cheat was activated. Achievements Hardcore Mode disabled for the current session. Disable cheats and restart to enable hardcore mode." ) MSG_HASH( MSG_RESAMPLER_QUALITY_LOWEST, diff --git a/managers/cheat_manager.c b/managers/cheat_manager.c index a00649e306..b7209c818e 100644 --- a/managers/cheat_manager.c +++ b/managers/cheat_manager.c @@ -61,12 +61,21 @@ unsigned cheat_manager_get_size(void) return cheat_manager_state.size; } +#ifdef HAVE_CHEEVOS +static void cheat_manager_pause_cheevos() +{ + if (rcheevos_hardcore_active && rcheevos_loaded && !rcheevos_hardcore_paused) + { + rcheevos_pause_hardcore(); + + runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + RARCH_LOG("%s\n", msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT)); + } +} +#endif + void cheat_manager_apply_cheats(void) { -#ifdef HAVE_CHEEVOS - bool data_bool = false; - -#endif unsigned i, idx = 0; if (!cheat_manager_state.cheats) @@ -96,8 +105,8 @@ void cheat_manager_apply_cheats(void) } #ifdef HAVE_CHEEVOS - data_bool = idx != 0; - rcheevos_apply_cheats(&data_bool); + if (idx != 0) + cheat_manager_pause_cheevos(); #endif } @@ -1318,6 +1327,7 @@ void cheat_manager_apply_retro_cheats(void) unsigned int bits = 8; unsigned int curr_val = 0; bool run_cheat = true; + bool cheat_applied = false; if ((!cheat_manager_state.cheats)) return; @@ -1407,6 +1417,7 @@ void cheat_manager_apply_retro_cheats(void) if (set_value) { + cheat_applied = true; for (repeat_iter = 1; repeat_iter <= cheat_manager_state.cheats[i].repeat_count; repeat_iter++) { switch (bytes_per_item) @@ -1495,6 +1506,11 @@ void cheat_manager_apply_retro_cheats(void) } } } + +#ifdef HAVE_CHEEVOS + if (cheat_applied) + cheat_manager_pause_cheevos(); +#endif } void cheat_manager_match_action(enum cheat_match_action_type match_action, unsigned int target_match_idx, unsigned int *address, unsigned int *address_mask, diff --git a/msg_hash.h b/msg_hash.h index 8c0f065e02..2b1564de57 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2661,6 +2661,7 @@ enum msg_hash_enums MSG_CHEAT_SEARCH_ADD_MATCH_FAIL, MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS, MSG_CHEEVOS_HARDCORE_MODE_DISABLED, + MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT, MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD, diff --git a/retroarch.c b/retroarch.c index 5543bd9ca5..4f2ec6f36f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -7116,9 +7116,6 @@ bool command_event(enum event_command cmd, void *data) 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 - rcheevos_set_cheats(); -#endif core_reset(); #ifdef HAVE_CHEEVOS rcheevos_reset_game(); @@ -29001,10 +28998,7 @@ int runloop_iterate(void) libretro_core_runtime_usec += rarch_core_runtime_tick(current_time); #ifdef HAVE_CHEEVOS - if ( settings->bools.cheevos_enable && - rcheevos_loaded && - (!rcheevos_cheats_are_enabled && !rcheevos_cheats_were_enabled) - ) + if (settings->bools.cheevos_enable && rcheevos_loaded) rcheevos_test(); #endif cheat_manager_apply_retro_cheats(); diff --git a/tasks/task_content.c b/tasks/task_content.c index 6846d4a688..077de9aa74 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1077,8 +1077,6 @@ static bool content_file_load( const char *content_path = content->elems[0].data; enum rarch_content_type type = path_is_media_type(content_path); - rcheevos_set_cheats(); - if (type == RARCH_CONTENT_NONE && !string_is_empty(content_path)) rcheevos_load(info); else