mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Renaming input_ptr/input_frame_count back to self_.
This commit is contained in:
parent
4ff8982355
commit
2ea3936d16
@ -42,6 +42,10 @@ In general, other ≤ unread and other ≤ self. In all likelihood, unread ≤ s
|
|||||||
but it is both possible and supported for the remote host to get ahead of the
|
but it is both possible and supported for the remote host to get ahead of the
|
||||||
local host.
|
local host.
|
||||||
|
|
||||||
|
There is an additional location, run, used when input latency is desired. In
|
||||||
|
that case, self points to where input is being read, and run points to the
|
||||||
|
frame actually being executed. Run is purely local.
|
||||||
|
|
||||||
The server has a slightly more complicated job as it can handle multiple
|
The server has a slightly more complicated job as it can handle multiple
|
||||||
clients, however it is not vastly more complicated: For each connection which
|
clients, however it is not vastly more complicated: For each connection which
|
||||||
is playing (i.e., has a controller), it maintains a per-player unread frame,
|
is playing (i.e., has a controller), it maintains a per-player unread frame,
|
||||||
|
@ -106,10 +106,10 @@ static bool netplay_can_poll(netplay_t *netplay)
|
|||||||
static bool get_self_input_state(netplay_t *netplay)
|
static bool get_self_input_state(netplay_t *netplay)
|
||||||
{
|
{
|
||||||
uint32_t state[WORDS_PER_INPUT] = {0, 0, 0};
|
uint32_t state[WORDS_PER_INPUT] = {0, 0, 0};
|
||||||
struct delta_frame *ptr = &netplay->buffer[netplay->input_ptr];
|
struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr];
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!netplay_delta_frame_ready(netplay, ptr, netplay->input_frame_count))
|
if (!netplay_delta_frame_ready(netplay, ptr, netplay->self_frame_count))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ptr->have_local)
|
if (ptr->have_local)
|
||||||
@ -118,7 +118,7 @@ static bool get_self_input_state(netplay_t *netplay)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!input_driver_is_libretro_input_blocked() && netplay->input_frame_count > 0)
|
if (!input_driver_is_libretro_input_blocked() && netplay->self_frame_count > 0)
|
||||||
{
|
{
|
||||||
/* First frame we always give zero input since relying on
|
/* First frame we always give zero input since relying on
|
||||||
* input from first frame screws up when we use -F 0. */
|
* input from first frame screws up when we use -F 0. */
|
||||||
@ -264,7 +264,7 @@ static bool netplay_poll(void)
|
|||||||
case NETPLAY_STALL_RUNNING_FAST:
|
case NETPLAY_STALL_RUNNING_FAST:
|
||||||
{
|
{
|
||||||
if (netplay_data->unread_frame_count + NETPLAY_MAX_STALL_FRAMES - 2
|
if (netplay_data->unread_frame_count + NETPLAY_MAX_STALL_FRAMES - 2
|
||||||
> netplay_data->input_frame_count)
|
> netplay_data->self_frame_count)
|
||||||
{
|
{
|
||||||
netplay_data->stall = NETPLAY_STALL_NONE;
|
netplay_data->stall = NETPLAY_STALL_NONE;
|
||||||
for (i = 0; i < netplay_data->connections_size; i++)
|
for (i = 0; i < netplay_data->connections_size; i++)
|
||||||
@ -312,7 +312,7 @@ static bool netplay_poll(void)
|
|||||||
/* Have we not reat enough latency frames? */
|
/* Have we not reat enough latency frames? */
|
||||||
if (netplay_data->self_mode == NETPLAY_CONNECTION_PLAYING &&
|
if (netplay_data->self_mode == NETPLAY_CONNECTION_PLAYING &&
|
||||||
netplay_data->connected_players &&
|
netplay_data->connected_players &&
|
||||||
netplay_data->run_frame_count + netplay_data->input_latency_frames > netplay_data->input_frame_count)
|
netplay_data->run_frame_count + netplay_data->input_latency_frames > netplay_data->self_frame_count)
|
||||||
{
|
{
|
||||||
netplay_data->stall = NETPLAY_STALL_INPUT_LATENCY;
|
netplay_data->stall = NETPLAY_STALL_INPUT_LATENCY;
|
||||||
netplay_data->stall_time = 0;
|
netplay_data->stall_time = 0;
|
||||||
@ -320,7 +320,7 @@ static bool netplay_poll(void)
|
|||||||
|
|
||||||
/* Are we too far ahead? */
|
/* Are we too far ahead? */
|
||||||
if (netplay_data->unread_frame_count + NETPLAY_MAX_STALL_FRAMES
|
if (netplay_data->unread_frame_count + NETPLAY_MAX_STALL_FRAMES
|
||||||
<= netplay_data->input_frame_count)
|
<= netplay_data->self_frame_count)
|
||||||
{
|
{
|
||||||
netplay_data->stall = NETPLAY_STALL_RUNNING_FAST;
|
netplay_data->stall = NETPLAY_STALL_RUNNING_FAST;
|
||||||
netplay_data->stall_time = cpu_features_get_time_usec();
|
netplay_data->stall_time = cpu_features_get_time_usec();
|
||||||
@ -546,7 +546,7 @@ static void netplay_flip_users(netplay_t *netplay)
|
|||||||
{
|
{
|
||||||
/* Must be in the future because we may have
|
/* Must be in the future because we may have
|
||||||
* already sent this frame's data */
|
* already sent this frame's data */
|
||||||
uint32_t flip_frame = netplay->input_frame_count + 1;
|
uint32_t flip_frame = netplay->self_frame_count + 1;
|
||||||
uint32_t flip_frame_net = htonl(flip_frame);
|
uint32_t flip_frame_net = htonl(flip_frame);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -777,8 +777,8 @@ void netplay_load_savestate(netplay_t *netplay,
|
|||||||
|
|
||||||
/* Wherever we're inputting, that's where we consider our state to be loaded
|
/* Wherever we're inputting, that's where we consider our state to be loaded
|
||||||
* (FIXME: Need to be more careful about saving it?) */
|
* (FIXME: Need to be more careful about saving it?) */
|
||||||
netplay->run_ptr = netplay->input_ptr;
|
netplay->run_ptr = netplay->self_ptr;
|
||||||
netplay->run_frame_count = netplay->input_frame_count;
|
netplay->run_frame_count = netplay->self_frame_count;
|
||||||
|
|
||||||
/* Record it in our own buffer */
|
/* Record it in our own buffer */
|
||||||
if (save || !serial_info)
|
if (save || !serial_info)
|
||||||
@ -866,7 +866,7 @@ static void netplay_toggle_play_spectate(netplay_t *netplay)
|
|||||||
uint32_t payload[2];
|
uint32_t payload[2];
|
||||||
char msg[512];
|
char msg[512];
|
||||||
const char *dmsg = NULL;
|
const char *dmsg = NULL;
|
||||||
payload[0] = htonl(netplay->input_frame_count);
|
payload[0] = htonl(netplay->self_frame_count);
|
||||||
if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING)
|
if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING)
|
||||||
{
|
{
|
||||||
/* Mark us as no longer playing */
|
/* Mark us as no longer playing */
|
||||||
|
@ -518,7 +518,7 @@ bool netplay_handshake_sync(netplay_t *netplay, struct netplay_connection *conne
|
|||||||
cmd[0] = htonl(NETPLAY_CMD_SYNC);
|
cmd[0] = htonl(NETPLAY_CMD_SYNC);
|
||||||
cmd[1] = htonl(3*sizeof(uint32_t) + MAX_USERS*sizeof(uint32_t) +
|
cmd[1] = htonl(3*sizeof(uint32_t) + MAX_USERS*sizeof(uint32_t) +
|
||||||
NETPLAY_NICK_LEN + mem_info.size);
|
NETPLAY_NICK_LEN + mem_info.size);
|
||||||
cmd[2] = htonl(netplay->input_frame_count);
|
cmd[2] = htonl(netplay->self_frame_count);
|
||||||
connected_players = netplay->connected_players;
|
connected_players = netplay->connected_players;
|
||||||
if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING)
|
if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING)
|
||||||
connected_players |= 1<<netplay->self_player;
|
connected_players |= 1<<netplay->self_player;
|
||||||
@ -904,7 +904,7 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
|
|||||||
netplay->flip_frame = flip_frame;
|
netplay->flip_frame = flip_frame;
|
||||||
|
|
||||||
/* Set our frame counters as requested */
|
/* Set our frame counters as requested */
|
||||||
netplay->input_frame_count = netplay->run_frame_count =
|
netplay->self_frame_count = netplay->run_frame_count =
|
||||||
netplay->other_frame_count = netplay->unread_frame_count =
|
netplay->other_frame_count = netplay->unread_frame_count =
|
||||||
netplay->server_frame_count = new_frame_count;
|
netplay->server_frame_count = new_frame_count;
|
||||||
for (i = 0; i < netplay->buffer_size; i++)
|
for (i = 0; i < netplay->buffer_size; i++)
|
||||||
@ -912,7 +912,7 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
|
|||||||
struct delta_frame *ptr = &netplay->buffer[i];
|
struct delta_frame *ptr = &netplay->buffer[i];
|
||||||
ptr->used = false;
|
ptr->used = false;
|
||||||
|
|
||||||
if (i == netplay->input_ptr)
|
if (i == netplay->self_ptr)
|
||||||
{
|
{
|
||||||
/* Clear out any current data but still use this frame */
|
/* Clear out any current data but still use this frame */
|
||||||
if (!netplay_delta_frame_ready(netplay, ptr, 0))
|
if (!netplay_delta_frame_ready(netplay, ptr, 0))
|
||||||
@ -928,8 +928,8 @@ bool netplay_handshake_pre_sync(netplay_t *netplay,
|
|||||||
{
|
{
|
||||||
if (connected_players & (1<<i))
|
if (connected_players & (1<<i))
|
||||||
{
|
{
|
||||||
netplay->read_ptr[i] = netplay->input_ptr;
|
netplay->read_ptr[i] = netplay->self_ptr;
|
||||||
netplay->read_frame_count[i] = netplay->input_frame_count;
|
netplay->read_frame_count[i] = netplay->self_frame_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ static void print_state(netplay_t *netplay)
|
|||||||
#define APPEND(out) cur += snprintf out
|
#define APPEND(out) cur += snprintf out
|
||||||
#define M msg + cur, sizeof(msg) - cur
|
#define M msg + cur, sizeof(msg) - cur
|
||||||
|
|
||||||
APPEND((M, "NETPLAY: S:%u U:%u O:%u", netplay->input_frame_count, netplay->unread_frame_count, netplay->other_frame_count));
|
APPEND((M, "NETPLAY: S:%u U:%u O:%u", netplay->self_frame_count, netplay->unread_frame_count, netplay->other_frame_count));
|
||||||
if (!netplay->is_server)
|
if (!netplay->is_server)
|
||||||
APPEND((M, " H:%u", netplay->server_frame_count));
|
APPEND((M, " H:%u", netplay->server_frame_count));
|
||||||
for (player = 0; player < MAX_USERS; player++)
|
for (player = 0; player < MAX_USERS; player++)
|
||||||
@ -204,7 +204,7 @@ static bool send_input_frame(netplay_t *netplay,
|
|||||||
bool netplay_send_cur_input(netplay_t *netplay,
|
bool netplay_send_cur_input(netplay_t *netplay,
|
||||||
struct netplay_connection *connection)
|
struct netplay_connection *connection)
|
||||||
{
|
{
|
||||||
struct delta_frame *dframe = &netplay->buffer[netplay->input_ptr];
|
struct delta_frame *dframe = &netplay->buffer[netplay->self_ptr];
|
||||||
uint32_t player;
|
uint32_t player;
|
||||||
|
|
||||||
if (netplay->is_server)
|
if (netplay->is_server)
|
||||||
@ -220,7 +220,7 @@ bool netplay_send_cur_input(netplay_t *netplay,
|
|||||||
if (dframe->have_real[player])
|
if (dframe->have_real[player])
|
||||||
{
|
{
|
||||||
if (!send_input_frame(netplay, connection, NULL,
|
if (!send_input_frame(netplay, connection, NULL,
|
||||||
netplay->input_frame_count, player,
|
netplay->self_frame_count, player,
|
||||||
dframe->real_input_state[player]))
|
dframe->real_input_state[player]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ bool netplay_send_cur_input(netplay_t *netplay,
|
|||||||
/* If we're not playing, send a NOINPUT */
|
/* If we're not playing, send a NOINPUT */
|
||||||
if (netplay->self_mode != NETPLAY_CONNECTION_PLAYING)
|
if (netplay->self_mode != NETPLAY_CONNECTION_PLAYING)
|
||||||
{
|
{
|
||||||
uint32_t payload = htonl(netplay->input_frame_count);
|
uint32_t payload = htonl(netplay->self_frame_count);
|
||||||
if (!netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_NOINPUT,
|
if (!netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_NOINPUT,
|
||||||
&payload, sizeof(payload)))
|
&payload, sizeof(payload)))
|
||||||
return false;
|
return false;
|
||||||
@ -242,7 +242,7 @@ bool netplay_send_cur_input(netplay_t *netplay,
|
|||||||
if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING)
|
if (netplay->self_mode == NETPLAY_CONNECTION_PLAYING)
|
||||||
{
|
{
|
||||||
if (!send_input_frame(netplay, connection, NULL,
|
if (!send_input_frame(netplay, connection, NULL,
|
||||||
netplay->input_frame_count,
|
netplay->self_frame_count,
|
||||||
(netplay->is_server ? NETPLAY_CMD_INPUT_BIT_SERVER : 0) | netplay->self_player,
|
(netplay->is_server ? NETPLAY_CMD_INPUT_BIT_SERVER : 0) | netplay->self_player,
|
||||||
dframe->self_state))
|
dframe->self_state))
|
||||||
return false;
|
return false;
|
||||||
@ -505,7 +505,7 @@ static bool netplay_get_cmd(netplay_t *netplay,
|
|||||||
if (netplay->is_server)
|
if (netplay->is_server)
|
||||||
{
|
{
|
||||||
/* Forward it on if it's past data*/
|
/* Forward it on if it's past data*/
|
||||||
if (dframe->frame <= netplay->input_frame_count)
|
if (dframe->frame <= netplay->self_frame_count)
|
||||||
send_input_frame(netplay, NULL, connection, buffer[0],
|
send_input_frame(netplay, NULL, connection, buffer[0],
|
||||||
player, dframe->real_input_state[player]);
|
player, dframe->real_input_state[player]);
|
||||||
}
|
}
|
||||||
@ -585,7 +585,7 @@ static bool netplay_get_cmd(netplay_t *netplay,
|
|||||||
/* Force a rewind to assure the flip happens: This just prevents us
|
/* Force a rewind to assure the flip happens: This just prevents us
|
||||||
* from skipping other past the flip because our prediction was
|
* from skipping other past the flip because our prediction was
|
||||||
* correct */
|
* correct */
|
||||||
if (flip_frame < netplay->input_frame_count)
|
if (flip_frame < netplay->self_frame_count)
|
||||||
netplay->force_rewind = true;
|
netplay->force_rewind = true;
|
||||||
|
|
||||||
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_NETPLAY_USERS_HAS_FLIPPED));
|
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_NETPLAY_USERS_HAS_FLIPPED));
|
||||||
@ -638,7 +638,7 @@ static bool netplay_get_cmd(netplay_t *netplay,
|
|||||||
{
|
{
|
||||||
uint32_t payload[2];
|
uint32_t payload[2];
|
||||||
uint32_t player = 0;
|
uint32_t player = 0;
|
||||||
payload[0] = htonl(netplay->input_frame_count + 1);
|
payload[0] = htonl(netplay->self_frame_count + 1);
|
||||||
|
|
||||||
if (!netplay->is_server)
|
if (!netplay->is_server)
|
||||||
{
|
{
|
||||||
@ -695,8 +695,8 @@ static bool netplay_get_cmd(netplay_t *netplay,
|
|||||||
netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_MODE, payload, sizeof(payload));
|
netplay_send_raw_cmd(netplay, connection, NETPLAY_CMD_MODE, payload, sizeof(payload));
|
||||||
|
|
||||||
/* And expect their data */
|
/* And expect their data */
|
||||||
netplay->read_ptr[player] = NEXT_PTR(netplay->input_ptr);
|
netplay->read_ptr[player] = NEXT_PTR(netplay->self_ptr);
|
||||||
netplay->read_frame_count[player] = netplay->input_frame_count + 1;
|
netplay->read_frame_count[player] = netplay->self_frame_count + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,7 +734,7 @@ static bool netplay_get_cmd(netplay_t *netplay,
|
|||||||
frame = ntohl(payload[0]);
|
frame = ntohl(payload[0]);
|
||||||
|
|
||||||
/* We're changing past input, so must replay it */
|
/* We're changing past input, so must replay it */
|
||||||
if (frame < netplay->input_frame_count)
|
if (frame < netplay->self_frame_count)
|
||||||
netplay->force_rewind = true;
|
netplay->force_rewind = true;
|
||||||
|
|
||||||
mode = ntohl(payload[1]);
|
mode = ntohl(payload[1]);
|
||||||
@ -767,16 +767,16 @@ static bool netplay_get_cmd(netplay_t *netplay,
|
|||||||
netplay->self_player = player;
|
netplay->self_player = player;
|
||||||
|
|
||||||
/* Fix up current frame info */
|
/* Fix up current frame info */
|
||||||
if (frame <= netplay->input_frame_count)
|
if (frame <= netplay->self_frame_count)
|
||||||
{
|
{
|
||||||
/* It wanted past frames, better send 'em! */
|
/* It wanted past frames, better send 'em! */
|
||||||
START(netplay->server_ptr);
|
START(netplay->server_ptr);
|
||||||
while (dframe->used && dframe->frame <= netplay->input_frame_count)
|
while (dframe->used && dframe->frame <= netplay->self_frame_count)
|
||||||
{
|
{
|
||||||
memcpy(dframe->real_input_state[player], dframe->self_state, sizeof(dframe->self_state));
|
memcpy(dframe->real_input_state[player], dframe->self_state, sizeof(dframe->self_state));
|
||||||
dframe->have_real[player] = true;
|
dframe->have_real[player] = true;
|
||||||
send_input_frame(netplay, connection, NULL, dframe->frame, player, dframe->self_state);
|
send_input_frame(netplay, connection, NULL, dframe->frame, player, dframe->self_state);
|
||||||
if (dframe->frame == netplay->input_frame_count) break;
|
if (dframe->frame == netplay->self_frame_count) break;
|
||||||
NEXT();
|
NEXT();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,8 +786,8 @@ static bool netplay_get_cmd(netplay_t *netplay,
|
|||||||
uint32_t frame_count;
|
uint32_t frame_count;
|
||||||
|
|
||||||
/* It wants future frames, make sure we don't capture or send intermediate ones */
|
/* It wants future frames, make sure we don't capture or send intermediate ones */
|
||||||
START(netplay->input_ptr);
|
START(netplay->self_ptr);
|
||||||
frame_count = netplay->input_frame_count;
|
frame_count = netplay->self_frame_count;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (!dframe->used)
|
if (!dframe->used)
|
||||||
@ -1143,10 +1143,10 @@ static bool netplay_get_cmd(netplay_t *netplay,
|
|||||||
* will make the other side unhappy. */
|
* will make the other side unhappy. */
|
||||||
netplay->run_ptr = PREV_PTR(netplay->read_ptr[connection->player]);
|
netplay->run_ptr = PREV_PTR(netplay->read_ptr[connection->player]);
|
||||||
netplay->run_frame_count = frame - 1;
|
netplay->run_frame_count = frame - 1;
|
||||||
if (frame > netplay->input_frame_count)
|
if (frame > netplay->self_frame_count)
|
||||||
{
|
{
|
||||||
netplay->input_ptr = netplay->run_ptr;
|
netplay->self_ptr = netplay->run_ptr;
|
||||||
netplay->input_frame_count = netplay->run_frame_count;
|
netplay->self_frame_count = netplay->run_frame_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1353,7 +1353,7 @@ int netplay_poll_net_input(netplay_t *netplay, bool block)
|
|||||||
*/
|
*/
|
||||||
bool netplay_flip_port(netplay_t *netplay)
|
bool netplay_flip_port(netplay_t *netplay)
|
||||||
{
|
{
|
||||||
size_t frame = netplay->input_frame_count;
|
size_t frame = netplay->self_frame_count;
|
||||||
|
|
||||||
if (netplay->flip_frame == 0)
|
if (netplay->flip_frame == 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -359,10 +359,11 @@ struct netplay
|
|||||||
size_t packet_buffer_size;
|
size_t packet_buffer_size;
|
||||||
|
|
||||||
/* The frame we're currently inputting */
|
/* The frame we're currently inputting */
|
||||||
size_t input_ptr;
|
size_t self_ptr;
|
||||||
uint32_t input_frame_count;
|
uint32_t self_frame_count;
|
||||||
|
|
||||||
/* The frame we're currently running */
|
/* The frame we're currently running, which may be behind the frame we're
|
||||||
|
* currently inputting if we're using input latency */
|
||||||
size_t run_ptr;
|
size_t run_ptr;
|
||||||
uint32_t run_frame_count;
|
uint32_t run_frame_count;
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ void netplay_update_unread_ptr(netplay_t *netplay)
|
|||||||
if (netplay->is_server && !netplay->connected_players)
|
if (netplay->is_server && !netplay->connected_players)
|
||||||
{
|
{
|
||||||
/* Nothing at all to read! */
|
/* Nothing at all to read! */
|
||||||
netplay->unread_ptr = netplay->input_ptr;
|
netplay->unread_ptr = netplay->self_ptr;
|
||||||
netplay->unread_frame_count = netplay->input_frame_count;
|
netplay->unread_frame_count = netplay->self_frame_count;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -203,13 +203,13 @@ bool netplay_sync_pre_frame(netplay_t *netplay)
|
|||||||
{
|
{
|
||||||
/* Bring our running frame and input frames into parity so we don't
|
/* Bring our running frame and input frames into parity so we don't
|
||||||
* send old info */
|
* send old info */
|
||||||
if (netplay->run_ptr != netplay->input_ptr)
|
if (netplay->run_ptr != netplay->self_ptr)
|
||||||
{
|
{
|
||||||
memcpy(netplay->buffer[netplay->input_ptr].state,
|
memcpy(netplay->buffer[netplay->self_ptr].state,
|
||||||
netplay->buffer[netplay->run_ptr].state,
|
netplay->buffer[netplay->run_ptr].state,
|
||||||
netplay->state_size);
|
netplay->state_size);
|
||||||
netplay->run_ptr = netplay->input_ptr;
|
netplay->run_ptr = netplay->self_ptr;
|
||||||
netplay->run_frame_count = netplay->input_frame_count;
|
netplay->run_frame_count = netplay->self_frame_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send this along to the other side */
|
/* Send this along to the other side */
|
||||||
@ -372,20 +372,20 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
|
|||||||
netplay->run_frame_count++;
|
netplay->run_frame_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We've finished an input frame even if we're stalling, unless we're too
|
/* We've finished an input frame even if we're stalling */
|
||||||
* far ahead of ourselves */
|
if ((!stalled || netplay->stall == NETPLAY_STALL_INPUT_LATENCY) &&
|
||||||
if (netplay->input_frame_count < netplay->run_frame_count + netplay->input_latency_frames)
|
netplay->self_frame_count < netplay->run_frame_count + netplay->input_latency_frames)
|
||||||
{
|
{
|
||||||
netplay->input_ptr = NEXT_PTR(netplay->input_ptr);
|
netplay->self_ptr = NEXT_PTR(netplay->self_ptr);
|
||||||
netplay->input_frame_count++;
|
netplay->self_frame_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only relevant if we're connected */
|
/* Only relevant if we're connected */
|
||||||
if ((netplay->is_server && !netplay->connected_players) ||
|
if ((netplay->is_server && !netplay->connected_players) ||
|
||||||
(netplay->self_mode < NETPLAY_CONNECTION_CONNECTED))
|
(netplay->self_mode < NETPLAY_CONNECTION_CONNECTED))
|
||||||
{
|
{
|
||||||
netplay->other_frame_count = netplay->input_frame_count;
|
netplay->other_frame_count = netplay->self_frame_count;
|
||||||
netplay->other_ptr = netplay->input_ptr;
|
netplay->other_ptr = netplay->self_ptr;
|
||||||
/* FIXME: Duplication */
|
/* FIXME: Duplication */
|
||||||
if (netplay->catch_up)
|
if (netplay->catch_up)
|
||||||
{
|
{
|
||||||
@ -539,7 +539,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
|
|||||||
if (netplay->catch_up)
|
if (netplay->catch_up)
|
||||||
{
|
{
|
||||||
/* Are we caught up? */
|
/* Are we caught up? */
|
||||||
if (netplay->input_frame_count >= lo_frame_count)
|
if (netplay->self_frame_count >= lo_frame_count)
|
||||||
{
|
{
|
||||||
netplay->catch_up = false;
|
netplay->catch_up = false;
|
||||||
input_driver_unset_nonblock_state();
|
input_driver_unset_nonblock_state();
|
||||||
@ -549,7 +549,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
|
|||||||
}
|
}
|
||||||
else if (!stalled)
|
else if (!stalled)
|
||||||
{
|
{
|
||||||
if (netplay->input_frame_count + 2 < lo_frame_count)
|
if (netplay->self_frame_count + 2 < lo_frame_count)
|
||||||
{
|
{
|
||||||
/* Are we falling behind? */
|
/* Are we falling behind? */
|
||||||
netplay->catch_up = true;
|
netplay->catch_up = true;
|
||||||
@ -557,7 +557,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
|
|||||||
driver_set_nonblock_state();
|
driver_set_nonblock_state();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (netplay->input_frame_count + 2 < hi_frame_count)
|
else if (netplay->self_frame_count + 2 < hi_frame_count)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -573,16 +573,16 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
|
|||||||
player = connection->player;
|
player = connection->player;
|
||||||
|
|
||||||
/* Are they ahead? */
|
/* Are they ahead? */
|
||||||
if (netplay->input_frame_count + 2 < netplay->read_frame_count[player])
|
if (netplay->self_frame_count + 2 < netplay->read_frame_count[player])
|
||||||
{
|
{
|
||||||
/* Tell them to stall */
|
/* Tell them to stall */
|
||||||
if (connection->stall_frame + NETPLAY_MAX_REQ_STALL_FREQUENCY <
|
if (connection->stall_frame + NETPLAY_MAX_REQ_STALL_FREQUENCY <
|
||||||
netplay->input_frame_count)
|
netplay->self_frame_count)
|
||||||
{
|
{
|
||||||
connection->stall_frame = netplay->input_frame_count;
|
connection->stall_frame = netplay->self_frame_count;
|
||||||
netplay_cmd_stall(netplay, connection,
|
netplay_cmd_stall(netplay, connection,
|
||||||
netplay->read_frame_count[player] -
|
netplay->read_frame_count[player] -
|
||||||
netplay->input_frame_count + 1);
|
netplay->self_frame_count + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user