401 changes: 0 additions & 401 deletions Source/Core/Core/Src/NetPlay.cpp

This file was deleted.

275 changes: 0 additions & 275 deletions Source/Core/Core/Src/NetPlay.h

This file was deleted.

386 changes: 380 additions & 6 deletions Source/Core/Core/Src/NetPlayClient.cpp

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions Source/Core/Core/Src/NetPlayClient.h
@@ -0,0 +1,135 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.

#ifndef _NETPLAY_H
#define _NETPLAY_H

#include "Common.h"
#include "CommonTypes.h"
#include "Thread.h"
#include "Timer.h"

#include <SFML/Network.hpp>

#include "NetPlayProto.h"
#include "GCPadStatus.h"

#include <functional>
#include <map>
#include <queue>
#include <sstream>

#include "FifoQueue.h"

class NetPad
{
public:
NetPad();
NetPad(const SPADStatus* const);

u32 nHi;
u32 nLo;
};

class NetPlayUI
{
public:
virtual ~NetPlayUI() {};

virtual void BootGame(const std::string& filename) = 0;
virtual void StopGame() = 0;

virtual void Update() = 0;
virtual void AppendChat(const std::string& msg) = 0;

virtual void OnMsgChangeGame(const std::string& filename) = 0;
virtual void OnMsgStartGame() = 0;
virtual void OnMsgStopGame() = 0;
};

extern NetSettings g_NetPlaySettings;

class NetPlayClient
{
public:
void ThreadFunc();

NetPlayClient(const std::string& address, const u16 port, NetPlayUI* dialog, const std::string& name);
~NetPlayClient();

void GetPlayerList(std::string& list, std::vector<int>& pid_list);

bool is_connected;

bool StartGame(const std::string &path);
bool StopGame();
bool ChangeGame(const std::string& game);
void SendChatMessage(const std::string& msg);

// Send and receive pads values
void WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size);
void WiimoteUpdate(int _number);
bool GetNetPads(const u8 pad_nb, const SPADStatus* const, NetPad* const netvalues);

u8 GetPadNum(u8 numPAD);

protected:
void ClearBuffers();

struct
{
std::recursive_mutex game;
// lock order
std::recursive_mutex players, send;
} m_crit;

class Player
{
public:
Player();
std::string ToString() const;

PlayerId pid;
std::string name;
PadMapping pad_map[4];
std::string revision;
u32 ping;
};

Common::FifoQueue<NetPad> m_pad_buffer[4];
Common::FifoQueue<NetWiimote> m_wiimote_buffer[4];

NetWiimote m_wiimote_input[4];

NetPlayUI* m_dialog;
sf::SocketTCP m_socket;
std::thread m_thread;
sf::Selector<sf::SocketTCP> m_selector;

std::string m_selected_game;
volatile bool m_is_running;
volatile bool m_do_loop;

unsigned int m_target_buffer_size;

Player* m_local_player;

u32 m_current_game;

private:
void SendPadState(const PadMapping local_nb, const NetPad& np);
unsigned int OnData(sf::Packet& packet);

PlayerId m_pid;
std::map<PlayerId, Player> m_players;
};

namespace NetPlay {
bool IsNetPlayRunning();
};

void NetPlay_Enable(NetPlayClient* const np);
void NetPlay_Disable();

#endif
68 changes: 68 additions & 0 deletions Source/Core/Core/Src/NetPlayProto.h
@@ -0,0 +1,68 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.

#ifndef _NETPLAY_PROTO_H
#define _NETPLAY_PROTO_H

#include "Common.h"
#include "CommonTypes.h"

struct NetSettings
{
bool m_DSPHLE;
bool m_DSPEnableJIT;
bool m_WriteToMemcard;
u8 m_Controllers[4];
};

struct Rpt : public std::vector<u8>
{
u16 channel;
};

typedef std::vector<Rpt> NetWiimote;

#define NETPLAY_VERSION "Dolphin NetPlay 2013-08-05"

// messages
enum
{
NP_MSG_PLAYER_JOIN = 0x10,
NP_MSG_PLAYER_LEAVE = 0x11,

NP_MSG_CHAT_MESSAGE = 0x30,

NP_MSG_PAD_DATA = 0x60,
NP_MSG_PAD_MAPPING = 0x61,
NP_MSG_PAD_BUFFER = 0x62,

NP_MSG_WIIMOTE_DATA = 0x70,
NP_MSG_WIIMOTE_MAPPING = 0x71, // just using pad mapping for now

NP_MSG_START_GAME = 0xA0,
NP_MSG_CHANGE_GAME = 0xA1,
NP_MSG_STOP_GAME = 0xA2,
NP_MSG_DISABLE_GAME = 0xA3,

NP_MSG_READY = 0xD0,
NP_MSG_NOT_READY = 0xD1,

NP_MSG_PING = 0xE0,
NP_MSG_PONG = 0xE1,
NP_MSG_PLAYER_PING_DATA = 0xE2,
};

typedef u8 MessageId;
typedef u8 PlayerId;
typedef s8 PadMapping;
typedef u32 FrameNum;

enum
{
CON_ERR_SERVER_FULL = 1,
CON_ERR_GAME_RUNNING,
CON_ERR_VERSION_MISMATCH
};

#endif
132 changes: 40 additions & 92 deletions Source/Core/Core/Src/NetPlayServer.cpp
Expand Up @@ -2,15 +2,31 @@
// Licensed under GPLv2
// Refer to the license.txt file included.

#include "NetPlay.h"
#include "NetPlayServer.h"

NetPlayServer::Client::Client()
{
memset(pad_map, -1, sizeof(pad_map));
}

// called from ---GUI--- thread
std::string NetPlayServer::Client::ToString() const
{
std::ostringstream ss;
ss << name << '[' << (char)(pid+'0') << "] : " << revision << " |";
for (unsigned int i=0; i<4; ++i)
ss << (pad_map[i]>=0 ? (char)(pad_map[i]+'1') : '-');
ss << '|';
return ss.str();
}

NetPlayServer::~NetPlayServer()
{
if (is_connected)
{
m_do_loop = false;
m_thread.join();
m_socket.Close();
}

#ifdef USE_UPNP
Expand All @@ -22,35 +38,15 @@ NetPlayServer::~NetPlayServer()
}

// called from ---GUI--- thread
NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayUI* dialog) : NetPlay(dialog)
NetPlayServer::NetPlayServer(const u16 port) : is_connected(false), m_is_running(false)
{
m_update_pings = true;

if (m_socket.Listen(port))
{
Client player;
player.pid = 0;
player.revision = netplay_dolphin_ver;
player.socket = m_socket;
player.name = name;

// map local pad 1 to game pad 1
player.pad_map[0] = 0;

// add self to player list
m_players[m_socket] = player;
m_local_player = &m_players[m_socket];
//PanicAlertT("Listening");

m_dialog->Update();

is_connected = true;

m_do_loop = true;
m_selector.Add(m_socket);
m_thread = std::thread(std::mem_fun(&NetPlayServer::ThreadFunc), this);
}
else
is_connected = false;
}

// called from ---NETPLAY--- thread
Expand Down Expand Up @@ -258,8 +254,6 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket)
// add client to selector/ used for receiving
m_selector.Add(socket);

m_dialog->Update();

return 0;
}

Expand All @@ -271,7 +265,6 @@ unsigned int NetPlayServer::OnDisconnect(sf::SocketTCP& socket)
PanicAlertT("Client disconnect while game is running!! NetPlay is disabled. You must manually stop the game.");
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
m_is_running = false;
NetPlay_Disable();

sf::Packet spac;
spac << (MessageId)NP_MSG_DISABLE_GAME;
Expand All @@ -293,8 +286,6 @@ unsigned int NetPlayServer::OnDisconnect(sf::SocketTCP& socket)
std::lock_guard<std::recursive_mutex> lks(m_crit.send);
SendToClients(spac);

m_dialog->Update();

return 0;
}

Expand Down Expand Up @@ -357,8 +348,6 @@ bool NetPlayServer::SetPadMapping(const int pid, const int map[])
std::lock_guard<std::recursive_mutex> lks(m_crit.send);
UpdatePadMapping(); // sync pad mappings with everyone

m_dialog->Update();

return true;
}

Expand All @@ -380,29 +369,6 @@ void NetPlayServer::UpdatePadMapping()

}

// called from ---GUI--- thread and ---NETPLAY--- thread
u64 NetPlayServer::CalculateMinimumBufferTime()
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);

std::map<sf::SocketTCP, Client>::const_iterator
i = m_players.begin(),
e = m_players.end();
std::priority_queue<unsigned int> pings;
for ( ;i!=e; ++i)
pings.push(i->second.ping/2);

unsigned int required_ms = pings.top();
// if there is more than 1 client, buffersize must be >= (2 highest ping times combined)
if (pings.size() > 1)
{
pings.pop();
required_ms += pings.top();
}

return required_ms;
}

// called from ---GUI--- thread and ---NETPLAY--- thread
void NetPlayServer::AdjustPadBufferSize(unsigned int size)
{
Expand Down Expand Up @@ -447,12 +413,6 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
std::lock_guard<std::recursive_mutex> lks(m_crit.send);
SendToClients(spac, player.pid);
}

// add to gui
std::ostringstream ss;
ss << player.name << '[' << (char)(player.pid+'0') << "]: " << msg;

m_dialog->AppendChat(ss.str());
}
break;

Expand All @@ -463,8 +423,8 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
break;

PadMapping map = 0;
NetPad np;
packet >> map >> np.nHi >> np.nLo;
int hi, lo;
packet >> map >> hi >> lo;

// check if client's pad indeed maps in game
if (map >= 0 && map < 4)
Expand All @@ -477,14 +437,12 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
if (map < 0)
return 1;

// add to pad buffer
m_pad_buffer[(unsigned)map].Push(np);

// relay to clients
sf::Packet spac;
spac << (MessageId)NP_MSG_PAD_DATA;
spac << map; // in game mapping
spac << np.nHi << np.nLo;
spac << hi << lo;

std::lock_guard<std::recursive_mutex> lks(m_crit.send);
SendToClients(spac, player.pid);
Expand All @@ -498,11 +456,15 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
packet >> ping_key;

if (m_ping_key == ping_key)
{
//PanicAlertT("Good pong");
player.ping = ping;
}
m_dialog->Update();

sf::Packet spac;
spac << (MessageId)NP_MSG_PLAYER_PING_DATA;
spac << player.pid;
spac << player.ping;

std::lock_guard<std::recursive_mutex> lks(m_crit.send);
SendToClients(spac);
}
break;

Expand Down Expand Up @@ -573,29 +535,16 @@ bool NetPlayServer::ChangeGame(const std::string &game)
return true;
}

// called from ---CPU--- thread
void NetPlayServer::SendPadState(const PadMapping local_nb, const NetPad& np)
// called from ---GUI--- thread
void NetPlayServer::SetNetSettings(const NetSettings &settings)
{
// send to server
sf::Packet spac;
spac << (MessageId)NP_MSG_PAD_DATA;
spac << m_local_player->pad_map[local_nb]; // in-game pad num
spac << np.nHi << np.nLo;

std::lock_guard<std::recursive_mutex> lks(m_crit.send);
SendToClients(spac);
m_settings = settings;
}

// called from ---GUI--- thread
bool NetPlayServer::StartGame(const std::string &path)
{
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);

GetNetSettings();
if (false == NetPlay::StartGame(path))
return false;

// TODO: i dont like this here
m_current_game = Common::Timer::GetTimeMs();

// no change, just update with clients
Expand All @@ -604,27 +553,26 @@ bool NetPlayServer::StartGame(const std::string &path)
// tell clients to start game
sf::Packet spac;
spac << (MessageId)NP_MSG_START_GAME;
spac << NetPlay::m_current_game;
spac << g_NetPlaySettings.m_DSPEnableJIT;
spac << g_NetPlaySettings.m_DSPHLE;
spac << g_NetPlaySettings.m_WriteToMemcard;
spac << m_current_game;
spac << m_settings.m_DSPEnableJIT;
spac << m_settings.m_DSPHLE;
spac << m_settings.m_WriteToMemcard;
for (unsigned int i = 0; i < 4; ++i)
spac << g_NetPlaySettings.m_Controllers[i];
spac << m_settings.m_Controllers[i];

std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard<std::recursive_mutex> lks(m_crit.send);
SendToClients(spac);

m_is_running = true;

return true;
}


// called from ---GUI--- thread
bool NetPlayServer::StopGame()
{
if (false == NetPlay::StopGame())
return false;

// tell clients to stop game
sf::Packet spac;
spac << (MessageId)NP_MSG_STOP_GAME;
Expand Down
116 changes: 116 additions & 0 deletions Source/Core/Core/Src/NetPlayServer.h
@@ -0,0 +1,116 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.

#ifndef _NETPLAY_SERVER_H
#define _NETPLAY_SERVER_H

#include "Common.h"
#include "CommonTypes.h"
#include "Thread.h"
#include "Timer.h"

#include <SFML/Network.hpp>

#include "NetPlayProto.h"

#include <functional>
#include <map>
#include <queue>
#include <sstream>

class NetPlayServer
{
public:
void ThreadFunc();

NetPlayServer(const u16 port);
~NetPlayServer();

void GetPlayerList(std::string& list, std::vector<int>& pid_list);

bool ChangeGame(const std::string& game);
void SendChatMessage(const std::string& msg);

void SetNetSettings(const NetSettings &settings);

bool StartGame(const std::string &path);
bool StopGame();

bool GetPadMapping(const int pid, int map[]);
bool SetPadMapping(const int pid, const int map[]);

void AdjustPadBufferSize(unsigned int size);

bool is_connected;

#ifdef USE_UPNP
void TryPortmapping(u16 port);
#endif

private:
class Client
{
public:
Client();
std::string ToString() const;

PlayerId pid;
std::string name;
PadMapping pad_map[4];
std::string revision;

sf::SocketTCP socket;
u32 ping;
u32 current_game;
};

void SendToClients(sf::Packet& packet, const PlayerId skip_pid = 0);
unsigned int OnConnect(sf::SocketTCP& socket);
unsigned int OnDisconnect(sf::SocketTCP& socket);
unsigned int OnData(sf::Packet& packet, sf::SocketTCP& socket);
void UpdatePadMapping();

NetSettings m_settings;

bool m_is_running;
bool m_do_loop;
Common::Timer m_ping_timer;
u32 m_ping_key;
bool m_update_pings;
u32 m_current_game;
unsigned int m_target_buffer_size;

std::map<sf::SocketTCP, Client> m_players;

struct
{
std::recursive_mutex game;
// lock order
std::recursive_mutex players, send;
} m_crit;

std::string m_selected_game;

sf::SocketTCP m_socket;
std::thread m_thread;
sf::Selector<sf::SocketTCP> m_selector;

#ifdef USE_UPNP
static void mapPortThread(const u16 port);
static void unmapPortThread();

static bool initUPnP();
static bool UPnPMapPort(const std::string& addr, const u16 port);
static bool UPnPUnmapPort(const u16 port);

static struct UPNPUrls m_upnp_urls;
static struct IGDdatas m_upnp_data;
static u16 m_upnp_mapped;
static bool m_upnp_inited;
static bool m_upnp_error;
static std::thread m_upnp_thread;
#endif
};

#endif
130 changes: 74 additions & 56 deletions Source/Core/DolphinWX/Src/NetWindow.cpp
Expand Up @@ -6,10 +6,12 @@
#include <IniFile.h>

#include "WxUtils.h"
#include "NetPlay.h"
#include "NetPlayClient.h"
#include "NetPlayServer.h"
#include "NetWindow.h"
#include "Frame.h"
#include "Core.h"
#include "ConfigManager.h"

#include <sstream>
#include <string>
Expand All @@ -20,7 +22,8 @@ BEGIN_EVENT_TABLE(NetPlayDiag, wxFrame)
EVT_COMMAND(wxID_ANY, wxEVT_THREAD, NetPlayDiag::OnThread)
END_EVENT_TABLE()

static NetPlay* netplay_ptr = NULL;
static NetPlayServer* netplay_server = NULL;
static NetPlayClient* netplay_client = NULL;
extern CFrame* main_frame;
NetPlayDiag *NetPlayDiag::npd = NULL;

Expand Down Expand Up @@ -200,6 +203,28 @@ NetPlaySetupDiag::~NetPlaySetupDiag()
main_frame->g_NetPlaySetupDiag = NULL;
}

void NetPlaySetupDiag::MakeNetPlayDiag(int port, const std::string &game, bool is_hosting)
{
NetPlayDiag *&npd = NetPlayDiag::GetInstance();
std::string ip;
npd = new NetPlayDiag(m_parent, m_game_list, game, is_hosting);
if (is_hosting)
ip = "127.0.0.1";
else
ip = WxStrToStr(m_connect_ip_text->GetValue());

netplay_client = new NetPlayClient(ip, (u16)port, npd, WxStrToStr(m_nickname_text->GetValue()));
if (netplay_client->is_connected)
{
npd->Show();
Destroy();
}
else
{
npd->Destroy();
}
}

void NetPlaySetupDiag::OnHost(wxCommandEvent&)
{
NetPlayDiag *&npd = NetPlayDiag::GetInstance();
Expand All @@ -217,25 +242,19 @@ void NetPlaySetupDiag::OnHost(wxCommandEvent&)

std::string game(WxStrToStr(m_game_lbox->GetStringSelection()));

npd = new NetPlayDiag(m_parent, m_game_list, game, true);
unsigned long port = 0;
m_host_port_text->GetValue().ToULong(&port);
netplay_ptr = new NetPlayServer(u16(port), WxStrToStr(m_nickname_text->GetValue()), npd);
netplay_ptr->ChangeGame(game);
if (netplay_ptr->is_connected)
netplay_server = new NetPlayServer(u16(port));
netplay_server->ChangeGame(game);
if (netplay_server->is_connected)
{
#ifdef USE_UPNP
if(m_upnp_chk->GetValue())
((NetPlayServer*)netplay_ptr)->TryPortmapping(port);
netplay_server->TryPortmapping(port);
#endif
npd->Show();
Destroy();
}
else
{
PanicAlertT("Failed to Listen!!");
npd->Destroy();
}

MakeNetPlayDiag(port, game, true);
}

void NetPlaySetupDiag::OnJoin(wxCommandEvent&)
Expand All @@ -247,20 +266,9 @@ void NetPlaySetupDiag::OnJoin(wxCommandEvent&)
return;
}

npd = new NetPlayDiag(m_parent, m_game_list, "");
unsigned long port = 0;
m_connect_port_text->GetValue().ToULong(&port);
netplay_ptr = new NetPlayClient(WxStrToStr(m_connect_ip_text->GetValue())
, (u16)port, npd, WxStrToStr(m_nickname_text->GetValue()));
if (netplay_ptr->is_connected)
{
npd->Show();
Destroy();
}
else
{
npd->Destroy();
}
MakeNetPlayDiag(port, "", false);
}

void NetPlaySetupDiag::OnQuit(wxCommandEvent&)
Expand Down Expand Up @@ -344,7 +352,6 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game
}

m_memcard_write = new wxCheckBox(panel, wxID_ANY, _("Write memcards (GC)"));
m_memcard_write->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &NetPlayDiag::OnMemcardWriteCheck, this);
bottom_szr->Add(m_memcard_write, 0, wxCENTER);

bottom_szr->AddStretchSpacer(1);
Expand All @@ -366,10 +373,15 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game

NetPlayDiag::~NetPlayDiag()
{
if (netplay_ptr)
if (netplay_client)
{
delete netplay_client;
netplay_client = NULL;
}
if (netplay_server)
{
delete netplay_ptr;
netplay_ptr = NULL;
delete netplay_server;
netplay_server = NULL;
}
npd = NULL;
}
Expand All @@ -380,37 +392,50 @@ void NetPlayDiag::OnChat(wxCommandEvent&)

if (s.Length())
{
netplay_ptr->SendChatMessage(WxStrToStr(s));
netplay_client->SendChatMessage(WxStrToStr(s));
m_chat_text->AppendText(s.Prepend(wxT(" >> ")).Append(wxT('\n')));
m_chat_msg_text->Clear();
}
}

void NetPlayDiag::OnStart(wxCommandEvent&)
void NetPlayDiag::GetNetSettings(NetSettings &settings)
{
SConfig &instance = SConfig::GetInstance();
settings.m_DSPHLE = instance.m_LocalCoreStartupParameter.bDSPHLE;
settings.m_DSPEnableJIT = instance.m_EnableJIT;
settings.m_WriteToMemcard = m_memcard_write->GetValue();

for (unsigned int i = 0; i < 4; ++i)
settings.m_Controllers[i] = SConfig::GetInstance().m_SIDevice[i];
}

const std::string& NetPlayDiag::FindGame()
{
// find path for selected game, sloppy..
for (u32 i = 0 ; auto game = m_game_list->GetISO(i); ++i)
{
if (m_selected_game == BuildGameName(*game))
{
netplay_ptr->StartGame(game->GetFileName());
return;
}
}
return game->GetFileName();

PanicAlertT("Game not found!");
return "";
}

void NetPlayDiag::OnStart(wxCommandEvent&)
{
NetSettings settings;
GetNetSettings(settings);
netplay_server->SetNetSettings(settings);
netplay_server->StartGame(FindGame());
}

void NetPlayDiag::OnStop(wxCommandEvent&)
{
netplay_ptr->StopGame();
netplay_server->StopGame();
}

void NetPlayDiag::BootGame(const std::string& filename)
{
main_frame->BootGame(filename);

Core::g_CoreStartupParameter.bEnableMemcardSaving = m_memcard_write->GetValue();
}

void NetPlayDiag::StopGame()
Expand Down Expand Up @@ -452,19 +477,14 @@ void NetPlayDiag::OnMsgStopGame()
GetEventHandler()->AddPendingEvent(evt);
}

void NetPlayDiag::OnMemcardWriteCheck(wxCommandEvent &event)
{
netplay_ptr->SetMemcardWriteEnabled(m_memcard_write->GetValue());
}

void NetPlayDiag::OnAdjustBuffer(wxCommandEvent& event)
{
const int val = ((wxSpinCtrl*)event.GetEventObject())->GetValue();
((NetPlayServer*)netplay_ptr)->AdjustPadBufferSize(val);
netplay_server->AdjustPadBufferSize(val);

std::ostringstream ss;
ss << "< Pad Buffer: " << val << " >";
netplay_ptr->SendChatMessage(ss.str());
netplay_client->SendChatMessage(ss.str());
m_chat_text->AppendText(StrToWxStr(ss.str()).Append(wxT('\n')));
}

Expand All @@ -479,7 +499,7 @@ void NetPlayDiag::OnThread(wxCommandEvent& event)
// player list
m_playerids.clear();
std::string tmps;
netplay_ptr->GetPlayerList(tmps, m_playerids);
netplay_client->GetPlayerList(tmps, m_playerids);

const int selection = m_player_lbox->GetSelection();

Expand All @@ -502,15 +522,13 @@ void NetPlayDiag::OnThread(wxCommandEvent& event)
case NP_GUI_EVT_START_GAME :
// client start game :/
{
wxCommandEvent evt;
OnStart(evt);
netplay_client->StartGame(FindGame());
}
break;
case NP_GUI_EVT_STOP_GAME :
// client stop game
{
wxCommandEvent evt;
OnStop(evt);
netplay_client->StopGame();
}
break;
}
Expand All @@ -534,7 +552,7 @@ void NetPlayDiag::OnChangeGame(wxCommandEvent&)
if (game_name.length())
{
m_selected_game = WxStrToStr(game_name);
netplay_ptr->ChangeGame(m_selected_game);
netplay_server->ChangeGame(m_selected_game);
m_game_btn->SetLabel(game_name.Prepend(_(" Game : ")));
}
}
Expand All @@ -549,13 +567,13 @@ void NetPlayDiag::OnConfigPads(wxCommandEvent&)
return;
pid = m_playerids.at(pid);

if (false == ((NetPlayServer*)netplay_ptr)->GetPadMapping(pid, mapping))
if (false == netplay_server->GetPadMapping(pid, mapping))
return;

PadMapDiag pmd(this, mapping);
pmd.ShowModal();

if (false == ((NetPlayServer*)netplay_ptr)->SetPadMapping(pid, mapping))
if (false == netplay_server->SetPadMapping(pid, mapping))
PanicAlertT("Could not set pads. The player left or the game is currently running!\n"
"(setting pads while the game is running is not yet supported)");
}
Expand Down
7 changes: 5 additions & 2 deletions Source/Core/DolphinWX/Src/NetWindow.h
Expand Up @@ -23,7 +23,7 @@

#include "FifoQueue.h"

#include "NetPlay.h"
#include "NetPlayClient.h"

enum
{
Expand All @@ -42,6 +42,8 @@ class NetPlaySetupDiag : public wxFrame
void OnHost(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);

void MakeNetPlayDiag(int port, const std::string &game, bool is_hosting);

wxTextCtrl *m_nickname_text,
*m_host_port_text,
*m_connect_port_text,
Expand Down Expand Up @@ -85,11 +87,12 @@ class NetPlayDiag : public wxFrame, public NetPlayUI

void OnChat(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
void OnMemcardWriteCheck(wxCommandEvent& event);
void OnThread(wxCommandEvent& event);
void OnChangeGame(wxCommandEvent& event);
void OnAdjustBuffer(wxCommandEvent& event);
void OnConfigPads(wxCommandEvent& event);
void GetNetSettings(NetSettings &settings);
const std::string& FindGame();

wxListBox* m_player_lbox;
wxTextCtrl* m_chat_text;
Expand Down