diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp index b5d8db07b0..0b4dd33693 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp @@ -1542,7 +1542,8 @@ void CEXISlippi::handleOnlineInputs(u8* payload) // Reset character selections as they are no longer needed localSelections.Reset(); - slippi_netplay->StartSlippiGame(); + if (slippi_netplay) + slippi_netplay->StartSlippiGame(); } if (isDisconnected()) @@ -1919,13 +1920,13 @@ void CEXISlippi::prepareOnlineMatchState() u8 localPlayerReady = localSelections.isCharacterSelected; u8 remotePlayersReady = 0; - u8 localPlayerIndex = matchmaking->LocalPlayerIndex(); - u8 remotePlayerIndex = 1; auto userInfo = user->GetUserInfo(); if (mmState == SlippiMatchmaking::ProcessState::CONNECTION_SUCCESS) { + localPlayerIndex = matchmaking->LocalPlayerIndex(); + if (!slippi_netplay) { #ifdef LOCAL_TESTING diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h index c8860b9a88..90173c6a06 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h @@ -198,7 +198,6 @@ private: void prepareGctLength(); void prepareGctLoad(u8* payload); void prepareDelayResponse(); - int getCharColor(u8 charId, u8 teamId); void FileWriteThread(void); @@ -232,6 +231,11 @@ private: // Used to determine when to detect when a new session has started bool is_play_session_active = false; + // We put these at the class level to preserve values in the case of a disconnect + // while loading. Without this, someone could load into a game playing the wrong char + u8 localPlayerIndex = 0; + u8 remotePlayerIndex = 1; + // Frame skipping variables int framesToSkip = 0; bool isCurrentlySkipping = false; diff --git a/Source/Core/Core/Slippi/SlippiNetplay.h b/Source/Core/Core/Slippi/SlippiNetplay.h index ffb5eeaad9..27e9e5891a 100644 --- a/Source/Core/Core/Slippi/SlippiNetplay.h +++ b/Source/Core/Core/Slippi/SlippiNetplay.h @@ -34,8 +34,8 @@ struct SlippiRemotePadOutput { - int32_t latestFrame; - u8 playerIdx; + int32_t latestFrame{}; + u8 playerIdx{}; std::vector data; }; @@ -185,7 +185,7 @@ protected: struct FrameOffsetData { // TODO: Should the buffer size be dynamic based on time sync interval or not? - int idx; + int idx{}; std::vector buf; };