Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netplay netpacket interface connection flow improvements #15986

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion menu/cbs/menu_cbs_ok.c
Original file line number Diff line number Diff line change
Expand Up @@ -7701,7 +7701,14 @@ static void action_ok_netplay_enable_client_hostname_cb(void *userdata,
{
if (!string_is_empty(line))
{
if (!task_push_netplay_content_reload(line))
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL))
{
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
command_event(CMD_EVENT_NETPLAY_INIT_DIRECT, (void*)line);
menu_input_dialog_end();
retroarch_menu_running_finished(false);
}
else if (!task_push_netplay_content_reload(line))
{
#ifdef HAVE_DYNAMIC
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
Expand Down
2 changes: 1 addition & 1 deletion network/netplay/netplay_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ enum rarch_netplay_ctl_state
RARCH_NETPLAY_CTL_KICK_CLIENT,
RARCH_NETPLAY_CTL_BAN_CLIENT,
RARCH_NETPLAY_CTL_SET_CORE_PACKET_INTERFACE,
RARCH_NETPLAY_CTL_SKIP_NETPLAY_CALLBACKS,
RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE,
RARCH_NETPLAY_CTL_ALLOW_TIMESKIP
};

Expand Down
14 changes: 11 additions & 3 deletions network/netplay/netplay_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -9242,9 +9242,17 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
break;

case RARCH_NETPLAY_CTL_PAUSE:
if ( netplay
&& (!(netplay->local_paused)))
if (netplay && !netplay->local_paused)
netplay_frontend_paused(netplay, true);

if (netplay && netplay->modus == NETPLAY_MODUS_CORE_PACKET_INTERFACE)
{
/* handle new connections while paused, unpause on connect */
if (!netplay_sync_pre_frame(netplay))
netplay_disconnect(netplay);
else if (netplay_have_any_active_connection(netplay))
command_event(CMD_EVENT_UNPAUSE, NULL);
}
break;

case RARCH_NETPLAY_CTL_UNPAUSE:
Expand Down Expand Up @@ -9372,7 +9380,7 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
}
break;

case RARCH_NETPLAY_CTL_SKIP_NETPLAY_CALLBACKS:
case RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE:
ret = (net_st->core_netpacket_interface != NULL);
break;

Expand Down
7 changes: 6 additions & 1 deletion retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -3958,7 +3958,12 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_NETPLAY_ENABLE_HOST:
{
if (!task_push_netplay_content_reload(NULL))
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL))
{
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL);
command_event(CMD_EVENT_NETPLAY_INIT, NULL);
}
else if (!task_push_netplay_content_reload(NULL))
{
#ifdef HAVE_DYNAMIC
command_event(CMD_EVENT_NETPLAY_DEINIT, NULL);
Expand Down
4 changes: 2 additions & 2 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -7445,7 +7445,7 @@ bool core_set_netplay_callbacks(void)
{
runloop_state_t *runloop_st = &runloop_state;

if (netplay_driver_ctl(RARCH_NETPLAY_CTL_SKIP_NETPLAY_CALLBACKS, NULL))
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL))
return true;

/* Force normal poll type for netplay. */
Expand Down Expand Up @@ -8031,7 +8031,7 @@ void runloop_path_set_redirect(settings_t *settings,
/* Special save directory for netplay clients. */
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_SKIP_NETPLAY_CALLBACKS, NULL))
&& !netplay_driver_ctl(RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE, NULL))
{
fill_pathname_join(new_savefile_dir, new_savefile_dir, ".netplay",
sizeof(new_savefile_dir));
Expand Down
Loading