From 53a1ff446d1c0433c19ef1878927a91569f4ad45 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Fri, 28 Apr 2023 22:50:03 +0200 Subject: [PATCH] Turn another function static --- menu/menu_displaylist.c | 324 ++++++++++++++++++++-------------------- menu/menu_displaylist.h | 4 - 2 files changed, 163 insertions(+), 165 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 51e119411b..c973dae906 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6137,6 +6137,169 @@ static unsigned menu_displaylist_populate_subsystem( return count; } +#ifdef HAVE_NETWORKING +static unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list) +{ + int i, j; + char buf[256]; + char passworded[64]; + char country[8]; + const char *room_type; + const char *cnc_netplay_room = NULL; + const char *msg_int_nc = NULL; + const char *msg_int_relay = NULL; + const char *msg_int = NULL; + const char *msg_local = NULL; + const char *msg_room_pwd = NULL; + unsigned count = 0; + core_info_list_t *coreinfos = NULL; + settings_t *settings = config_get_ptr(); + net_driver_state_t *net_st = networking_state_get_ptr(); + bool show_only_connectable = + settings->bools.netplay_show_only_connectable; + bool show_only_installed_cores = + settings->bools.netplay_show_only_installed_cores; + bool show_passworded = settings->bools.netplay_show_passworded; + + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, list); + + if (menu_entries_append(list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETWORK_HOSTING_SETTINGS), + msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_HOSTING_SETTINGS), + MENU_ENUM_LABEL_NETWORK_HOSTING_SETTINGS, + MENU_SETTING_ACTION, 0, 0, NULL)) + count++; + + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) && + !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL) && + netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL)) + { + if (menu_entries_append(list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT), + msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT), + MENU_ENUM_LABEL_NETPLAY_DISCONNECT, + MENU_SETTING_ACTION, 0, 0, NULL)) + count++; + } + + if (menu_entries_append(list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT), + msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_ENABLE_CLIENT), + MENU_ENUM_LABEL_NETPLAY_ENABLE_CLIENT, + MENU_SETTING_ACTION, 0, 0, NULL)) + count++; + + if (menu_entries_append(list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETWORK_SETTINGS), + msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_SETTINGS), + MENU_ENUM_LABEL_NETWORK_SETTINGS, + MENU_SETTING_ACTION, 0, 0, NULL)) + count++; + + if (menu_entries_append(list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_LOBBY_FILTERS), + msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_LOBBY_FILTERS), + MENU_ENUM_LABEL_NETPLAY_LOBBY_FILTERS, + MENU_SETTING_ACTION, 0, 0, NULL)) + count++; + + if (menu_entries_append(list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS), + msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS), + MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS, + MENU_SETTING_ACTION, 0, 0, NULL)) + count++; + +#ifdef HAVE_NETPLAYDISCOVERY + if (menu_entries_append(list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_LAN), + msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_LAN), + MENU_ENUM_LABEL_NETPLAY_REFRESH_LAN, + MENU_SETTING_ACTION, 0, 0, NULL)) + count++; +#endif + + core_info_get_list(&coreinfos); + + msg_int_nc = msg_hash_to_str(MSG_INTERNET_NOT_CONNECTABLE); + msg_int_relay = msg_hash_to_str(MSG_INTERNET_RELAY); + msg_int = msg_hash_to_str(MSG_INTERNET); + msg_local = msg_hash_to_str(MSG_LOCAL); + msg_room_pwd = msg_hash_to_str(MSG_ROOM_PASSWORDED); + cnc_netplay_room = msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM); + + for (i = 0; i < net_st->room_count; i++) + { + struct netplay_room *room = &net_st->room_list[i]; + + /* Get rid of any room that is not running RetroArch. */ + if (!room->is_retroarch) + continue; + + /* Get rid of rooms running older (incompatible) versions. */ + if (!netplay_compatible_version(room->retroarch_version)) + continue; + + /* Get rid of any room that is not connectable, + if the user opt-in. */ + if (!room->connectable) + { + if (show_only_connectable) + continue; + + room_type = msg_int_nc; + } + else if (room->lan) + room_type = msg_local; + else if (room->host_method == NETPLAY_HOST_METHOD_MITM) + room_type = msg_int_relay; + else + room_type = msg_int; + + /* Get rid of any room running a core that we don't have installed, + if the user opt-in. */ + if (show_only_installed_cores) + { + for (j = 0; j < (int)coreinfos->count; j++) + { + if (string_is_equal_case_insensitive(coreinfos->list[j].core_name, + room->corename)) + break; + } + if (j >= (int)coreinfos->count) + continue; + } + + /* Get rid of any room that is passworded, + if the user opt-in. */ + if (room->has_password || room->has_spectate_password) + { + if (!show_passworded) + continue; + snprintf(passworded, sizeof(passworded), "[%s] ", msg_room_pwd); + } + else + *passworded = '\0'; + + if (!room->lan && !string_is_empty(room->country)) + snprintf(country, sizeof(country), " (%s)", room->country); + else + *country = '\0'; + + snprintf(buf, sizeof(buf), "%s%s: %s%s", + passworded, room_type, room->nickname, country); + + if (menu_entries_append(list, buf, + cnc_netplay_room, + MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM, + (unsigned)MENU_SETTINGS_NETPLAY_ROOMS_START + i, 0, 0, NULL)) + count++; + } + + return count; +} +#endif + unsigned menu_displaylist_build_list( file_list_t *list, settings_t *settings, @@ -10762,167 +10925,6 @@ static unsigned menu_displaylist_build_shader_parameter( } #ifdef HAVE_NETWORKING -unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list) -{ - int i, j; - char buf[256]; - char passworded[64]; - char country[8]; - const char *room_type; - const char *cnc_netplay_room = NULL; - const char *msg_int_nc = NULL; - const char *msg_int_relay = NULL; - const char *msg_int = NULL; - const char *msg_local = NULL; - const char *msg_room_pwd = NULL; - unsigned count = 0; - core_info_list_t *coreinfos = NULL; - settings_t *settings = config_get_ptr(); - net_driver_state_t *net_st = networking_state_get_ptr(); - bool show_only_connectable = - settings->bools.netplay_show_only_connectable; - bool show_only_installed_cores = - settings->bools.netplay_show_only_installed_cores; - bool show_passworded = settings->bools.netplay_show_passworded; - - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, list); - - if (menu_entries_append(list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETWORK_HOSTING_SETTINGS), - msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_HOSTING_SETTINGS), - MENU_ENUM_LABEL_NETWORK_HOSTING_SETTINGS, - MENU_SETTING_ACTION, 0, 0, NULL)) - count++; - - if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL) && - !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_SERVER, NULL) && - netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_CONNECTED, NULL)) - { - if (menu_entries_append(list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_DISCONNECT), - msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_DISCONNECT), - MENU_ENUM_LABEL_NETPLAY_DISCONNECT, - MENU_SETTING_ACTION, 0, 0, NULL)) - count++; - } - - if (menu_entries_append(list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ENABLE_CLIENT), - msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_ENABLE_CLIENT), - MENU_ENUM_LABEL_NETPLAY_ENABLE_CLIENT, - MENU_SETTING_ACTION, 0, 0, NULL)) - count++; - - if (menu_entries_append(list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETWORK_SETTINGS), - msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_SETTINGS), - MENU_ENUM_LABEL_NETWORK_SETTINGS, - MENU_SETTING_ACTION, 0, 0, NULL)) - count++; - - if (menu_entries_append(list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_LOBBY_FILTERS), - msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_LOBBY_FILTERS), - MENU_ENUM_LABEL_NETPLAY_LOBBY_FILTERS, - MENU_SETTING_ACTION, 0, 0, NULL)) - count++; - - if (menu_entries_append(list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS), - msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS), - MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS, - MENU_SETTING_ACTION, 0, 0, NULL)) - count++; - -#ifdef HAVE_NETPLAYDISCOVERY - if (menu_entries_append(list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_LAN), - msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_LAN), - MENU_ENUM_LABEL_NETPLAY_REFRESH_LAN, - MENU_SETTING_ACTION, 0, 0, NULL)) - count++; -#endif - - core_info_get_list(&coreinfos); - - msg_int_nc = msg_hash_to_str(MSG_INTERNET_NOT_CONNECTABLE); - msg_int_relay = msg_hash_to_str(MSG_INTERNET_RELAY); - msg_int = msg_hash_to_str(MSG_INTERNET); - msg_local = msg_hash_to_str(MSG_LOCAL); - msg_room_pwd = msg_hash_to_str(MSG_ROOM_PASSWORDED); - cnc_netplay_room = msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM); - - for (i = 0; i < net_st->room_count; i++) - { - struct netplay_room *room = &net_st->room_list[i]; - - /* Get rid of any room that is not running RetroArch. */ - if (!room->is_retroarch) - continue; - - /* Get rid of rooms running older (incompatible) versions. */ - if (!netplay_compatible_version(room->retroarch_version)) - continue; - - /* Get rid of any room that is not connectable, - if the user opt-in. */ - if (!room->connectable) - { - if (show_only_connectable) - continue; - - room_type = msg_int_nc; - } - else if (room->lan) - room_type = msg_local; - else if (room->host_method == NETPLAY_HOST_METHOD_MITM) - room_type = msg_int_relay; - else - room_type = msg_int; - - /* Get rid of any room running a core that we don't have installed, - if the user opt-in. */ - if (show_only_installed_cores) - { - for (j = 0; j < (int)coreinfos->count; j++) - { - if (string_is_equal_case_insensitive(coreinfos->list[j].core_name, - room->corename)) - break; - } - if (j >= (int)coreinfos->count) - continue; - } - - /* Get rid of any room that is passworded, - if the user opt-in. */ - if (room->has_password || room->has_spectate_password) - { - if (!show_passworded) - continue; - snprintf(passworded, sizeof(passworded), "[%s] ", msg_room_pwd); - } - else - *passworded = '\0'; - - if (!room->lan && !string_is_empty(room->country)) - snprintf(country, sizeof(country), " (%s)", room->country); - else - *country = '\0'; - - snprintf(buf, sizeof(buf), "%s%s: %s%s", - passworded, room_type, room->nickname, country); - - if (menu_entries_append(list, buf, - cnc_netplay_room, - MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM, - (unsigned)MENU_SETTINGS_NETPLAY_ROOMS_START + i, 0, 0, NULL)) - count++; - } - - return count; -} - static unsigned print_buf_lines(file_list_t *list, char *buf, const char *label, int buf_size, enum msg_file_type type, bool append, bool extended) diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index 3336a241cb..d007057896 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -351,10 +351,6 @@ void menu_displaylist_info_init(menu_displaylist_info_t *info); bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist_info_t *info, settings_t *settings); -#ifdef HAVE_NETWORKING -unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list); -#endif - bool menu_displaylist_has_subsystems(void); #if defined(HAVE_LIBRETRODB)