Merge pull request #11748 from lioncash/enet

Common/ENetUtil: Move interface into Common namespace
This commit is contained in:
Admiral H. Curtiss 2023-04-11 21:58:52 +02:00 committed by GitHub
commit d6ae7ad59c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 18 deletions

View File

@ -41,8 +41,8 @@ add_library(common
DebugInterface.h DebugInterface.h
DynamicLibrary.cpp DynamicLibrary.cpp
DynamicLibrary.h DynamicLibrary.h
ENetUtil.cpp ENet.cpp
ENetUtil.h ENet.h
EnumFormatter.h EnumFormatter.h
EnumMap.h EnumMap.h
Event.h Event.h

View File

@ -1,12 +1,12 @@
// Copyright 2015 Dolphin Emulator Project // Copyright 2015 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "Common/ENetUtil.h" #include "Common/ENet.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
namespace ENetUtil namespace Common::ENet
{ {
void WakeupThread(ENetHost* host) void WakeupThread(ENetHost* host)
{ {
@ -62,4 +62,4 @@ bool SendPacket(ENetPeer* socket, const sf::Packet& packet, u8 channel_id)
return true; return true;
} }
} // namespace ENetUtil } // namespace Common::ENet

View File

@ -9,9 +9,9 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
namespace ENetUtil namespace Common::ENet
{ {
void WakeupThread(ENetHost* host); void WakeupThread(ENetHost* host);
int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event); int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event);
bool SendPacket(ENetPeer* socket, const sf::Packet& packet, u8 channel_id); bool SendPacket(ENetPeer* socket, const sf::Packet& packet, u8 channel_id);
} // namespace ENetUtil } // namespace Common::ENet

View File

@ -23,7 +23,7 @@
#include "Common/CommonPaths.h" #include "Common/CommonPaths.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Crypto/SHA1.h" #include "Common/Crypto/SHA1.h"
#include "Common/ENetUtil.h" #include "Common/ENet.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
@ -168,7 +168,7 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlay
{ {
if (Connect()) if (Connect())
{ {
m_client->intercept = ENetUtil::InterceptCallback; m_client->intercept = Common::ENet::InterceptCallback;
m_thread = std::thread(&NetPlayClient::ThreadFunc, this); m_thread = std::thread(&NetPlayClient::ThreadFunc, this);
} }
} }
@ -1522,7 +1522,7 @@ void NetPlayClient::OnGameDigestAbort()
void NetPlayClient::Send(const sf::Packet& packet, const u8 channel_id) void NetPlayClient::Send(const sf::Packet& packet, const u8 channel_id)
{ {
ENetUtil::SendPacket(m_server, packet, channel_id); Common::ENet::SendPacket(m_server, packet, channel_id);
} }
void NetPlayClient::DisplayPlayersPing() void NetPlayClient::DisplayPlayersPing()
@ -1577,7 +1577,7 @@ void NetPlayClient::SendAsync(sf::Packet&& packet, const u8 channel_id)
std::lock_guard lkq(m_crit.async_queue_write); std::lock_guard lkq(m_crit.async_queue_write);
m_async_queue.Push(AsyncQueueEntry{std::move(packet), channel_id}); m_async_queue.Push(AsyncQueueEntry{std::move(packet), channel_id});
} }
ENetUtil::WakeupThread(m_client); Common::ENet::WakeupThread(m_client);
} }
// called from ---NETPLAY--- thread // called from ---NETPLAY--- thread

View File

@ -20,7 +20,7 @@
#include <fmt/format.h> #include <fmt/format.h>
#include "Common/CommonPaths.h" #include "Common/CommonPaths.h"
#include "Common/ENetUtil.h" #include "Common/ENet.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/HttpRequest.h" #include "Common/HttpRequest.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
@ -153,7 +153,7 @@ NetPlayServer::NetPlayServer(const u16 port, const bool forward_port, NetPlayUI*
if (m_server != nullptr) if (m_server != nullptr)
{ {
m_server->mtu = std::min(m_server->mtu, NetPlay::MAX_ENET_MTU); m_server->mtu = std::min(m_server->mtu, NetPlay::MAX_ENET_MTU);
m_server->intercept = ENetUtil::InterceptCallback; m_server->intercept = Common::ENet::InterceptCallback;
} }
SetupIndex(); SetupIndex();
@ -701,7 +701,7 @@ void NetPlayServer::SendAsync(sf::Packet&& packet, const PlayerId pid, const u8
std::lock_guard lkq(m_crit.async_queue_write); std::lock_guard lkq(m_crit.async_queue_write);
m_async_queue.Push(AsyncQueueEntry{std::move(packet), pid, TargetMode::Only, channel_id}); m_async_queue.Push(AsyncQueueEntry{std::move(packet), pid, TargetMode::Only, channel_id});
} }
ENetUtil::WakeupThread(m_server); Common::ENet::WakeupThread(m_server);
} }
void NetPlayServer::SendAsyncToClients(sf::Packet&& packet, const PlayerId skip_pid, void NetPlayServer::SendAsyncToClients(sf::Packet&& packet, const PlayerId skip_pid,
@ -712,7 +712,7 @@ void NetPlayServer::SendAsyncToClients(sf::Packet&& packet, const PlayerId skip_
m_async_queue.Push( m_async_queue.Push(
AsyncQueueEntry{std::move(packet), skip_pid, TargetMode::AllExcept, channel_id}); AsyncQueueEntry{std::move(packet), skip_pid, TargetMode::AllExcept, channel_id});
} }
ENetUtil::WakeupThread(m_server); Common::ENet::WakeupThread(m_server);
} }
void NetPlayServer::SendChunked(sf::Packet&& packet, const PlayerId pid, const std::string& title) void NetPlayServer::SendChunked(sf::Packet&& packet, const PlayerId pid, const std::string& title)
@ -2183,7 +2183,7 @@ void NetPlayServer::SendToClients(const sf::Packet& packet, const PlayerId skip_
void NetPlayServer::Send(ENetPeer* socket, const sf::Packet& packet, const u8 channel_id) void NetPlayServer::Send(ENetPeer* socket, const sf::Packet& packet, const u8 channel_id)
{ {
ENetUtil::SendPacket(socket, packet, channel_id); Common::ENet::SendPacket(socket, packet, channel_id);
} }
void NetPlayServer::KickPlayer(PlayerId player) void NetPlayServer::KickPlayer(PlayerId player)

View File

@ -42,7 +42,7 @@
<ClInclude Include="Common\Debug\Watches.h" /> <ClInclude Include="Common\Debug\Watches.h" />
<ClInclude Include="Common\DebugInterface.h" /> <ClInclude Include="Common\DebugInterface.h" />
<ClInclude Include="Common\DynamicLibrary.h" /> <ClInclude Include="Common\DynamicLibrary.h" />
<ClInclude Include="Common\ENetUtil.h" /> <ClInclude Include="Common\ENet.h" />
<ClInclude Include="Common\EnumFormatter.h" /> <ClInclude Include="Common\EnumFormatter.h" />
<ClInclude Include="Common\EnumMap.h" /> <ClInclude Include="Common\EnumMap.h" />
<ClInclude Include="Common\Event.h" /> <ClInclude Include="Common\Event.h" />
@ -753,7 +753,7 @@
<ClCompile Include="Common\Debug\MemoryPatches.cpp" /> <ClCompile Include="Common\Debug\MemoryPatches.cpp" />
<ClCompile Include="Common\Debug\Watches.cpp" /> <ClCompile Include="Common\Debug\Watches.cpp" />
<ClCompile Include="Common\DynamicLibrary.cpp" /> <ClCompile Include="Common\DynamicLibrary.cpp" />
<ClCompile Include="Common\ENetUtil.cpp" /> <ClCompile Include="Common\ENet.cpp" />
<ClCompile Include="Common\FatFsUtil.cpp" /> <ClCompile Include="Common\FatFsUtil.cpp" />
<ClCompile Include="Common\FileSearch.cpp" /> <ClCompile Include="Common\FileSearch.cpp" />
<ClCompile Include="Common\FileUtil.cpp" /> <ClCompile Include="Common\FileUtil.cpp" />