Merge pull request #7268 from fr500/master

WIP: prevent loading states before achievements are fully loaded
This commit is contained in:
Twinaphex 2018-09-23 08:42:53 +02:00 committed by GitHub
commit a1d876b44e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 3 deletions

View File

@ -288,6 +288,7 @@ static cheevos_locals_t cheevos_locals =
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;
@ -2265,11 +2266,15 @@ bool cheevos_toggle_hardcore_mode(void)
return false;
/* reset and deinit rewind to avoid cheat the score */
if (settings->bools.cheevos_hardcore_mode_enable && !cheevos_hardcore_paused)
if (settings->bools.cheevos_hardcore_mode_enable
&& !cheevos_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;
/* send reset core cmd to avoid any user
* savestate previusly loaded. */
command_event(CMD_EVENT_RESET, NULL);

View File

@ -155,8 +155,10 @@ cheevos_console_t cheevos_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;
;
RETRO_END_DECLS

View File

@ -1675,6 +1675,9 @@ static bool command_event_main_state(unsigned cmd)
case CMD_EVENT_LOAD_STATE:
if (content_load_state(state_path, false, false))
{
#ifdef HAVE_CHEEVOS
cheevos_state_loaded_flag = true;
#endif
ret = true;
#ifdef HAVE_NETWORKING
netplay_driver_ctl(RARCH_NETPLAY_CTL_LOAD_SAVESTATE, NULL);
@ -1905,6 +1908,8 @@ bool command_event(enum event_command cmd, void *data)
command_event_init_controllers();
break;
case CMD_EVENT_RESET:
cheevos_state_loaded_flag = false;
cheevos_hardcore_paused = false;
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET));
runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true);

View File

@ -3711,7 +3711,7 @@ MSG_HASH(
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_MODE_ENABLE,
"Hardcore Mode Enabled, savestate & rewind were disabled."
"Achievements Hardcore Mode Enabled, savestate & rewind were disabled."
)
MSG_HASH(
MSG_COMPARING_WITH_KNOWN_MAGIC_NUMBERS,
@ -7542,3 +7542,7 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_META_STREAMING_TOGGLE,
"Streaming toggle"
)
MSG_HASH(
MSG_CHEEVOS_HARDCORE_MODE_DISABLED,
"A savestate was loaded, Achievements Hardcore Mode disabled for the current session. Restart to enable hardcore mode."
)

View File

@ -50,6 +50,11 @@
#endif
#ifdef HAVE_CHEEVOS
#include "../cheevos/cheevos.h"
#endif
#include "../frontend/frontend_driver.h"
#include "widgets/menu_input_bind_dialog.h"
@ -1871,6 +1876,23 @@ static void overlay_enable_toggle_change_handler(rarch_setting_t *setting)
}
#endif
#ifdef HAVE_CHEEVOS
static void achievement_hardcore_mode_write_handler(rarch_setting_t *setting)
{
settings_t *settings = config_get_ptr();
if (!setting)
return;
if (settings && settings->bools.cheevos_hardcore_mode_enable && cheevos_state_loaded_flag)
{
cheevos_hardcore_paused = true;
runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED), 0, 180, true);
return;
}
}
#endif
#ifdef HAVE_LAKKA
static void systemd_service_toggle(const char *path, char *unit, bool enable)
{
@ -7671,7 +7693,7 @@ static bool setting_append_list(
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
achievement_hardcore_mode_write_handler,
general_read_handler,
SD_FLAG_NONE
);

View File

@ -2107,6 +2107,7 @@ enum msg_hash_enums
MSG_CHEAT_SEARCH_ADD_MATCH_SUCCESS,
MSG_CHEAT_SEARCH_ADD_MATCH_FAIL,
MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS,
MSG_CHEEVOS_HARDCORE_MODE_DISABLED,
MSG_LAST
};

View File

@ -3156,6 +3156,12 @@ static enum runloop_state runloop_check_state(
&& settings->bools.cheevos_hardcore_mode_enable
&& cheevos_loaded && !cheevos_hardcore_paused;
if (cheevos_hardcore_active && cheevos_state_loaded_flag)
{
cheevos_hardcore_paused = true;
runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED), 0, 180, true);
}
if (!cheevos_hardcore_active)
#endif
{