Netplay: receive spectating option from frontend.

This commit is contained in:
Jamie Meyer 2023-05-31 00:03:57 +02:00
parent 932f6f1b55
commit a346e2b0e0
No known key found for this signature in database
GPG Key ID: BF30D71B2F1305C7
5 changed files with 11 additions and 7 deletions

View File

@ -1898,9 +1898,11 @@ bool Netplay::CreateSession(std::string nickname, s32 port, s32 max_players, std
return true; return true;
} }
bool Netplay::JoinSession(std::string nickname, const std::string& hostname, s32 port, std::string password) bool Netplay::JoinSession(std::string nickname, const std::string& hostname, s32 port, std::string password, bool spectating)
{ {
s_local_session_password = password; s_local_session_password = password;
s_local_spectating = spectating;
// TODO: input delay. GGPO Should support changing it on the fly. // TODO: input delay. GGPO Should support changing it on the fly.
const s32 input_delay = 1; const s32 input_delay = 1;

View File

@ -11,7 +11,7 @@ enum : s32
MAX_PLAYERS = 2, MAX_PLAYERS = 2,
// Maximum number of spectators allowed to watch the session. // Maximum number of spectators allowed to watch the session.
MAX_SPECTATORS = 4, MAX_SPECTATORS = 1,
// Maximum netplay prediction frames // Maximum netplay prediction frames
MAX_ROLLBACK_FRAMES = 8, MAX_ROLLBACK_FRAMES = 8,
@ -32,7 +32,7 @@ enum : u8
}; };
bool CreateSession(std::string nickname, s32 port, s32 max_players, std::string password); 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); bool JoinSession(std::string nickname, const std::string& hostname, s32 port, std::string password, bool spectating);
bool IsActive(); bool IsActive();

View File

@ -82,6 +82,7 @@ void JoinNetplaySessionDialog::accept()
const QString& nickname = m_ui.nickname->text(); const QString& nickname = m_ui.nickname->text();
const QString& hostname = m_ui.hostname->text(); const QString& hostname = m_ui.hostname->text();
const QString& password = m_ui.password->text(); const QString& password = m_ui.password->text();
const bool spectating = m_ui.spectating->isChecked();
QDialog::accept(); QDialog::accept();
g_emu_thread->joinNetplaySession(nickname.trimmed(), hostname.trimmed(), port, password); g_emu_thread->joinNetplaySession(nickname.trimmed(), hostname.trimmed(), port, password);

View File

@ -1092,16 +1092,17 @@ void EmuThread::createNetplaySession(const QString& nickname, qint32 port, qint3
} }
void EmuThread::joinNetplaySession(const QString& nickname, const QString& hostname, qint32 port, void EmuThread::joinNetplaySession(const QString& nickname, const QString& hostname, qint32 port,
const QString& password) const QString& password, bool spectating)
{ {
if (!isOnThread()) if (!isOnThread())
{ {
QMetaObject::invokeMethod(this, "joinNetplaySession", Qt::QueuedConnection, Q_ARG(const QString&, nickname), QMetaObject::invokeMethod(this, "joinNetplaySession", Qt::QueuedConnection, Q_ARG(const QString&, nickname),
Q_ARG(const QString&, hostname), Q_ARG(qint32, port), Q_ARG(const QString&, password)); Q_ARG(const QString&, hostname), Q_ARG(qint32, port), Q_ARG(const QString&, password),
Q_ARG(bool, spectating));
return; return;
} }
if (!Netplay::JoinSession(nickname.toStdString(), hostname.toStdString(), port, password.toStdString())) if (!Netplay::JoinSession(nickname.toStdString(), hostname.toStdString(), port, password.toStdString(), spectating))
{ {
errorReported(tr("Netplay Error"), tr("Failed to join netplay session. The log may contain more information.")); errorReported(tr("Netplay Error"), tr("Failed to join netplay session. The log may contain more information."));
return; return;

View File

@ -188,7 +188,7 @@ public Q_SLOTS:
void applyCheat(quint32 index); void applyCheat(quint32 index);
void reloadPostProcessingShaders(); void reloadPostProcessingShaders();
void createNetplaySession(const QString& nickname, qint32 port, qint32 max_players, const QString& password); 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); void joinNetplaySession(const QString& nickname, const QString& hostname, qint32 port, bool spectating);
private Q_SLOTS: private Q_SLOTS:
void stopInThread(); void stopInThread();