mirror of
https://github.com/libretro/RetroArch
synced 2025-03-17 19:21:09 +00:00
Merge pull request #12321 from jdgleaver/core-info-optimisation
(core_info) Performance optimisations + code clean-ups/refactors
This commit is contained in:
commit
a904b1665f
935
core_info.c
935
core_info.c
File diff suppressed because it is too large
Load Diff
48
core_info.h
48
core_info.h
@ -45,25 +45,19 @@ typedef struct
|
||||
|
||||
/* Simple container/convenience struct for
|
||||
* holding the 'id' of a core file
|
||||
* > 'id' is the filename without extension or
|
||||
* > 'str' is the filename without extension or
|
||||
* platform-specific suffix
|
||||
* > 'id' is used for core info searches - enables
|
||||
* matching regardless of core file base path,
|
||||
* and is platform-independent (e.g. an Android
|
||||
* core file will be correctly identified on Linux)
|
||||
* > 'len' is used to cache the length of 'str', for
|
||||
* improved performance when performing string
|
||||
* comparisons */
|
||||
* > 'hash' is a hash key used for efficient core
|
||||
* list searches */
|
||||
typedef struct
|
||||
{
|
||||
char *str;
|
||||
size_t len;
|
||||
uint32_t hash;
|
||||
} core_file_id_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *path;
|
||||
void *config_data;
|
||||
char *display_name;
|
||||
char *display_version;
|
||||
char *core_name;
|
||||
@ -89,8 +83,8 @@ typedef struct
|
||||
struct string_list *required_hw_api_list;
|
||||
core_info_firmware_t *firmware;
|
||||
core_file_id_t core_file_id; /* ptr alignment */
|
||||
void *userdata;
|
||||
size_t firmware_count;
|
||||
bool has_info;
|
||||
bool supports_no_game;
|
||||
bool database_match_archive_member;
|
||||
bool is_experimental;
|
||||
@ -112,6 +106,7 @@ typedef struct
|
||||
core_info_t *list;
|
||||
char *all_ext;
|
||||
size_t count;
|
||||
size_t info_count;
|
||||
} core_info_list_t;
|
||||
|
||||
typedef struct core_info_ctx_firmware
|
||||
@ -123,12 +118,6 @@ typedef struct core_info_ctx_firmware
|
||||
} directory;
|
||||
} core_info_ctx_firmware_t;
|
||||
|
||||
typedef struct core_info_ctx_find
|
||||
{
|
||||
core_info_t *inf;
|
||||
const char *path;
|
||||
} core_info_ctx_find_t;
|
||||
|
||||
struct core_info_state
|
||||
{
|
||||
#ifdef HAVE_COMPRESSION
|
||||
@ -141,30 +130,21 @@ struct core_info_state
|
||||
|
||||
typedef struct core_info_state core_info_state_t;
|
||||
|
||||
size_t core_info_list_num_info_files(core_info_list_t *list);
|
||||
|
||||
/* Non-reentrant, does not allocate. Returns pointer to internal state. */
|
||||
void core_info_list_get_supported_cores(core_info_list_t *list,
|
||||
const char *path, const core_info_t **infos, size_t *num_infos);
|
||||
|
||||
bool core_info_list_get_display_name(core_info_list_t *list,
|
||||
const char *path, char *s, size_t len);
|
||||
|
||||
bool core_info_get_display_name(const char *path, char *s, size_t len);
|
||||
const char *core_path, char *s, size_t len);
|
||||
|
||||
/* Returns core_info parameters required for
|
||||
* core updater tasks, read from specified file.
|
||||
* Returned core_updater_info_t object must be
|
||||
* freed using core_info_free_core_updater_info().
|
||||
* Returns NULL if 'path' is invalid. */
|
||||
core_updater_info_t *core_info_get_core_updater_info(const char *path);
|
||||
core_updater_info_t *core_info_get_core_updater_info(const char *info_path);
|
||||
void core_info_free_core_updater_info(core_updater_info_t *info);
|
||||
|
||||
void core_info_get_name(const char *path, char *s, size_t len,
|
||||
const char *path_info, const char *dir_cores,
|
||||
const char *exts, bool show_hidden_files,
|
||||
bool get_display_name);
|
||||
|
||||
core_info_t *core_info_get(core_info_list_t *list, size_t i);
|
||||
|
||||
void core_info_free_current_core(core_info_state_t *p_coreinfo);
|
||||
@ -186,22 +166,20 @@ size_t core_info_count(void);
|
||||
bool core_info_list_update_missing_firmware(core_info_ctx_firmware_t *info,
|
||||
bool *set_missing_bios);
|
||||
|
||||
bool core_info_find(core_info_ctx_find_t *info);
|
||||
bool core_info_find(const char *core_path,
|
||||
core_info_t **core_info);
|
||||
|
||||
bool core_info_load(
|
||||
core_info_ctx_find_t *info,
|
||||
bool core_info_load(const char *core_path,
|
||||
core_info_state_t *p_coreinfo);
|
||||
|
||||
bool core_info_database_supports_content_path(const char *database_path, const char *path);
|
||||
|
||||
bool core_info_database_match_archive_member(const char *database_path);
|
||||
|
||||
bool core_info_unsupported_content_path(const char *path);
|
||||
|
||||
void core_info_qsort(core_info_list_t *core_info_list, enum core_info_list_qsort_type qsort_type);
|
||||
|
||||
bool core_info_list_get_info(core_info_list_t *core_info_list,
|
||||
core_info_t *out_info, const char *path);
|
||||
core_info_t *out_info, const char *core_path);
|
||||
|
||||
bool core_info_hw_api_supported(core_info_t *info);
|
||||
|
||||
@ -223,7 +201,7 @@ bool core_info_get_core_lock(const char *core_path, bool validate_path);
|
||||
|
||||
core_info_state_t *coreinfo_get_ptr(void);
|
||||
|
||||
bool core_info_core_file_id_is_equal(const char* core_path_a, const char* core_path_b);
|
||||
bool core_info_core_file_id_is_equal(const char *core_path_a, const char *core_path_b);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
@ -284,13 +284,13 @@ bool gfx_widget_start_load_content_animation(void)
|
||||
const char *content_path = path_get(RARCH_PATH_CONTENT);
|
||||
const char *core_path = path_get(RARCH_PATH_CORE);
|
||||
playlist_t *playlist = playlist_get_cached();
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
bool playlist_entry_found = false;
|
||||
bool has_content = false;
|
||||
bool has_system = false;
|
||||
bool has_db_name = false;
|
||||
|
||||
core_info_ctx_find_t core_info_finder;
|
||||
char icon_path[PATH_MAX_LENGTH];
|
||||
|
||||
icon_path[0] = '\0';
|
||||
@ -314,13 +314,10 @@ bool gfx_widget_start_load_content_animation(void)
|
||||
return false;
|
||||
|
||||
/* Check core validity */
|
||||
core_info_finder.inf = NULL;
|
||||
core_info_finder.path = core_path;
|
||||
|
||||
if (!core_info_find(&core_info_finder))
|
||||
if (!core_info_find(core_path, &core_info))
|
||||
return false;
|
||||
|
||||
core_path = core_info_finder.inf->path;
|
||||
core_path = core_info->path;
|
||||
|
||||
/* Parse content path
|
||||
* > If we have a cached playlist, attempt to find
|
||||
@ -357,10 +354,8 @@ bool gfx_widget_start_load_content_animation(void)
|
||||
|
||||
/* Check whether core matches... */
|
||||
if (string_is_empty(entry_core_file) ||
|
||||
!string_starts_with_size(
|
||||
entry_core_file,
|
||||
core_info_finder.inf->core_file_id.str,
|
||||
core_info_finder.inf->core_file_id.len))
|
||||
!string_starts_with(entry_core_file,
|
||||
core_info->core_file_id.str))
|
||||
entry = NULL;
|
||||
}
|
||||
}
|
||||
@ -430,8 +425,8 @@ bool gfx_widget_start_load_content_animation(void)
|
||||
if (!has_system)
|
||||
{
|
||||
/* Use core display name, if available */
|
||||
if (!string_is_empty(core_info_finder.inf->display_name))
|
||||
strlcpy(state->system_name, core_info_finder.inf->display_name,
|
||||
if (!string_is_empty(core_info->display_name))
|
||||
strlcpy(state->system_name, core_info->display_name,
|
||||
sizeof(state->system_name));
|
||||
/* Otherwise, just use 'RetroArch' as a fallback */
|
||||
else
|
||||
@ -466,7 +461,7 @@ bool gfx_widget_start_load_content_animation(void)
|
||||
{
|
||||
const char *core_db_name = NULL;
|
||||
struct string_list *databases_list =
|
||||
core_info_finder.inf->databases_list;
|
||||
core_info->databases_list;
|
||||
|
||||
/* We can only use the core db_name if the
|
||||
* core is associated with exactly one database */
|
||||
|
@ -451,19 +451,16 @@ static void menu_action_setting_disp_set_label_core_updater_entry(
|
||||
core_updater_list_get_filename(core_list, path, &entry) &&
|
||||
!string_is_empty(entry->local_core_path))
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
/* Check whether core is installed
|
||||
* > Note: We search core_info here instead
|
||||
* of calling path_is_valid() since we don't
|
||||
* want to perform disk access every frame */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = entry->local_core_path;
|
||||
|
||||
if (core_info_find(&core_info))
|
||||
if (core_info_find(entry->local_core_path, &core_info))
|
||||
{
|
||||
/* Highlight locked cores */
|
||||
if (core_info.inf->is_locked)
|
||||
if (core_info->is_locked)
|
||||
{
|
||||
s[0] = '[';
|
||||
s[1] = '#';
|
||||
@ -493,12 +490,12 @@ static void menu_action_setting_disp_set_label_core_manager_entry(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
const char *alt = list->list[i].alt
|
||||
? list->list[i].alt
|
||||
: list->list[i].path;
|
||||
*s = '\0';
|
||||
*w = 0;
|
||||
core_info_t *core_info = NULL;
|
||||
const char *alt = list->list[i].alt
|
||||
? list->list[i].alt
|
||||
: list->list[i].path;
|
||||
*s = '\0';
|
||||
*w = 0;
|
||||
|
||||
if (alt)
|
||||
strlcpy(s2, alt, len2);
|
||||
@ -507,11 +504,8 @@ static void menu_action_setting_disp_set_label_core_manager_entry(
|
||||
* > Note: We search core_info here instead of
|
||||
* calling core_info_get_core_lock() since we
|
||||
* don't want to perform disk access every frame */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = path;
|
||||
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->is_locked)
|
||||
if (core_info_find(path, &core_info) &&
|
||||
core_info->is_locked)
|
||||
{
|
||||
s[0] = '[';
|
||||
s[1] = '!';
|
||||
@ -529,12 +523,12 @@ static void menu_action_setting_disp_set_label_core_lock(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
const char *alt = list->list[i].alt
|
||||
? list->list[i].alt
|
||||
: list->list[i].path;
|
||||
*s = '\0';
|
||||
*w = 0;
|
||||
core_info_t *core_info = NULL;
|
||||
const char *alt = list->list[i].alt
|
||||
? list->list[i].alt
|
||||
: list->list[i].path;
|
||||
*s = '\0';
|
||||
*w = 0;
|
||||
|
||||
if (alt)
|
||||
strlcpy(s2, alt, len2);
|
||||
@ -543,11 +537,8 @@ static void menu_action_setting_disp_set_label_core_lock(
|
||||
* > Note: We search core_info here instead of
|
||||
* calling core_info_get_core_lock() since we
|
||||
* don't want to perform disk access every frame */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = path;
|
||||
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->is_locked)
|
||||
if (core_info_find(path, &core_info) &&
|
||||
core_info->is_locked)
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON), len);
|
||||
else
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF), len);
|
||||
|
@ -3556,44 +3556,36 @@ static int action_ok_path_manual_scan_directory(const char *path,
|
||||
static int action_ok_core_deferred_set(const char *new_core_path,
|
||||
const char *content_label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
char ext_name[255];
|
||||
char core_display_name[PATH_MAX_LENGTH];
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
struct playlist_entry entry = {0};
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
core_info_t *core_info = NULL;
|
||||
const char *core_display_name = NULL;
|
||||
char resolved_core_path[PATH_MAX_LENGTH];
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
struct playlist_entry entry = {0};
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *path_libretro_info = settings->paths.path_libretro_info;
|
||||
const char *path_dir_libretro = settings->paths.directory_libretro;
|
||||
bool show_hidden_files = settings->bools.show_hidden_files;
|
||||
|
||||
ext_name[0] = '\0';
|
||||
core_display_name[0] = '\0';
|
||||
resolved_core_path[0] = '\0';
|
||||
msg[0] = '\0';
|
||||
resolved_core_path[0] = '\0';
|
||||
msg[0] = '\0';
|
||||
|
||||
if (!menu)
|
||||
if (!menu ||
|
||||
string_is_empty(new_core_path))
|
||||
return menu_cbs_exit();
|
||||
|
||||
if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name)))
|
||||
return menu_cbs_exit();
|
||||
/* Get core display name */
|
||||
if (core_info_find(new_core_path, &core_info))
|
||||
core_display_name = core_info->display_name;
|
||||
|
||||
core_info_get_name(new_core_path,
|
||||
core_display_name, sizeof(core_display_name),
|
||||
path_libretro_info,
|
||||
path_dir_libretro,
|
||||
ext_name,
|
||||
show_hidden_files,
|
||||
true);
|
||||
if (string_is_empty(core_display_name))
|
||||
core_display_name = path_basename_nocompression(new_core_path);
|
||||
|
||||
/* Get 'real' core path */
|
||||
strlcpy(resolved_core_path, new_core_path, sizeof(resolved_core_path));
|
||||
playlist_resolve_path(PLAYLIST_SAVE, true, resolved_core_path, sizeof(resolved_core_path));
|
||||
|
||||
/* the update function reads our entry
|
||||
* as const, so these casts are safe */
|
||||
entry.core_path = (char*)resolved_core_path;
|
||||
entry.core_name = core_display_name;
|
||||
entry.core_name = (char*)core_display_name;
|
||||
|
||||
command_playlist_update_write(
|
||||
NULL,
|
||||
@ -5200,19 +5192,16 @@ static int action_ok_add_to_favorites(const char *path,
|
||||
{
|
||||
if (!string_is_empty(path_get(RARCH_PATH_CORE)))
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
/* >> core_path */
|
||||
strlcpy(core_path, path_get(RARCH_PATH_CORE), sizeof(core_path));
|
||||
|
||||
/* >> core_name
|
||||
* (always use display name, if available) */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
|
||||
if (core_info_find(&core_info))
|
||||
if (!string_is_empty(core_info.inf->display_name))
|
||||
strlcpy(core_name, core_info.inf->display_name,
|
||||
if (core_info_find(core_path, &core_info))
|
||||
if (!string_is_empty(core_info->display_name))
|
||||
strlcpy(core_name, core_info->display_name,
|
||||
sizeof(core_name));
|
||||
}
|
||||
|
||||
@ -5336,19 +5325,16 @@ static int action_ok_add_to_favorites_playlist(const char *path,
|
||||
/* > core_path + core_name */
|
||||
if (!string_is_empty(entry->core_path) && !string_is_empty(entry->core_name))
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
/* >> core_path */
|
||||
string_list_append(str_list, entry->core_path, attr);
|
||||
|
||||
/* >> core_name
|
||||
* (always use display name, if available) */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = entry->core_path;
|
||||
|
||||
if (core_info_find(&core_info))
|
||||
if (!string_is_empty(core_info.inf->display_name))
|
||||
strlcpy(core_display_name, core_info.inf->display_name, sizeof(core_display_name));
|
||||
if (core_info_find(entry->core_path, &core_info))
|
||||
if (!string_is_empty(core_info->display_name))
|
||||
strlcpy(core_display_name, core_info->display_name, sizeof(core_display_name));
|
||||
|
||||
if (!string_is_empty(core_display_name))
|
||||
string_list_append(str_list, core_display_name, attr);
|
||||
@ -7181,19 +7167,17 @@ int action_ok_core_lock(const char *path,
|
||||
if (!core_info_set_core_lock(core_path, lock))
|
||||
{
|
||||
const char *core_name = NULL;
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
|
||||
msg[0] = '\0';
|
||||
|
||||
/* Need to fetch core name for error message */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
|
||||
/* If core is found, use display name */
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->display_name)
|
||||
core_name = core_info.inf->display_name;
|
||||
if (core_info_find(core_path, &core_info) &&
|
||||
core_info->display_name)
|
||||
core_name = core_info->display_name;
|
||||
/* If not, use core file name */
|
||||
else
|
||||
core_name = path_basename_nocompression(core_path);
|
||||
@ -7240,20 +7224,18 @@ static int action_ok_core_delete(const char *path,
|
||||
/* Check whether core is locked */
|
||||
if (core_info_get_core_lock(core_path, true))
|
||||
{
|
||||
const char *core_name = NULL;
|
||||
core_info_ctx_find_t core_info;
|
||||
const char *core_name = NULL;
|
||||
core_info_t *core_info = NULL;
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
|
||||
msg[0] = '\0';
|
||||
|
||||
/* Need to fetch core name for notification */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
|
||||
/* If core is found, use display name */
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->display_name)
|
||||
core_name = core_info.inf->display_name;
|
||||
if (core_info_find(core_path, &core_info) &&
|
||||
core_info->display_name)
|
||||
core_name = core_info->display_name;
|
||||
/* If not, use core file name */
|
||||
else
|
||||
core_name = path_basename_nocompression(core_path);
|
||||
|
@ -571,20 +571,18 @@ static int action_start_core_lock(
|
||||
/* ...Otherwise, attempt to unlock it */
|
||||
if (!core_info_set_core_lock(core_path, false))
|
||||
{
|
||||
const char *core_name = NULL;
|
||||
core_info_ctx_find_t core_info;
|
||||
const char *core_name = NULL;
|
||||
core_info_t *core_info = NULL;
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
|
||||
msg[0] = '\0';
|
||||
|
||||
/* Need to fetch core name for error message */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
|
||||
/* If core is found, use display name */
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->display_name)
|
||||
core_name = core_info.inf->display_name;
|
||||
if (core_info_find(core_path, &core_info) &&
|
||||
core_info->display_name)
|
||||
core_name = core_info->display_name;
|
||||
/* If not, use core file name */
|
||||
else
|
||||
core_name = path_basename(core_path);
|
||||
|
@ -65,25 +65,23 @@
|
||||
|
||||
static int menu_action_sublabel_file_browser_core(file_list_t *list, unsigned type, unsigned i, const char *label, const char *path, char *s, size_t len)
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
/* Set sublabel prefix */
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len);
|
||||
strlcat(s, ": ", len);
|
||||
|
||||
/* Search for specified core */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = path;
|
||||
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->licenses_list)
|
||||
if (core_info_find(path, &core_info) &&
|
||||
core_info->licenses_list)
|
||||
{
|
||||
char tmp[MENU_SUBLABEL_MAX_LENGTH];
|
||||
tmp[0] = '\0';
|
||||
|
||||
/* Add license text */
|
||||
string_list_join_concat(tmp, sizeof(tmp),
|
||||
core_info.inf->licenses_list, ", ");
|
||||
core_info->licenses_list, ", ");
|
||||
strlcat(s, tmp, len);
|
||||
return 1;
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ static int action_get_title_deferred_playlist_list(const char *path, const char
|
||||
static int action_get_title_deferred_core_backup_list(
|
||||
const char *core_path, const char *prefix, char *s, size_t len)
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
if (string_is_empty(core_path) || string_is_empty(prefix))
|
||||
return 0;
|
||||
@ -417,17 +417,14 @@ static int action_get_title_deferred_core_backup_list(
|
||||
strlcpy(s, prefix, len);
|
||||
strlcat(s, ": ", len);
|
||||
|
||||
/* Search for specified core */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
|
||||
/* If core is found, add display name */
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->display_name)
|
||||
strlcat(s, core_info.inf->display_name, len);
|
||||
/* Search for specified core
|
||||
* > If core is found, add display name */
|
||||
if (core_info_find(core_path, &core_info) &&
|
||||
core_info->display_name)
|
||||
strlcat(s, core_info->display_name, len);
|
||||
else
|
||||
{
|
||||
/* If not, use core file name */
|
||||
/* > If not, use core file name */
|
||||
const char *core_filename = path_basename_nocompression(core_path);
|
||||
|
||||
if (!string_is_empty(core_filename))
|
||||
@ -463,19 +460,15 @@ static int action_get_core_information_list(
|
||||
if ((menu_type == FILE_TYPE_DOWNLOAD_CORE) ||
|
||||
(menu_type == MENU_SETTING_ACTION_CORE_MANAGER_OPTIONS))
|
||||
{
|
||||
const char *core_path = path;
|
||||
core_info_ctx_find_t core_info_finder;
|
||||
core_info_t *core_info_menu = NULL;
|
||||
|
||||
if (string_is_empty(core_path))
|
||||
if (string_is_empty(path))
|
||||
goto error;
|
||||
|
||||
/* Core updater/manager entry - search for
|
||||
* corresponding core info */
|
||||
core_info_finder.inf = NULL;
|
||||
core_info_finder.path = core_path;
|
||||
|
||||
if (core_info_find(&core_info_finder))
|
||||
core_info = core_info_finder.inf;
|
||||
if (core_info_find(path, &core_info_menu))
|
||||
core_info = core_info_menu;
|
||||
}
|
||||
else
|
||||
core_info_get_current_core(&core_info);
|
||||
|
@ -9066,7 +9066,7 @@ static int materialui_list_push(void *data, void *userdata,
|
||||
MENU_SETTING_ACTION_FAVORITES_DIR, 0, 0);
|
||||
|
||||
core_info_get_list(&list);
|
||||
if (core_info_list_num_info_files(list))
|
||||
if (list->info_count > 0)
|
||||
{
|
||||
menu_entries_append_enum(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DOWNLOADED_FILE_DETECT_CORE_LIST),
|
||||
|
@ -1456,7 +1456,7 @@ static int ozone_list_push(void *data, void *userdata,
|
||||
MENU_SETTING_ACTION_FAVORITES_DIR, 0, 0);
|
||||
|
||||
core_info_get_list(&list);
|
||||
if (core_info_list_num_info_files(list))
|
||||
if (list->info_count > 0)
|
||||
{
|
||||
menu_entries_append_enum(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DOWNLOADED_FILE_DETECT_CORE_LIST),
|
||||
|
@ -4144,7 +4144,7 @@ static int stripes_list_push(void *data, void *userdata,
|
||||
MENU_SETTING_ACTION_FAVORITES_DIR, 0, 0);
|
||||
|
||||
core_info_get_list(&list);
|
||||
if (core_info_list_num_info_files(list))
|
||||
if (list->info_count > 0)
|
||||
{
|
||||
menu_entries_append_enum(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DOWNLOADED_FILE_DETECT_CORE_LIST),
|
||||
|
@ -6799,7 +6799,7 @@ static int xmb_list_push(void *data, void *userdata,
|
||||
MENU_SETTING_ACTION_FAVORITES_DIR, 0, 0);
|
||||
|
||||
core_info_get_list(&list);
|
||||
if (core_info_list_num_info_files(list))
|
||||
if (list->info_count > 0)
|
||||
menu_entries_append_enum(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DOWNLOADED_FILE_DETECT_CORE_LIST),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST),
|
||||
|
@ -471,22 +471,19 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info,
|
||||
if ((info->type == FILE_TYPE_DOWNLOAD_CORE) ||
|
||||
(info->type == MENU_SETTING_ACTION_CORE_MANAGER_OPTIONS))
|
||||
{
|
||||
core_info_ctx_find_t core_info_finder;
|
||||
core_info_t *core_info_menu = NULL;
|
||||
|
||||
core_path = info->path;
|
||||
|
||||
/* Core updater entry - search for corresponding
|
||||
* core info */
|
||||
core_info_finder.inf = NULL;
|
||||
core_info_finder.path = core_path;
|
||||
|
||||
if (core_info_find(&core_info_finder))
|
||||
core_info = core_info_finder.inf;
|
||||
if (core_info_find(core_path, &core_info_menu))
|
||||
core_info = core_info_menu;
|
||||
}
|
||||
else if (core_info_get_current_core(&core_info) && core_info)
|
||||
core_path = core_info->path;
|
||||
|
||||
if (!core_info || !core_info->config_data)
|
||||
if (!core_info || !core_info->has_info)
|
||||
{
|
||||
if (menu_entries_append_enum(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE_INFORMATION_AVAILABLE),
|
||||
@ -3074,7 +3071,7 @@ static unsigned menu_displaylist_parse_information_list(file_list_t *info_list)
|
||||
!string_is_equal(system->library_name,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE))
|
||||
)
|
||||
&& core_info && core_info->config_data
|
||||
&& core_info && core_info->has_info
|
||||
)
|
||||
if (menu_entries_append_enum(info_list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFORMATION),
|
||||
@ -3843,18 +3840,15 @@ static unsigned menu_displaylist_parse_content_information(
|
||||
}
|
||||
else
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
/* No playlist - just extract what we can... */
|
||||
content_path = loaded_content_path;
|
||||
core_path = loaded_core_path;
|
||||
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
|
||||
if (core_info_find(&core_info))
|
||||
if (!string_is_empty(core_info.inf->display_name))
|
||||
strlcpy(core_name, core_info.inf->display_name, sizeof(core_name));
|
||||
if (core_info_find(core_path, &core_info))
|
||||
if (!string_is_empty(core_info->display_name))
|
||||
strlcpy(core_name, core_info->display_name, sizeof(core_name));
|
||||
}
|
||||
|
||||
/* Content label */
|
||||
@ -6031,7 +6025,7 @@ unsigned menu_displaylist_build_list(
|
||||
{
|
||||
core_info_list_t *info_list = NULL;
|
||||
core_info_get_list(&info_list);
|
||||
if (core_info_list_num_info_files(info_list))
|
||||
if (info_list->info_count > 0)
|
||||
{
|
||||
if (menu_entries_append_enum(list,
|
||||
msg_hash_to_str(
|
||||
|
18
playlist.c
18
playlist.c
@ -2866,17 +2866,14 @@ bool playlist_entry_has_core(const struct playlist_entry *entry)
|
||||
* core association */
|
||||
core_info_t *playlist_entry_get_core_info(const struct playlist_entry* entry)
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
if (!playlist_entry_has_core(entry))
|
||||
return NULL;
|
||||
|
||||
/* Search for associated core */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = entry->core_path;
|
||||
|
||||
if (core_info_find(&core_info))
|
||||
return core_info.inf;
|
||||
if (core_info_find(entry->core_path, &core_info))
|
||||
return core_info;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -2888,7 +2885,7 @@ core_info_t *playlist_entry_get_core_info(const struct playlist_entry* entry)
|
||||
* default core association */
|
||||
core_info_t *playlist_get_default_core_info(playlist_t* playlist)
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
if (!playlist ||
|
||||
string_is_empty(playlist->default_core_path) ||
|
||||
@ -2898,11 +2895,8 @@ core_info_t *playlist_get_default_core_info(playlist_t* playlist)
|
||||
return NULL;
|
||||
|
||||
/* Search for associated core */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = playlist->default_core_path;
|
||||
|
||||
if (core_info_find(&core_info))
|
||||
return core_info.inf;
|
||||
if (core_info_find(playlist->default_core_path, &core_info))
|
||||
return core_info;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
18
retroarch.c
18
retroarch.c
@ -1986,17 +1986,15 @@ static int generic_menu_iterate(
|
||||
#endif
|
||||
case MENU_ENUM_LABEL_CORE_MANAGER_ENTRY:
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
const char *path = selection_buf->list[selection].path;
|
||||
/* Search for specified core */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = path;
|
||||
core_info_t *core_info = NULL;
|
||||
const char *path = selection_buf->list[selection].path;
|
||||
|
||||
/* Search for specified core */
|
||||
if ( path
|
||||
&& core_info_find(&core_info)
|
||||
&& !string_is_empty(core_info.inf->description))
|
||||
&& core_info_find(path, &core_info)
|
||||
&& !string_is_empty(core_info->description))
|
||||
strlcpy(menu->menu_state_msg,
|
||||
core_info.inf->description,
|
||||
core_info->description,
|
||||
sizeof(menu->menu_state_msg));
|
||||
else
|
||||
strlcpy(menu->menu_state_msg,
|
||||
@ -13618,7 +13616,6 @@ bool command_event(enum event_command cmd, void *data)
|
||||
break;
|
||||
case CMD_EVENT_LOAD_CORE_PERSIST:
|
||||
{
|
||||
core_info_ctx_find_t info_find;
|
||||
rarch_system_info_t *system_info = &p_rarch->runloop_system;
|
||||
struct retro_system_info *system = &system_info->info;
|
||||
const char *core_path = path_get(RARCH_PATH_CORE);
|
||||
@ -13634,9 +13631,8 @@ bool command_event(enum event_command cmd, void *data)
|
||||
system,
|
||||
&system_info->load_no_content))
|
||||
return false;
|
||||
info_find.path = core_path;
|
||||
|
||||
if (!core_info_load(&info_find, &p_rarch->core_info_st))
|
||||
if (!core_info_load(core_path, &p_rarch->core_info_st))
|
||||
{
|
||||
#ifdef HAVE_DYNAMIC
|
||||
return false;
|
||||
|
@ -238,7 +238,7 @@ runtime_log_t *runtime_log_init(
|
||||
char log_file_dir[PATH_MAX_LENGTH];
|
||||
char log_file_path[PATH_MAX_LENGTH];
|
||||
char tmp_buf[PATH_MAX_LENGTH];
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
runtime_log_t *runtime_log = NULL;
|
||||
|
||||
content_name[0] = '\0';
|
||||
@ -266,12 +266,9 @@ runtime_log_t *runtime_log_init(
|
||||
* we are performing aggregate (not per core) logging,
|
||||
* since content name is sometimes dependent upon core
|
||||
* (e.g. see TyrQuake below) */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->core_name)
|
||||
strlcpy(core_name, core_info.inf->core_name, sizeof(core_name));
|
||||
if (core_info_find(core_path, &core_info) &&
|
||||
core_info->core_name)
|
||||
strlcpy(core_name, core_info->core_name, sizeof(core_name));
|
||||
|
||||
if (string_is_empty(core_name))
|
||||
return NULL;
|
||||
|
@ -556,15 +556,12 @@ void *task_push_core_backup(
|
||||
core_name = core_display_name;
|
||||
else
|
||||
{
|
||||
core_info_ctx_find_t core_info;
|
||||
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
/* If core is found, use display name */
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->display_name)
|
||||
core_name = core_info.inf->display_name;
|
||||
if (core_info_find(core_path, &core_info) &&
|
||||
core_info->display_name)
|
||||
core_name = core_info->display_name;
|
||||
else
|
||||
{
|
||||
/* If not, use core file name */
|
||||
@ -926,8 +923,8 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
|
||||
bool *core_loaded)
|
||||
{
|
||||
task_finder_data_t find_data;
|
||||
core_info_ctx_find_t core_info;
|
||||
enum core_backup_type backup_type;
|
||||
core_info_t *core_info = NULL;
|
||||
const char *core_name = NULL;
|
||||
retro_task_t *task = NULL;
|
||||
core_backup_handle_t *backup_handle = NULL;
|
||||
@ -974,17 +971,14 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Get core name */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
|
||||
/* If core is found, use display name */
|
||||
if (core_info_find(&core_info) &&
|
||||
core_info.inf->display_name)
|
||||
core_name = core_info.inf->display_name;
|
||||
/* Get core name
|
||||
* > If core is found, use display name */
|
||||
if (core_info_find(core_path, &core_info) &&
|
||||
core_info->display_name)
|
||||
core_name = core_info->display_name;
|
||||
else
|
||||
{
|
||||
/* If not, use core file name */
|
||||
/* > If not, use core file name */
|
||||
core_name = path_basename(core_path);
|
||||
|
||||
if (string_is_empty(core_name))
|
||||
|
@ -474,17 +474,14 @@ static void pl_manager_validate_core_association(
|
||||
else
|
||||
{
|
||||
char core_display_name[PATH_MAX_LENGTH];
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *core_info = NULL;
|
||||
|
||||
core_display_name[0] = '\0';
|
||||
|
||||
/* Search core info */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = core_path;
|
||||
|
||||
if (core_info_find(&core_info) &&
|
||||
!string_is_empty(core_info.inf->display_name))
|
||||
strlcpy(core_display_name, core_info.inf->display_name,
|
||||
if (core_info_find(core_path, &core_info) &&
|
||||
!string_is_empty(core_info->display_name))
|
||||
strlcpy(core_display_name, core_info->display_name,
|
||||
sizeof(core_display_name));
|
||||
|
||||
/* If core_display_name string is empty, it means the
|
||||
|
@ -981,7 +981,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||
|
||||
if (!specialPlaylist && selectedAction->parent() == associateMenu.data())
|
||||
{
|
||||
core_info_ctx_find_t coreInfo;
|
||||
core_info_t *coreInfo = NULL;
|
||||
playlist_t *cachedPlaylist = playlist_get_cached();
|
||||
playlist_t *playlist = NULL;
|
||||
bool loadPlaylist = true;
|
||||
@ -1010,14 +1010,11 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||
if (playlist)
|
||||
{
|
||||
/* Get core info */
|
||||
coreInfo.inf = NULL;
|
||||
coreInfo.path = corePath;
|
||||
|
||||
if (core_info_find(&coreInfo))
|
||||
if (core_info_find(corePath, &coreInfo))
|
||||
{
|
||||
/* Set new core association */
|
||||
playlist_set_default_core_path(playlist, coreInfo.inf->path);
|
||||
playlist_set_default_core_name(playlist, coreInfo.inf->display_name);
|
||||
playlist_set_default_core_path(playlist, coreInfo->path);
|
||||
playlist_set_default_core_name(playlist, coreInfo->display_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2308,22 +2308,17 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
|
||||
{
|
||||
unsigned i;
|
||||
QVector<QHash<QString, QString> > infoList;
|
||||
core_info_ctx_find_t core_info_finder;
|
||||
QHash<QString, QString> currentCore = getSelectedCore();
|
||||
const core_info_t *core_info = NULL;
|
||||
core_info_t *core_info = NULL;
|
||||
QByteArray currentCorePathArray = currentCore["core_path"].toUtf8();
|
||||
const char *current_core_path_data = currentCorePathArray.constData();
|
||||
|
||||
/* Search for current core */
|
||||
core_info_finder.inf = NULL;
|
||||
core_info_finder.path = current_core_path_data;
|
||||
|
||||
if (core_info_find(&core_info_finder))
|
||||
core_info = core_info_finder.inf;
|
||||
core_info_find(current_core_path_data, &core_info);
|
||||
|
||||
if ( currentCore["core_path"].isEmpty()
|
||||
|| !core_info
|
||||
|| !core_info->config_data)
|
||||
|| !core_info->has_info)
|
||||
{
|
||||
QHash<QString, QString> hash;
|
||||
|
||||
@ -2780,7 +2775,7 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
|
||||
const char *contentCrc32 = NULL;
|
||||
QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value<QVariantMap>();
|
||||
core_selection coreSelection = static_cast<core_selection>(coreMap.value("core_selection").toInt());
|
||||
core_info_ctx_find_t core_info;
|
||||
core_info_t *coreInfo = NULL;
|
||||
|
||||
contentDbNameFull[0] = '\0';
|
||||
|
||||
@ -2876,12 +2871,9 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
|
||||
|
||||
/* Search for specified core - ensures path
|
||||
* is 'sanitised' */
|
||||
core_info.inf = NULL;
|
||||
core_info.path = corePath;
|
||||
|
||||
if (core_info_find(&core_info) &&
|
||||
!string_is_empty(core_info.inf->path))
|
||||
corePath = core_info.inf->path;
|
||||
if (core_info_find(corePath, &coreInfo) &&
|
||||
!string_is_empty(coreInfo->path))
|
||||
corePath = coreInfo->path;
|
||||
|
||||
/* Add lpl extension to db_name, if required */
|
||||
if (!string_is_empty(contentDbName))
|
||||
@ -3056,7 +3048,6 @@ void MainWindow::setCoreActions()
|
||||
if (!defaultCorePath.isEmpty())
|
||||
{
|
||||
QString currentPlaylistItemDataString;
|
||||
core_info_ctx_find_t core_info_finder;
|
||||
bool allPlaylists = false;
|
||||
int row = 0;
|
||||
QByteArray defaultCorePathArray = defaultCorePath.toUtf8();
|
||||
@ -3071,6 +3062,8 @@ void MainWindow::setCoreActions()
|
||||
|
||||
for (row = 0; row < m_listWidget->count(); row++)
|
||||
{
|
||||
core_info_t *coreInfo = NULL;
|
||||
|
||||
if (allPlaylists)
|
||||
{
|
||||
QFileInfo info;
|
||||
@ -3084,14 +3077,9 @@ void MainWindow::setCoreActions()
|
||||
}
|
||||
|
||||
/* Search for default core */
|
||||
core_info_finder.inf = NULL;
|
||||
core_info_finder.path = default_core_path_data;
|
||||
|
||||
if (core_info_find(&core_info_finder))
|
||||
if (core_info_find(default_core_path_data, &coreInfo))
|
||||
{
|
||||
const core_info_t *info = core_info_finder.inf;
|
||||
|
||||
if (m_launchWithComboBox->findText(info->core_name) == -1)
|
||||
if (m_launchWithComboBox->findText(coreInfo->core_name) == -1)
|
||||
{
|
||||
int i = 0;
|
||||
bool found_existing = false;
|
||||
@ -3106,9 +3094,9 @@ void MainWindow::setCoreActions()
|
||||
const char *core_path_data = CorePathArray.constData();
|
||||
|
||||
if (string_starts_with(path_basename(core_path_data),
|
||||
info->core_file_id.str) ||
|
||||
map.value("core_name").toString() == info->core_name ||
|
||||
map.value("core_name").toString() == info->display_name)
|
||||
coreInfo->core_file_id.str) ||
|
||||
map.value("core_name").toString() == coreInfo->core_name ||
|
||||
map.value("core_name").toString() == coreInfo->display_name)
|
||||
{
|
||||
found_existing = true;
|
||||
break;
|
||||
@ -3118,10 +3106,10 @@ void MainWindow::setCoreActions()
|
||||
if (!found_existing)
|
||||
{
|
||||
QVariantMap comboBoxMap;
|
||||
comboBoxMap["core_name"] = info->core_name;
|
||||
comboBoxMap["core_path"] = info->path;
|
||||
comboBoxMap["core_name"] = coreInfo->core_name;
|
||||
comboBoxMap["core_path"] = coreInfo->path;
|
||||
comboBoxMap["core_selection"] = CORE_SELECTION_PLAYLIST_DEFAULT;
|
||||
m_launchWithComboBox->addItem(info->core_name, QVariant::fromValue(comboBoxMap));
|
||||
m_launchWithComboBox->addItem(coreInfo->core_name, QVariant::fromValue(comboBoxMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user