mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Core: Namespace NetPlay utilities under the NetPlay namespace
Previously there was only one function under the NetPlay namespace, which is kind of silly considering we have all of these other types and functions existing outside of the namespace. This moves the rest of them into the namespace. This gets some general names, like Player, for example, out of the global namespace.
This commit is contained in:
parent
3d1a7737d8
commit
675260b0f7
@ -334,20 +334,21 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
|
||||
|
||||
if (NetPlay::IsNetPlayRunning())
|
||||
{
|
||||
Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(g_NetPlaySettings));
|
||||
StartUp.bCPUThread = g_NetPlaySettings.m_CPUthread;
|
||||
StartUp.bEnableCheats = g_NetPlaySettings.m_EnableCheats;
|
||||
StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE;
|
||||
StartUp.bEnableMemcardSdWriting = g_NetPlaySettings.m_WriteToMemcard;
|
||||
StartUp.bCopyWiiSaveNetplay = g_NetPlaySettings.m_CopyWiiSave;
|
||||
StartUp.cpu_core = g_NetPlaySettings.m_CPUcore;
|
||||
StartUp.SelectedLanguage = g_NetPlaySettings.m_SelectedLanguage;
|
||||
StartUp.bOverrideGCLanguage = g_NetPlaySettings.m_OverrideGCLanguage;
|
||||
StartUp.m_DSPEnableJIT = g_NetPlaySettings.m_DSPEnableJIT;
|
||||
StartUp.m_OCEnable = g_NetPlaySettings.m_OCEnable;
|
||||
StartUp.m_OCFactor = g_NetPlaySettings.m_OCFactor;
|
||||
StartUp.m_EXIDevice[0] = g_NetPlaySettings.m_EXIDevice[0];
|
||||
StartUp.m_EXIDevice[1] = g_NetPlaySettings.m_EXIDevice[1];
|
||||
const NetPlay::NetSettings& netplay_settings = NetPlay::g_NetPlaySettings;
|
||||
Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings));
|
||||
StartUp.bCPUThread = netplay_settings.m_CPUthread;
|
||||
StartUp.bEnableCheats = netplay_settings.m_EnableCheats;
|
||||
StartUp.bDSPHLE = netplay_settings.m_DSPHLE;
|
||||
StartUp.bEnableMemcardSdWriting = netplay_settings.m_WriteToMemcard;
|
||||
StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave;
|
||||
StartUp.cpu_core = netplay_settings.m_CPUcore;
|
||||
StartUp.SelectedLanguage = netplay_settings.m_SelectedLanguage;
|
||||
StartUp.bOverrideGCLanguage = netplay_settings.m_OverrideGCLanguage;
|
||||
StartUp.m_DSPEnableJIT = netplay_settings.m_DSPEnableJIT;
|
||||
StartUp.m_OCEnable = netplay_settings.m_OCEnable;
|
||||
StartUp.m_OCFactor = netplay_settings.m_OCFactor;
|
||||
StartUp.m_EXIDevice[0] = netplay_settings.m_EXIDevice[0];
|
||||
StartUp.m_EXIDevice[1] = netplay_settings.m_EXIDevice[1];
|
||||
config_cache.bSetEXIDevice[0] = true;
|
||||
config_cache.bSetEXIDevice[1] = true;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace ConfigLoaders
|
||||
class NetPlayConfigLayerLoader final : public Config::ConfigLayerLoader
|
||||
{
|
||||
public:
|
||||
explicit NetPlayConfigLayerLoader(const NetSettings& settings)
|
||||
explicit NetPlayConfigLayerLoader(const NetPlay::NetSettings& settings)
|
||||
: ConfigLayerLoader(Config::LayerType::Netplay), m_settings(settings)
|
||||
{
|
||||
}
|
||||
@ -47,11 +47,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const NetSettings m_settings;
|
||||
const NetPlay::NetSettings m_settings;
|
||||
};
|
||||
|
||||
// Loader generation
|
||||
std::unique_ptr<Config::ConfigLayerLoader> GenerateNetPlayConfigLoader(const NetSettings& settings)
|
||||
std::unique_ptr<Config::ConfigLayerLoader>
|
||||
GenerateNetPlayConfigLoader(const NetPlay::NetSettings& settings)
|
||||
{
|
||||
return std::make_unique<NetPlayConfigLayerLoader>(settings);
|
||||
}
|
||||
|
@ -6,14 +6,18 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
struct NetSettings;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
class ConfigLayerLoader;
|
||||
}
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
struct NetSettings;
|
||||
}
|
||||
|
||||
namespace ConfigLoaders
|
||||
{
|
||||
std::unique_ptr<Config::ConfigLayerLoader> GenerateNetPlayConfigLoader(const NetSettings& settings);
|
||||
std::unique_ptr<Config::ConfigLayerLoader>
|
||||
GenerateNetPlayConfigLoader(const NetPlay::NetSettings& settings);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ void SetIsThrottlerTempDisabled(bool disable)
|
||||
void FrameUpdateOnCPUThread()
|
||||
{
|
||||
if (NetPlay::IsNetPlayRunning())
|
||||
NetPlayClient::SendTimeBase();
|
||||
NetPlay::NetPlayClient::SendTimeBase();
|
||||
}
|
||||
|
||||
// Display messages and return values
|
||||
|
@ -41,6 +41,8 @@
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
static std::mutex crit_netplay_client;
|
||||
static NetPlayClient* netplay_client = nullptr;
|
||||
NetSettings g_NetPlaySettings;
|
||||
@ -1306,41 +1308,59 @@ const PadMappingArray& NetPlayClient::GetWiimoteMapping() const
|
||||
return m_wiimote_map;
|
||||
}
|
||||
|
||||
bool IsNetPlayRunning()
|
||||
{
|
||||
return netplay_client != nullptr;
|
||||
}
|
||||
|
||||
void NetPlay_Enable(NetPlayClient* const np)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
netplay_client = np;
|
||||
}
|
||||
|
||||
void NetPlay_Disable()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
netplay_client = nullptr;
|
||||
}
|
||||
} // namespace NetPlay
|
||||
|
||||
// stuff hacked into dolphin
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// Actual Core function which is called on every frame
|
||||
bool SerialInterface::CSIDevice_GCController::NetPlay_GetInput(int numPAD, GCPadStatus* PadStatus)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
std::lock_guard<std::mutex> lk(NetPlay::crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return netplay_client->GetNetPads(numPAD, PadStatus);
|
||||
else
|
||||
return false;
|
||||
if (NetPlay::netplay_client)
|
||||
return NetPlay::netplay_client->GetNetPads(numPAD, PadStatus);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WiimoteEmu::Wiimote::NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size, u8 reporting_mode)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
std::lock_guard<std::mutex> lk(NetPlay::crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return netplay_client->WiimoteUpdate(wiimote, data, size, reporting_mode);
|
||||
else
|
||||
return false;
|
||||
if (NetPlay::netplay_client)
|
||||
return NetPlay::netplay_client->WiimoteUpdate(wiimote, data, size, reporting_mode);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sync the info whether a button was pressed or not. Used for the reconnect on button press feature
|
||||
bool Wiimote::NetPlay_GetButtonPress(int wiimote, bool pressed)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
std::lock_guard<std::mutex> lk(NetPlay::crit_netplay_client);
|
||||
|
||||
// Use the reporting mode 0 for the button pressed event, the real ones start at RT_REPORT_CORE
|
||||
u8 data[2] = {static_cast<u8>(pressed), 0};
|
||||
|
||||
if (netplay_client)
|
||||
if (NetPlay::netplay_client)
|
||||
{
|
||||
if (netplay_client->WiimoteUpdate(wiimote, data, 2, 0))
|
||||
if (NetPlay::netplay_client->WiimoteUpdate(wiimote, data, 2, 0))
|
||||
{
|
||||
return data[0];
|
||||
}
|
||||
@ -1357,39 +1377,22 @@ bool Wiimote::NetPlay_GetButtonPress(int wiimote, bool pressed)
|
||||
// also called from ---GUI--- thread when starting input recording
|
||||
u64 ExpansionInterface::CEXIIPL::NetPlay_GetEmulatedTime()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
std::lock_guard<std::mutex> lk(NetPlay::crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return g_netplay_initial_rtc;
|
||||
else
|
||||
return 0;
|
||||
if (NetPlay::netplay_client)
|
||||
return NetPlay::g_netplay_initial_rtc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
// return the local pad num that should rumble given a ingame pad num
|
||||
int SerialInterface::CSIDevice_GCController::NetPlay_InGamePadToLocalPad(int numPAD)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
std::lock_guard<std::mutex> lk(NetPlay::crit_netplay_client);
|
||||
|
||||
if (netplay_client)
|
||||
return netplay_client->InGamePadToLocalPad(numPAD);
|
||||
else
|
||||
return numPAD;
|
||||
}
|
||||
if (NetPlay::netplay_client)
|
||||
return NetPlay::netplay_client->InGamePadToLocalPad(numPAD);
|
||||
|
||||
bool NetPlay::IsNetPlayRunning()
|
||||
{
|
||||
return netplay_client != nullptr;
|
||||
}
|
||||
|
||||
void NetPlay_Enable(NetPlayClient* const np)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
netplay_client = np;
|
||||
}
|
||||
|
||||
void NetPlay_Disable()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
netplay_client = nullptr;
|
||||
return numPAD;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
class NetPlayUI
|
||||
{
|
||||
public:
|
||||
@ -186,3 +188,4 @@ private:
|
||||
|
||||
void NetPlay_Enable(NetPlayClient* const np);
|
||||
void NetPlay_Disable();
|
||||
} // namespace NetPlay
|
||||
|
@ -14,6 +14,8 @@ namespace PowerPC
|
||||
enum class CPUCore;
|
||||
}
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
struct NetSettings
|
||||
{
|
||||
bool m_CPUthread;
|
||||
@ -109,7 +111,5 @@ using FrameNum = u32;
|
||||
using PadMapping = s8;
|
||||
using PadMappingArray = std::array<PadMapping, 4>;
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
bool IsNetPlayRunning();
|
||||
}
|
||||
} // namespace NetPlay
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
u64 g_netplay_initial_rtc = 1272737767;
|
||||
|
||||
NetPlayServer::~NetPlayServer()
|
||||
@ -951,3 +953,4 @@ std::vector<std::pair<std::string, std::string>> NetPlayServer::GetInterfaceList
|
||||
result.emplace_back(std::make_pair("!local!", "127.0.0.1"));
|
||||
return result;
|
||||
}
|
||||
} // namespace NetPlay
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include "Common/TraversalClient.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
|
||||
enum class PlayerGameStatus;
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
class NetPlayUI;
|
||||
enum class PlayerGameStatus;
|
||||
|
||||
@ -124,3 +124,4 @@ private:
|
||||
TraversalClient* m_traversal_client = nullptr;
|
||||
NetPlayUI* m_dialog = nullptr;
|
||||
};
|
||||
} // namespace NetPlay
|
||||
|
@ -1086,10 +1086,11 @@ bool MainWindow::NetPlayJoin()
|
||||
const std::string nickname = Config::Get(Config::NETPLAY_NICKNAME);
|
||||
|
||||
// Create Client
|
||||
Settings::Instance().ResetNetPlayClient(new NetPlayClient(
|
||||
const bool is_hosting_netplay = Settings::Instance().GetNetPlayServer() != nullptr;
|
||||
Settings::Instance().ResetNetPlayClient(new NetPlay::NetPlayClient(
|
||||
host_ip, host_port, m_netplay_dialog, nickname,
|
||||
NetTraversalConfig{Settings::Instance().GetNetPlayServer() != nullptr ? false : is_traversal,
|
||||
traversal_host, traversal_port}));
|
||||
NetPlay::NetTraversalConfig{is_hosting_netplay ? false : is_traversal, traversal_host,
|
||||
traversal_port}));
|
||||
|
||||
if (!Settings::Instance().GetNetPlayClient()->IsConnected())
|
||||
{
|
||||
@ -1133,8 +1134,9 @@ bool MainWindow::NetPlayHost(const QString& game_id)
|
||||
host_port = Config::Get(Config::NETPLAY_LISTEN_PORT);
|
||||
|
||||
// Create Server
|
||||
Settings::Instance().ResetNetPlayServer(new NetPlayServer(
|
||||
host_port, use_upnp, NetTraversalConfig{is_traversal, traversal_host, traversal_port}));
|
||||
Settings::Instance().ResetNetPlayServer(new NetPlay::NetPlayServer(
|
||||
host_port, use_upnp,
|
||||
NetPlay::NetTraversalConfig{is_traversal, traversal_host, traversal_port}));
|
||||
|
||||
if (!Settings::Instance().GetNetPlayServer()->is_connected)
|
||||
{
|
||||
|
@ -34,9 +34,7 @@ class JITWidget;
|
||||
class LogConfigWidget;
|
||||
class LogWidget;
|
||||
class MemoryWidget;
|
||||
class NetPlayClient;
|
||||
class NetPlayDialog;
|
||||
class NetPlayServer;
|
||||
class NetPlaySetupDialog;
|
||||
class RegisterWidget;
|
||||
class SearchBar;
|
||||
|
@ -285,7 +285,7 @@ void NetPlayDialog::OnStart()
|
||||
return;
|
||||
}
|
||||
|
||||
NetSettings settings;
|
||||
NetPlay::NetSettings settings;
|
||||
|
||||
// Copy all relevant settings
|
||||
SConfig& instance = SConfig::GetInstance();
|
||||
@ -379,7 +379,8 @@ void NetPlayDialog::UpdateGUI()
|
||||
{tr("Player"), tr("Game Status"), tr("Ping"), tr("Mapping"), tr("Revision")});
|
||||
m_players_list->setRowCount(player_count);
|
||||
|
||||
const auto get_mapping_string = [](const Player* player, const PadMappingArray& array) {
|
||||
const auto get_mapping_string = [](const NetPlay::Player* player,
|
||||
const NetPlay::PadMappingArray& array) {
|
||||
std::string str;
|
||||
for (size_t i = 0; i < array.size(); i++)
|
||||
{
|
||||
@ -392,8 +393,10 @@ void NetPlayDialog::UpdateGUI()
|
||||
return '|' + str + '|';
|
||||
};
|
||||
|
||||
static const std::map<PlayerGameStatus, QString> player_status{
|
||||
{PlayerGameStatus::Ok, tr("OK")}, {PlayerGameStatus::NotFound, tr("Not Found")}};
|
||||
static const std::map<NetPlay::PlayerGameStatus, QString> player_status{
|
||||
{NetPlay::PlayerGameStatus::Ok, tr("OK")},
|
||||
{NetPlay::PlayerGameStatus::NotFound, tr("Not Found")},
|
||||
};
|
||||
|
||||
for (int i = 0; i < player_count; i++)
|
||||
{
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
class MD5Dialog;
|
||||
class GameListModel;
|
||||
class NetPlayServer;
|
||||
class PadMappingDialog;
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
@ -26,7 +25,7 @@ class QTableWidget;
|
||||
class QTextEdit;
|
||||
class QToolButton;
|
||||
|
||||
class NetPlayDialog : public QDialog, public NetPlayUI
|
||||
class NetPlayDialog : public QDialog, public NetPlay::NetPlayUI
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -94,12 +94,13 @@ int PadMappingDialog::exec()
|
||||
|
||||
return QDialog::exec();
|
||||
}
|
||||
PadMappingArray PadMappingDialog::GetGCPadArray()
|
||||
|
||||
NetPlay::PadMappingArray PadMappingDialog::GetGCPadArray()
|
||||
{
|
||||
return m_pad_mapping;
|
||||
}
|
||||
|
||||
PadMappingArray PadMappingDialog::GetWiimoteArray()
|
||||
NetPlay::PadMappingArray PadMappingDialog::GetWiimoteArray()
|
||||
{
|
||||
return m_wii_mapping;
|
||||
}
|
||||
|
@ -8,12 +8,15 @@
|
||||
|
||||
#include "Core/NetPlayProto.h"
|
||||
|
||||
class NetPlayClient;
|
||||
class Player;
|
||||
class QGridLayout;
|
||||
class QComboBox;
|
||||
class QDialogButtonBox;
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
class Player;
|
||||
}
|
||||
|
||||
class PadMappingDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -22,8 +25,8 @@ public:
|
||||
|
||||
int exec() override;
|
||||
|
||||
PadMappingArray GetGCPadArray();
|
||||
PadMappingArray GetWiimoteArray();
|
||||
NetPlay::PadMappingArray GetGCPadArray();
|
||||
NetPlay::PadMappingArray GetWiimoteArray();
|
||||
|
||||
private:
|
||||
void CreateWidgets();
|
||||
@ -31,12 +34,12 @@ private:
|
||||
|
||||
void OnMappingChanged();
|
||||
|
||||
PadMappingArray m_pad_mapping;
|
||||
PadMappingArray m_wii_mapping;
|
||||
NetPlay::PadMappingArray m_pad_mapping;
|
||||
NetPlay::PadMappingArray m_wii_mapping;
|
||||
|
||||
QGridLayout* m_main_layout;
|
||||
std::array<QComboBox*, 4> m_gc_boxes;
|
||||
std::array<QComboBox*, 4> m_wii_boxes;
|
||||
std::vector<const Player*> m_players;
|
||||
std::vector<const NetPlay::Player*> m_players;
|
||||
QDialogButtonBox* m_button_box;
|
||||
};
|
||||
|
@ -267,22 +267,22 @@ GameListModel* Settings::GetGameListModel() const
|
||||
return model;
|
||||
}
|
||||
|
||||
NetPlayClient* Settings::GetNetPlayClient()
|
||||
NetPlay::NetPlayClient* Settings::GetNetPlayClient()
|
||||
{
|
||||
return m_client.get();
|
||||
}
|
||||
|
||||
void Settings::ResetNetPlayClient(NetPlayClient* client)
|
||||
void Settings::ResetNetPlayClient(NetPlay::NetPlayClient* client)
|
||||
{
|
||||
m_client.reset(client);
|
||||
}
|
||||
|
||||
NetPlayServer* Settings::GetNetPlayServer()
|
||||
NetPlay::NetPlayServer* Settings::GetNetPlayServer()
|
||||
{
|
||||
return m_server.get();
|
||||
}
|
||||
|
||||
void Settings::ResetNetPlayServer(NetPlayServer* server)
|
||||
void Settings::ResetNetPlayServer(NetPlay::NetPlayServer* server)
|
||||
{
|
||||
m_server.reset(server);
|
||||
}
|
||||
|
@ -93,10 +93,10 @@ public:
|
||||
void DecreaseVolume(int volume);
|
||||
|
||||
// NetPlay
|
||||
NetPlayClient* GetNetPlayClient();
|
||||
void ResetNetPlayClient(NetPlayClient* client = nullptr);
|
||||
NetPlayServer* GetNetPlayServer();
|
||||
void ResetNetPlayServer(NetPlayServer* server = nullptr);
|
||||
NetPlay::NetPlayClient* GetNetPlayClient();
|
||||
void ResetNetPlayClient(NetPlay::NetPlayClient* client = nullptr);
|
||||
NetPlay::NetPlayServer* GetNetPlayServer();
|
||||
void ResetNetPlayServer(NetPlay::NetPlayServer* server = nullptr);
|
||||
|
||||
// Cheats
|
||||
bool GetCheatsEnabled() const;
|
||||
@ -163,8 +163,8 @@ signals:
|
||||
private:
|
||||
bool m_batch = false;
|
||||
bool m_controller_state_needed = false;
|
||||
std::unique_ptr<NetPlayClient> m_client;
|
||||
std::unique_ptr<NetPlayServer> m_server;
|
||||
std::unique_ptr<NetPlay::NetPlayClient> m_client;
|
||||
std::unique_ptr<NetPlay::NetPlayServer> m_server;
|
||||
Settings();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user