mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Create menu_hash_calculate
This commit is contained in:
parent
bd7b6c1acf
commit
897361b9d4
@ -15,8 +15,6 @@
|
||||
|
||||
#include <file/file_path.h>
|
||||
|
||||
#include <rhash.h>
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_hash.h"
|
||||
#include "../menu_displaylist.h"
|
||||
@ -644,7 +642,7 @@ int menu_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
|
||||
|
||||
if (setting)
|
||||
{
|
||||
uint32_t parent_group_hash = djb2_calculate(setting->parent_group);
|
||||
uint32_t parent_group_hash = menu_hash_calculate(setting->parent_group);
|
||||
|
||||
if ((parent_group_hash == MENU_VALUE_MAIN_MENU) && setting->type == ST_GROUP)
|
||||
{
|
||||
|
@ -14,11 +14,11 @@
|
||||
*/
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_cbs.h"
|
||||
#include "../menu_shader.h"
|
||||
#include "../menu_hash.h"
|
||||
|
||||
#include "../../general.h"
|
||||
#include "../../performance.h"
|
||||
@ -764,7 +764,7 @@ static void menu_action_setting_disp_set_label(file_list_t* list,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
uint32_t hash_label = djb2_calculate(label);
|
||||
uint32_t hash_label = menu_hash_calculate(label);
|
||||
|
||||
*s = '\0';
|
||||
*w = 19;
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include <compat/strl.h>
|
||||
#include <file/file_path.h>
|
||||
#include <rhash.h>
|
||||
#include <retro_inline.h>
|
||||
|
||||
#include "../menu.h"
|
||||
@ -502,7 +501,7 @@ static int action_iterate_main(const char *label, unsigned action)
|
||||
menu_navigation_t *nav = menu_navigation_get_ptr();
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
uint32_t hash = djb2_calculate(label);
|
||||
uint32_t hash = menu_hash_calculate(label);
|
||||
if (!menu || !menu_list)
|
||||
return 0;
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_hash.h"
|
||||
@ -348,7 +347,7 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs,
|
||||
|
||||
if (setting)
|
||||
{
|
||||
uint32_t parent_group_hash = djb2_calculate(setting->parent_group);
|
||||
uint32_t parent_group_hash = menu_hash_calculate(setting->parent_group);
|
||||
|
||||
if ((parent_group_hash == MENU_VALUE_MAIN_MENU) && (setting->type == ST_GROUP))
|
||||
{
|
||||
@ -365,7 +364,7 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs,
|
||||
label_setting[0] = '\0';
|
||||
snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1);
|
||||
|
||||
label_setting_hash = djb2_calculate(label_setting);
|
||||
label_setting_hash = menu_hash_calculate(label_setting);
|
||||
|
||||
if (label_hash != label_setting_hash)
|
||||
continue;
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_display.h"
|
||||
@ -122,7 +121,7 @@ static int action_ok_file_load_with_detect_core_carchive(
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
menu_displaylist_info_t info = {0};
|
||||
uint32_t hash_label = djb2_calculate(label);
|
||||
uint32_t hash_label = menu_hash_calculate(label);
|
||||
|
||||
strlcat(detect_content_path, "#", sizeof(detect_content_path));
|
||||
strlcat(detect_content_path, path, sizeof(detect_content_path));
|
||||
@ -134,7 +133,7 @@ static int action_ok_file_load_with_detect_core(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
menu_displaylist_info_t info = {0};
|
||||
uint32_t hash_label = djb2_calculate(label);
|
||||
uint32_t hash_label = menu_hash_calculate(label);
|
||||
|
||||
return rarch_defer_core_wrapper(&info, idx, entry_idx, path, hash_label, false);
|
||||
}
|
||||
@ -164,7 +163,7 @@ static int action_ok_playlist_entry(const char *path,
|
||||
size_t selection_ptr = 0;
|
||||
content_playlist_t *playlist = g_defaults.history;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
uint32_t hash_label = djb2_calculate(label);
|
||||
uint32_t hash_label = menu_hash_calculate(label);
|
||||
|
||||
if (!menu)
|
||||
return -1;
|
||||
@ -202,8 +201,8 @@ static int action_ok_playlist_entry(const char *path,
|
||||
core_path, core_name, selection_ptr);
|
||||
#endif
|
||||
|
||||
core_path_hash = core_path ? djb2_calculate(core_path) : 0;
|
||||
core_name_hash = core_name ? djb2_calculate(core_name) : 0;
|
||||
core_path_hash = core_path ? menu_hash_calculate(core_path) : 0;
|
||||
core_name_hash = core_name ? menu_hash_calculate(core_name) : 0;
|
||||
|
||||
if (
|
||||
(core_path_hash == MENU_VALUE_DETECT) &&
|
||||
@ -1490,7 +1489,7 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
|
||||
const char *label, uint32_t hash, const char *elem0)
|
||||
{
|
||||
rarch_setting_t *setting = menu_setting_find(label);
|
||||
uint32_t elem0_hash = djb2_calculate(elem0);
|
||||
uint32_t elem0_hash = menu_hash_calculate(elem0);
|
||||
|
||||
if (elem0[0] != '\0' && (is_rdb_entry(elem0_hash) == 0))
|
||||
{
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_hash.h"
|
||||
@ -418,7 +417,7 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs,
|
||||
|
||||
if (setting)
|
||||
{
|
||||
uint32_t parent_group_hash = djb2_calculate(setting->parent_group);
|
||||
uint32_t parent_group_hash = menu_hash_calculate(setting->parent_group);
|
||||
|
||||
if ((parent_group_hash == MENU_LABEL_SETTINGS) && (setting->type == ST_GROUP))
|
||||
{
|
||||
@ -435,7 +434,7 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs,
|
||||
label_setting[0] = '\0';
|
||||
snprintf(label_setting, sizeof(label_setting), "input_player%d_joypad_index", i + 1);
|
||||
|
||||
label_setting_hash = djb2_calculate(label_setting);
|
||||
label_setting_hash = menu_hash_calculate(label_setting);
|
||||
|
||||
if (label_hash != label_setting_hash)
|
||||
continue;
|
||||
|
@ -17,8 +17,6 @@
|
||||
#include <string/stdstring.h>
|
||||
#include <file/file_path.h>
|
||||
|
||||
#include <rhash.h>
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_hash.h"
|
||||
|
||||
@ -521,7 +519,7 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs,
|
||||
|
||||
if (setting)
|
||||
{
|
||||
uint32_t parent_group_hash = djb2_calculate(setting->parent_group);
|
||||
uint32_t parent_group_hash = menu_hash_calculate(setting->parent_group);
|
||||
|
||||
if ((parent_group_hash == MENU_VALUE_MAIN_MENU) && setting->type == ST_GROUP)
|
||||
{
|
||||
|
@ -24,13 +24,13 @@
|
||||
#include <compat/posix_string.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <string/string_list.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_driver.h"
|
||||
#include "../menu_entry.h"
|
||||
#include "../menu_animation.h"
|
||||
#include "../menu_display.h"
|
||||
#include "../menu_hash.h"
|
||||
|
||||
#include "../menu_cbs.h"
|
||||
|
||||
@ -1073,8 +1073,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
|
||||
|
||||
menu_entry_get(&entry, i, list, true);
|
||||
|
||||
hash_label = djb2_calculate(entry.label);
|
||||
hash_value = djb2_calculate(entry.value);
|
||||
hash_label = menu_hash_calculate(entry.label);
|
||||
hash_value = menu_hash_calculate(entry.value);
|
||||
|
||||
if (entry.type == MENU_FILE_CONTENTLIST_ENTRY)
|
||||
strlcpy(entry.path, path_basename(entry.path), sizeof(entry.path));
|
||||
|
@ -15,9 +15,9 @@
|
||||
|
||||
#include <compat/strl.h>
|
||||
#include <string/string_list.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_hash.h"
|
||||
#include "menu_cbs.h"
|
||||
|
||||
#if 0
|
||||
@ -88,8 +88,8 @@ void menu_cbs_init(void *data,
|
||||
str_list = NULL;
|
||||
}
|
||||
|
||||
label_hash = djb2_calculate(label);
|
||||
menu_label_hash = djb2_calculate(menu_label);
|
||||
label_hash = menu_hash_calculate(label);
|
||||
menu_label_hash = menu_hash_calculate(menu_label);
|
||||
|
||||
ret = menu_cbs_init_bind_ok(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash);
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <file/file_path.h>
|
||||
#include <file/file_extract.h>
|
||||
#include <file/dir_list.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_hash.h"
|
||||
@ -634,7 +633,7 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
|
||||
&path, &label, NULL, &core_name, &crc32, &db_name);
|
||||
strlcpy(fill_buf, core_name, sizeof(fill_buf));
|
||||
|
||||
core_name_hash = core_name ? djb2_calculate(core_name) : 0;
|
||||
core_name_hash = core_name ? menu_hash_calculate(core_name) : 0;
|
||||
|
||||
if (path)
|
||||
{
|
||||
@ -880,7 +879,7 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
|
||||
if (tmp_str_list->size > 1)
|
||||
strlcpy(elem1, tmp_str_list->elems[1].data, sizeof(elem1));
|
||||
|
||||
hash_value = djb2_calculate(elem1);
|
||||
hash_value = menu_hash_calculate(elem1);
|
||||
|
||||
switch (hash_value)
|
||||
{
|
||||
@ -905,8 +904,8 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
|
||||
|
||||
rdb_entry_start_game_selection_ptr = j;
|
||||
|
||||
core_name_hash = djb2_calculate(playlist->entries[j].core_name);
|
||||
core_path_hash = djb2_calculate(playlist->entries[j].core_path);
|
||||
core_name_hash = menu_hash_calculate(playlist->entries[j].core_name);
|
||||
core_path_hash = menu_hash_calculate(playlist->entries[j].core_path);
|
||||
|
||||
if (
|
||||
(core_name_hash != MENU_VALUE_DETECT) &&
|
||||
@ -1479,7 +1478,7 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool *n
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
uint32_t hash_label = djb2_calculate(info->label);
|
||||
uint32_t hash_label = menu_hash_calculate(info->label);
|
||||
|
||||
(void)device;
|
||||
|
||||
@ -2058,7 +2057,7 @@ int menu_displaylist_push(file_list_t *list, file_list_t *menu_list)
|
||||
strlcpy(info.path, path, sizeof(info.path));
|
||||
strlcpy(info.label, label, sizeof(info.label));
|
||||
|
||||
hash_label = djb2_calculate(label);
|
||||
hash_label = menu_hash_calculate(label);
|
||||
|
||||
if (!info.list)
|
||||
return -1;
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "menu_hash.h"
|
||||
|
||||
@ -78,3 +79,8 @@ const char *menu_hash_to_str(uint32_t hash)
|
||||
|
||||
return "null";
|
||||
}
|
||||
|
||||
uint32_t menu_hash_calculate(const char *s)
|
||||
{
|
||||
return djb2_calculate(s);
|
||||
}
|
||||
|
@ -372,6 +372,8 @@ extern "C" {
|
||||
|
||||
const char *menu_hash_to_str(uint32_t hash);
|
||||
|
||||
uint32_t menu_hash_calculate(const char *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <rhash.h>
|
||||
|
||||
#include "menu_input.h"
|
||||
#include "menu.h"
|
||||
#include "menu_display.h"
|
||||
@ -152,7 +150,7 @@ void menu_input_st_string_callback(void *userdata, const char *str)
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t hash_label = djb2_calculate(menu_input->keyboard.label_setting);
|
||||
uint32_t hash_label = menu_hash_calculate(menu_input->keyboard.label_setting);
|
||||
|
||||
switch (hash_label)
|
||||
{
|
||||
|
@ -17,10 +17,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "../driver.h"
|
||||
#include "menu.h"
|
||||
#include "menu_hash.h"
|
||||
#include "menu_list.h"
|
||||
#include "menu_navigation.h"
|
||||
|
||||
@ -304,15 +304,15 @@ void menu_list_pop_stack_by_needle(menu_list_t *list,
|
||||
|
||||
menu_entries_set_refresh();
|
||||
menu_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
|
||||
needle_hash = djb2_calculate(needle);
|
||||
label_hash = djb2_calculate(label);
|
||||
needle_hash = menu_hash_calculate(needle);
|
||||
label_hash = menu_hash_calculate(label);
|
||||
|
||||
while (needle_hash == label_hash)
|
||||
{
|
||||
menu_list_pop(list->menu_stack, &nav->selection_ptr);
|
||||
menu_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
|
||||
label_hash = djb2_calculate(label);
|
||||
needle_hash = djb2_calculate(needle);
|
||||
label_hash = menu_hash_calculate(label);
|
||||
needle_hash = menu_hash_calculate(needle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <file/config_file.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_input.h"
|
||||
@ -64,7 +63,7 @@ static bool menu_settings_list_append(rarch_setting_t **list,
|
||||
return false;
|
||||
}
|
||||
|
||||
value.name_hash = value.name ? djb2_calculate(value.name) : 0;
|
||||
value.name_hash = value.name ? menu_hash_calculate(value.name) : 0;
|
||||
|
||||
(*list)[list_info->index++] = value;
|
||||
return true;
|
||||
@ -318,7 +317,7 @@ rarch_setting_t *menu_setting_find(const char *label)
|
||||
if (!label)
|
||||
return NULL;
|
||||
|
||||
needle = djb2_calculate(label);
|
||||
needle = menu_hash_calculate(label);
|
||||
|
||||
for (; settings->type != ST_NONE; settings++)
|
||||
{
|
||||
@ -539,7 +538,7 @@ int setting_set_with_string_representation(rarch_setting_t* setting,
|
||||
strlcpy(setting->value.string, value, setting->size);
|
||||
break;
|
||||
case ST_BOOL:
|
||||
value_hash = djb2_calculate(value);
|
||||
value_hash = menu_hash_calculate(value);
|
||||
|
||||
switch (value_hash)
|
||||
{
|
||||
@ -2110,7 +2109,7 @@ static int setting_get_description_compare_label(uint32_t label_hash,
|
||||
switch (label_hash)
|
||||
{
|
||||
case MENU_LABEL_INPUT_DRIVER:
|
||||
driver_hash = djb2_calculate(settings->input.driver);
|
||||
driver_hash = menu_hash_calculate(settings->input.driver);
|
||||
|
||||
switch (driver_hash)
|
||||
{
|
||||
@ -2203,7 +2202,7 @@ static int setting_get_description_compare_label(uint32_t label_hash,
|
||||
);
|
||||
break;
|
||||
case MENU_LABEL_VIDEO_DRIVER:
|
||||
driver_hash = djb2_calculate(settings->video.driver);
|
||||
driver_hash = menu_hash_calculate(settings->video.driver);
|
||||
|
||||
switch (driver_hash)
|
||||
{
|
||||
@ -2281,7 +2280,7 @@ static int setting_get_description_compare_label(uint32_t label_hash,
|
||||
);
|
||||
break;
|
||||
case MENU_LABEL_AUDIO_RESAMPLER_DRIVER:
|
||||
driver_hash = djb2_calculate(settings->audio.resampler);
|
||||
driver_hash = menu_hash_calculate(settings->audio.resampler);
|
||||
|
||||
switch (driver_hash)
|
||||
{
|
||||
@ -3066,7 +3065,7 @@ int setting_get_description(const char *label, char *s,
|
||||
size_t len)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
uint32_t label_hash = djb2_calculate(label);
|
||||
uint32_t label_hash = menu_hash_calculate(label);
|
||||
|
||||
if (setting_get_description_compare_label(label_hash, settings, s, len) == 0)
|
||||
return 0;
|
||||
@ -3147,7 +3146,7 @@ static void general_read_handler(void *data)
|
||||
{
|
||||
rarch_setting_t *setting = (rarch_setting_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
uint32_t hash = setting ? djb2_calculate(setting->name) : 0;
|
||||
uint32_t hash = setting ? menu_hash_calculate(setting->name) : 0;
|
||||
|
||||
if (!setting)
|
||||
return;
|
||||
@ -3200,7 +3199,7 @@ static void general_write_handler(void *data)
|
||||
driver_t *driver = driver_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
uint32_t hash = setting ? djb2_calculate(setting->name) : 0;
|
||||
uint32_t hash = setting ? menu_hash_calculate(setting->name) : 0;
|
||||
|
||||
if (!setting)
|
||||
return;
|
||||
@ -3527,7 +3526,7 @@ static bool setting_append_list_main_menu_options(
|
||||
{
|
||||
struct retro_system_info *info = (struct retro_system_info*)
|
||||
global ? &global->system.info : NULL;
|
||||
uint32_t info_library_name_hash = info ? djb2_calculate(info->library_name) : 0;
|
||||
uint32_t info_library_name_hash = info ? menu_hash_calculate(info->library_name) : 0;
|
||||
|
||||
if (info && (info_library_name_hash != MENU_VALUE_NO_CORE))
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include <compat/strl.h>
|
||||
#include <file/file_path.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_hash.h"
|
||||
@ -74,7 +73,7 @@ void menu_shader_manager_init(menu_handle_t *menu)
|
||||
}
|
||||
|
||||
ext = path_get_extension(settings->video.shader_path);
|
||||
ext_hash = djb2_calculate(ext);
|
||||
ext_hash = menu_hash_calculate(ext);
|
||||
|
||||
switch (ext_hash)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user