mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-29 03:00:24 +00:00
Better error messages when the Netplay handshake fails
This commit is contained in:
parent
0c74d19112
commit
98f0d4d45b
@ -170,7 +170,7 @@ bool netplay_handshake(netplay_t *netplay)
|
||||
bool is_server = netplay->is_server;
|
||||
int compression = 0;
|
||||
|
||||
msg[0] = '\0';
|
||||
msg[0] = msg[sizeof(msg)-1] = '\0';
|
||||
|
||||
mem_info.id = RETRO_MEMORY_SAVE_RAM;
|
||||
|
||||
@ -190,22 +190,21 @@ bool netplay_handshake(netplay_t *netplay)
|
||||
|
||||
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;
|
||||
strncpy(msg, msg_hash_to_str(MSG_FAILED_TO_RECEIVE_HEADER_FROM_CLIENT), sizeof(msg)-1);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (*content_crc_ptr != ntohl(header[0]))
|
||||
{
|
||||
RARCH_ERR("%s\n", msg_hash_to_str(MSG_CONTENT_CRC32S_DIFFER));
|
||||
return false;
|
||||
strncpy(msg, msg_hash_to_str(MSG_CONTENT_CRC32S_DIFFER), sizeof(msg)-1);
|
||||
goto error;
|
||||
}
|
||||
|
||||
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;
|
||||
strncpy(msg, "Implementations differ. Make sure you're using exact same "
|
||||
"libretro implementations and RetroArch version.", sizeof(msg)-1);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Some cores only report the correct sram size late, so we can't actually
|
||||
@ -223,13 +222,17 @@ bool netplay_handshake(netplay_t *netplay)
|
||||
netplay_endian_mismatch(local_pmagic, remote_pmagic))
|
||||
{
|
||||
RARCH_ERR("Endianness mismatch with an endian-sensitive core.\n");
|
||||
return false;
|
||||
strncpy(msg, "This core does not support inter-architecture netplay "
|
||||
"between these systems.", sizeof(msg)-1);
|
||||
goto error;
|
||||
}
|
||||
if ((netplay->quirks & NETPLAY_QUIRK_PLATFORM_DEPENDENT) &&
|
||||
(local_pmagic != remote_pmagic))
|
||||
{
|
||||
RARCH_ERR("Platform mismatch with a platform-sensitive core.\n");
|
||||
return false;
|
||||
strncpy(msg, "This core does not support inter-architecture netplay.",
|
||||
sizeof(msg)-1);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Clear any existing compression */
|
||||
@ -267,21 +270,22 @@ bool netplay_handshake(netplay_t *netplay)
|
||||
{
|
||||
if (!netplay_send_nickname(netplay, netplay->fd))
|
||||
{
|
||||
RARCH_ERR("%s\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_SEND_NICKNAME_TO_HOST));
|
||||
return false;
|
||||
strncpy(msg, msg_hash_to_str(MSG_FAILED_TO_SEND_NICKNAME_TO_HOST),
|
||||
sizeof(msg)-1);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (!netplay_get_nickname(netplay, netplay->fd))
|
||||
{
|
||||
if (is_server)
|
||||
RARCH_ERR("%s\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_GET_NICKNAME_FROM_CLIENT));
|
||||
strncpy(msg, msg_hash_to_str(MSG_FAILED_TO_GET_NICKNAME_FROM_CLIENT),
|
||||
sizeof(msg)-1);
|
||||
else
|
||||
RARCH_ERR("%s\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_RECEIVE_NICKNAME_FROM_HOST));
|
||||
return false;
|
||||
strncpy(msg,
|
||||
msg_hash_to_str(MSG_FAILED_TO_RECEIVE_NICKNAME_FROM_HOST),
|
||||
sizeof(msg)-1);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (is_server)
|
||||
@ -378,6 +382,14 @@ bool netplay_handshake(netplay_t *netplay)
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (msg[0])
|
||||
{
|
||||
RARCH_ERR("%s\n", msg);
|
||||
runloop_msg_queue_push(msg, 1, 180, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool netplay_is_server(netplay_t* netplay)
|
||||
|
Loading…
Reference in New Issue
Block a user