Get rid of global->sram.use, turn it into static boolean

variable inside rarch_ctl
This commit is contained in:
twinaphex 2016-09-28 07:17:14 +02:00
parent f0a2159f9a
commit 5bce79369a
7 changed files with 34 additions and 22 deletions

View File

@ -2053,12 +2053,9 @@ bool command_event(enum event_command cmd, void *data)
break; break;
case CMD_EVENT_AUTOSAVE_DEINIT: case CMD_EVENT_AUTOSAVE_DEINIT:
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
{ if (!rarch_ctl(RARCH_CTL_IS_SRAM_USED, NULL))
global_t *global = global_get_ptr(); return false;
if (!global->sram.use) autosave_deinit();
return false;
autosave_deinit();
}
#endif #endif
break; break;
case CMD_EVENT_AUTOSAVE_INIT: case CMD_EVENT_AUTOSAVE_INIT:

20
paths.c
View File

@ -384,24 +384,32 @@ static bool path_init_subsystem(void)
void path_init_savefile(void) void path_init_savefile(void)
{ {
bool should_sram_be_used = false;
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
if (!global) if (!global)
return; 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 #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) (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)
|| !global->netplay.is_client); || !global->netplay.is_client);
#endif #endif
if (!global->sram.use) if (should_sram_be_used)
RARCH_LOG("%s\n", rarch_ctl(RARCH_CTL_SET_SRAM_ENABLE_FORCE, NULL);
msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED)); 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); 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) static void path_init_savefile_internal(void)

View File

@ -1085,6 +1085,7 @@ error:
bool rarch_ctl(enum rarch_ctl_state state, void *data) bool rarch_ctl(enum rarch_ctl_state state, void *data)
{ {
static bool rarch_use_sram = false;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
switch(state) switch(state)
@ -1181,14 +1182,17 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
return false; return false;
path_set_redirect(); path_set_redirect();
break; break;
case RARCH_CTL_IS_SRAM_USED:
return rarch_use_sram;
case RARCH_CTL_SET_SRAM_ENABLE: case RARCH_CTL_SET_SRAM_ENABLE:
{ rarch_use_sram = rarch_ctl(RARCH_CTL_IS_PLAIN_CORE, NULL)
global_t *global = global_get_ptr(); && !content_does_not_need_content();
break;
if (global) case RARCH_CTL_SET_SRAM_ENABLE_FORCE:
global->sram.use = rarch_ctl(RARCH_CTL_IS_PLAIN_CORE, NULL) rarch_use_sram = true;
&& !content_does_not_need_content(); break;
} case RARCH_CTL_UNSET_SRAM_ENABLE:
rarch_use_sram = false;
break; break;
case RARCH_CTL_SET_ERROR_ON_INIT: case RARCH_CTL_SET_ERROR_ON_INIT:
rarch_error_on_init = true; rarch_error_on_init = true;

View File

@ -59,7 +59,10 @@ enum rarch_ctl_state
RARCH_CTL_SET_PATHS_REDIRECT, RARCH_CTL_SET_PATHS_REDIRECT,
RARCH_CTL_IS_SRAM_USED,
RARCH_CTL_SET_SRAM_ENABLE, RARCH_CTL_SET_SRAM_ENABLE,
RARCH_CTL_SET_SRAM_ENABLE_FORCE,
RARCH_CTL_UNSET_SRAM_ENABLE,
/* Force fullscreen */ /* Force fullscreen */
RARCH_CTL_SET_FORCE_FULLSCREEN, RARCH_CTL_SET_FORCE_FULLSCREEN,

View File

@ -741,6 +741,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL);
rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL);
rarch_ctl(RARCH_CTL_UNSET_SRAM_ENABLE, NULL);
path_clear_content(); path_clear_content();
runloop_overrides_active = false; runloop_overrides_active = false;

View File

@ -166,7 +166,6 @@ typedef struct global
{ {
bool load_disable; bool load_disable;
bool save_disable; bool save_disable;
bool use;
} sram; } sram;
#ifdef HAVE_NETPLAY #ifdef HAVE_NETPLAY

View File

@ -41,6 +41,7 @@
#include "../file_path_special.h" #include "../file_path_special.h"
#include "../configuration.h" #include "../configuration.h"
#include "../msg_hash.h" #include "../msg_hash.h"
#include "../retroarch.h"
#include "../runloop.h" #include "../runloop.h"
#include "../verbosity.h" #include "../verbosity.h"
#include "tasks_internal.h" #include "tasks_internal.h"
@ -919,9 +920,8 @@ bool content_save_ram_file(unsigned slot)
bool event_save_files(void) bool event_save_files(void)
{ {
unsigned i; 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; return false;
for (i = 0; i < task_save_files->size; i++) for (i = 0; i < task_save_files->size; i++)