diff --git a/src/core/netplay.cpp b/src/core/netplay.cpp
index 94c9ccf48..db115caa0 100644
--- a/src/core/netplay.cpp
+++ b/src/core/netplay.cpp
@@ -1267,8 +1267,8 @@ void Netplay::UpdateResetState()
{
if (!IsValidPlayerId(i) || s_reset_players.test(i))
continue;
-
- if (s_peers[i].peer->state == ENET_PEER_STATE_CONNECTED)
+ // be sure to first check whether the peer is still valid.
+ if (s_peers[i].peer && s_peers[i].peer->state == ENET_PEER_STATE_CONNECTED)
s_reset_players.set(i);
}
@@ -1430,7 +1430,7 @@ void Netplay::SetSettings()
Settings::GetControllerTypeName(ControllerType::DigitalController));
}
- //si.SetStringValue("CPU", "ExecutionMode", "Interpreter");
+ // si.SetStringValue("CPU", "ExecutionMode", "Interpreter");
// No runahead or rewind, that'd be a disaster.
si.SetIntValue("Main", "RunaheadFrameCount", 0);
@@ -1642,13 +1642,9 @@ void Netplay::SetInputs(Netplay::Input inputs[2])
}
}
-void Netplay::StartNetplaySession(s32 local_handle, u16 local_port, const std::string& remote_addr, u16 remote_port,
- s32 input_delay, std::string game_path)
+void Netplay::TestNetplaySession(s32 local_handle, u16 local_port, const std::string& remote_addr, u16 remote_port,
+ s32 input_delay, std::string game_path)
{
- // dont want to start a session when theres already one going on.
- if (IsActive())
- return;
-
const bool is_hosting = (local_handle == 1);
if (!CreateSystem(std::move(game_path), is_hosting))
{
@@ -1664,22 +1660,6 @@ void Netplay::StartNetplaySession(s32 local_handle, u16 local_port, const std::s
Log_ErrorPrint("Failed to Create Netplay Session!");
System::ShutdownSystem(false);
}
- else if (IsHost())
- {
- // Load savestate if available and only when you are the host.
- // the other peers will get state from the host
- std::string save = EmuFolders::SaveStates + "/netplay/" + System::GetRunningSerial() + ".sav";
- System::LoadState(save.c_str());
- }
-}
-
-void Netplay::StopNetplaySession()
-{
- if (!IsActive())
- return;
-
- // This will call back to us.
- System::ShutdownSystem(false);
}
bool Netplay::CreateSession(std::string nickname, s32 port, s32 max_players, std::string password)
@@ -1693,6 +1673,13 @@ bool Netplay::CreateSession(std::string nickname, s32 port, s32 max_players, std
CloseSession();
return false;
}
+ else if (IsHost())
+ {
+ // Load savestate if available and only when you are the host.
+ // the other peers will get state from the host
+ auto save_path = fmt::format("{}\\netplay\\{}.sav", EmuFolders::SaveStates, System::GetRunningSerial());
+ System::LoadState(save_path.c_str());
+ }
return true;
}
diff --git a/src/core/netplay.h b/src/core/netplay.h
index b71791e59..acdc5b896 100644
--- a/src/core/netplay.h
+++ b/src/core/netplay.h
@@ -28,10 +28,8 @@ enum : u8
NUM_ENET_CHANNELS,
};
-void StartNetplaySession(s32 local_handle, u16 local_port, const std::string& remote_addr, u16 remote_port,
+void TestNetplaySession(s32 local_handle, u16 local_port, const std::string& remote_addr, u16 remote_port,
s32 input_delay, std::string game_path);
-void StopNetplaySession();
-
bool CreateSession(std::string nickname, s32 port, s32 max_players, std::string password);
bool JoinSession(std::string nickname, const std::string& hostname, s32 port, std::string password);
diff --git a/src/duckstation-qt/duckstation-qt.vcxproj b/src/duckstation-qt/duckstation-qt.vcxproj
index c6f002d71..5d8f6356e 100644
--- a/src/duckstation-qt/duckstation-qt.vcxproj
+++ b/src/duckstation-qt/duckstation-qt.vcxproj
@@ -42,7 +42,6 @@
-
@@ -100,7 +99,6 @@
-
@@ -134,9 +132,6 @@
Document
-
- Document
-
Document
@@ -268,7 +263,6 @@
-
diff --git a/src/duckstation-qt/duckstation-qt.vcxproj.filters b/src/duckstation-qt/duckstation-qt.vcxproj.filters
index 55e1624f1..be9e21dca 100644
--- a/src/duckstation-qt/duckstation-qt.vcxproj.filters
+++ b/src/duckstation-qt/duckstation-qt.vcxproj.filters
@@ -94,10 +94,9 @@
-
-
+
@@ -159,7 +158,6 @@
-
@@ -202,7 +200,6 @@
-
diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp
index ce5190277..93065ae0a 100644
--- a/src/duckstation-qt/mainwindow.cpp
+++ b/src/duckstation-qt/mainwindow.cpp
@@ -2104,7 +2104,6 @@ void MainWindow::connectSignals()
updateMenuSelectedTheme();
// Netplay UI , TODO
- connect(m_ui.actionSetupNetplaySession, &QAction::triggered, this, &MainWindow::onSetupNetplaySessionClicked);
connect(m_ui.actionCreateNetplaySession, &QAction::triggered, this, &MainWindow::onCreateNetplaySessionClicked);
connect(m_ui.actionJoinNetplaySession, &QAction::triggered, this, &MainWindow::onJoinNetplaySessionClicked);
}
@@ -2771,28 +2770,6 @@ void MainWindow::onCPUDebuggerClosed()
m_debugger_window = nullptr;
}
-void MainWindow::onSetupNetplaySessionClicked()
-{
- Assert(!m_netplay_window);
-
- m_netplay_window = new NetplayWidget(this);
- m_netplay_window->setWindowIcon(windowIcon());
- m_netplay_window->setWindowTitle("Netplay Session");
- m_netplay_window->setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint);
- m_netplay_window->show();
-
- m_ui.menuNetplay->setDisabled(true);
-
- connect(m_netplay_window, &NetplayWidget::finished, [this]() {
- Assert(m_netplay_window);
-
- m_netplay_window->deleteLater();
- m_netplay_window = nullptr;
-
- m_ui.menuNetplay->setDisabled(false);
- });
-}
-
void MainWindow::onCreateNetplaySessionClicked()
{
CreateNetplaySessionDialog dlg(this);
diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h
index 369173072..c94f83d1b 100644
--- a/src/duckstation-qt/mainwindow.h
+++ b/src/duckstation-qt/mainwindow.h
@@ -16,7 +16,6 @@
#include "displaywidget.h"
#include "settingsdialog.h"
#include "ui_mainwindow.h"
-#include
class QLabel;
class QThread;
@@ -169,7 +168,6 @@ private Q_SLOTS:
void openCPUDebugger();
void onCPUDebuggerClosed();
- void onSetupNetplaySessionClicked();
void onCreateNetplaySessionClicked();
void onJoinNetplaySessionClicked();
@@ -278,7 +276,6 @@ private:
MemoryCardEditorDialog* m_memory_card_editor_dialog = nullptr;
CheatManagerDialog* m_cheat_manager_dialog = nullptr;
DebuggerWindow* m_debugger_window = nullptr;
- NetplayWidget* m_netplay_window = nullptr;
std::string m_current_game_title;
std::string m_current_game_serial;
diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui
index c472832a1..ddc29abca 100644
--- a/src/duckstation-qt/mainwindow.ui
+++ b/src/duckstation-qt/mainwindow.ui
@@ -241,7 +241,6 @@
Netplay
-
@@ -986,11 +985,6 @@
Cover Downloader
-
-
- Setup Session
-
-
Create Session...
diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp
index acb78640c..bf0be0ed6 100644
--- a/src/duckstation-qt/qthost.cpp
+++ b/src/duckstation-qt/qthost.cpp
@@ -1069,36 +1069,6 @@ void EmuThread::reloadPostProcessingShaders()
System::ReloadPostProcessingShaders();
}
-void EmuThread::startNetplaySession(int local_handle, quint16 local_port, const QString& remote_addr,
- quint16 remote_port, int input_delay, const QString& game_path)
-{
- if (!isOnThread())
- {
- QMetaObject::invokeMethod(this, "startNetplaySession", Qt::QueuedConnection, Q_ARG(int, local_handle),
- Q_ARG(quint16, local_port), Q_ARG(const QString&, remote_addr),
- Q_ARG(quint16, remote_port), Q_ARG(int, input_delay), Q_ARG(const QString&, game_path));
- return;
- }
-
- auto remAddr = remote_addr.trimmed().toStdString();
- auto gamePath = game_path.trimmed().toStdString();
- Netplay::StartNetplaySession(local_handle, local_port, remAddr, remote_port, input_delay, gamePath);
-
- // TODO: Fix this junk.. for some reason, it stays sleeping...
- g_emu_thread->wakeThread();
-}
-
-void EmuThread::sendNetplayMessage(const QString& message)
-{
- if (!isOnThread())
- {
- QMetaObject::invokeMethod(this, "sendNetplayMessage", Qt::QueuedConnection, Q_ARG(const QString&, message));
- return;
- }
- // TODO REDO NETPLAY UI
- // Netplay::SendMsg(message.toStdString().c_str());
-}
-
void EmuThread::createNetplaySession(const QString& nickname, qint32 port, qint32 max_players, const QString& password)
{
if (!isOnThread())
@@ -1138,16 +1108,6 @@ void EmuThread::joinNetplaySession(const QString& nickname, const QString& hostn
g_emu_thread->wakeThread();
}
-void EmuThread::stopNetplaySession()
-{
- if (!isOnThread())
- {
- QMetaObject::invokeMethod(this, "stopNetplaySession", Qt::QueuedConnection);
- return;
- }
- Netplay::StopNetplaySession();
-}
-
void EmuThread::runOnEmuThread(std::function callback)
{
callback();
@@ -2273,7 +2233,7 @@ int main(int argc, char* argv[])
const int port_base = 31200;
std::string remote = "127.0.0.1";
std::string game = "D:\\PSX\\chd\\padtest.chd";
- Netplay::StartNetplaySession(h, port_base + h, remote, port_base + nh, 1, game);
+ Netplay::TestNetplaySession(h, port_base + h, remote, port_base + nh, 1, game);
// TODO: Fix this junk.. for some reason, it stays sleeping...
g_emu_thread->wakeThread();
diff --git a/src/duckstation-qt/qthost.h b/src/duckstation-qt/qthost.h
index b6ca31514..b64c66e8f 100644
--- a/src/duckstation-qt/qthost.h
+++ b/src/duckstation-qt/qthost.h
@@ -187,10 +187,6 @@ public Q_SLOTS:
void setCheatEnabled(quint32 index, bool enabled);
void applyCheat(quint32 index);
void reloadPostProcessingShaders();
- void startNetplaySession(int local_handle, quint16 local_port, const QString& remote_addr, quint16 remote_port,
- int input_delay, const QString& game_path);
- void stopNetplaySession();
- void sendNetplayMessage(const QString& message);
void createNetplaySession(const QString& nickname, qint32 port, qint32 max_players, const QString& password);
void joinNetplaySession(const QString& nickname, const QString& hostname, qint32 port, const QString& password);