From ece3d5a9ec0427d99b2f72e1e94a9ab070e0c236 Mon Sep 17 00:00:00 2001 From: r2dliu Date: Fri, 17 Jul 2020 15:51:51 -0400 Subject: [PATCH] pull in 54b7318 from ishii --- Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp | 32 ++++++++++++++++++-- Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h | 2 ++ Source/Core/DolphinQt/AboutDialog.cpp | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp index 20994639af..86e1388361 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp @@ -1702,7 +1702,9 @@ void CEXISlippi::prepareOnlineMatchState() m_read_queue.clear(); - SlippiMatchmaking::ProcessState mmState = matchmaking->GetMatchmakeState(); + auto errorState = SlippiMatchmaking::ProcessState::ERROR_ENCOUNTERED; + + SlippiMatchmaking::ProcessState mmState = !forcedError.empty() ? errorState : matchmaking->GetMatchmakeState(); #ifdef LOCAL_TESTING if (localSelections.isCharacterSelected || isLocalConnected) @@ -1761,6 +1763,8 @@ void CEXISlippi::prepareOnlineMatchState() #ifndef LOCAL_TESTING // If we get here, our opponent likely disconnected. Let's trigger a clean up handleConnectionCleanup(); + prepareOnlineMatchState(); + return; #endif } } @@ -1778,6 +1782,8 @@ void CEXISlippi::prepareOnlineMatchState() std::string p1Name = ""; std::string p2Name = ""; + auto directMode = SlippiMatchmaking::OnlinePlayMode::DIRECT; + if (localPlayerReady && remotePlayerReady) { auto isDecider = slippi_netplay->IsDecider(); @@ -1791,11 +1797,28 @@ void CEXISlippi::prepareOnlineMatchState() onlineMatchBlock[0x63 + localPlayerIndex * 0x24] = lps.characterColor; #ifdef LOCAL_TESTING - rps.characterId = 2; + rps.characterId = 0x2; rps.characterColor = 2; rps.playerName = std::string("Player"); #endif + // Check if someone is picking dumb characters in non-direct + auto localCharOk = lps.characterId < 26; + auto remoteCharOk = rps.characterId < 26; + if (lastSearch.mode != directMode && (!localCharOk || !remoteCharOk)) + { + // If we get here, someone is doing something bad, clear the lobby + handleConnectionCleanup(); + if (!localCharOk) + forcedError = "The character you selected is not allowed in this mode"; + prepareOnlineMatchState(); + return; + } + + // Overwrite local player character + onlineMatchBlock[0x60 + localPlayerIndex * 0x24] = lps.characterId; + onlineMatchBlock[0x63 + localPlayerIndex * 0x24] = lps.characterColor; + // Overwrite remote player character onlineMatchBlock[0x60 + remotePlayerIndex * 0x24] = rps.characterId; onlineMatchBlock[0x63 + remotePlayerIndex * 0x24] = rps.characterColor; @@ -1856,7 +1879,7 @@ void CEXISlippi::prepareOnlineMatchState() m_read_queue.insert(m_read_queue.end(), oppName.begin(), oppName.end()); // Add error message if there is one - auto errorStr = matchmaking->GetErrorMessage(); + auto errorStr = auto errorStr = !forcedError.empty() ? forcedError : matchmaking->GetErrorMessage(); errorStr = ConvertStringForGame(errorStr, 120); m_read_queue.insert(m_read_queue.end(), errorStr.begin(), errorStr.end()); @@ -2071,6 +2094,9 @@ void CEXISlippi::handleConnectionCleanup() // Reset random stage pool stagePool.clear(); + // Reset any forced errors + forcedError.clear() + #ifdef LOCAL_TESTING isLocalConnected = false; #endif diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h index 7f51249747..85d2771b3d 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h @@ -205,6 +205,8 @@ namespace ExpansionInterface std::default_random_engine generator; + std::string forcedError = ""; + // Frame skipping variables int framesToSkip = 0; bool isCurrentlySkipping = false; diff --git a/Source/Core/DolphinQt/AboutDialog.cpp b/Source/Core/DolphinQt/AboutDialog.cpp index 877bde9ccb..e70ce07ab6 100644 --- a/Source/Core/DolphinQt/AboutDialog.cpp +++ b/Source/Core/DolphinQt/AboutDialog.cpp @@ -19,7 +19,7 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent) const QString text = QStringLiteral(R"( -

Dolphin

+

Slippi Dolphin

%VERSION_STRING%