mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
When we replay, resimulate input so that it doesn't judder between
remote states
This commit is contained in:
parent
83be6daa93
commit
fcd57801bd
@ -554,13 +554,17 @@ static int poll_input(netplay_t *netplay, bool block)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Somewhat better prediction. :P */
|
/**
|
||||||
static void simulate_input(netplay_t *netplay)
|
* netplay_simulate_input:
|
||||||
|
* @netplay : pointer to netplay object
|
||||||
|
* @sim_ptr : frame index for which to simulate input
|
||||||
|
*
|
||||||
|
* "Simulate" input by assuming it hasn't changed since the last read input.
|
||||||
|
*/
|
||||||
|
void netplay_simulate_input(netplay_t *netplay, uint32_t sim_ptr)
|
||||||
{
|
{
|
||||||
size_t ptr = netplay->self_ptr;
|
|
||||||
size_t prev = PREV_PTR(netplay->read_ptr);
|
size_t prev = PREV_PTR(netplay->read_ptr);
|
||||||
|
memcpy(netplay->buffer[sim_ptr].simulated_input_state,
|
||||||
memcpy(netplay->buffer[ptr].simulated_input_state,
|
|
||||||
netplay->buffer[prev].real_input_state,
|
netplay->buffer[prev].real_input_state,
|
||||||
sizeof(netplay->buffer[prev].real_input_state));
|
sizeof(netplay->buffer[prev].real_input_state));
|
||||||
}
|
}
|
||||||
@ -603,7 +607,7 @@ static bool netplay_poll(netplay_t *netplay)
|
|||||||
|
|
||||||
/* Simulate the input if we don't have real input */
|
/* Simulate the input if we don't have real input */
|
||||||
if (!netplay->buffer[netplay->self_ptr].have_remote)
|
if (!netplay->buffer[netplay->self_ptr].have_remote)
|
||||||
simulate_input(netplay);
|
netplay_simulate_input(netplay, netplay->self_ptr);
|
||||||
|
|
||||||
/* Consider stalling */
|
/* Consider stalling */
|
||||||
switch (netplay->stall) {
|
switch (netplay->stall) {
|
||||||
|
@ -214,9 +214,14 @@ static void netplay_net_post_frame(netplay_t *netplay)
|
|||||||
serial_info.size = netplay->state_size;
|
serial_info.size = netplay->state_size;
|
||||||
serial_info.data_const = NULL;
|
serial_info.data_const = NULL;
|
||||||
|
|
||||||
|
/* Remember the current state */
|
||||||
core_serialize(&serial_info);
|
core_serialize(&serial_info);
|
||||||
|
if (netplay->replay_frame_count < netplay->read_frame_count)
|
||||||
|
netplay_handle_frame_hash(netplay, ptr);
|
||||||
|
|
||||||
netplay_handle_frame_hash(netplay, ptr);
|
/* Simulate this frame's input */
|
||||||
|
if (netplay->replay_frame_count >= netplay->read_frame_count)
|
||||||
|
netplay_simulate_input(netplay, netplay->replay_ptr);
|
||||||
|
|
||||||
#if defined(HAVE_THREADS)
|
#if defined(HAVE_THREADS)
|
||||||
autosave_lock();
|
autosave_lock();
|
||||||
|
@ -177,6 +177,8 @@ struct netplay_callbacks* netplay_get_cbs_net(void);
|
|||||||
|
|
||||||
struct netplay_callbacks* netplay_get_cbs_spectate(void);
|
struct netplay_callbacks* netplay_get_cbs_spectate(void);
|
||||||
|
|
||||||
|
void netplay_simulate_input(netplay_t *netplay, uint32_t sim_ptr);
|
||||||
|
|
||||||
void netplay_log_connection(const struct sockaddr_storage *their_addr,
|
void netplay_log_connection(const struct sockaddr_storage *their_addr,
|
||||||
unsigned slot, const char *nick);
|
unsigned slot, const char *nick);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user