From ac72ba5af847aa9c7948d12728a5afff7a7c35d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 28 Jan 2020 19:15:05 +0100 Subject: [PATCH] Revert "(Netplay) Cleanups" This reverts commit 646eba5a922065d35b72aa9c6511cb77b97f7cf7. --- network/netplay/netplay_frontend.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 050e11c1df..11aeafdea0 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -81,8 +81,10 @@ extern bool discord_is_inited; **/ static bool netplay_is_alive(netplay_t *netplay) { + if (!netplay) + return false; return (netplay->is_server) || - (netplay->self_mode >= NETPLAY_CONNECTION_CONNECTED); + (!netplay->is_server && netplay->self_mode >= NETPLAY_CONNECTION_CONNECTED); } /** @@ -97,9 +99,9 @@ static bool netplay_is_alive(netplay_t *netplay) **/ static bool netplay_should_skip(netplay_t *netplay) { - if (netplay) - return netplay->is_replay && (netplay->self_mode >= NETPLAY_CONNECTION_CONNECTED); - return false; + if (!netplay) + return false; + return netplay->is_replay && (netplay->self_mode >= NETPLAY_CONNECTION_CONNECTED); } /** @@ -109,9 +111,9 @@ static bool netplay_should_skip(netplay_t *netplay) */ static bool netplay_can_poll(netplay_t *netplay) { - if (netplay) - return netplay->can_poll; - return false; + if (!netplay) + return false; + return netplay->can_poll; } /** @@ -564,12 +566,16 @@ static int16_t netplay_input_state(netplay_t *netplay, unsigned port, unsigned device, unsigned idx, unsigned id) { - netplay_input_state_t istate; - size_t ptr = netplay->is_replay ? + size_t ptr = netplay->is_replay ? netplay->replay_ptr : netplay->run_ptr; - struct delta_frame *delta = NULL; + struct delta_frame *delta; + netplay_input_state_t istate; + const uint32_t *curr_input_state = NULL; + if (port >= MAX_INPUT_DEVICES) + return 0; + /* If the port doesn't seem to correspond to the device, "correct" it. This * is common with devices that typically only have one instance, such as * keyboards, mice and lightguns. */ @@ -890,7 +896,7 @@ int16_t input_state_net(unsigned port, unsigned device, unsigned idx, unsigned id) { netplay_t *netplay = netplay_data; - if (netplay && netplay_is_alive(netplay) && port < MAX_INPUT_DEVICES) + if (netplay_is_alive(netplay)) return netplay_input_state(netplay, port, device, idx, id); return netplay->cbs.state_cb(port, device, idx, id); }