Revert "Update Link code to use SMFL Version 2" and "Enable link functionality by default"

This reverts commit 9a359f5b8e.
This reverts commit 3d3229f899.
This commit is contained in:
Arthur Moore 2015-04-10 02:52:14 -04:00
parent bc6f047c44
commit 06c753fe25
6 changed files with 85 additions and 90 deletions

View File

@ -18,7 +18,7 @@ option( ENABLE_NLS "Enable translations" ON )
option( ENABLE_ASM_CORE "Enable x86 ASM CPU cores" OFF ) option( ENABLE_ASM_CORE "Enable x86 ASM CPU cores" OFF )
option( ENABLE_ASM_SCALERS "Enable x86 ASM graphic filters" OFF ) option( ENABLE_ASM_SCALERS "Enable x86 ASM graphic filters" OFF )
option( ENABLE_MMX "Enable MMX" OFF ) option( ENABLE_MMX "Enable MMX" OFF )
option( ENABLE_LINK "Enable GBA linking functionality" ON ) option( ENABLE_LINK "Enable GBA linking functionality" OFF )
option( ENABLE_LIRC "Enable LIRC support" OFF ) option( ENABLE_LIRC "Enable LIRC support" OFF )
option( ENABLE_FFMPEG "Enable ffmpeg A/V recording" OFF ) option( ENABLE_FFMPEG "Enable ffmpeg A/V recording" OFF )
if(ENABLE_ASM_SCALERS) if(ENABLE_ASM_SCALERS)

View File

@ -162,7 +162,7 @@ int WaitForSingleObject(sem_t *s, int t)
int linktime = 0; int linktime = 0;
GBASockClient* dol = NULL; GBASockClient* dol = NULL;
sf::IpAddress joybusHostAddr = sf::IpAddress::LocalHost; sf::IPAddress joybusHostAddr = sf::IPAddress::LocalHost;
// Hodgepodge // Hodgepodge
u8 tspeed = 3; u8 tspeed = 3;
@ -1105,7 +1105,7 @@ void CloseLink(void){
char outbuffer[4]; char outbuffer[4];
outbuffer[0] = 4; outbuffer[0] = 4;
outbuffer[1] = -32; outbuffer[1] = -32;
if(lanlink.type==0) lanlink.tcpsocket.send(outbuffer, 4); if(lanlink.type==0) lanlink.tcpsocket.Send(outbuffer, 4);
} else { } else {
char outbuffer[12]; char outbuffer[12];
int i; int i;
@ -1113,9 +1113,9 @@ void CloseLink(void){
outbuffer[1] = -32; outbuffer[1] = -32;
for(i=1;i<=lanlink.numslaves;i++){ for(i=1;i<=lanlink.numslaves;i++){
if(lanlink.type==0){ if(lanlink.type==0){
ls.tcpsocket[i].send(outbuffer, 12); ls.tcpsocket[i].Send(outbuffer, 12);
} }
ls.tcpsocket[i].disconnect(); ls.tcpsocket[i].Close();
} }
} }
} }
@ -1187,7 +1187,7 @@ lserver::lserver(void){
bool lserver::Init(ServerInfoDisplay *sid){ bool lserver::Init(ServerInfoDisplay *sid){
// too bad Listen() doesn't take an address as well // too bad Listen() doesn't take an address as well
// then again, old code used INADDR_ANY anyway // then again, old code used INADDR_ANY anyway
if(!lanlink.listener.listen(IP_LINK_PORT)) if(!lanlink.tcpsocket.Listen(IP_LINK_PORT))
// Note: old code closed socket & retried once on bind failure // Note: old code closed socket & retried once on bind failure
return false; // FIXME: error code? return false; // FIXME: error code?
@ -1200,10 +1200,10 @@ bool lserver::Init(ServerInfoDisplay *sid){
linkid = 0; linkid = 0;
// should probably use GetPublicAddress() // should probably use GetPublicAddress()
sid->ShowServerIP(sf::IpAddress::getLocalAddress()); sid->ShowServerIP(sf::IPAddress::GetLocalAddress());
lanlink.thread = new sf::Thread(LinkServerThread, sid); lanlink.thread = new sf::Thread(LinkServerThread, sid);
lanlink.thread->launch(); lanlink.thread->Launch();
return true; return true;
@ -1211,7 +1211,7 @@ bool lserver::Init(ServerInfoDisplay *sid){
void LinkServerThread(void *_sid){ void LinkServerThread(void *_sid){
ServerInfoDisplay *sid = (ServerInfoDisplay *)_sid; ServerInfoDisplay *sid = (ServerInfoDisplay *)_sid;
sf::SocketSelector fdset; sf::Selector<sf::SocketTCP> fdset;
char inbuffer[256], outbuffer[256]; char inbuffer[256], outbuffer[256];
s32 *intinbuffer = (s32*)inbuffer; s32 *intinbuffer = (s32*)inbuffer;
u16 *u16inbuffer = (u16*)inbuffer; u16 *u16inbuffer = (u16*)inbuffer;
@ -1221,24 +1221,24 @@ void LinkServerThread(void *_sid){
i = 0; i = 0;
while(i<lanlink.numslaves){ while(i<lanlink.numslaves){
fdset.clear(); fdset.Clear();
fdset.add(lanlink.tcpsocket); fdset.Add(lanlink.tcpsocket);
if(lanlink.terminate){ if(lanlink.terminate){
ReleaseSemaphore(linksync[vbaid], 1, NULL); ReleaseSemaphore(linksync[vbaid], 1, NULL);
goto CloseInfoDisplay; goto CloseInfoDisplay;
} }
if(fdset.wait(sf::seconds(0.1))==1){ if(fdset.Wait(0.1)==1){
sf::Socket::Status st = sf::Socket::Status st =
lanlink.listener.accept(ls.tcpsocket[i+1]); lanlink.tcpsocket.Accept(ls.tcpsocket[i+1]);
if(st == sf::Socket::Error) { if(st == sf::Socket::Error) {
for(int j=1;j<i;j++) ls.tcpsocket[j].disconnect(); for(int j=1;j<i;j++) ls.tcpsocket[j].Close();
systemMessage(0, N_("Network error.")); systemMessage(0, N_("Network error."));
lanlink.terminate = true; lanlink.terminate = true;
} else { } else {
i++; i++;
WRITE16LE(&u16outbuffer[0], i); WRITE16LE(&u16outbuffer[0], i);
WRITE16LE(&u16outbuffer[1], lanlink.numslaves); WRITE16LE(&u16outbuffer[1], lanlink.numslaves);
ls.tcpsocket[i].send(outbuffer, 4); ls.tcpsocket[i].Send(outbuffer, 4);
sid->ShowConnect(i); sid->ShowConnect(i);
} }
} }
@ -1251,7 +1251,7 @@ void LinkServerThread(void *_sid){
for(i=1;i<=lanlink.numslaves;i++){ for(i=1;i<=lanlink.numslaves;i++){
outbuffer[0] = 4; outbuffer[0] = 4;
ls.tcpsocket[i].send(outbuffer, 4); ls.tcpsocket[i].Send(outbuffer, 4);
} }
CloseInfoDisplay: CloseInfoDisplay:
@ -1265,9 +1265,9 @@ void lserver::Send(void){
outbuffer[0] = 4; outbuffer[0] = 4;
outbuffer[1] = -32; //0xe0 outbuffer[1] = -32; //0xe0
for(i=1;i<=lanlink.numslaves;i++){ for(i=1;i<=lanlink.numslaves;i++){
tcpsocket[i].send(outbuffer, 4); tcpsocket[i].Send(outbuffer, 4);
size_t nr; size_t nr;
tcpsocket[i].receive(inbuffer, 4, nr); tcpsocket[i].Receive(inbuffer, 4, nr);
} }
} }
outbuffer[1] = tspeed; outbuffer[1] = tspeed;
@ -1276,27 +1276,27 @@ void lserver::Send(void){
if(lanlink.numslaves==1){ if(lanlink.numslaves==1){
if(lanlink.type==0){ if(lanlink.type==0){
outbuffer[0] = 8; outbuffer[0] = 8;
tcpsocket[1].send(outbuffer, 8); tcpsocket[1].Send(outbuffer, 8);
} }
} }
else if(lanlink.numslaves==2){ else if(lanlink.numslaves==2){
WRITE16LE(&u16outbuffer[4], linkdata[2]); WRITE16LE(&u16outbuffer[4], linkdata[2]);
if(lanlink.type==0){ if(lanlink.type==0){
outbuffer[0] = 10; outbuffer[0] = 10;
tcpsocket[1].send(outbuffer, 10); tcpsocket[1].Send(outbuffer, 10);
WRITE16LE(&u16outbuffer[4], linkdata[1]); WRITE16LE(&u16outbuffer[4], linkdata[1]);
tcpsocket[2].send(outbuffer, 10); tcpsocket[2].Send(outbuffer, 10);
} }
} else { } else {
if(lanlink.type==0){ if(lanlink.type==0){
outbuffer[0] = 12; outbuffer[0] = 12;
WRITE16LE(&u16outbuffer[4], linkdata[2]); WRITE16LE(&u16outbuffer[4], linkdata[2]);
WRITE16LE(&u16outbuffer[5], linkdata[3]); WRITE16LE(&u16outbuffer[5], linkdata[3]);
tcpsocket[1].send(outbuffer, 12); tcpsocket[1].Send(outbuffer, 12);
WRITE16LE(&u16outbuffer[4], linkdata[1]); WRITE16LE(&u16outbuffer[4], linkdata[1]);
tcpsocket[2].send(outbuffer, 12); tcpsocket[2].Send(outbuffer, 12);
WRITE16LE(&u16outbuffer[5], linkdata[2]); WRITE16LE(&u16outbuffer[5], linkdata[2]);
tcpsocket[3].send(outbuffer, 12); tcpsocket[3].Send(outbuffer, 12);
} }
} }
} }
@ -1306,10 +1306,10 @@ void lserver::Send(void){
void lserver::Recv(void){ void lserver::Recv(void){
int numbytes; int numbytes;
if(lanlink.type==0){ // TCP if(lanlink.type==0){ // TCP
fdset.clear(); fdset.Clear();
for(i=0;i<lanlink.numslaves;i++) fdset.add(tcpsocket[i+1]); for(i=0;i<lanlink.numslaves;i++) fdset.Add(tcpsocket[i+1]);
// was linktimeout/1000 (i.e., drop ms part), but that's wrong // was linktimeout/1000 (i.e., drop ms part), but that's wrong
if (fdset.wait(sf::seconds((float)(linktimeout / 1000.))) == 0) if (fdset.Wait((float)(linktimeout / 1000.)) == 0)
{ {
return; return;
} }
@ -1319,7 +1319,7 @@ void lserver::Recv(void){
inbuffer[0] = 1; inbuffer[0] = 1;
while(numbytes<howmanytimes*inbuffer[0]) { while(numbytes<howmanytimes*inbuffer[0]) {
size_t nr; size_t nr;
tcpsocket[i+1].receive(inbuffer+numbytes, howmanytimes*inbuffer[0]-numbytes, nr); tcpsocket[i+1].Receive(inbuffer+numbytes, howmanytimes*inbuffer[0]-numbytes, nr);
numbytes += nr; numbytes += nr;
} }
if(howmanytimes>1) memmove(inbuffer, inbuffer+inbuffer[0]*(howmanytimes-1), inbuffer[0]); if(howmanytimes>1) memmove(inbuffer, inbuffer+inbuffer[0]*(howmanytimes-1), inbuffer[0]);
@ -1331,10 +1331,10 @@ void lserver::Recv(void){
outbuffer[0] = 4; outbuffer[0] = 4;
outbuffer[1] = -32; outbuffer[1] = -32;
for(i=1;i<lanlink.numslaves;i++){ for(i=1;i<lanlink.numslaves;i++){
tcpsocket[i].send(outbuffer, 12); tcpsocket[i].Send(outbuffer, 12);
size_t nr; size_t nr;
tcpsocket[i].receive(inbuffer, 256, nr); tcpsocket[i].Receive(inbuffer, 256, nr);
tcpsocket[i].disconnect(); tcpsocket[i].Close();
} }
return; return;
} }
@ -1357,10 +1357,10 @@ lclient::lclient(void){
return; return;
} }
bool lclient::Init(sf::IpAddress addr, ClientInfoDisplay *cid){ bool lclient::Init(sf::IPAddress addr, ClientInfoDisplay *cid){
serveraddr = addr; serveraddr = addr;
serverport = IP_LINK_PORT; serverport = IP_LINK_PORT;
lanlink.tcpsocket.setBlocking(false); lanlink.tcpsocket.SetBlocking(false);
if(lanlink.thread!=NULL){ if(lanlink.thread!=NULL){
lanlink.terminate = true; lanlink.terminate = true;
@ -1371,19 +1371,19 @@ bool lclient::Init(sf::IpAddress addr, ClientInfoDisplay *cid){
cid->ConnectStart(addr); cid->ConnectStart(addr);
lanlink.terminate = false; lanlink.terminate = false;
lanlink.thread = new sf::Thread(LinkClientThread, cid); lanlink.thread = new sf::Thread(LinkClientThread, cid);
lanlink.thread->launch(); lanlink.thread->Launch();
return true; return true;
} }
void LinkClientThread(void *_cid){ void LinkClientThread(void *_cid){
ClientInfoDisplay *cid = (ClientInfoDisplay *)_cid; ClientInfoDisplay *cid = (ClientInfoDisplay *)_cid;
sf::SocketSelector fdset; sf::Selector<sf::SocketTCP> fdset;
int numbytes; int numbytes;
char inbuffer[16]; char inbuffer[16];
u16 *u16inbuffer = (u16*)inbuffer; u16 *u16inbuffer = (u16*)inbuffer;
unsigned long block = 0; unsigned long block = 0;
while(lanlink.tcpsocket.connect(lc.serveraddr, lc.serverport) != sf::Socket::Done) { while(lanlink.tcpsocket.Connect(lc.serverport, lc.serveraddr) != sf::Socket::Done) {
// stupid SFML has no way of giving what sort of error occurred // stupid SFML has no way of giving what sort of error occurred
// so we'll just have to do a retry loop, I guess. // so we'll just have to do a retry loop, I guess.
cid->Ping(); cid->Ping();
@ -1403,14 +1403,14 @@ void LinkClientThread(void *_cid){
numbytes = 0; numbytes = 0;
size_t got; size_t got;
while(numbytes<4) { while(numbytes<4) {
lanlink.tcpsocket.receive(inbuffer+numbytes, 4 - numbytes, got); lanlink.tcpsocket.Receive(inbuffer+numbytes, 4 - numbytes, got);
numbytes += got; numbytes += got;
fdset.clear(); fdset.Clear();
fdset.add(lanlink.tcpsocket); fdset.Add(lanlink.tcpsocket);
fdset.wait(sf::seconds(0.1)); fdset.Wait(0.1);
cid->Ping(); cid->Ping();
if(lanlink.terminate) { if(lanlink.terminate) {
lanlink.tcpsocket.disconnect(); lanlink.tcpsocket.Close();
goto CloseInfoDisplay; goto CloseInfoDisplay;
} }
} }
@ -1422,14 +1422,14 @@ void LinkClientThread(void *_cid){
numbytes = 0; numbytes = 0;
inbuffer[0] = 1; inbuffer[0] = 1;
while(numbytes<inbuffer[0]) { while(numbytes<inbuffer[0]) {
lanlink.tcpsocket.receive(inbuffer+numbytes, inbuffer[0] - got, got); lanlink.tcpsocket.Receive(inbuffer+numbytes, inbuffer[0] - got, got);
numbytes += got; numbytes += got;
fdset.clear(); fdset.Clear();
fdset.add(lanlink.tcpsocket); fdset.Add(lanlink.tcpsocket);
fdset.wait(sf::seconds(0.1)); fdset.Wait(0.1);
cid->Ping(); cid->Ping();
if(lanlink.terminate) { if(lanlink.terminate) {
lanlink.tcpsocket.disconnect(); lanlink.tcpsocket.Close();
goto CloseInfoDisplay; goto CloseInfoDisplay;
} }
} }
@ -1445,16 +1445,16 @@ CloseInfoDisplay:
void lclient::CheckConn(void){ void lclient::CheckConn(void){
size_t nr; size_t nr;
lanlink.tcpsocket.receive(inbuffer, 1, nr); lanlink.tcpsocket.Receive(inbuffer, 1, nr);
numbytes = nr; numbytes = nr;
if(numbytes>0){ if(numbytes>0){
while(numbytes<inbuffer[0]) { while(numbytes<inbuffer[0]) {
lanlink.tcpsocket.receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr); lanlink.tcpsocket.Receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr);
numbytes += nr; numbytes += nr;
} }
if(inbuffer[1]==-32){ if(inbuffer[1]==-32){
outbuffer[0] = 4; outbuffer[0] = 4;
lanlink.tcpsocket.send(outbuffer, 4); lanlink.tcpsocket.Send(outbuffer, 4);
lanlink.connected = false; lanlink.connected = false;
systemScreenMessage(_("Server disconnected.")); systemScreenMessage(_("Server disconnected."));
return; return;
@ -1475,11 +1475,11 @@ void lclient::CheckConn(void){
} }
void lclient::Recv(void){ void lclient::Recv(void){
fdset.clear(); fdset.Clear();
// old code used socket # instead of mask again // old code used socket # instead of mask again
fdset.add(lanlink.tcpsocket); fdset.Add(lanlink.tcpsocket);
// old code stripped off ms again // old code stripped off ms again
if (fdset.wait(sf::seconds((float)(linktimeout / 1000.))) == 0) if (fdset.Wait((float)(linktimeout / 1000.)) == 0)
{ {
numtransfers = 0; numtransfers = 0;
return; return;
@ -1488,12 +1488,12 @@ void lclient::Recv(void){
inbuffer[0] = 1; inbuffer[0] = 1;
size_t nr; size_t nr;
while(numbytes<inbuffer[0]) { while(numbytes<inbuffer[0]) {
lanlink.tcpsocket.receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr); lanlink.tcpsocket.Receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr);
numbytes += nr; numbytes += nr;
} }
if(inbuffer[1]==-32){ if(inbuffer[1]==-32){
outbuffer[0] = 4; outbuffer[0] = 4;
lanlink.tcpsocket.send(outbuffer, 4); lanlink.tcpsocket.Send(outbuffer, 4);
lanlink.connected = false; lanlink.connected = false;
systemScreenMessage(_("Server disconnected.")); systemScreenMessage(_("Server disconnected."));
return; return;
@ -1515,7 +1515,7 @@ void lclient::Send(){
outbuffer[0] = 4; outbuffer[0] = 4;
outbuffer[1] = linkid<<2; outbuffer[1] = linkid<<2;
WRITE16LE(&u16outbuffer[1], linkdata[linkid]); WRITE16LE(&u16outbuffer[1], linkdata[linkid]);
lanlink.tcpsocket.send(outbuffer, 4); lanlink.tcpsocket.Send(outbuffer, 4);
return; return;
} }
#endif #endif

View File

@ -1,7 +1,6 @@
#ifndef GBA_GBALINK_H #ifndef GBA_GBALINK_H
#define GBA_GBALINK_H #define GBA_GBALINK_H
#pragma once #pragma once
// register definitions; these are always present // register definitions; these are always present
@ -55,9 +54,6 @@ enum
extern const char *MakeInstanceFilename(const char *Input); extern const char *MakeInstanceFilename(const char *Input);
#ifndef NO_LINK #ifndef NO_LINK
//Fix for X.h breaking things
#undef None
// Link implementation // Link implementation
#include <SFML/System.hpp> #include <SFML/System.hpp>
#include <SFML/Network.hpp> #include <SFML/Network.hpp>
@ -65,7 +61,7 @@ extern const char *MakeInstanceFilename(const char *Input);
class ServerInfoDisplay class ServerInfoDisplay
{ {
public: public:
virtual void ShowServerIP(const sf::IpAddress& addr) = 0; virtual void ShowServerIP(const sf::IPAddress& addr) = 0;
virtual void ShowConnect(const int player) = 0; virtual void ShowConnect(const int player) = 0;
virtual void Ping() = 0; virtual void Ping() = 0;
virtual void Connected() = 0; virtual void Connected() = 0;
@ -88,7 +84,7 @@ typedef struct {
class lserver{ class lserver{
int numbytes; int numbytes;
sf::SocketSelector fdset; sf::Selector<sf::SocketTCP> fdset;
//timeval udptimeout; //timeval udptimeout;
char inbuffer[256], outbuffer[256]; char inbuffer[256], outbuffer[256];
s32 *intinbuffer; s32 *intinbuffer;
@ -99,8 +95,8 @@ class lserver{
int done; int done;
public: public:
int howmanytimes; int howmanytimes;
sf::TcpSocket tcpsocket[4]; sf::SocketTCP tcpsocket[4];
sf::IpAddress udpaddr[4]; sf::IPAddress udpaddr[4];
lserver(void); lserver(void);
bool Init(ServerInfoDisplay *); bool Init(ServerInfoDisplay *);
void Send(void); void Send(void);
@ -109,14 +105,14 @@ public:
class ClientInfoDisplay { class ClientInfoDisplay {
public: public:
virtual void ConnectStart(const sf::IpAddress& addr) = 0; virtual void ConnectStart(const sf::IPAddress& addr) = 0;
virtual void Ping() = 0; virtual void Ping() = 0;
virtual void ShowConnect(const int player, const int togo) = 0; virtual void ShowConnect(const int player, const int togo) = 0;
virtual void Connected() = 0; virtual void Connected() = 0;
}; };
class lclient{ class lclient{
sf::SocketSelector fdset; sf::Selector<sf::SocketTCP> fdset;
char inbuffer[256], outbuffer[256]; char inbuffer[256], outbuffer[256];
s32 *intinbuffer; s32 *intinbuffer;
u16 *u16inbuffer; u16 *u16inbuffer;
@ -124,20 +120,19 @@ class lclient{
u16 *u16outbuffer; u16 *u16outbuffer;
int numbytes; int numbytes;
public: public:
sf::IpAddress serveraddr; sf::IPAddress serveraddr;
unsigned short serverport; unsigned short serverport;
sf::TcpSocket noblock; sf::SocketTCP noblock;
int numtransfers; int numtransfers;
lclient(void); lclient(void);
bool Init(sf::IpAddress, ClientInfoDisplay *); bool Init(sf::IPAddress, ClientInfoDisplay *);
void Send(void); void Send(void);
void Recv(void); void Recv(void);
void CheckConn(void); void CheckConn(void);
}; };
typedef struct { typedef struct {
sf::TcpListener listener; sf::SocketTCP tcpsocket;
sf::TcpSocket tcpsocket;
//sf::SocketUDP udpsocket; //sf::SocketUDP udpsocket;
int numslaves; int numslaves;
sf::Thread *thread; sf::Thread *thread;
@ -152,7 +147,7 @@ typedef struct {
extern bool gba_joybus_enabled; extern bool gba_joybus_enabled;
extern bool gba_link_enabled; extern bool gba_link_enabled;
extern sf::IpAddress joybusHostAddr; extern sf::IPAddress joybusHostAddr;
extern void JoyBusConnect(); extern void JoyBusConnect();
extern void JoyBusShutdown(); extern void JoyBusShutdown();
extern void JoyBusUpdate(int ticks); extern void JoyBusUpdate(int ticks);

View File

@ -4,20 +4,20 @@
// Currently only for Joybus communications // Currently only for Joybus communications
GBASockClient::GBASockClient(sf::IpAddress _server_addr) GBASockClient::GBASockClient(sf::IPAddress _server_addr)
{ {
if (_server_addr == sf::IpAddress::None) if (!_server_addr.IsValid())
server_addr = sf::IpAddress::LocalHost; server_addr = sf::IPAddress::LocalHost;
else else
server_addr = _server_addr; server_addr = _server_addr;
client.connect(server_addr, 0xd6ba); client.Connect(0xd6ba, server_addr);
//client.SetBlocking(false); //client.SetBlocking(false);
} }
GBASockClient::~GBASockClient() GBASockClient::~GBASockClient()
{ {
client.disconnect(); client.Close();
} }
void GBASockClient::Send(std::vector<char> data) void GBASockClient::Send(std::vector<char> data)
@ -25,7 +25,7 @@ void GBASockClient::Send(std::vector<char> data)
char* plain_data = new char[data.size()]; char* plain_data = new char[data.size()];
std::copy(data.begin(), data.end(), plain_data); std::copy(data.begin(), data.end(), plain_data);
client.send(plain_data, data.size()); client.Send(plain_data, data.size());
delete[] plain_data; delete[] plain_data;
} }
@ -34,7 +34,7 @@ void GBASockClient::Send(std::vector<char> data)
char GBASockClient::ReceiveCmd(char* data_in) char GBASockClient::ReceiveCmd(char* data_in)
{ {
std::size_t num_received; std::size_t num_received;
client.receive(data_in, 5, num_received); client.Receive(data_in, 5, num_received);
return data_in[0]; return data_in[0];
} }

View File

@ -3,16 +3,16 @@
#include <SFML/Network.hpp> #include <SFML/Network.hpp>
#include "../common/Types.h" #include "../common/Types.h"
class GBASockClient : public sf::TcpSocket class GBASockClient : public sf::SocketTCP
{ {
public: public:
GBASockClient(sf::IpAddress server_addr); GBASockClient(sf::IPAddress server_addr);
~GBASockClient(); ~GBASockClient();
void Send(std::vector<char> data); void Send(std::vector<char> data);
char ReceiveCmd(char* data_in); char ReceiveCmd(char* data_in);
private: private:
sf::IpAddress server_addr; sf::IPAddress server_addr;
sf::TcpSocket client; sf::SocketTCP client;
}; };

View File

@ -91,8 +91,8 @@ public:
sid_t(wxMutex *m, wxCondition *c, wxString *cm, wxString *pm, sid_t(wxMutex *m, wxCondition *c, wxString *cm, wxString *pm,
bool *d) : bool *d) :
lock(m), sig(c), connmsg(cm), pmsg(pm), done(d) {} lock(m), sig(c), connmsg(cm), pmsg(pm), done(d) {}
void ShowServerIP(const sf::IpAddress &addr) { void ShowServerIP(const sf::IPAddress &addr) {
wxString addr_s(addr.toString().c_str(), wxConvLibc); wxString addr_s(addr.ToString().c_str(), wxConvLibc);
wxString msg; wxString msg;
msg.Printf(_("Server IP address is: %s\n"), addr_s.c_str()); msg.Printf(_("Server IP address is: %s\n"), addr_s.c_str());
connmsg->append(msg); connmsg->append(msg);
@ -155,8 +155,8 @@ public:
cid_t(wxMutex *m, wxCondition *c, wxString *cm, wxString *pm, cid_t(wxMutex *m, wxCondition *c, wxString *cm, wxString *pm,
bool *d) : bool *d) :
lock(m), sig(c), connmsg(cm), pmsg(pm), done(d) {} lock(m), sig(c), connmsg(cm), pmsg(pm), done(d) {}
void ConnectStart(const sf::IpAddress &addr) { void ConnectStart(const sf::IPAddress &addr) {
wxString addr_s(addr.toString().c_str(), wxConvLibc); wxString addr_s(addr.ToString().c_str(), wxConvLibc);
connmsg->Printf(_("Connecting to %s\n"), addr_s.c_str()); connmsg->Printf(_("Connecting to %s\n"), addr_s.c_str());
} }
void ShowConnect(int player, int togo) { void ShowConnect(int player, int togo) {
@ -188,7 +188,7 @@ public:
cid_t* cid = new cid_t(&lock, &sig, &connmsg, &pmsg, &done); cid_t* cid = new cid_t(&lock, &sig, &connmsg, &pmsg, &done);
if (!lc.Init(sf::IpAddress(std::string(gopts.link_host.mb_str())), cid)) { if (!lc.Init(sf::IPAddress(std::string(gopts.link_host.mb_str())), cid)) {
wxLogError(_("Error occurred.\nPlease try again.")); wxLogError(_("Error occurred.\nPlease try again."));
lock.Unlock(); lock.Unlock();
delete cid; delete cid;
@ -1470,8 +1470,8 @@ public:
if(val.empty()) if(val.empty())
isv = false; isv = false;
else { else {
sf::IpAddress srv = std::string(val.mb_str()); sf::IPAddress srv = std::string(val.mb_str());
isv = (joybusHostAddr == sf::IpAddress::None); isv = srv.IsValid();
} }
if(!isv) if(!isv)
wxMessageBox(_("You must enter a valid host name"), wxMessageBox(_("You must enter a valid host name"),
@ -3098,7 +3098,7 @@ bool MainFrame::InitMore(void)
bool isv = !gopts.joybus_host.empty(); bool isv = !gopts.joybus_host.empty();
if(isv) { if(isv) {
joybusHostAddr = std::string(gopts.joybus_host.mb_str()); joybusHostAddr = std::string(gopts.joybus_host.mb_str());
isv = (joybusHostAddr == sf::IpAddress::None); isv = joybusHostAddr.IsValid();
} }
if(!isv) { if(!isv) {
wxLogError(_("JoyBus host invalid; disabling")); wxLogError(_("JoyBus host invalid; disabling"));