mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
split this function to avoid some code duplication
This commit is contained in:
parent
a98033f375
commit
4710bfcf43
@ -3447,6 +3447,75 @@ static int action_ok_push_scan_file(const char *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
|
void netplay_refresh_rooms_menu(file_list_t *list)
|
||||||
|
{
|
||||||
|
char s[PATH_MAX_LENGTH];
|
||||||
|
int i, j , k;
|
||||||
|
if (netplay_room_count != 0)
|
||||||
|
{
|
||||||
|
RARCH_LOG ("Found %d rooms...\n", netplay_room_count);
|
||||||
|
|
||||||
|
for (i = 0; i < netplay_room_count; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*strlcpy(netplay_room_list[i].nickname,
|
||||||
|
room_data->elems[j + 0].data,
|
||||||
|
sizeof(netplay_room_list[i].nickname));
|
||||||
|
strlcpy(netplay_room_list[i].address,
|
||||||
|
room_data->elems[j + 1].data,
|
||||||
|
sizeof(netplay_room_list[i].address));
|
||||||
|
strlcpy(netplay_room_list[i].corename,
|
||||||
|
room_data->elems[j + 3].data,
|
||||||
|
sizeof(netplay_room_list[i].corename));
|
||||||
|
strlcpy(netplay_room_list[i].coreversion,
|
||||||
|
room_data->elems[j + 4].data,
|
||||||
|
sizeof(netplay_room_list[i].coreversion));
|
||||||
|
strlcpy(netplay_room_list[i].gamename,
|
||||||
|
room_data->elems[j + 5].data,
|
||||||
|
sizeof(netplay_room_list[i].gamename));
|
||||||
|
|
||||||
|
netplay_room_list[i].port = atoi(room_data->elems[j + 2].data);
|
||||||
|
netplay_room_list[i].gamecrc = atoi(room_data->elems[j + 6].data);
|
||||||
|
netplay_room_list[i].timestamp = atoi(room_data->elems[j + 7].data);*/
|
||||||
|
|
||||||
|
/* Uncomment this to debug mismatched room parameters*/
|
||||||
|
#if 0
|
||||||
|
RARCH_LOG("Room Data: %d\n"
|
||||||
|
"Nickname: %s\n"
|
||||||
|
"Address: %s\n"
|
||||||
|
"Port: %d\n"
|
||||||
|
"Core: %s\n"
|
||||||
|
"Core Version: %s\n"
|
||||||
|
"Game: %s\n"
|
||||||
|
"Game CRC: %08x\n"
|
||||||
|
"Timestamp: %d\n", room_data->elems[j + 6].data,
|
||||||
|
netplay_room_list[i].nickname,
|
||||||
|
netplay_room_list[i].address,
|
||||||
|
netplay_room_list[i].port,
|
||||||
|
netplay_room_list[i].corename,
|
||||||
|
netplay_room_list[i].coreversion,
|
||||||
|
netplay_room_list[i].gamename,
|
||||||
|
netplay_room_list[i].gamecrc,
|
||||||
|
netplay_room_list[i].timestamp);
|
||||||
|
#endif
|
||||||
|
j+=8;
|
||||||
|
|
||||||
|
snprintf(s, sizeof(s),
|
||||||
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME),
|
||||||
|
netplay_room_list[i].nickname);
|
||||||
|
|
||||||
|
menu_entries_append_enum(list,
|
||||||
|
s,
|
||||||
|
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM),
|
||||||
|
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
|
||||||
|
MENU_ROOM, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
netplay_rooms_free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const char *err)
|
static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const char *err)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX_LENGTH];
|
char buf[PATH_MAX_LENGTH];
|
||||||
@ -3546,69 +3615,10 @@ finish:
|
|||||||
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
|
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
|
||||||
MENU_SETTING_ACTION, 0, 0);
|
MENU_SETTING_ACTION, 0, 0);
|
||||||
|
|
||||||
if (netplay_room_count != 0)
|
for (i = 0; i < netplay_room_count; i++)
|
||||||
{
|
memcpy(&netplay_room_list[i], netplay_room_get(i), sizeof(netplay_room_list[i]));
|
||||||
RARCH_LOG ("Found %d rooms...\n", netplay_room_count);
|
|
||||||
|
|
||||||
for (i = 0; i < netplay_room_count; i++)
|
netplay_refresh_rooms_menu(file_list);
|
||||||
{
|
|
||||||
memcpy(&netplay_room_list[i], netplay_room_get(i), sizeof(netplay_room_list[i]));
|
|
||||||
|
|
||||||
/*strlcpy(netplay_room_list[i].nickname,
|
|
||||||
room_data->elems[j + 0].data,
|
|
||||||
sizeof(netplay_room_list[i].nickname));
|
|
||||||
strlcpy(netplay_room_list[i].address,
|
|
||||||
room_data->elems[j + 1].data,
|
|
||||||
sizeof(netplay_room_list[i].address));
|
|
||||||
strlcpy(netplay_room_list[i].corename,
|
|
||||||
room_data->elems[j + 3].data,
|
|
||||||
sizeof(netplay_room_list[i].corename));
|
|
||||||
strlcpy(netplay_room_list[i].coreversion,
|
|
||||||
room_data->elems[j + 4].data,
|
|
||||||
sizeof(netplay_room_list[i].coreversion));
|
|
||||||
strlcpy(netplay_room_list[i].gamename,
|
|
||||||
room_data->elems[j + 5].data,
|
|
||||||
sizeof(netplay_room_list[i].gamename));
|
|
||||||
|
|
||||||
netplay_room_list[i].port = atoi(room_data->elems[j + 2].data);
|
|
||||||
netplay_room_list[i].gamecrc = atoi(room_data->elems[j + 6].data);
|
|
||||||
netplay_room_list[i].timestamp = atoi(room_data->elems[j + 7].data);*/
|
|
||||||
|
|
||||||
/* Uncomment this to debug mismatched room parameters*/
|
|
||||||
#if 0
|
|
||||||
RARCH_LOG("Room Data: %d\n"
|
|
||||||
"Nickname: %s\n"
|
|
||||||
"Address: %s\n"
|
|
||||||
"Port: %d\n"
|
|
||||||
"Core: %s\n"
|
|
||||||
"Core Version: %s\n"
|
|
||||||
"Game: %s\n"
|
|
||||||
"Game CRC: %08x\n"
|
|
||||||
"Timestamp: %d\n", room_data->elems[j + 6].data,
|
|
||||||
netplay_room_list[i].nickname,
|
|
||||||
netplay_room_list[i].address,
|
|
||||||
netplay_room_list[i].port,
|
|
||||||
netplay_room_list[i].corename,
|
|
||||||
netplay_room_list[i].coreversion,
|
|
||||||
netplay_room_list[i].gamename,
|
|
||||||
netplay_room_list[i].gamecrc,
|
|
||||||
netplay_room_list[i].timestamp);
|
|
||||||
#endif
|
|
||||||
j+=8;
|
|
||||||
|
|
||||||
snprintf(s, sizeof(s),
|
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME),
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
netplay_rooms_free();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lan_room_count != 0)
|
if (lan_room_count != 0)
|
||||||
{
|
{
|
||||||
|
@ -3048,26 +3048,9 @@ static int menu_displaylist_parse_netplay_room_list(
|
|||||||
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS),
|
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS),
|
||||||
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
|
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
|
||||||
MENU_SETTING_ACTION, 0, 0);
|
MENU_SETTING_ACTION, 0, 0);
|
||||||
|
|
||||||
if (netplay_room_count > 0)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
for (i = 0; i < (unsigned)netplay_room_count; i++)
|
|
||||||
{
|
|
||||||
char s[PATH_MAX_LENGTH];
|
|
||||||
|
|
||||||
s[0] = '\0';
|
netplay_refresh_rooms_menu(info->list);
|
||||||
|
|
||||||
snprintf(s, sizeof(s),
|
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME), netplay_room_list[i].nickname);
|
|
||||||
menu_entries_append_enum(info->list,
|
|
||||||
s,
|
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM),
|
|
||||||
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
|
|
||||||
MENU_ROOM, 0, 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -206,7 +206,9 @@ typedef struct menu_displaylist_ctx_entry
|
|||||||
} menu_displaylist_ctx_entry_t;
|
} menu_displaylist_ctx_entry_t;
|
||||||
|
|
||||||
bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data);
|
bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data);
|
||||||
|
#ifdef HAVE_NETWORKING
|
||||||
|
void netplay_refresh_rooms_menu(file_list_t *list);
|
||||||
|
#endif
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user