mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
Get rid of global->sram.use, turn it into static boolean
variable inside rarch_ctl
This commit is contained in:
parent
f0a2159f9a
commit
5bce79369a
@ -2053,12 +2053,9 @@ bool command_event(enum event_command cmd, void *data)
|
||||
break;
|
||||
case CMD_EVENT_AUTOSAVE_DEINIT:
|
||||
#ifdef HAVE_THREADS
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
if (!global->sram.use)
|
||||
return false;
|
||||
autosave_deinit();
|
||||
}
|
||||
if (!rarch_ctl(RARCH_CTL_IS_SRAM_USED, NULL))
|
||||
return false;
|
||||
autosave_deinit();
|
||||
#endif
|
||||
break;
|
||||
case CMD_EVENT_AUTOSAVE_INIT:
|
||||
|
20
paths.c
20
paths.c
@ -384,24 +384,32 @@ static bool path_init_subsystem(void)
|
||||
|
||||
void path_init_savefile(void)
|
||||
{
|
||||
bool should_sram_be_used = false;
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!global)
|
||||
return;
|
||||
|
||||
global->sram.use = global->sram.use && !global->sram.save_disable;
|
||||
should_sram_be_used = rarch_ctl(RARCH_CTL_IS_SRAM_USED, NULL) && !global->sram.save_disable;
|
||||
#ifdef HAVE_NETPLAY
|
||||
global->sram.use = global->sram.use &&
|
||||
should_sram_be_used = should_sram_be_used &&
|
||||
(!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)
|
||||
|| !global->netplay.is_client);
|
||||
#endif
|
||||
|
||||
if (!global->sram.use)
|
||||
RARCH_LOG("%s\n",
|
||||
msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED));
|
||||
if (should_sram_be_used)
|
||||
rarch_ctl(RARCH_CTL_SET_SRAM_ENABLE_FORCE, NULL);
|
||||
else
|
||||
rarch_ctl(RARCH_CTL_UNSET_SRAM_ENABLE, NULL);
|
||||
|
||||
if (global->sram.use)
|
||||
if (rarch_ctl(RARCH_CTL_IS_SRAM_USED, NULL))
|
||||
{
|
||||
command_event(CMD_EVENT_AUTOSAVE_INIT, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
RARCH_LOG("%s\n",
|
||||
msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED));
|
||||
}
|
||||
|
||||
static void path_init_savefile_internal(void)
|
||||
|
18
retroarch.c
18
retroarch.c
@ -1085,6 +1085,7 @@ error:
|
||||
|
||||
bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
{
|
||||
static bool rarch_use_sram = false;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
switch(state)
|
||||
@ -1181,14 +1182,17 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
return false;
|
||||
path_set_redirect();
|
||||
break;
|
||||
case RARCH_CTL_IS_SRAM_USED:
|
||||
return rarch_use_sram;
|
||||
case RARCH_CTL_SET_SRAM_ENABLE:
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (global)
|
||||
global->sram.use = rarch_ctl(RARCH_CTL_IS_PLAIN_CORE, NULL)
|
||||
&& !content_does_not_need_content();
|
||||
}
|
||||
rarch_use_sram = rarch_ctl(RARCH_CTL_IS_PLAIN_CORE, NULL)
|
||||
&& !content_does_not_need_content();
|
||||
break;
|
||||
case RARCH_CTL_SET_SRAM_ENABLE_FORCE:
|
||||
rarch_use_sram = true;
|
||||
break;
|
||||
case RARCH_CTL_UNSET_SRAM_ENABLE:
|
||||
rarch_use_sram = false;
|
||||
break;
|
||||
case RARCH_CTL_SET_ERROR_ON_INIT:
|
||||
rarch_error_on_init = true;
|
||||
|
@ -59,7 +59,10 @@ enum rarch_ctl_state
|
||||
|
||||
RARCH_CTL_SET_PATHS_REDIRECT,
|
||||
|
||||
RARCH_CTL_IS_SRAM_USED,
|
||||
RARCH_CTL_SET_SRAM_ENABLE,
|
||||
RARCH_CTL_SET_SRAM_ENABLE_FORCE,
|
||||
RARCH_CTL_UNSET_SRAM_ENABLE,
|
||||
|
||||
/* Force fullscreen */
|
||||
RARCH_CTL_SET_FORCE_FULLSCREEN,
|
||||
|
@ -741,6 +741,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
||||
command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL);
|
||||
|
||||
rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL);
|
||||
rarch_ctl(RARCH_CTL_UNSET_SRAM_ENABLE, NULL);
|
||||
path_clear_content();
|
||||
runloop_overrides_active = false;
|
||||
|
||||
|
@ -166,7 +166,6 @@ typedef struct global
|
||||
{
|
||||
bool load_disable;
|
||||
bool save_disable;
|
||||
bool use;
|
||||
} sram;
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "../file_path_special.h"
|
||||
#include "../configuration.h"
|
||||
#include "../msg_hash.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../runloop.h"
|
||||
#include "../verbosity.h"
|
||||
#include "tasks_internal.h"
|
||||
@ -919,9 +920,8 @@ bool content_save_ram_file(unsigned slot)
|
||||
bool event_save_files(void)
|
||||
{
|
||||
unsigned i;
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!global || !task_save_files || !global->sram.use)
|
||||
if (!task_save_files || !rarch_ctl(RARCH_CTL_IS_SRAM_USED, NULL))
|
||||
return false;
|
||||
|
||||
for (i = 0; i < task_save_files->size; i++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user