disable hardcore when cheats are enabled

This commit is contained in:
Jamiras 2020-05-16 08:01:24 -06:00
parent f1158b988c
commit 6946f878ef
7 changed files with 32 additions and 34 deletions

View File

@ -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;

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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();

View File

@ -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