From 8f0a47e6c314f367e09557d09ee39b2248581d8e Mon Sep 17 00:00:00 2001 From: Themaister Date: Sat, 21 Jan 2012 16:14:10 +0100 Subject: [PATCH] Small cleanup. --- netplay.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/netplay.c b/netplay.c index 80fe12acec..0f26e9448f 100644 --- a/netplay.c +++ b/netplay.c @@ -115,6 +115,7 @@ struct netplay uint32_t frame_count; uint32_t read_frame_count; uint32_t other_frame_count; + uint32_t tmp_frame_count; struct addrinfo *addr; struct sockaddr_storage their_addr; bool has_client_addr; @@ -970,15 +971,7 @@ static bool netplay_flip_port(netplay_t *handle, bool port) if (handle->flip_frame == 0) return port; - size_t frame = 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); - } + size_t frame = handle->is_replay ? handle->tmp_frame_count : handle->frame_count; return port ^ handle->flip ^ (frame < handle->flip_frame); } @@ -1198,6 +1191,8 @@ static void netplay_post_frame_net(netplay_t *handle) // Replay frames handle->is_replay = true; 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); bool first = true; while (first || (handle->tmp_ptr != handle->self_ptr)) @@ -1211,8 +1206,10 @@ static void netplay_post_frame_net(netplay_t *handle) unlock_autosave(); #endif handle->tmp_ptr = NEXT_PTR(handle->tmp_ptr); + handle->tmp_frame_count++; first = false; } + handle->other_ptr = handle->read_ptr; handle->other_frame_count = handle->read_frame_count; handle->is_replay = false;