From 34af0d3452192a5d880a0b305d7fd31e9375da52 Mon Sep 17 00:00:00 2001 From: Hamish Milne Date: Sat, 11 Apr 2020 20:33:38 +0100 Subject: [PATCH] Attempt to fix network bug --- src/core/hle/service/nwm/nwm_uds.cpp | 3 +++ src/core/savestate.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 1a95d2295..8ebb8a6e3 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -504,6 +504,9 @@ void NWM_UDS::HandleDataFrame(const Network::WifiPacket& packet) { /// Callback to parse and handle a received wifi packet. void NWM_UDS::OnWifiPacketReceived(const Network::WifiPacket& packet) { + if (!initialized) { + return; + } switch (packet.type) { case Network::WifiPacket::PacketType::Beacon: HandleBeaconFrame(packet); diff --git a/src/core/savestate.cpp b/src/core/savestate.cpp index ece6406a1..2a6fb92cb 100644 --- a/src/core/savestate.cpp +++ b/src/core/savestate.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include "common/archives.h" #include "common/logging/log.h" @@ -11,6 +12,7 @@ #include "core/cheats/cheats.h" #include "core/core.h" #include "core/savestate.h" +#include "network/network.h" #include "video_core/video_core.h" namespace Core { @@ -23,6 +25,11 @@ struct CSTHeader { u64_le time; /// The time when this save state was created std::array reserved; /// Make heading 256 bytes so it has consistent size + + template + void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::binary_object(this, sizeof(CSTHeader)); + } }; static_assert(sizeof(CSTHeader) == 256, "CSTHeader should be 256 bytes"); #pragma pack(pop) @@ -127,6 +134,11 @@ void System::SaveState(u32 slot) const { } void System::LoadState(u32 slot) { + if (Network::GetRoomMember().lock()->IsConnected()) { + LOG_ERROR(Core, "Unable to load while connected to multiplayer"); + return; + } + const auto path = GetSaveStatePath(title_id, slot); if (!FileUtil::Exists(path)) { LOG_ERROR(Core, "File not exist {}", path);