Fixing some counters.

This commit is contained in:
Gregor Richards 2017-09-09 22:04:31 -04:00
parent d1ca90e136
commit 8c551f3990
3 changed files with 28 additions and 12 deletions

View File

@ -164,7 +164,10 @@ static bool get_self_input_state(netplay_t *netplay)
}
}
ptr->have_real[netplay->self_client_num] = true;
ptr->have_local = true;
netplay->read_ptr1[netplay->self_client_num] = NEXT_PTR(netplay->self_ptr);
netplay->read_frame_count1[netplay->self_client_num] = netplay->self_frame_count + 1;
/* And send this input to our peers */
for (i = 0; i < netplay->connections_size; i++)
@ -1174,6 +1177,8 @@ static void netplay_toggle_play_spectate(netplay_t *netplay)
netplay->connected_players1 |= 1;
netplay->client_devices[0] = netplay->self_devices = (1<<device);
netplay->device_clients[device] = 1;
netplay->read_ptr1[0] = netplay->self_ptr;
netplay->read_frame_count1[0] = netplay->self_frame_count;
dmsg = msg;
msg[sizeof(msg)-1] = '\0';

View File

@ -48,7 +48,6 @@ static void print_state(netplay_t *netplay)
if ((netplay->connected_players1 & (1<<client)))
APPEND((M, " %u:%u", client, netplay->read_frame_count1[client]));
}
APPEND((M, "\n"));
msg[sizeof(msg)-1] = '\0';
RARCH_LOG("%s\n", msg);
@ -241,6 +240,7 @@ static bool send_input_frame(netplay_t *netplay, struct delta_frame *dframe,
#ifdef DEBUG_NETPLAY_STEPS
RARCH_LOG("Sending input for client %u\n", (unsigned) client_num);
print_state(netplay);
#endif
if (only)
@ -288,10 +288,10 @@ bool netplay_send_cur_input(netplay_t *netplay,
size_t i;
netplay_input_state_t istate;
to_client = connection - netplay->connections + 1;
if (netplay->is_server)
{
to_client = connection - netplay->connections + 1;
/* Send the other players' input data (FIXME: This involves an
* unacceptable amount of recalculating) */
for (from_client = 1; from_client < MAX_CLIENTS; from_client++)
@ -359,6 +359,8 @@ bool netplay_send_raw_cmd(netplay_t *netplay,
if (!netplay_send(&connection->send_packet_buffer, connection->fd, data, size))
return false;
netplay_send_flush(&connection->send_packet_buffer, connection->fd, true);
return true;
}
@ -659,8 +661,8 @@ static bool netplay_get_cmd(netplay_t *netplay,
/* If this was server data, advance our server pointer too */
if (!netplay->is_server && client_num == 0)
{
netplay->server_ptr = netplay->read_ptr1[client_num];
netplay->server_frame_count = netplay->read_frame_count1[client_num];
netplay->server_ptr = netplay->read_ptr1[0];
netplay->server_frame_count = netplay->read_frame_count1[0];
}
#ifdef DEBUG_NETPLAY_STEPS
@ -702,6 +704,10 @@ static bool netplay_get_cmd(netplay_t *netplay,
netplay->server_ptr = NEXT_PTR(netplay->server_ptr);
netplay->server_frame_count++;
#ifdef DEBUG_NETPLAY_STEPS
RARCH_LOG("Received server noinput\n");
print_state(netplay);
#endif
break;
}
@ -989,19 +995,22 @@ static bool netplay_get_cmd(netplay_t *netplay,
/* Fix up current frame info */
if (frame <= netplay->self_frame_count)
{
/* FIXME: Must generate frames with 0 data */
#if 0
/* It wanted past frames, better send 'em! */
START(netplay->server_ptr);
while (dframe->used && dframe->frame <= netplay->self_frame_count)
{
memcpy(dframe->real_input_state[player], dframe->self_state, sizeof(dframe->self_state));
dframe->have_real[player] = true;
send_input_frame(netplay, connection, NULL, dframe->frame, player, dframe->self_state);
for (device = 0; device < MAX_INPUT_DEVICES; device++)
{
if (!(devices & (1<<device))) continue;
netplay_input_state_t istate = netplay_input_state_for(&dframe->real_input[device], client_num, 3 /* FIXME */, true);
memset(istate->data, 0, istate->size*sizeof(uint32_t));
}
dframe->have_local = true;
dframe->have_real[client_num] = true;
send_input_frame(netplay, dframe, connection, NULL, client_num);
if (dframe->frame == netplay->self_frame_count) break;
NEXT();
}
#endif
}
else

View File

@ -416,7 +416,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
}
/* Only relevant if we're connected and not in a desynching operation */
if ((netplay->is_server && (netplay->connected_players1>1)) ||
if ((netplay->is_server && (netplay->connected_players1<=1)) ||
(netplay->self_mode < NETPLAY_CONNECTION_CONNECTED) ||
(netplay->desync))
{
@ -440,6 +440,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
}
#ifndef DEBUG_NONDETERMINISTIC_CORES
#if 0 /* FIXME: netplay_resolve_input is broken */
if (!netplay->force_rewind)
{
/* Skip ahead if we predicted correctly.
@ -459,6 +460,7 @@ void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
netplay->other_frame_count++;
}
}
#endif
#endif
/* Now replay the real input if we've gotten ahead of it */