IOS/WiiSockMan: Move instance to IOS Kernel.

This commit is contained in:
Admiral H. Curtiss
2023-04-17 04:38:48 +02:00
parent 37a30a5e50
commit b2ee958058
9 changed files with 104 additions and 74 deletions

View File

@ -24,8 +24,10 @@
#include "Common/FileUtil.h"
#include "Core/Config/MainSettings.h"
#include "Core/Core.h"
#include "Core/IOS/Network/SSL.h"
#include "Core/IOS/Network/Socket.h"
#include "Core/System.h"
#include "DolphinQt/Host.h"
#include "DolphinQt/Settings.h"
@ -95,9 +97,8 @@ QTableWidgetItem* GetSocketState(s32 host_fd)
return new QTableWidgetItem(QTableWidget::tr("Unbound"));
}
QTableWidgetItem* GetSocketBlocking(s32 wii_fd)
static QTableWidgetItem* GetSocketBlocking(const IOS::HLE::WiiSockMan& socket_manager, s32 wii_fd)
{
const auto& socket_manager = IOS::HLE::WiiSockMan::GetInstance();
if (socket_manager.GetHostSocket(wii_fd) < 0)
return new QTableWidgetItem();
const bool is_blocking = socket_manager.IsSocketBlocking(wii_fd);
@ -238,16 +239,27 @@ void NetworkWidget::Update()
if (!isVisible())
return;
// needed because there's a race condition on the IOS instance otherwise
Core::CPUThreadGuard guard(Core::System::GetInstance());
auto* ios = IOS::HLE::GetIOS();
if (!ios)
return;
auto socket_manager = ios->GetSocketManager();
if (!socket_manager)
return;
m_socket_table->setRowCount(0);
for (u32 wii_fd = 0; wii_fd < IOS::HLE::WII_SOCKET_FD_MAX; wii_fd++)
{
m_socket_table->insertRow(wii_fd);
const s32 host_fd = IOS::HLE::WiiSockMan::GetInstance().GetHostSocket(wii_fd);
const s32 host_fd = socket_manager->GetHostSocket(wii_fd);
m_socket_table->setItem(wii_fd, 0, new QTableWidgetItem(QString::number(wii_fd)));
m_socket_table->setItem(wii_fd, 1, GetSocketDomain(host_fd));
m_socket_table->setItem(wii_fd, 2, GetSocketType(host_fd));
m_socket_table->setItem(wii_fd, 3, GetSocketState(host_fd));
m_socket_table->setItem(wii_fd, 4, GetSocketBlocking(wii_fd));
m_socket_table->setItem(wii_fd, 4, GetSocketBlocking(*socket_manager, wii_fd));
m_socket_table->setItem(wii_fd, 5, GetSocketName(host_fd));
}
m_socket_table->resizeColumnsToContents();