(Netplay) Disable netplay for unsupported cores (#13916)

With stateless mode being disabled for now, there is no reason not to include this.

Refuse to initialize netplay when the current core is not supported (no proper savestates support).
This commit is contained in:
Cthulhu-throwaway 2022-05-05 23:31:37 -03:00 committed by GitHub
parent 5a85748de6
commit 9a3b8f4a0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 13 deletions

View File

@ -12194,6 +12194,10 @@ MSG_HASH(
MSG_NETPLAY_FAILED,
"Failed to initialize netplay."
)
MSG_HASH(
MSG_NETPLAY_UNSUPPORTED,
"Core does not support netplay."
)
MSG_HASH(
MSG_NO_CONTENT_STARTING_DUMMY_CORE,
"No content, starting dummy core."

View File

@ -184,6 +184,7 @@ enum msg_hash_enums
MSG_NETPLAY_HOST_FULL,
MSG_FAILED_TO_RECEIVE_HEADER_FROM_HOST,
MSG_NETPLAY_FAILED,
MSG_NETPLAY_UNSUPPORTED,
MSG_UNKNOWN_NETPLAY_COMMAND_RECEIVED,
MSG_CONNECTING_TO_NETPLAY_HOST,
MSG_NETPLAY_LAN_SCAN_COMPLETE,

View File

@ -8277,20 +8277,29 @@ bool init_netplay(const char *server, unsigned port, const char *mitm_session)
if (!net_st->netplay_enabled)
return false;
#ifdef HAVE_NETPLAYDISCOVERY
net_st->lan_ad_server_fd = -1;
#endif
serialization_quirks = core_serialization_quirks();
if (!core_info_current_supports_netplay() ||
serialization_quirks & ~((uint64_t) NETPLAY_QUIRK_MAP_UNDERSTOOD) ||
serialization_quirks & NETPLAY_QUIRK_MAP_NO_SAVESTATES ||
serialization_quirks & NETPLAY_QUIRK_MAP_NO_TRANSMISSION)
{
RARCH_ERR("[Netplay] %s\n", msg_hash_to_str(MSG_NETPLAY_UNSUPPORTED));
runloop_msg_queue_push(
msg_hash_to_str(MSG_NETPLAY_UNSUPPORTED), 0, 180, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
goto failure;
}
core_set_default_callbacks(&cbs);
if (!core_set_netplay_callbacks())
goto failure;
/* Map the core's quirks to our quirks */
serialization_quirks = core_serialization_quirks();
/* Quirks we don't support! Just disable everything. */
if (serialization_quirks & ~((uint64_t) NETPLAY_QUIRK_MAP_UNDERSTOOD))
quirks |= NETPLAY_QUIRK_NO_SAVESTATES;
if (serialization_quirks & NETPLAY_QUIRK_MAP_NO_SAVESTATES)
quirks |= NETPLAY_QUIRK_NO_SAVESTATES;
if (serialization_quirks & NETPLAY_QUIRK_MAP_NO_TRANSMISSION)
quirks |= NETPLAY_QUIRK_NO_TRANSMISSION;
if (serialization_quirks & NETPLAY_QUIRK_MAP_INITIALIZATION)
quirks |= NETPLAY_QUIRK_INITIALIZATION;
if (serialization_quirks & NETPLAY_QUIRK_MAP_ENDIAN_DEPENDENT)
@ -8343,10 +8352,6 @@ bool init_netplay(const char *server, unsigned port, const char *mitm_session)
net_st->netplay_client_deferred = false;
#ifdef HAVE_NETPLAYDISCOVERY
net_st->lan_ad_server_fd = -1;
#endif
net_st->chat = (struct netplay_chat*)calloc(1, sizeof(*net_st->chat));
if (!net_st->chat)
goto failure;