LINK: Don't silently fail when unable to connect to Dolphin

git-svn-id: https://svn.code.sf.net/p/vbam/code/branches/bgk-link@1138 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
bgk 2012-09-23 12:07:02 +00:00
parent 160e60d6a4
commit 82282f0978
3 changed files with 25 additions and 12 deletions

View File

@ -451,12 +451,20 @@ void StartGPLink(u16 value)
}
}
static void JoyBusConnect()
static ConnectionState JoyBusConnect()
{
delete dol;
dol = NULL;
dol = new GBASockClient(joybusHostAddr);
dol = new GBASockClient();
bool connected = dol->Connect(joybusHostAddr);
if (connected) {
return LINK_OK;
} else {
systemMessage(0, N_("Error, could not connect to Dolphin"));
return LINK_ERROR;
}
}
static void JoyBusShutdown()
@ -1171,10 +1179,10 @@ ConnectionState InitLink(LinkMode mode)
gba_connection_state = LINK_OK;
if (mode == LINK_GAMECUBE_DOLPHIN) {
JoyBusConnect();
} else if (mode == LINK_CABLE_IPC || mode == LINK_RFU_IPC) {
gba_connection_state = InitIPC();
if (mode == LINK_GAMECUBE_DOLPHIN) {
gba_connection_state = JoyBusConnect();
} else if (mode == LINK_CABLE_IPC || mode == LINK_RFU_IPC) {
gba_connection_state = InitIPC();
} else if (mode == LINK_CABLE_SOCKET) {
linkid = 0;

View File

@ -4,15 +4,19 @@
// Currently only for Joybus communications
GBASockClient::GBASockClient(sf::IPAddress _server_addr)
GBASockClient::GBASockClient()
{
if (!_server_addr.IsValid())
server_addr = sf::IPAddress::LocalHost;
else
server_addr = sf::IPAddress::LocalHost;
}
bool GBASockClient::Connect(sf::IPAddress _server_addr) {
if (_server_addr.IsValid())
server_addr = _server_addr;
client.Connect(0xd6ba, server_addr);
sf::Socket::Status result = client.Connect(0xd6ba, server_addr);
//client.SetBlocking(false);
return result == sf::Socket::Done;
}
GBASockClient::~GBASockClient()

View File

@ -6,9 +6,10 @@
class GBASockClient
{
public:
GBASockClient(sf::IPAddress server_addr);
GBASockClient();
~GBASockClient();
bool Connect(sf::IPAddress server_addr);
void Send(std::vector<char> data);
char ReceiveCmd(char* data_in);