Updated to SFML 2.2. Fixed LINK build on Linux.

This commit is contained in:
skidau 2015-04-04 04:39:25 +00:00
parent a91f99d111
commit 193322a33e
7 changed files with 98 additions and 89 deletions

View File

@ -64,7 +64,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;SFML_SYSTEM_EXPORTS;SFML_NETWORK_EXPORTS;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@ -110,7 +110,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;SFML_SYSTEM_EXPORTS;SFML_NETWORK_EXPORTS;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel>

View File

@ -118,7 +118,7 @@
<ClInclude Include="..\..\src\gba\BreakpointStructures.h">
<Filter>Core\GBA</Filter>
</ClInclude>
<ClInclude Include="..\..\src\gba\debugger-expr-yacc.h">
<ClInclude Include="..\..\src\gba\debugger-expr-yacc.hpp">
<Filter>Core\GBA</Filter>
</ClInclude>
<ClInclude Include="..\..\src\gba\EEprom.h">

View File

@ -71,7 +71,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;SFML_SYSTEM_EXPORTS;SFML_NETWORK_EXPORTS;DEV_VERSION;BKPT_SUPPORT;GBA_LOGGING;MMX;ASM;_CRT_SECURE_NO_WARNINGS;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>false</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@ -117,7 +117,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<AdditionalIncludeDirectories>..\..\src;..\..\fex;..\..\..\dependencies\libpng;..\..\..\dependencies\msvc;..\..\..\dependencies\SFML\include;..\..\..\dependencies\SubWCRev;..\..\..\dependencies\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;SFML_SYSTEM_EXPORTS;SFML_NETWORK_EXPORTS;GBA_LOGGING;OEMRESOURCE;MMX;ASM;FINAL_VERSION;BKPT_SUPPORT;_CRT_SECURE_NO_DEPRECATE;HAS_FILE_EXTRACTOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel>

View File

@ -1000,6 +1000,7 @@ void gbWriteMemory(register u16 address, register u8 value)
case 0x02: {
gbSerialOn = (value & 0x80);
#ifndef NO_LINK
#if (defined __WIN32__ || defined _WIN32)
//trying to detect whether the game has exited multiplay mode, pokemon blue start w/ 0x7e while pocket racing start w/ 0x7c
if (EmuReseted || (gbMemory[0xff02] & 0x7c) || (value & 0x7c) || (!(value & 0x81))) {
LinkFirstTime = true;
@ -1035,6 +1036,7 @@ void gbWriteMemory(register u16 address, register u8 value)
gbSerialBits = 0;
return;
#endif
#endif
}
@ -2493,10 +2495,12 @@ static void gbSelectColorizationPalette()
void gbReset()
{
#ifndef NO_LINK
#if (defined __WIN32__ || defined _WIN32)
if (GetLinkMode() == LINK_GAMEBOY) {
EmuReseted = true;
gbInitLink();
}
#endif
#endif
gbGetHardwareType();
@ -5556,6 +5560,7 @@ void gbEmulate(int ticksToStop)
gbMemory[0xff41] = register_STAT;
#ifndef NO_LINK
#if (defined __WIN32__ || defined _WIN32)
// serial emulation
gbSerialOn = (gbMemory[0xff02] & 0x80);
static int SIOctr = 0;
@ -5649,6 +5654,7 @@ void gbEmulate(int ticksToStop)
}
#endif
}
#endif
#endif
soundTicks -= clockTicks;

View File

@ -323,17 +323,17 @@ static ConnectionState gba_connection_state = LINK_OK;
static int linktime = 0;
static GBASockClient* dol = NULL;
static sf::IPAddress joybusHostAddr = sf::IPAddress::LocalHost;
static sf::IpAddress joybusHostAddr = sf::IpAddress::LocalHost;
static const LinkDriver linkDrivers[] =
{
#if (defined __WIN32__ || defined _WIN32)
{ LINK_CABLE_IPC, InitIPC, NULL, StartCableIPC, UpdateCableIPC, CloseIPC, false },
{ LINK_RFU_IPC, InitIPC, NULL, StartRFU, UpdateRFUIPC, CloseIPC, false },
{ LINK_GAMEBOY, InitIPC, NULL, NULL, NULL, CloseIPC, false },
{ LINK_CABLE_IPC, InitIPC, NULL, StartCableIPC, UpdateCableIPC, CloseIPC, false },
{ LINK_RFU_IPC, InitIPC, NULL, StartRFU, UpdateRFUIPC, CloseIPC, false },
{ LINK_GAMEBOY, InitIPC, NULL, NULL, NULL, CloseIPC, false },
#endif
{ LINK_CABLE_SOCKET, InitSocket, ConnectUpdateSocket, StartCableSocket, UpdateSocket, CloseSocket, true },
{ LINK_GAMECUBE_DOLPHIN, JoyBusConnect, NULL, NULL, JoyBusUpdate, JoyBusShutdown, false }
{ LINK_CABLE_SOCKET, InitSocket, ConnectUpdateSocket, StartCableSocket, UpdateSocket, CloseSocket, true },
{ LINK_GAMECUBE_DOLPHIN, JoyBusConnect, NULL, NULL, JoyBusUpdate, JoyBusShutdown, false }
};
enum
@ -345,7 +345,8 @@ enum
};
typedef struct {
sf::SocketTCP tcpsocket;
sf::TcpSocket tcpsocket;
sf::TcpListener tcplistener;
int numslaves;
int connectedSlaves;
int type;
@ -355,7 +356,7 @@ typedef struct {
class lserver{
int numbytes;
sf::Selector<sf::SocketTCP> fdset;
sf::SocketSelector fdset;
//timeval udptimeout;
char inbuffer[256], outbuffer[256];
s32 *intinbuffer;
@ -366,15 +367,15 @@ class lserver{
int done;
public:
int howmanytimes;
sf::SocketTCP tcpsocket[4];
sf::IPAddress udpaddr[4];
sf::TcpSocket tcpsocket[4];
sf::IpAddress udpaddr[4];
lserver(void);
void Send(void);
void Recv(void);
};
class lclient{
sf::Selector<sf::SocketTCP> fdset;
sf::SocketSelector fdset;
char inbuffer[256], outbuffer[256];
s32 *intinbuffer;
u16 *u16inbuffer;
@ -382,7 +383,7 @@ class lclient{
u16 *u16outbuffer;
int numbytes;
public:
sf::IPAddress serveraddr;
sf::IpAddress serveraddr;
unsigned short serverport;
int numtransfers;
lclient(void);
@ -474,20 +475,20 @@ void GetLinkServerHost(char * const host, size_t size) {
host[0] = '\0';
if (linkDriver && linkDriver->mode == LINK_GAMECUBE_DOLPHIN)
strncpy(host, joybusHostAddr.ToString().c_str(), size);
strncpy(host, joybusHostAddr.toString().c_str(), size);
else if (lanlink.server)
strncpy(host, sf::IPAddress::GetLocalAddress().ToString().c_str(), size);
strncpy(host, sf::IpAddress::getLocalAddress().toString().c_str(), size);
else
strncpy(host, lc.serveraddr.ToString().c_str(), size);
strncpy(host, lc.serveraddr.toString().c_str(), size);
}
bool SetLinkServerHost(const char *host) {
sf::IPAddress addr = sf::IPAddress(host);
sf::IpAddress addr = sf::IpAddress(host);
lc.serveraddr = addr;
joybusHostAddr = addr;
return addr.IsValid();
return addr != sf::IpAddress::None;
}
int GetLinkPlayerId() {
@ -646,8 +647,10 @@ void StartGPLink(u16 value)
break;
case GP:
#if (defined __WIN32__ || defined _WIN32)
if (GetLinkMode() == LINK_RFU_IPC)
rfu_state = RFU_INIT;
#endif
break;
}
}
@ -700,9 +703,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;
@ -711,27 +714,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);
}
}
}
@ -741,10 +744,10 @@ void lserver::Send(void) {
void lserver::Recv(void) {
int numbytes;
if(lanlink.type==0) { // TCP
fdset.Clear();
for(i=0;i<lanlink.numslaves;i++) fdset.Add(tcpsocket[i+1]);
fdset.clear();
for(i=0;i<lanlink.numslaves;i++) fdset.add(tcpsocket[i+1]);
// was linktimeout/1000 (i.e., drop ms part), but that's wrong
if (fdset.Wait((float)(linktimeout / 1000.)) == 0)
if (fdset.wait(sf::seconds((float)(linktimeout / 1000.))) == 0)
{
return;
}
@ -754,7 +757,7 @@ void lserver::Recv(void) {
inbuffer[0] = 1;
while(numbytes<howmanytimes*inbuffer[0]) {
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;
}
if(howmanytimes>1) memmove(inbuffer, inbuffer+inbuffer[0]*(howmanytimes-1), inbuffer[0]);
@ -765,10 +768,10 @@ void lserver::Recv(void) {
outbuffer[0] = 4;
outbuffer[1] = -32;
for(i=1;i<lanlink.numslaves;i++) {
tcpsocket[i].Send(outbuffer, 12);
tcpsocket[i].send(outbuffer, 12);
size_t nr;
tcpsocket[i].Receive(inbuffer, 256, nr);
tcpsocket[i].Close();
tcpsocket[i].receive(inbuffer, 256, nr);
tcpsocket[i].disconnect();
}
CloseLink();
return;
@ -793,16 +796,16 @@ lclient::lclient(void) {
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<inbuffer[0]) {
lanlink.tcpsocket.Receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr);
lanlink.tcpsocket.receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr);
numbytes += nr;
}
if(inbuffer[1]==-32) {
outbuffer[0] = 4;
lanlink.tcpsocket.Send(outbuffer, 4);
lanlink.tcpsocket.send(outbuffer, 4);
systemScreenMessage(_("Server disconnected."));
CloseLink();
return;
@ -823,11 +826,11 @@ void lclient::CheckConn(void) {
}
void lclient::Recv(void) {
fdset.Clear();
fdset.clear();
// old code used socket # instead of mask again
fdset.Add(lanlink.tcpsocket);
fdset.add(lanlink.tcpsocket);
// old code stripped off ms again
if (fdset.Wait((float)(linktimeout / 1000.)) == 0)
if (fdset.wait(sf::seconds((float)(linktimeout / 1000.))) == 0)
{
numtransfers = 0;
return;
@ -836,12 +839,12 @@ void lclient::Recv(void) {
inbuffer[0] = 1;
size_t nr;
while(numbytes<inbuffer[0]) {
lanlink.tcpsocket.Receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr);
lanlink.tcpsocket.receive(inbuffer+numbytes, inbuffer[0] - numbytes, nr);
numbytes += nr;
}
if(inbuffer[1]==-32) {
outbuffer[0] = 4;
lanlink.tcpsocket.Send(outbuffer, 4);
lanlink.tcpsocket.send(outbuffer, 4);
systemScreenMessage(_("Server disconnected."));
CloseLink();
return;
@ -863,7 +866,7 @@ void lclient::Send() {
outbuffer[0] = 4;
outbuffer[1] = linkid<<2;
WRITE16LE(&u16outbuffer[1], linkdata[linkid]);
lanlink.tcpsocket.Send(outbuffer, 4);
lanlink.tcpsocket.send(outbuffer, 4);
return;
}
@ -877,11 +880,11 @@ static ConnectionState InitSocket() {
if (lanlink.server) {
lanlink.connectedSlaves = 0;
// should probably use GetPublicAddress()
//sid->ShowServerIP(sf::IPAddress::GetLocalAddress());
//sid->ShowServerIP(sf::IpAddress::getLocalAddress());
// too bad Listen() doesn't take an address as well
// then again, old code used INADDR_ANY anyway
if (!lanlink.tcpsocket.Listen(IP_LINK_PORT))
if (lanlink.tcplistener.listen(IP_LINK_PORT) == sf::Socket::Error)
// Note: old code closed socket & retried once on bind failure
return LINK_ERROR; // FIXME: error code?
else
@ -889,11 +892,11 @@ static ConnectionState InitSocket() {
} else {
lc.serverport = IP_LINK_PORT;
if (!lc.serveraddr.IsValid()) {
if (lc.serveraddr == sf::IpAddress::None) {
return LINK_ERROR;
} else {
lanlink.tcpsocket.SetBlocking(false);
sf::Socket::Status status = lanlink.tcpsocket.Connect(lc.serverport, lc.serveraddr);
lanlink.tcpsocket.setBlocking(false);
sf::Socket::Status status = lanlink.tcpsocket.connect(lc.serveraddr, lc.serverport);
if (status == sf::Socket::Error || status == sf::Socket::Disconnected)
return LINK_ERROR;
@ -907,17 +910,17 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
ConnectionState newState = LINK_NEEDS_UPDATE;
if (lanlink.server) {
sf::Selector<sf::SocketTCP> fdset;
fdset.Add(lanlink.tcpsocket);
sf::SocketSelector fdset;
fdset.add(lanlink.tcplistener);
if (fdset.Wait(0.1) == 1) {
if (fdset.wait(sf::seconds(0.1f))) {
int nextSlave = lanlink.connectedSlaves + 1;
sf::Socket::Status st = lanlink.tcpsocket.Accept(ls.tcpsocket[nextSlave]);
sf::Socket::Status st = lanlink.tcplistener.accept(ls.tcpsocket[nextSlave]);
if (st == sf::Socket::Error) {
for (int j = 1; j < nextSlave; j++)
ls.tcpsocket[j].Close();
ls.tcpsocket[j].disconnect();
snprintf(message, size, N_("Network error."));
newState = LINK_ERROR;
@ -926,7 +929,7 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
packet << static_cast<sf::Uint16>(nextSlave)
<< static_cast<sf::Uint16>(lanlink.numslaves);
ls.tcpsocket[nextSlave].Send(packet);
ls.tcpsocket[nextSlave].send(packet);
snprintf(message, size, N_("Player %d connected"), nextSlave);
@ -939,7 +942,7 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
sf::Packet packet;
packet << true;
ls.tcpsocket[i].Send(packet);
ls.tcpsocket[i].send(packet);
}
snprintf(message, size, N_("All players connected"));
@ -948,7 +951,7 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
} else {
sf::Packet packet;
sf::Socket::Status status = lanlink.tcpsocket.Receive(packet);
sf::Socket::Status status = lanlink.tcpsocket.receive(packet);
if (status == sf::Socket::Error || status == sf::Socket::Disconnected) {
snprintf(message, size, N_("Network error."));
@ -976,9 +979,9 @@ static ConnectionState ConnectUpdateSocket(char * const message, size_t size) {
}
}
sf::Selector<sf::SocketTCP> fdset;
fdset.Add(lanlink.tcpsocket);
fdset.Wait(0.1);
sf::SocketSelector fdset;
fdset.add(lanlink.tcpsocket);
fdset.wait(sf::seconds(0.1f));
}
}
@ -1109,7 +1112,7 @@ static void CloseSocket() {
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;
@ -1117,12 +1120,12 @@ static void CloseSocket() {
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].Close();
ls.tcpsocket[i].disconnect();
}
}
lanlink.tcpsocket.Close();
lanlink.tcpsocket.disconnect();
}
// call this to clean up crashed program's shared state

View File

@ -4,18 +4,18 @@
// Currently only for Joybus communications
GBASockClient::GBASockClient(sf::IPAddress _server_addr)
GBASockClient::GBASockClient(sf::IpAddress _server_addr)
{
if (!_server_addr.IsValid())
server_addr = sf::IPAddress::LocalHost;
if (_server_addr == sf::IpAddress::None)
server_addr = sf::IpAddress::LocalHost;
else
server_addr = _server_addr;
client.Connect(0xd6ba, server_addr);
client.SetBlocking(false);
client.connect(server_addr, 0xd6ba);
client.setBlocking(false);
clock_client.Connect(0xc10c, server_addr);
clock_client.SetBlocking(false);
clock_client.connect(server_addr, 0xc10c);
clock_client.setBlocking(false);
clock_sync = 0;
is_disconnected = false;
@ -23,8 +23,8 @@ GBASockClient::GBASockClient(sf::IPAddress _server_addr)
GBASockClient::~GBASockClient()
{
client.Close();
clock_client.Close();
client.disconnect();
clock_client.disconnect();
}
u32 clock_sync_ticks = 0;
@ -34,7 +34,7 @@ void GBASockClient::Send(std::vector<char> 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;
}
@ -48,11 +48,11 @@ char GBASockClient::ReceiveCmd(char* data_in, bool block)
std::size_t num_received = 0;
if (block || clock_sync == 0)
{
sf::SelectorTCP Selector;
Selector.Add(client);
Selector.Wait(6);
sf::SocketSelector Selector;
Selector.add(client);
Selector.wait(sf::seconds(6));
}
if (client.Receive(data_in, 5, num_received) == sf::Socket::Disconnected)
if (client.receive(data_in, 5, num_received) == sf::Socket::Disconnected)
Disconnect();
return data_in[0];
@ -65,7 +65,7 @@ void GBASockClient::ReceiveClock(bool block)
char sync_ticks[4] = { 0, 0, 0, 0 };
std::size_t num_received = 0;
if (clock_client.Receive(sync_ticks, 4, num_received) == sf::Socket::Disconnected)
if (clock_client.receive(sync_ticks, 4, num_received) == sf::Socket::Disconnected)
Disconnect();
if (num_received == 4)
@ -88,12 +88,12 @@ void GBASockClient::ClockSync(u32 ticks)
void GBASockClient::Disconnect()
{
is_disconnected = true;
client.Close();
clock_client.Close();
client.disconnect();
clock_client.disconnect();
}
bool GBASockClient::IsDisconnected()
{
return !client.IsValid() || !clock_client.IsValid() || is_disconnected;
return is_disconnected;
}
#endif // NO_LINK

View File

@ -6,10 +6,10 @@
class GBASockClient
{
public:
GBASockClient(sf::IPAddress _server_addr);
GBASockClient(sf::IpAddress _server_addr);
~GBASockClient();
bool Connect(sf::IPAddress server_addr);
bool Connect(sf::IpAddress server_addr);
void Send(std::vector<char> data);
char ReceiveCmd(char* data_in, bool block);
void ReceiveClock(bool block);
@ -19,9 +19,9 @@ public:
bool IsDisconnected();
private:
sf::IPAddress server_addr;
sf::SocketTCP client;
sf::SocketTCP clock_client;
sf::IpAddress server_addr;
sf::TcpSocket client;
sf::TcpSocket clock_client;
s32 clock_sync;
bool is_disconnected;