From b5cd18707772ddeebca7a1d1271703c6434377d6 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 9 Dec 2016 23:11:18 -0500 Subject: [PATCH] Since there's now only one mode, removing netplay_callbacks entirely. --- network/netplay/netplay.c | 22 ++++++--------------- network/netplay/netplay_net.c | 33 ++++++------------------------- network/netplay/netplay_private.h | 12 +++-------- 3 files changed, 15 insertions(+), 52 deletions(-) diff --git a/network/netplay/netplay.c b/network/netplay/netplay.c index 88886cbcfe..537fde9737 100644 --- a/network/netplay/netplay.c +++ b/network/netplay/netplay.c @@ -315,11 +315,6 @@ static void hangup(netplay_t *netplay, struct netplay_connection *connection) netplay->stall = 0; } -static bool netplay_info_cb(netplay_t* netplay, unsigned delay_frames) -{ - return netplay->net_cbs->info_cb(netplay, delay_frames); -} - /** * netplay_should_skip: * @netplay : pointer to netplay object @@ -1477,8 +1472,6 @@ netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port, strlcpy(netplay->nick, nick[0] ? nick : RARCH_DEFAULT_NICK, sizeof(netplay->nick)); - netplay->net_cbs = netplay_get_cbs_net(); - if (!init_socket(netplay, direct_host, server, port)) { free(netplay); @@ -1493,12 +1486,10 @@ netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port, if (!netplay->is_server) { - fprintf(stderr, "CONNECTION 0 %d\n", netplay->connections[0].active); + netplay_handshake_init_send(netplay, &netplay->connections[0]); + netplay->connections[0].mode = netplay->self_mode = NETPLAY_CONNECTION_INIT; } - if(!netplay_info_cb(netplay, delay_frames)) - goto error; - /* FIXME: Not really the right place to do this, socket initialization needs * to be fixed in general */ if (netplay->is_server) @@ -1652,7 +1643,7 @@ void netplay_free(netplay_t *netplay) **/ bool netplay_pre_frame(netplay_t *netplay) { - retro_assert(netplay && netplay->net_cbs->pre_frame); + retro_assert(netplay); /* FIXME: This is an ugly way to learn we're not paused anymore */ if (netplay->local_paused) @@ -1687,7 +1678,7 @@ bool netplay_pre_frame(netplay_t *netplay) } } - if (!netplay->net_cbs->pre_frame(netplay)) + if (!netplay_sync_pre_frame(netplay)) return false; return (!netplay->have_player_connections || @@ -1704,9 +1695,8 @@ bool netplay_pre_frame(netplay_t *netplay) **/ void netplay_post_frame(netplay_t *netplay) { - retro_assert(netplay && netplay->net_cbs->post_frame); - netplay->net_cbs->post_frame(netplay); - /* FIXME: Per-connection send buffer */ + retro_assert(netplay); + netplay_sync_post_frame(netplay); if (netplay->connections_size > 0 && netplay->connections[0].active && !netplay_send_flush(&netplay->connections[0].send_packet_buffer, diff --git a/network/netplay/netplay_net.c b/network/netplay/netplay_net.c index 157eda9924..db06e6311d 100644 --- a/network/netplay/netplay_net.c +++ b/network/netplay/netplay_net.c @@ -66,12 +66,12 @@ static void netplay_handle_frame_hash(netplay_t *netplay, struct delta_frame *de } /** - * netplay_net_pre_frame: + * netplay_sync_pre_frame: * @netplay : pointer to netplay object * - * Pre-frame for Netplay (normal version). + * Pre-frame for Netplay synchronization. **/ -static bool netplay_net_pre_frame(netplay_t *netplay) +bool netplay_sync_pre_frame(netplay_t *netplay) { retro_ctx_serialize_info_t serial_info; @@ -235,13 +235,13 @@ process: } /** - * netplay_net_post_frame: + * netplay_sync_post_frame: * @netplay : pointer to netplay object * - * Post-frame for Netplay (normal version). + * Post-frame for Netplay synchronization. * We check if we have new input and replay from recorded input. **/ -static void netplay_net_post_frame(netplay_t *netplay) +void netplay_sync_post_frame(netplay_t *netplay) { netplay->self_ptr = NEXT_PTR(netplay->self_ptr); netplay->self_frame_count++; @@ -370,24 +370,3 @@ static void netplay_net_post_frame(netplay_t *netplay) core_unserialize(&serial_info); } } - -static bool netplay_net_info_cb(netplay_t* netplay, unsigned frames) -{ - if (!netplay_is_server(netplay)) - { - netplay_handshake_init_send(netplay, netplay->connections); - netplay->connections[0].mode = netplay->self_mode = NETPLAY_CONNECTION_INIT; - } - - return true; -} - -struct netplay_callbacks* netplay_get_cbs_net(void) -{ - static struct netplay_callbacks cbs = { - &netplay_net_pre_frame, - &netplay_net_post_frame, - &netplay_net_info_cb - }; - return &cbs; -} diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index 085223c811..dce6a995f7 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -216,12 +216,6 @@ struct socket_buffer size_t read; }; -struct netplay_callbacks { - bool (*pre_frame) (netplay_t *netplay); - void (*post_frame)(netplay_t *netplay); - bool (*info_cb) (netplay_t *netplay, unsigned frames); -}; - /* Each connection gets a connection struct */ struct netplay_connection { @@ -376,8 +370,6 @@ struct netplay /* Frequency with which to check CRCs */ uint32_t check_frames; - - struct netplay_callbacks* net_cbs; }; void input_poll_net(void); @@ -463,7 +455,9 @@ void netplay_load_savestate(netplay_t *netplay, retro_ctx_serialize_info_t *seri **/ bool netplay_disconnect(netplay_t *netplay); -struct netplay_callbacks* netplay_get_cbs_net(void); +bool netplay_sync_pre_frame(netplay_t *netplay); + +void netplay_sync_post_frame(netplay_t *netplay); /* Normally called at init time, unless the INITIALIZATION quirk is set */ bool netplay_init_serialization(netplay_t *netplay);