diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp index 9863d22366..2d617ddd04 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp @@ -2281,7 +2281,7 @@ void CEXISlippi::prepareOnlineMatchState() } std::vector CEXISlippi::singlesStages = { - // 0x2, // FoD + 0x2, // FoD 0x3, // Pokemon 0x8, // Yoshi's Story 0x1C, // Dream Land @@ -2289,7 +2289,7 @@ std::vector CEXISlippi::singlesStages = { 0x20, // Final Destination }; -u16 CEXISlippi::getRandomStage() +u16 CEXISlippi::getRandomStage(u8 onlineMode) { static u16 selectedStage; @@ -2304,6 +2304,14 @@ u16 CEXISlippi::getRandomStage() // Remove last selection from stage pool stagePool.erase(stagePool.begin() + randIndex); + // If the mode is teams, don't allow FoD to be selected, re-roll instead. Note that this will + // cause a stack overflow exception/infinite recursion in the case the FoD is the only stage in + // the singlesStages vector + if (onlineMode == (u8)SlippiMatchmaking::OnlinePlayMode::TEAMS && selectedStage == 0x2) + { + return getRandomStage(onlineMode); + } + return selectedStage; } @@ -2318,12 +2326,13 @@ void CEXISlippi::setMatchSelections(u8* payload) s.stageId = Common::swap16(&payload[4]); u8 stageSelectOption = payload[6]; + u8 onlineMode = payload[7]; s.isStageSelected = stageSelectOption == 1 || stageSelectOption == 3; if (stageSelectOption == 3) { // If stage requested is random, select a random stage - s.stageId = getRandomStage(); + s.stageId = getRandomStage(onlineMode); } INFO_LOG(SLIPPI, "LPS set char: %d, iSS: %d, %d, stage: %d, team: %d", s.isCharacterSelected, @@ -2334,7 +2343,7 @@ void CEXISlippi::setMatchSelections(u8* payload) if (matchmaking->LocalPlayerIndex() == 1 && firstMatch) { firstMatch = false; - s.stageId = getRandomStage(); + s.stageId = getRandomStage(onlineMode); } // Merge these selections diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h index 4d39b9d542..2aedf974e2 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h @@ -163,7 +163,7 @@ private: std::vector m_payload; // online play stuff - u16 getRandomStage(); + u16 getRandomStage(u8 onlineMode); bool isDisconnected(); void handleOnlineInputs(u8* payload); void prepareOpponentInputs(u8* payload);