Add CONTENT_CTL_DOES_NOT_NEED_CONTENT and CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT

This commit is contained in:
twinaphex 2016-01-19 23:15:19 +01:00
parent a5af9b653a
commit 5643b7d3d8
5 changed files with 28 additions and 16 deletions

View File

@ -533,13 +533,13 @@ static bool event_init_content(void)
if (global->inited.core.type == CORE_TYPE_DUMMY)
return true;
if (!global->inited.core.no_content)
if (!content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL))
rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL);
if (!content_ctl(CONTENT_CTL_INIT, NULL))
return false;
if (global->inited.core.no_content)
if (content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL))
return true;
event_set_savestate_auto_index();
@ -579,14 +579,15 @@ static bool event_init_core(void)
config_load_remap();
/* per-core saves: reset redirection paths */
if((settings->sort_savestates_enable || settings->sort_savefiles_enable) && !global->inited.core.no_content)
if((settings->sort_savestates_enable || settings->sort_savefiles_enable)
&& !content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL))
rarch_ctl(RARCH_CTL_SET_PATHS_REDIRECT, NULL);
rarch_ctl(RARCH_CTL_VERIFY_API_VERSION, NULL);
core.retro_init();
global->sram.use = (global->inited.core.type == CORE_TYPE_PLAIN) &&
!global->inited.core.no_content;
global->sram.use = (global->inited.core.type == CORE_TYPE_PLAIN)
&& !content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL);
if (!event_init_content())
return false;
@ -604,10 +605,12 @@ static bool event_save_auto_state(void)
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
if (!settings->savestate_auto_save ||
(global->inited.core.type == CORE_TYPE_DUMMY) ||
global->inited.core.no_content)
return false;
if (!settings->savestate_auto_save)
return false;
if (global->inited.core.type == CORE_TYPE_DUMMY)
return false;
if (content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL))
return false;
fill_pathname_noext(savestate_name_auto, global->name.savestate,
".auto", sizeof(savestate_name_auto));

View File

@ -675,7 +675,7 @@ static bool init_content_file_set_attribs(
attr.i |= system->info.need_fullpath << 1;
attr.i |= (!system->no_content) << 2;
if (global->inited.core.no_content
if (content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL)
&& settings->core.set_supports_no_game_enable)
string_list_append(content, "", attr);
else
@ -754,9 +754,15 @@ bool content_ctl(enum content_ctl_state state, void *data)
unsigned i;
static struct string_list *temporary_content = NULL;
static bool content_is_inited = false;
static bool core_does_not_need_content = false;
switch(state)
{
case CONTENT_CTL_DOES_NOT_NEED_CONTENT:
return core_does_not_need_content;
case CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT:
core_does_not_need_content = true;
break;
case CONTENT_CTL_LOAD_STATE:
{
const char *path = (const char*)data;
@ -775,8 +781,9 @@ bool content_ctl(enum content_ctl_state state, void *data)
return content_is_inited;
case CONTENT_CTL_DEINIT:
content_ctl(CONTENT_CTL_TEMPORARY_FREE, NULL);
content_is_inited = false;
return true;
content_is_inited = false;
core_does_not_need_content = false;
break;
case CONTENT_CTL_INIT:
content_is_inited = false;
if (content_init_file(temporary_content))

View File

@ -33,6 +33,10 @@ enum content_ctl_state
CONTENT_CTL_IS_INITED,
CONTENT_CTL_DOES_NOT_NEED_CONTENT,
CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT,
/* Initializes and loads a content file for the currently
* selected libretro core. */
CONTENT_CTL_INIT,

View File

@ -41,6 +41,7 @@
#include <file/file_path.h>
#include <retro_stat.h>
#include "content.h"
#include "core_info.h"
#include "msg_hash.h"
#include "movie.h"
@ -618,7 +619,6 @@ static void parse_input(int argc, char *argv[])
{ NULL, 0, NULL, 0 }
};
global->inited.core.no_content = false;
global->inited.core.type = CORE_TYPE_PLAIN;
*global->subsystem = '\0';
global->has_set.save_path = false;
@ -966,8 +966,7 @@ static void parse_input(int argc, char *argv[])
else if (*global->subsystem && optind < argc)
set_special_paths(argv + optind, argc - optind);
else
global->inited.core.no_content = true;
content_ctl(CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT, NULL);
/* Copy SRM/state dirs used, so they can be reused on reentrancy. */
if (global->has_set.save_path &&

View File

@ -287,7 +287,6 @@ typedef struct global
bool main;
struct
{
bool no_content;
enum rarch_core_type type;
} core;
} inited;