diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d855eef..91ac5dc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ option( ENABLE_NLS "Enable translations" ON ) option( ENABLE_ASM_CORE "Enable x86 ASM CPU cores" OFF ) option( ENABLE_ASM_SCALERS "Enable x86 ASM graphic filters" 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_FFMPEG "Enable ffmpeg A/V recording" OFF ) if(ENABLE_ASM_SCALERS) diff --git a/src/gba/GBALink.cpp b/src/gba/GBALink.cpp index b91d8e8b..3c78d8d9 100644 --- a/src/gba/GBALink.cpp +++ b/src/gba/GBALink.cpp @@ -162,7 +162,7 @@ int WaitForSingleObject(sem_t *s, int t) int linktime = 0; GBASockClient* dol = NULL; -sf::IpAddress joybusHostAddr = sf::IpAddress::LocalHost; +sf::IPAddress joybusHostAddr = sf::IPAddress::LocalHost; // Hodgepodge u8 tspeed = 3; @@ -1105,7 +1105,7 @@ void CloseLink(void){ char outbuffer[4]; outbuffer[0] = 4; outbuffer[1] = -32; - if(lanlink.type==0) lanlink.tcpsocket.send(outbuffer, 4); + if(lanlink.type==0) lanlink.tcpsocket.Send(outbuffer, 4); } else { char outbuffer[12]; int i; @@ -1113,9 +1113,9 @@ void CloseLink(void){ outbuffer[1] = -32; for(i=1;i<=lanlink.numslaves;i++){ 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){ // too bad Listen() doesn't take an address as well // 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 return false; // FIXME: error code? @@ -1200,10 +1200,10 @@ bool lserver::Init(ServerInfoDisplay *sid){ linkid = 0; // should probably use GetPublicAddress() - sid->ShowServerIP(sf::IpAddress::getLocalAddress()); + sid->ShowServerIP(sf::IPAddress::GetLocalAddress()); lanlink.thread = new sf::Thread(LinkServerThread, sid); - lanlink.thread->launch(); + lanlink.thread->Launch(); return true; @@ -1211,7 +1211,7 @@ bool lserver::Init(ServerInfoDisplay *sid){ void LinkServerThread(void *_sid){ ServerInfoDisplay *sid = (ServerInfoDisplay *)_sid; - sf::SocketSelector fdset; + sf::Selector fdset; char inbuffer[256], outbuffer[256]; s32 *intinbuffer = (s32*)inbuffer; u16 *u16inbuffer = (u16*)inbuffer; @@ -1221,24 +1221,24 @@ void LinkServerThread(void *_sid){ i = 0; while(iShowConnect(i); } } @@ -1251,7 +1251,7 @@ void LinkServerThread(void *_sid){ for(i=1;i<=lanlink.numslaves;i++){ outbuffer[0] = 4; - ls.tcpsocket[i].send(outbuffer, 4); + ls.tcpsocket[i].Send(outbuffer, 4); } CloseInfoDisplay: @@ -1265,9 +1265,9 @@ void lserver::Send(void){ outbuffer[0] = 4; outbuffer[1] = -32; //0xe0 for(i=1;i<=lanlink.numslaves;i++){ - tcpsocket[i].send(outbuffer, 4); + tcpsocket[i].Send(outbuffer, 4); size_t nr; - tcpsocket[i].receive(inbuffer, 4, nr); + tcpsocket[i].Receive(inbuffer, 4, nr); } } outbuffer[1] = tspeed; @@ -1276,27 +1276,27 @@ void lserver::Send(void){ if(lanlink.numslaves==1){ if(lanlink.type==0){ outbuffer[0] = 8; - tcpsocket[1].send(outbuffer, 8); + tcpsocket[1].Send(outbuffer, 8); } } else if(lanlink.numslaves==2){ WRITE16LE(&u16outbuffer[4], linkdata[2]); if(lanlink.type==0){ outbuffer[0] = 10; - tcpsocket[1].send(outbuffer, 10); + tcpsocket[1].Send(outbuffer, 10); WRITE16LE(&u16outbuffer[4], linkdata[1]); - tcpsocket[2].send(outbuffer, 10); + tcpsocket[2].Send(outbuffer, 10); } } else { if(lanlink.type==0){ outbuffer[0] = 12; WRITE16LE(&u16outbuffer[4], linkdata[2]); WRITE16LE(&u16outbuffer[5], linkdata[3]); - tcpsocket[1].send(outbuffer, 12); + tcpsocket[1].Send(outbuffer, 12); WRITE16LE(&u16outbuffer[4], linkdata[1]); - tcpsocket[2].send(outbuffer, 12); + tcpsocket[2].Send(outbuffer, 12); 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){ int numbytes; if(lanlink.type==0){ // TCP - fdset.clear(); - for(i=0;i1) memmove(inbuffer, inbuffer+inbuffer[0]*(howmanytimes-1), inbuffer[0]); @@ -1331,10 +1331,10 @@ void lserver::Recv(void){ outbuffer[0] = 4; outbuffer[1] = -32; for(i=1;iConnectStart(addr); lanlink.terminate = false; lanlink.thread = new sf::Thread(LinkClientThread, cid); - lanlink.thread->launch(); + lanlink.thread->Launch(); return true; } void LinkClientThread(void *_cid){ ClientInfoDisplay *cid = (ClientInfoDisplay *)_cid; - sf::SocketSelector fdset; + sf::Selector fdset; int numbytes; char inbuffer[16]; u16 *u16inbuffer = (u16*)inbuffer; 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 // so we'll just have to do a retry loop, I guess. cid->Ping(); @@ -1403,14 +1403,14 @@ void LinkClientThread(void *_cid){ numbytes = 0; size_t got; while(numbytes<4) { - lanlink.tcpsocket.receive(inbuffer+numbytes, 4 - numbytes, got); + lanlink.tcpsocket.Receive(inbuffer+numbytes, 4 - numbytes, got); numbytes += got; - fdset.clear(); - fdset.add(lanlink.tcpsocket); - fdset.wait(sf::seconds(0.1)); + fdset.Clear(); + fdset.Add(lanlink.tcpsocket); + fdset.Wait(0.1); cid->Ping(); if(lanlink.terminate) { - lanlink.tcpsocket.disconnect(); + lanlink.tcpsocket.Close(); goto CloseInfoDisplay; } } @@ -1422,14 +1422,14 @@ void LinkClientThread(void *_cid){ numbytes = 0; inbuffer[0] = 1; while(numbytesPing(); if(lanlink.terminate) { - lanlink.tcpsocket.disconnect(); + lanlink.tcpsocket.Close(); goto CloseInfoDisplay; } } @@ -1445,16 +1445,16 @@ CloseInfoDisplay: void lclient::CheckConn(void){ size_t nr; - lanlink.tcpsocket.receive(inbuffer, 1, nr); + lanlink.tcpsocket.Receive(inbuffer, 1, nr); numbytes = nr; if(numbytes>0){ while(numbytes #include @@ -65,7 +61,7 @@ extern const char *MakeInstanceFilename(const char *Input); class ServerInfoDisplay { 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 Ping() = 0; virtual void Connected() = 0; @@ -88,7 +84,7 @@ typedef struct { class lserver{ int numbytes; - sf::SocketSelector fdset; + sf::Selector fdset; //timeval udptimeout; char inbuffer[256], outbuffer[256]; s32 *intinbuffer; @@ -99,8 +95,8 @@ class lserver{ int done; public: int howmanytimes; - sf::TcpSocket tcpsocket[4]; - sf::IpAddress udpaddr[4]; + sf::SocketTCP tcpsocket[4]; + sf::IPAddress udpaddr[4]; lserver(void); bool Init(ServerInfoDisplay *); void Send(void); @@ -109,14 +105,14 @@ public: class ClientInfoDisplay { public: - virtual void ConnectStart(const sf::IpAddress& addr) = 0; + virtual void ConnectStart(const sf::IPAddress& addr) = 0; virtual void Ping() = 0; virtual void ShowConnect(const int player, const int togo) = 0; virtual void Connected() = 0; }; class lclient{ - sf::SocketSelector fdset; + sf::Selector fdset; char inbuffer[256], outbuffer[256]; s32 *intinbuffer; u16 *u16inbuffer; @@ -124,20 +120,19 @@ class lclient{ u16 *u16outbuffer; int numbytes; public: - sf::IpAddress serveraddr; + sf::IPAddress serveraddr; unsigned short serverport; - sf::TcpSocket noblock; + sf::SocketTCP noblock; int numtransfers; lclient(void); - bool Init(sf::IpAddress, ClientInfoDisplay *); + bool Init(sf::IPAddress, ClientInfoDisplay *); void Send(void); void Recv(void); void CheckConn(void); }; typedef struct { - sf::TcpListener listener; - sf::TcpSocket tcpsocket; + sf::SocketTCP tcpsocket; //sf::SocketUDP udpsocket; int numslaves; sf::Thread *thread; @@ -152,7 +147,7 @@ typedef struct { extern bool gba_joybus_enabled; extern bool gba_link_enabled; -extern sf::IpAddress joybusHostAddr; +extern sf::IPAddress joybusHostAddr; extern void JoyBusConnect(); extern void JoyBusShutdown(); extern void JoyBusUpdate(int ticks); diff --git a/src/gba/GBASockClient.cpp b/src/gba/GBASockClient.cpp index b6f97242..05843f56 100644 --- a/src/gba/GBASockClient.cpp +++ b/src/gba/GBASockClient.cpp @@ -4,20 +4,20 @@ // Currently only for Joybus communications -GBASockClient::GBASockClient(sf::IpAddress _server_addr) +GBASockClient::GBASockClient(sf::IPAddress _server_addr) { - if (_server_addr == sf::IpAddress::None) - server_addr = sf::IpAddress::LocalHost; + if (!_server_addr.IsValid()) + server_addr = sf::IPAddress::LocalHost; else server_addr = _server_addr; - client.connect(server_addr, 0xd6ba); + client.Connect(0xd6ba, server_addr); //client.SetBlocking(false); } GBASockClient::~GBASockClient() { - client.disconnect(); + client.Close(); } void GBASockClient::Send(std::vector data) @@ -25,7 +25,7 @@ void GBASockClient::Send(std::vector data) char* plain_data = new char[data.size()]; std::copy(data.begin(), data.end(), plain_data); - client.send(plain_data, data.size()); + client.Send(plain_data, data.size()); delete[] plain_data; } @@ -34,7 +34,7 @@ void GBASockClient::Send(std::vector data) char GBASockClient::ReceiveCmd(char* data_in) { std::size_t num_received; - client.receive(data_in, 5, num_received); + client.Receive(data_in, 5, num_received); return data_in[0]; } diff --git a/src/gba/GBASockClient.h b/src/gba/GBASockClient.h index c56c4031..937959d1 100644 --- a/src/gba/GBASockClient.h +++ b/src/gba/GBASockClient.h @@ -3,16 +3,16 @@ #include #include "../common/Types.h" -class GBASockClient : public sf::TcpSocket +class GBASockClient : public sf::SocketTCP { public: - GBASockClient(sf::IpAddress server_addr); + GBASockClient(sf::IPAddress server_addr); ~GBASockClient(); void Send(std::vector data); char ReceiveCmd(char* data_in); private: - sf::IpAddress server_addr; - sf::TcpSocket client; + sf::IPAddress server_addr; + sf::SocketTCP client; }; diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index 20289edc..1b430d1f 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -91,8 +91,8 @@ public: sid_t(wxMutex *m, wxCondition *c, wxString *cm, wxString *pm, bool *d) : lock(m), sig(c), connmsg(cm), pmsg(pm), done(d) {} - void ShowServerIP(const sf::IpAddress &addr) { - wxString addr_s(addr.toString().c_str(), wxConvLibc); + void ShowServerIP(const sf::IPAddress &addr) { + wxString addr_s(addr.ToString().c_str(), wxConvLibc); wxString msg; msg.Printf(_("Server IP address is: %s\n"), addr_s.c_str()); connmsg->append(msg); @@ -155,8 +155,8 @@ public: cid_t(wxMutex *m, wxCondition *c, wxString *cm, wxString *pm, bool *d) : lock(m), sig(c), connmsg(cm), pmsg(pm), done(d) {} - void ConnectStart(const sf::IpAddress &addr) { - wxString addr_s(addr.toString().c_str(), wxConvLibc); + void ConnectStart(const sf::IPAddress &addr) { + wxString addr_s(addr.ToString().c_str(), wxConvLibc); connmsg->Printf(_("Connecting to %s\n"), addr_s.c_str()); } void ShowConnect(int player, int togo) { @@ -188,7 +188,7 @@ public: 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.")); lock.Unlock(); delete cid; @@ -1470,8 +1470,8 @@ public: if(val.empty()) isv = false; else { - sf::IpAddress srv = std::string(val.mb_str()); - isv = (joybusHostAddr == sf::IpAddress::None); + sf::IPAddress srv = std::string(val.mb_str()); + isv = srv.IsValid(); } if(!isv) wxMessageBox(_("You must enter a valid host name"), @@ -3098,7 +3098,7 @@ bool MainFrame::InitMore(void) bool isv = !gopts.joybus_host.empty(); if(isv) { joybusHostAddr = std::string(gopts.joybus_host.mb_str()); - isv = (joybusHostAddr == sf::IpAddress::None); + isv = joybusHostAddr.IsValid(); } if(!isv) { wxLogError(_("JoyBus host invalid; disabling"));