mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-29 03:00:24 +00:00
Both sides should send the same header so either can check the other
This commit is contained in:
parent
55b865d375
commit
4a83e6dee9
@ -144,6 +144,32 @@ bool netplay_send_info(netplay_t *netplay)
|
||||
if (!socket_send_all_blocking(netplay->fd, header, sizeof(header), false))
|
||||
return false;
|
||||
|
||||
if (!socket_receive_all_blocking(netplay->fd, header, sizeof(header)))
|
||||
{
|
||||
RARCH_ERR("%s\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_RECEIVE_HEADER_FROM_CLIENT));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*content_crc_ptr != ntohl(header[0]))
|
||||
{
|
||||
RARCH_ERR("%s\n", msg_hash_to_str(MSG_CONTENT_CRC32S_DIFFER));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (netplay_impl_magic() != ntohl(header[1]))
|
||||
{
|
||||
RARCH_ERR("Implementations differ, make sure you're using exact same "
|
||||
"libretro implementations and RetroArch version.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mem_info.size != ntohl(header[2]))
|
||||
{
|
||||
RARCH_ERR("Content SRAM sizes do not correspond.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!netplay_send_nickname(netplay, netplay->fd))
|
||||
{
|
||||
RARCH_ERR("%s\n",
|
||||
@ -187,6 +213,18 @@ bool netplay_get_info(netplay_t *netplay)
|
||||
const void *sram = NULL;
|
||||
size_t i;
|
||||
|
||||
mem_info.id = RETRO_MEMORY_SAVE_RAM;
|
||||
|
||||
core_get_memory(&mem_info);
|
||||
content_get_crc(&content_crc_ptr);
|
||||
|
||||
header[0] = htonl(*content_crc_ptr);
|
||||
header[1] = htonl(netplay_impl_magic());
|
||||
header[2] = htonl(mem_info.size);
|
||||
|
||||
if (!socket_send_all_blocking(netplay->fd, header, sizeof(header), false))
|
||||
return false;
|
||||
|
||||
if (!socket_receive_all_blocking(netplay->fd, header, sizeof(header)))
|
||||
{
|
||||
RARCH_ERR("%s\n",
|
||||
@ -194,8 +232,6 @@ bool netplay_get_info(netplay_t *netplay)
|
||||
return false;
|
||||
}
|
||||
|
||||
content_get_crc(&content_crc_ptr);
|
||||
|
||||
if (*content_crc_ptr != ntohl(header[0]))
|
||||
{
|
||||
RARCH_ERR("%s\n", msg_hash_to_str(MSG_CONTENT_CRC32S_DIFFER));
|
||||
@ -209,10 +245,6 @@ bool netplay_get_info(netplay_t *netplay)
|
||||
return false;
|
||||
}
|
||||
|
||||
mem_info.id = RETRO_MEMORY_SAVE_RAM;
|
||||
|
||||
core_get_memory(&mem_info);
|
||||
|
||||
if (mem_info.size != ntohl(header[2]))
|
||||
{
|
||||
RARCH_ERR("Content SRAM sizes do not correspond.\n");
|
||||
|
Loading…
Reference in New Issue
Block a user