Add another parameter to content_get_status

This commit is contained in:
twinaphex 2017-01-25 15:51:57 +01:00
parent 361bd471de
commit 018cb7ebe6
6 changed files with 62 additions and 33 deletions

View File

@ -1232,8 +1232,8 @@ static void command_event_load_auto_state(void)
bool ret;
char msg[128] = {0};
char savestate_name_auto[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
#ifdef HAVE_NETWORKING
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
@ -1248,9 +1248,10 @@ static void command_event_load_auto_state(void)
if (!settings->savestate_auto_load)
return;
fill_pathname_noext(savestate_name_auto, global->name.savestate,
file_path_str(FILE_PATH_AUTO_EXTENSION),
sizeof(savestate_name_auto));
if (global)
fill_pathname_noext(savestate_name_auto, global->name.savestate,
file_path_str(FILE_PATH_AUTO_EXTENSION),
sizeof(savestate_name_auto));
if (!path_file_exists(savestate_name_auto))
return;
@ -1279,19 +1280,23 @@ static void command_event_set_savestate_auto_index(void)
if (!settings->savestate_auto_index)
return;
/* Find the file in the same directory as global->savestate_name
* with the largest numeral suffix.
*
* E.g. /foo/path/content.state, will try to find
* /foo/path/content.state%d, where %d is the largest number available.
*/
if (global)
{
/* Find the file in the same directory as global->savestate_name
* with the largest numeral suffix.
*
* E.g. /foo/path/content.state, will try to find
* /foo/path/content.state%d, where %d is the largest number available.
*/
fill_pathname_basedir(state_dir, global->name.savestate,
sizeof(state_dir));
fill_pathname_base(state_base, global->name.savestate,
sizeof(state_base));
}
fill_pathname_basedir(state_dir, global->name.savestate,
sizeof(state_dir));
fill_pathname_base(state_base, global->name.savestate,
sizeof(state_base));
dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL);
if (!(dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL)))
if (!dir_list)
return;
for (i = 0; i < dir_list->size; i++)
@ -1326,8 +1331,9 @@ static void command_event_set_savestate_auto_index(void)
static bool event_init_content(void)
{
bool contentless = false;
bool is_inited = false;
content_get_status(&contentless);
content_get_status(&contentless, &is_inited);
rarch_ctl(RARCH_CTL_SET_SRAM_ENABLE, NULL);
@ -1342,7 +1348,7 @@ static bool event_init_content(void)
if (!content_init())
return false;
content_get_status(&contentless);
content_get_status(&contentless, &is_inited);
if (contentless)
{
@ -1451,10 +1457,10 @@ static bool command_event_save_auto_state(void)
char savestate_name_auto[PATH_MAX_LENGTH] = {0};
bool ret = false;;
bool contentless = false;
bool is_inited = false;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
if (!settings || !settings->savestate_auto_save)
return false;
if (!global)
@ -1462,7 +1468,7 @@ static bool command_event_save_auto_state(void)
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
return false;
content_get_status(&contentless);
content_get_status(&contentless, &is_inited);
if (contentless)
return false;
@ -1957,12 +1963,17 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_UNLOAD_CORE:
{
bool contentless = false;
bool is_inited = false;
content_ctx_info_t content_info = {0};
content_get_status(&contentless, &is_inited);
command_event(CMD_EVENT_AUTOSAVE_STATE, NULL);
command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
if (content_is_inited())
if (is_inited)
if (!task_push_content_load_default(
NULL, NULL,
&content_info,

View File

@ -59,7 +59,8 @@ bool content_undo_load_state(void);
/* Restores the last savestate file which was overwritten */
bool content_undo_save_state(void);
void content_get_status(bool *contentless);
void content_get_status(bool *contentless,
bool *is_inited);
void content_set_does_not_need_content(void);
@ -67,8 +68,6 @@ void content_unset_does_not_need_content(void);
bool content_get_crc(uint32_t **content_crc_ptr);
bool content_is_inited(void);
void content_deinit(void);
/* Initializes and loads a content file for the currently

View File

@ -282,8 +282,9 @@ bool core_get_memory(retro_ctx_memory_info_t *info)
bool core_load_game(retro_ctx_load_content_info_t *load_info)
{
bool contentless = false;
bool is_inited = false;
content_get_status(&contentless);
content_get_status(&contentless, &is_inited);
if (load_info && load_info->special)
core_game_loaded = core.retro_load_game_special(

View File

@ -3815,12 +3815,17 @@ static int action_ok_netplay_enable_host(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
#ifdef HAVE_NETWORKING
bool contentless = false;
bool is_inited = false;
content_get_status(&contentless, &is_inited);
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL);
/* If we haven't yet started, this will load on its own */
if (!content_is_inited())
if (!is_inited)
{
runloop_msg_queue_push(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED),
@ -3860,13 +3865,17 @@ static int action_ok_netplay_enable_client(const char *path,
{
#ifdef HAVE_NETWORKING
settings_t *settings = config_get_ptr();
bool contentless = false;
bool is_inited = false;
content_get_status(&contentless, &is_inited);
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
/* If we haven't yet started, this will load on its own */
if (!content_is_inited())
if (!is_inited)
{
runloop_msg_queue_push(
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_START_WHEN_LOADED),

View File

@ -1263,7 +1263,8 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
case RARCH_CTL_SET_PATHS_REDIRECT:
{
bool contentless = false;
content_get_status(&contentless);
bool is_inited = false;
content_get_status(&contentless, &is_inited);
if (contentless)
return false;
@ -1291,7 +1292,8 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
case RARCH_CTL_SET_SRAM_ENABLE:
{
bool contentless = false;
content_get_status(&contentless);
bool is_inited = false;
content_get_status(&contentless, &is_inited);
rarch_use_sram = rarch_ctl(RARCH_CTL_IS_PLAIN_CORE, NULL)
&& !contentless;
}

View File

@ -692,8 +692,9 @@ static bool content_file_init_set_attribs(
else
{
bool contentless = false;
bool is_inited = false;
content_get_status(&contentless);
content_get_status(&contentless, &is_inited);
attr.i = content_ctx->block_extract;
attr.i |= content_ctx->need_fullpath << 1;
@ -822,16 +823,19 @@ static bool task_load_content(content_ctx_info_t *content_info,
char name[255];
char msg[255];
bool contentless = false;
bool is_inited = false;
name[0] = msg[0] = '\0';
content_get_status(&contentless);
content_get_status(&contentless, &is_inited);
if (!content_load(content_info))
goto error;
content_get_status(&contentless, &is_inited);
/* Push entry to top of history playlist */
if (_content_is_inited || contentless)
if (is_inited || contentless)
{
char tmp[PATH_MAX_LENGTH];
struct retro_system_info *info = NULL;
@ -1328,9 +1332,12 @@ cleanup:
#endif
}
void content_get_status(bool *contentless)
void content_get_status(
bool *contentless,
bool *is_inited)
{
*contentless = core_does_not_need_content;
*is_inited = _content_is_inited;
}
void content_set_does_not_need_content(void)