mirror of
https://github.com/libretro/RetroArch
synced 2025-02-19 21:40:49 +00:00
[netplay] finding content works now
cleanup
This commit is contained in:
parent
f0b8d2d12e
commit
9d0472c3ac
discord
menu/cbs
network/netplay
tasks
@ -187,8 +187,7 @@ static void handle_discord_join_cb(void *task_data, void *user_data, const char
|
||||
|
||||
RARCH_LOG("[Discord] joining lobby at: %s\n", tmp_hostname);
|
||||
task_push_netplay_crc_scan(room->gamecrc,
|
||||
room->gamename, tmp_hostname, room->corename);
|
||||
|
||||
room->gamename, tmp_hostname, room->corename, room->subsystem_name);
|
||||
}
|
||||
|
||||
finish:
|
||||
|
@ -4016,7 +4016,7 @@ static int action_ok_netplay_connect_room(const char *path,
|
||||
|
||||
task_push_netplay_crc_scan(netplay_room_list[idx - 3].gamecrc,
|
||||
netplay_room_list[idx - 3].gamename,
|
||||
tmp_hostname, netplay_room_list[idx - 3].corename);
|
||||
tmp_hostname, netplay_room_list[idx - 3].corename, netplay_room_list[idx - 3].subsystem_name);
|
||||
|
||||
#else
|
||||
return -1;
|
||||
|
@ -180,7 +180,7 @@ static int action_select_netplay_connect_room(const char *path,
|
||||
|
||||
task_push_netplay_crc_scan(netplay_room_list[idx - 3].gamecrc,
|
||||
netplay_room_list[idx - 3].gamename,
|
||||
tmp_hostname, netplay_room_list[idx - 3].corename);
|
||||
tmp_hostname, netplay_room_list[idx - 3].corename, netplay_room_list[idx - 3].subsystem_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -879,6 +879,7 @@ static void netplay_announce(void)
|
||||
}
|
||||
net_http_urlencode(&gamename, buf);
|
||||
net_http_urlencode(&subsystemname, path_get(RARCH_PATH_SUBSYSTEM));
|
||||
content_crc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -42,6 +42,7 @@ typedef struct
|
||||
char content_crc[PATH_MAX_LENGTH];
|
||||
char content_path[PATH_MAX_LENGTH];
|
||||
char hostname[512];
|
||||
char subsystem_name[512];
|
||||
char core_name[PATH_MAX_LENGTH];
|
||||
char core_path[PATH_MAX_LENGTH];
|
||||
char core_extensions[PATH_MAX_LENGTH];
|
||||
@ -62,10 +63,17 @@ static void netplay_crc_scan_callback(void *task_data,
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
if (!string_is_empty(state->subsystem_name) && !string_is_equal(state->subsystem_name, "N/A"))
|
||||
{
|
||||
RARCH_LOG("[lobby] subsystem not supported\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
/* regular core with content file */
|
||||
if (!string_is_empty(state->core_path) && !string_is_empty(state->content_path)
|
||||
&& !state->contentless && !state->current)
|
||||
&& !state->contentless && !state->current)
|
||||
{
|
||||
struct retro_system_info *system = runloop_get_libretro_system_info();
|
||||
|
||||
@ -113,7 +121,7 @@ static void netplay_crc_scan_callback(void *task_data,
|
||||
/* no match found */
|
||||
else
|
||||
{
|
||||
RARCH_LOG("Couldn't find a suitable %s\n",
|
||||
RARCH_LOG("[lobby] couldn't find a suitable %s\n",
|
||||
string_is_empty(state->content_path) ? "content file" : "core");
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_LOAD_CONTENT_MANUALLY),
|
||||
@ -163,7 +171,7 @@ static void get_entry(char *entry, int len, const char *path) {
|
||||
*/
|
||||
static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
{
|
||||
size_t i, j;
|
||||
size_t i, j, k;
|
||||
char entry[PATH_MAX_LENGTH];
|
||||
char *filename_match = NULL;
|
||||
bool have_crc = false;
|
||||
@ -212,7 +220,7 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
RARCH_LOG("[lobby] current content crc: %s\n", current);
|
||||
|
||||
if (string_is_equal(current, state->content_crc))
|
||||
{
|
||||
{
|
||||
RARCH_LOG("[lobby] CRC match %s with currently loaded content\n", current);
|
||||
strlcpy(state->content_path, "N/A", sizeof(state->content_path));
|
||||
state->found = true;
|
||||
@ -225,60 +233,32 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
}
|
||||
|
||||
/* now let's do the search */
|
||||
for(i = 0; i < state->lpl_list->size; i++)
|
||||
if (string_is_empty(state->subsystem_name) || string_is_equal(state->subsystem_name, "N/A"))
|
||||
{
|
||||
playlist_t *playlist = NULL;
|
||||
unsigned playlist_size = 0;
|
||||
const char *lpl_path = state->lpl_list->elems[i].data;
|
||||
for(i = 0; i < state->lpl_list->size; i++)
|
||||
{
|
||||
playlist_t *playlist = NULL;
|
||||
unsigned playlist_size = 0;
|
||||
const char *lpl_path = state->lpl_list->elems[i].data;
|
||||
|
||||
/* skip files without .lpl file extension */
|
||||
if (!strstr(lpl_path, file_path_str(FILE_PATH_LPL_EXTENSION)))
|
||||
continue;
|
||||
/* skip files without .lpl file extension */
|
||||
if (!strstr(lpl_path, file_path_str(FILE_PATH_LPL_EXTENSION)))
|
||||
continue;
|
||||
|
||||
RARCH_LOG("Searching playlist: %s\n", lpl_path);
|
||||
playlist = playlist_init(lpl_path, 99999);
|
||||
playlist_size = playlist_get_size(playlist);
|
||||
RARCH_LOG("[lobby] searching playlist: %s\n", lpl_path);
|
||||
playlist = playlist_init(lpl_path, 99999);
|
||||
playlist_size = playlist_get_size(playlist);
|
||||
|
||||
for(j = 0; j < playlist_size; j++)
|
||||
{
|
||||
const char *playlist_crc32 = NULL;
|
||||
const char *playlist_path = NULL;
|
||||
for(j = 0; j < playlist_size; j++)
|
||||
{
|
||||
const char *playlist_crc32 = NULL;
|
||||
const char *playlist_path = NULL;
|
||||
|
||||
playlist_get_index(playlist, j, &playlist_path, NULL, NULL, NULL, NULL, &playlist_crc32);
|
||||
|
||||
if(have_crc && string_is_equal(playlist_crc32, state->content_crc))
|
||||
{
|
||||
RARCH_LOG("[lobby] CRC match %s\n", playlist_crc32);
|
||||
strlcpy(state->content_path, playlist_path, sizeof(state->content_path));
|
||||
state->found = true;
|
||||
task_set_data(task, state);
|
||||
finish_task(task, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND));
|
||||
string_list_free(state->lpl_list);
|
||||
free(playlist);
|
||||
return;
|
||||
}
|
||||
|
||||
get_entry(entry, sizeof(entry), playlist_path);
|
||||
|
||||
/* See if the filename is a match. The response depends on whether or not we are doing a CRC
|
||||
* search.
|
||||
*
|
||||
* If we are doing a CRC search, we stow a copy of the filename match in filename_match, which
|
||||
* we'll use as our match if the CRC search is exhausted without a match.
|
||||
*
|
||||
* Otherwise, on match we complete the task and mark it as successful immediately.
|
||||
*/
|
||||
if(string_is_empty(filename_match) &&
|
||||
!string_is_empty(entry) &&
|
||||
string_is_equal(entry, state->content_path) &&
|
||||
strstr(state->core_extensions, path_get_extension(playlist_path)))
|
||||
{
|
||||
if(have_crc)
|
||||
filename_match = strdup(playlist_path);
|
||||
else
|
||||
{
|
||||
RARCH_LOG("[lobby] filename match %s\n", playlist_path);
|
||||
playlist_get_index(playlist, j, &playlist_path, NULL, NULL, NULL, NULL, &playlist_crc32);
|
||||
|
||||
if(have_crc && string_is_equal(playlist_crc32, state->content_crc))
|
||||
{
|
||||
RARCH_LOG("[lobby] CRC match %s\n", playlist_crc32);
|
||||
strlcpy(state->content_path, playlist_path, sizeof(state->content_path));
|
||||
state->found = true;
|
||||
task_set_data(task, state);
|
||||
@ -287,11 +267,120 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
free(playlist);
|
||||
return;
|
||||
}
|
||||
|
||||
get_entry(entry, sizeof(entry), playlist_path);
|
||||
|
||||
/* See if the filename is a match. The response depends on whether or not we are doing a CRC
|
||||
* search.
|
||||
*
|
||||
* If we are doing a CRC search, we stow a copy of the filename match in filename_match, which
|
||||
* we'll use as our match if the CRC search is exhausted without a match.
|
||||
*
|
||||
* Otherwise, on match we complete the task and mark it as successful immediately.
|
||||
*/
|
||||
|
||||
if(string_is_empty(filename_match) &&
|
||||
!string_is_empty(entry) &&
|
||||
string_is_equal(entry, state->content_path) &&
|
||||
strstr(state->core_extensions, path_get_extension(playlist_path)))
|
||||
{
|
||||
if(have_crc)
|
||||
filename_match = strdup(playlist_path);
|
||||
else
|
||||
{
|
||||
RARCH_LOG("[lobby] filename match %s\n", playlist_path);
|
||||
|
||||
strlcpy(state->content_path, playlist_path, sizeof(state->content_path));
|
||||
state->found = true;
|
||||
task_set_data(task, state);
|
||||
finish_task(task, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND));
|
||||
string_list_free(state->lpl_list);
|
||||
free(playlist);
|
||||
return;
|
||||
}
|
||||
}
|
||||
task_set_progress(task, (int)(j / playlist_size * 100.0));
|
||||
}
|
||||
|
||||
free(playlist);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool found[100];
|
||||
struct string_list *game_list = string_split(state->content_path, "|");
|
||||
|
||||
for (i = 0; i < game_list->size; i++)
|
||||
{
|
||||
found[i] = false;
|
||||
|
||||
for(j = 0; j < state->lpl_list->size && !found[i]; j++)
|
||||
{
|
||||
playlist_t *playlist = NULL;
|
||||
unsigned playlist_size = 0;
|
||||
const char *lpl_path = state->lpl_list->elems[j].data;
|
||||
|
||||
/* skip files without .lpl file extension */
|
||||
if (!strstr(lpl_path, file_path_str(FILE_PATH_LPL_EXTENSION)))
|
||||
continue;
|
||||
|
||||
RARCH_LOG("[lobby] searching rom %d/%d (%s) in playlist: %s\n", i + 1, game_list->size, game_list->elems[i].data, lpl_path);
|
||||
playlist = playlist_init(lpl_path, 99999);
|
||||
playlist_size = playlist_get_size(playlist);
|
||||
|
||||
|
||||
for(k = 0; k < playlist_size && !found[i]; k++)
|
||||
{
|
||||
const char *playlist_crc32 = NULL;
|
||||
const char *playlist_path = NULL;
|
||||
|
||||
playlist_get_index(playlist, k, &playlist_path, NULL, NULL, NULL, NULL, &playlist_crc32);
|
||||
get_entry(entry, sizeof(entry), playlist_path);
|
||||
|
||||
if(!string_is_empty(entry) &&
|
||||
strstr(game_list->elems[i].data, entry) &&
|
||||
strstr(state->core_extensions, path_get_extension(playlist_path)))
|
||||
{
|
||||
RARCH_LOG("[lobby] filename match %s\n", playlist_path);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
state->content_path[0] = '\0';
|
||||
strlcpy(state->content_path, playlist_path, sizeof(state->content_path));
|
||||
}
|
||||
else
|
||||
{
|
||||
strlcat(state->content_path, "|", sizeof(state->content_path));
|
||||
strlcat(state->content_path, playlist_path, sizeof(state->content_path));
|
||||
}
|
||||
found[i] = true;
|
||||
}
|
||||
task_set_progress(task, (int)(j / playlist_size * 100.0));
|
||||
}
|
||||
|
||||
free(playlist);
|
||||
}
|
||||
task_set_progress(task, (int)(j / playlist_size * 100.0));
|
||||
}
|
||||
|
||||
free(playlist);
|
||||
for (i = 0; i < game_list->size; i++)
|
||||
{
|
||||
state->found = true;
|
||||
if (found[i] == false)
|
||||
{
|
||||
state->found = false;
|
||||
filename_match[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (state->found)
|
||||
{
|
||||
RARCH_LOG("[lobby] subsystem matching set found %s\n", state->content_path);
|
||||
task_set_data(task, state);
|
||||
finish_task(task, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_COMPAT_CONTENT_FOUND));
|
||||
string_list_free(state->lpl_list);
|
||||
string_list_free(game_list);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(filename_match != NULL)
|
||||
@ -315,7 +404,7 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
}
|
||||
|
||||
bool task_push_netplay_crc_scan(uint32_t crc, char* name,
|
||||
const char *hostname, const char *core_name)
|
||||
const char *hostname, const char *core_name, const char *subsystem)
|
||||
{
|
||||
unsigned i;
|
||||
union string_list_elem_attr attr;
|
||||
@ -330,10 +419,11 @@ bool task_push_netplay_crc_scan(uint32_t crc, char* name,
|
||||
if (!task || !state)
|
||||
goto error;
|
||||
|
||||
state->content_crc[0] = '\0';
|
||||
state->content_path[0] = '\0';
|
||||
state->hostname[0] = '\0';
|
||||
state->core_name[0] = '\0';
|
||||
state->content_crc[0] = '\0';
|
||||
state->content_path[0] = '\0';
|
||||
state->hostname[0] = '\0';
|
||||
state->core_name[0] = '\0';
|
||||
state->subsystem_name[0] = '\0';
|
||||
attr.i = 0;
|
||||
|
||||
snprintf(state->content_crc,
|
||||
@ -344,6 +434,8 @@ bool task_push_netplay_crc_scan(uint32_t crc, char* name,
|
||||
name, sizeof(state->content_path));
|
||||
strlcpy(state->hostname,
|
||||
hostname, sizeof(state->hostname));
|
||||
strlcpy(state->subsystem_name,
|
||||
subsystem, sizeof(state->subsystem_name));
|
||||
strlcpy(state->core_name,
|
||||
core_name, sizeof(state->core_name));
|
||||
|
||||
|
@ -113,7 +113,7 @@ bool task_push_wifi_scan(retro_task_callback_t cb);
|
||||
bool task_push_netplay_lan_scan(retro_task_callback_t cb);
|
||||
|
||||
bool task_push_netplay_crc_scan(uint32_t crc, char* name,
|
||||
const char *hostname, const char *corename);
|
||||
const char *hostname, const char *corename, const char* subsystem);
|
||||
|
||||
bool task_push_netplay_lan_scan_rooms(retro_task_callback_t cb);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user