mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Switched tcp over to enet
This commit is contained in:
@@ -482,6 +482,9 @@
|
||||
<ProjectReference Include="$(CoreDir)VideoCommon\VideoCommon.vcxproj">
|
||||
<Project>{3de9ee35-3e91-4f27-a014-2866ad8c3fe3}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Externals\enet\enet.vcxproj">
|
||||
<Project>{cbc76802-c128-4b17-bf6c-23b08c313e5e}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
+338
-247
File diff suppressed because it is too large
Load Diff
@@ -8,16 +8,14 @@
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
|
||||
#include <SFML/Network.hpp>
|
||||
|
||||
#include "enet/enet.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FifoQueue.h"
|
||||
#include "Common/Thread.h"
|
||||
#include "Common/Timer.h"
|
||||
|
||||
#include "Core/NetPlayProto.h"
|
||||
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
#include <SFML/Network/Packet.hpp>
|
||||
|
||||
class NetPlayUI
|
||||
{
|
||||
@@ -38,7 +36,7 @@ public:
|
||||
|
||||
class Player
|
||||
{
|
||||
public:
|
||||
public:
|
||||
PlayerId pid;
|
||||
std::string name;
|
||||
std::string revision;
|
||||
@@ -87,9 +85,10 @@ protected:
|
||||
Common::FifoQueue<NetWiimote> m_wiimote_buffer[4];
|
||||
|
||||
NetPlayUI* m_dialog;
|
||||
sf::TcpSocket m_socket;
|
||||
std::thread m_thread;
|
||||
sf::SocketSelector m_selector;
|
||||
|
||||
ENetHost* m_client;
|
||||
ENetPeer* m_server;
|
||||
std::thread m_thread;
|
||||
|
||||
std::string m_selected_game;
|
||||
volatile bool m_is_running;
|
||||
@@ -111,9 +110,17 @@ private:
|
||||
void SendPadState(const PadMapping in_game_pad, const GCPadStatus& np);
|
||||
void SendWiimoteState(const PadMapping in_game_pad, const NetWiimote& nw);
|
||||
unsigned int OnData(sf::Packet& packet);
|
||||
void Send(sf::Packet& packet);
|
||||
void Disconnect();
|
||||
bool Connect();
|
||||
|
||||
void OnTraversalDisconnect(int fail);
|
||||
|
||||
PlayerId m_pid;
|
||||
std::map<PlayerId, Player> m_players;
|
||||
std::string m_host_spec;
|
||||
std::string m_player_name;
|
||||
bool m_connecting;
|
||||
};
|
||||
|
||||
void NetPlay_Enable(NetPlayClient* const np);
|
||||
|
||||
+254
-204
File diff suppressed because it is too large
Load Diff
@@ -7,15 +7,13 @@
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <SFML/Network.hpp>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "enet/enet.h"
|
||||
#include "Common/Thread.h"
|
||||
#include "Common/Timer.h"
|
||||
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include <SFML/Network/Packet.hpp>
|
||||
|
||||
class NetPlayServer
|
||||
{
|
||||
@@ -40,7 +38,9 @@ public:
|
||||
|
||||
void AdjustPadBufferSize(unsigned int size);
|
||||
|
||||
void KickPlayer(u8 player);
|
||||
void KickPlayer(PlayerId player);
|
||||
|
||||
u16 GetPort();
|
||||
|
||||
bool is_connected;
|
||||
|
||||
@@ -56,20 +56,10 @@ private:
|
||||
std::string name;
|
||||
std::string revision;
|
||||
|
||||
std::unique_ptr<sf::TcpSocket> socket;
|
||||
ENetPeer* socket;
|
||||
u32 ping;
|
||||
u32 current_game;
|
||||
|
||||
// VS2013 does not generate the right constructors here automatically
|
||||
// like GCC does, so we implement them manually
|
||||
Client() = default;
|
||||
Client(const Client& other) = delete;
|
||||
Client(Client&& other)
|
||||
: pid(other.pid), name(std::move(other.name)), revision(std::move(other.revision)),
|
||||
socket(std::move(other.socket)), ping(other.ping), current_game(other.current_game)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const Client& other) const
|
||||
{
|
||||
return this == &other;
|
||||
@@ -77,7 +67,8 @@ private:
|
||||
};
|
||||
|
||||
void SendToClients(sf::Packet& packet, const PlayerId skip_pid = 0);
|
||||
unsigned int OnConnect(std::unique_ptr<sf::TcpSocket>& socket);
|
||||
void Send(ENetPeer* socket, sf::Packet& packet);
|
||||
unsigned int OnConnect(ENetPeer* socket);
|
||||
unsigned int OnDisconnect(Client& player);
|
||||
unsigned int OnData(sf::Packet& packet, Client& player);
|
||||
void UpdatePadMapping();
|
||||
@@ -95,7 +86,7 @@ private:
|
||||
PadMapping m_pad_map[4];
|
||||
PadMapping m_wiimote_map[4];
|
||||
|
||||
std::list<Client> m_players;
|
||||
std::map<u32, Client> m_players;
|
||||
|
||||
struct
|
||||
{
|
||||
@@ -105,10 +96,9 @@ private:
|
||||
} m_crit;
|
||||
|
||||
std::string m_selected_game;
|
||||
|
||||
sf::TcpListener m_socket;
|
||||
std::thread m_thread;
|
||||
sf::SocketSelector m_selector;
|
||||
|
||||
ENetHost* m_server;
|
||||
|
||||
#ifdef USE_UPNP
|
||||
static void mapPortThread(const u16 port);
|
||||
|
||||
Reference in New Issue
Block a user