mirror of
https://github.com/libretro/RetroArch
synced 2025-02-25 21:41:03 +00:00
Small cleanup.
This commit is contained in:
parent
20528b9d1f
commit
8f0a47e6c3
15
netplay.c
15
netplay.c
@ -115,6 +115,7 @@ struct netplay
|
|||||||
uint32_t frame_count;
|
uint32_t frame_count;
|
||||||
uint32_t read_frame_count;
|
uint32_t read_frame_count;
|
||||||
uint32_t other_frame_count;
|
uint32_t other_frame_count;
|
||||||
|
uint32_t tmp_frame_count;
|
||||||
struct addrinfo *addr;
|
struct addrinfo *addr;
|
||||||
struct sockaddr_storage their_addr;
|
struct sockaddr_storage their_addr;
|
||||||
bool has_client_addr;
|
bool has_client_addr;
|
||||||
@ -970,15 +971,7 @@ static bool netplay_flip_port(netplay_t *handle, bool port)
|
|||||||
if (handle->flip_frame == 0)
|
if (handle->flip_frame == 0)
|
||||||
return port;
|
return port;
|
||||||
|
|
||||||
size_t frame = handle->frame_count;
|
size_t frame = handle->is_replay ? handle->tmp_frame_count : handle->frame_count;
|
||||||
if (handle->is_replay)
|
|
||||||
{
|
|
||||||
size_t self = PREV_PTR(handle->self_ptr);
|
|
||||||
if (self >= handle->tmp_ptr)
|
|
||||||
frame = frame + handle->tmp_ptr - self;
|
|
||||||
else
|
|
||||||
frame = frame + handle->tmp_ptr - (self + handle->buffer_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
return port ^ handle->flip ^ (frame < handle->flip_frame);
|
return port ^ handle->flip ^ (frame < handle->flip_frame);
|
||||||
}
|
}
|
||||||
@ -1198,6 +1191,8 @@ static void netplay_post_frame_net(netplay_t *handle)
|
|||||||
// Replay frames
|
// Replay frames
|
||||||
handle->is_replay = true;
|
handle->is_replay = true;
|
||||||
handle->tmp_ptr = handle->other_ptr;
|
handle->tmp_ptr = handle->other_ptr;
|
||||||
|
handle->tmp_frame_count = handle->other_frame_count;
|
||||||
|
|
||||||
psnes_unserialize(handle->buffer[handle->other_ptr].state, handle->state_size);
|
psnes_unserialize(handle->buffer[handle->other_ptr].state, handle->state_size);
|
||||||
bool first = true;
|
bool first = true;
|
||||||
while (first || (handle->tmp_ptr != handle->self_ptr))
|
while (first || (handle->tmp_ptr != handle->self_ptr))
|
||||||
@ -1211,8 +1206,10 @@ static void netplay_post_frame_net(netplay_t *handle)
|
|||||||
unlock_autosave();
|
unlock_autosave();
|
||||||
#endif
|
#endif
|
||||||
handle->tmp_ptr = NEXT_PTR(handle->tmp_ptr);
|
handle->tmp_ptr = NEXT_PTR(handle->tmp_ptr);
|
||||||
|
handle->tmp_frame_count++;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->other_ptr = handle->read_ptr;
|
handle->other_ptr = handle->read_ptr;
|
||||||
handle->other_frame_count = handle->read_frame_count;
|
handle->other_frame_count = handle->read_frame_count;
|
||||||
handle->is_replay = false;
|
handle->is_replay = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user