From 51f29f40eefdf6f12d885e5cd0b0651a18858a24 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 26 Dec 2022 18:44:28 +1000 Subject: [PATCH] USB: Fix loading old states without USB.bin --- pcsx2/USB/USB.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pcsx2/USB/USB.cpp b/pcsx2/USB/USB.cpp index 3b648eebad..a5712b4954 100644 --- a/pcsx2/USB/USB.cpp +++ b/pcsx2/USB/USB.cpp @@ -383,15 +383,15 @@ bool USB::DoState(StateWrapper& sw) { std::array valid_devices = {}; - if (!sw.DoMarker("USB") || !USB::DoOHCIState(sw)) - { - Console.Error("USB state is invalid, resetting."); - USBreset(); - return false; - } - if (sw.IsReading()) { + if (!sw.DoMarker("USB") || !USB::DoOHCIState(sw)) + { + Console.Error("USB state is invalid, resetting."); + USBreset(); + return true; + } + for (u32 port = 0; port < USB::NUM_PORTS; port++) { s32 state_devtype; @@ -444,6 +444,9 @@ bool USB::DoState(StateWrapper& sw) } else { + if (!sw.DoMarker("USB") || !USB::DoOHCIState(sw)) + return false; + for (u32 port = 0; port < USB::NUM_PORTS; port++) { s32 state_devtype = EmuConfig.USB.Ports[port].DeviceType;