forked from speed-dreams/speed-dreams-code
Fixed crash when connecting to server with empty/bad address
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3594 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 2d9b9b279e9417b2cba390a7d1a34f05c62608fa Former-commit-id: 581058d7f055cddd2d58f055809e22d682cc9257
This commit is contained in:
parent
f88deecb2e
commit
13e86b06c5
1 changed files with 45 additions and 47 deletions
|
@ -41,8 +41,6 @@ Client::~Client()
|
|||
{
|
||||
ResetNetwork();
|
||||
SetClient(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Client::Disconnect()
|
||||
|
@ -55,7 +53,6 @@ Client::~Client()
|
|||
|
||||
void Client::ResetNetwork()
|
||||
{
|
||||
|
||||
if (m_pClient == NULL)
|
||||
return;
|
||||
|
||||
|
@ -155,6 +152,7 @@ bool Client::ConnectToServer(const char *pAddress,int port, Driver *pDriver)
|
|||
|
||||
ENetAddress caddress;
|
||||
caddress.host = ENET_HOST_ANY;
|
||||
|
||||
/* Bind the server to port*/
|
||||
caddress.port = SPEEDDREAMSPEERPORT;
|
||||
|
||||
|
@ -200,7 +198,7 @@ bool Client::ConnectToServer(const char *pAddress,int port, Driver *pDriver)
|
|||
address.port = port;
|
||||
|
||||
/* Initiate the connection, allocating the two channels 0 and 1. */
|
||||
GfLogError ("Initiating network connection to host %s:%d ...\n", pAddress, port);
|
||||
GfLogError ("Initiating network connection to host '%s:%d' ...\n", pAddress, port);
|
||||
#if (ENET_VERSION >= 0x010300)
|
||||
m_pServer = enet_host_connect (m_pClient, & address, 2, 0);
|
||||
#else
|
||||
|
@ -227,6 +225,8 @@ bool Client::ConnectToServer(const char *pAddress,int port, Driver *pDriver)
|
|||
{
|
||||
m_bConnected = false;
|
||||
ResetNetwork();
|
||||
GfLogError ("Network connection refused.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_eClientAccepted = PROCESSINGCLIENT;
|
||||
|
@ -235,9 +235,7 @@ bool Client::ConnectToServer(const char *pAddress,int port, Driver *pDriver)
|
|||
//Wait for server to accept or reject
|
||||
GfLogInfo ("Sent local driver info to the network server : waiting ...\n");
|
||||
while(m_eClientAccepted == PROCESSINGCLIENT)
|
||||
{
|
||||
SDL_Delay(50);
|
||||
}
|
||||
|
||||
if (m_eClientAccepted == CLIENTREJECTED)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue