diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 06b2c4c71c..3a0614e528 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -2400,6 +2400,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "Aktualisieren") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, "Nickname: %s") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN, + "Nickname (lan): %s") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND, "Kompatibler Inhalt gefunden") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_CROP_OVERSCAN, diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 4d3be0310f..76a68124e8 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -2279,3 +2279,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "Refresh Room List") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, "Nickname: %s") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN, + "Nickname (lan): %s") diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 01bb610aec..b3dae4a13a 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -2402,6 +2402,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "ルーム表を更新") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, "ニックネーム: %s") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN, + "Nickname (lan): %s") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND, "対応するコンテンツが見つかりました") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_CROP_OVERSCAN, diff --git a/intl/msg_hash_pt.h b/intl/msg_hash_pt.h index 27d946a16a..816c2a19d6 100644 --- a/intl/msg_hash_pt.h +++ b/intl/msg_hash_pt.h @@ -2398,6 +2398,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "Atualizar") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, "Apelido: %s") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN, + "Nickname (lan): %s") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND, "Conteúdo compatível encontrado") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_CROP_OVERSCAN, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index cb8540aff2..d09208bf93 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2406,6 +2406,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "Refresh") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, "Nickname: %s") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN, + "Nickname (lan): %s") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND, "Compatible content found") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_CROP_OVERSCAN, diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index be9b5f223e..ed0499aa6f 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3389,6 +3389,7 @@ static int action_ok_push_scan_file(const char *path, static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const char *err) { char buf[PATH_MAX_LENGTH]; + int lan_room_count = 0; http_transfer_data_t *data = (http_transfer_data_t*)task_data; @@ -3422,8 +3423,12 @@ finish: file_list_t *file_list = menu_entries_get_selection_buf_ptr(0); struct netplay_host_list *lan_hosts; - if (!netplay_discovery_driver_ctl(RARCH_NETPLAY_DISCOVERY_CTL_LAN_GET_RESPONSES, &lan_hosts)) - lan_hosts = NULL; + //netplay_discovery_driver_ctl(RARCH_NETPLAY_DISCOVERY_CTL_LAN_GET_RESPONSES, &lan_hosts); + + if (lan_hosts) + lan_room_count = lan_hosts->size; + else + lan_room_count = 0; menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, file_list); @@ -3435,7 +3440,7 @@ finish: netplay_room_count = (int)(room_data->size / 8); netplay_room_list = (struct netplay_room*) malloc(sizeof(struct netplay_room) * netplay_room_count + - lan_hosts->size); + lan_room_count); #if 0 for (int i = 0; i < room_data->size; i++) @@ -3512,44 +3517,42 @@ finish: MENU_ROOM, 0, 0); } - struct netplay_host *host = &lan_hosts->hosts[k]; - for (; i < netplay_room_count + lan_hosts->size; i++) + if (lan_room_count != 0) { - strlcpy(netplay_room_list[i].nickname, - host->nick, - sizeof(netplay_room_list[i].nickname)); - /* to-do: get address fron host-> addr */ - strlcpy(netplay_room_list[i].address, - "", - sizeof(netplay_room_list[i].address)); - strlcpy(netplay_room_list[i].corename, - host->core, - sizeof(netplay_room_list[i].corename)); - strlcpy(netplay_room_list[i].coreversion, - host->core_version, - sizeof(netplay_room_list[i].coreversion)); - strlcpy(netplay_room_list[i].gamename, - host->content, - sizeof(netplay_room_list[i].coreversion)); + struct netplay_host *host = &lan_hosts->hosts[k]; + for (; i < netplay_room_count + lan_room_count; i++) + { + strlcpy(netplay_room_list[i].nickname, + host->nick, + sizeof(netplay_room_list[i].nickname)); + struct sockaddr* address = &host->addr; + strlcpy(netplay_room_list[i].address, + inet_ntoa(((struct sockaddr_in*)(address))->sin_addr), + sizeof(netplay_room_list[i].address)); + strlcpy(netplay_room_list[i].corename, + host->core, + sizeof(netplay_room_list[i].corename)); + strlcpy(netplay_room_list[i].coreversion, + host->core_version, + sizeof(netplay_room_list[i].coreversion)); + strlcpy(netplay_room_list[i].gamename, + host->content, + sizeof(netplay_room_list[i].coreversion)); - /* to-do: this will only work with default port os - we should have a start LAN game entry that always - uses that port - */ - netplay_room_list[i].port = 55435; - /* to-do: lan announce doesn't announce CRC */ - netplay_room_list[i].gamecrc = 0; - netplay_room_list[i].timestamp = 0; + netplay_room_list[i].port = 55435; + netplay_room_list[i].gamecrc = host->content_crc; + netplay_room_list[i].timestamp = 0; - snprintf(s, sizeof(s), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME), - netplay_room_list[i].nickname); + snprintf(s, sizeof(s), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME_LAN), + netplay_room_list[i].nickname); - menu_entries_append_enum(file_list, - s, - msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM), - MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM, - MENU_ROOM, 0, 0); - k++; + menu_entries_append_enum(file_list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM), + MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM, + MENU_ROOM, 0, 0); + k++; + } } } } diff --git a/msg_hash.h b/msg_hash.h index 15a8569b1c..21b3df48ec 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -870,6 +870,7 @@ enum msg_hash_enums MENU_LABEL(SCAN_FILE), MENU_LABEL(NETPLAY_REFRESH_ROOMS), MENU_LABEL(NETPLAY_ROOM_NICKNAME), + MENU_LABEL(NETPLAY_ROOM_NICKNAME_LAN), MENU_LABEL(ADD_CONTENT_LIST), MENU_LABEL(CONFIGURATIONS_LIST), diff --git a/network/netplay/netplay_discovery.c b/network/netplay/netplay_discovery.c index a6c3429d27..69c7eed3c7 100644 --- a/network/netplay/netplay_discovery.c +++ b/network/netplay/netplay_discovery.c @@ -34,6 +34,11 @@ #include #include #include +#include +#include +#include "../../file_path_special.h" +#include "../../paths.h" +#include "../../content.h" #include #include @@ -58,6 +63,7 @@ struct ad_packet char core[NETPLAY_HOST_STR_LEN]; char core_version[NETPLAY_HOST_STR_LEN]; char content[NETPLAY_HOST_STR_LEN]; + char content_crc[NETPLAY_HOST_STR_LEN]; }; bool netplay_lan_ad_client(void); @@ -240,6 +246,8 @@ bool netplay_lan_ad_server(netplay_t *netplay) runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); /* Now build our response */ + uint32_t *content_crc_ptr = NULL; + content_get_crc(&content_crc_ptr); memset(&ad_packet_buffer, 0, sizeof(struct ad_packet)); memcpy(&ad_packet_buffer, "RANS", 4); ad_packet_buffer.protocol_version = @@ -247,6 +255,8 @@ bool netplay_lan_ad_server(netplay_t *netplay) ad_packet_buffer.port = htonl(netplay->tcp_port); strlcpy(ad_packet_buffer.retroarch_version, PACKAGE_VERSION, NETPLAY_HOST_STR_LEN); + strlcpy(ad_packet_buffer.content, !string_is_empty(path_basename(path_get(RARCH_PATH_BASENAME))) ? path_basename(path_get(RARCH_PATH_BASENAME)) : "N/A", + NETPLAY_HOST_STR_LEN); strlcpy(ad_packet_buffer.nick, netplay->nick, NETPLAY_HOST_STR_LEN); if (info) { @@ -255,6 +265,10 @@ bool netplay_lan_ad_server(netplay_t *netplay) strlcpy(ad_packet_buffer.core_version, info->info.library_version, NETPLAY_HOST_STR_LEN); } + char s[NETPLAY_HOST_STR_LEN]; + snprintf(s, sizeof(s), "%d", *content_crc_ptr); + strlcpy(ad_packet_buffer.content_crc, s, + NETPLAY_HOST_STR_LEN); /* And send it */ sendto(lan_ad_server_fd, (const char*)&ad_packet_buffer, @@ -372,6 +386,7 @@ bool netplay_lan_ad_client(void) NETPLAY_HOST_STR_LEN); strlcpy(host->content, ad_packet_buffer.content, NETPLAY_HOST_STR_LEN); + host->content_crc = atoi(ad_packet_buffer.content_crc); host->nick[NETPLAY_HOST_STR_LEN-1] = host->core[NETPLAY_HOST_STR_LEN-1] = host->core_version[NETPLAY_HOST_STR_LEN-1] = diff --git a/network/netplay/netplay_discovery.h b/network/netplay/netplay_discovery.h index e3254c94a3..68119cd020 100644 --- a/network/netplay/netplay_discovery.h +++ b/network/netplay/netplay_discovery.h @@ -39,6 +39,7 @@ struct netplay_host char core[NETPLAY_HOST_STR_LEN]; char core_version[NETPLAY_HOST_STR_LEN]; char content[NETPLAY_HOST_STR_LEN]; + int content_crc; }; struct netplay_host_list diff --git a/tasks/task_netplay_lan_scan.c b/tasks/task_netplay_lan_scan.c index 2842035f1d..ca77d9ba28 100644 --- a/tasks/task_netplay_lan_scan.c +++ b/tasks/task_netplay_lan_scan.c @@ -15,6 +15,7 @@ #include #include +#include "../paths.h" #include "tasks_internal.h"