Network - Added reconnect with the last address you connected on.
This commit is contained in:
parent
f1cd73425c
commit
717e95bdfe
|
@ -126,9 +126,6 @@ void LanMenuState::ChangeState( ClientState next )
|
||||||
// attempt to connect to lobby
|
// attempt to connect to lobby
|
||||||
if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
|
if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
|
||||||
return;
|
return;
|
||||||
//this->privData->nwClient->Disconnect();
|
|
||||||
//if( !this->privData->nwClient->Reconnect() )
|
|
||||||
//return;
|
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,8 +157,6 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//this is a hotfix, fix so you only load the relevant data when the file is updated
|
//this is a hotfix, fix so you only load the relevant data when the file is updated
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//Couldn't find specialType
|
//Couldn't find specialType
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -152,10 +152,9 @@ namespace GameLogic
|
||||||
start = 0;
|
start = 0;
|
||||||
LevelLoaderInternal::FormatVersion version;
|
LevelLoaderInternal::FormatVersion version;
|
||||||
memcpy(&version, &buf[0], sizeof(version));
|
memcpy(&version, &buf[0], sizeof(version));
|
||||||
start += 4;
|
start += 8;
|
||||||
|
|
||||||
memcpy(&volume.geoType, &buf[start], sizeof(volume.geoType));
|
memcpy(&volume.geoType, &buf[start], sizeof(volume.geoType));
|
||||||
start += sizeof(volume.geoType);
|
|
||||||
|
|
||||||
switch(volume.geoType)
|
switch(volume.geoType)
|
||||||
{
|
{
|
||||||
|
|
|
@ -290,9 +290,12 @@ bool NetworkClient::Connect(ConnectionInfo& socket)
|
||||||
|
|
||||||
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
||||||
{
|
{
|
||||||
if(this->IsConnected()) return false;
|
//Return true if you are already connected.
|
||||||
if(this->privateData) return false;
|
if(this->IsConnected())
|
||||||
if(!this->privateData) this->privateData = new PrivateData();
|
return true;
|
||||||
|
|
||||||
|
if(!this->privateData)
|
||||||
|
this->privateData = new PrivateData();
|
||||||
|
|
||||||
int result = this->privateData->connection.Connect(port, serverIP, false);
|
int result = this->privateData->connection.Connect(port, serverIP, false);
|
||||||
|
|
||||||
|
@ -319,10 +322,10 @@ bool NetworkClient::Connect(unsigned short port, std::wstring serverIP)
|
||||||
|
|
||||||
bool NetworkClient::Reconnect()
|
bool NetworkClient::Reconnect()
|
||||||
{
|
{
|
||||||
|
//Return true if you are already connected.
|
||||||
if(this->IsConnected())
|
if(this->IsConnected())
|
||||||
return false;
|
return true;
|
||||||
//if(this->privateData)
|
|
||||||
//return false;
|
|
||||||
if(!this->privateData) this->privateData = new PrivateData();
|
if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
||||||
int result = this->privateData->connection.Reconnect();
|
int result = this->privateData->connection.Reconnect();
|
||||||
|
@ -342,11 +345,10 @@ void NetworkClient::Disconnect()
|
||||||
{
|
{
|
||||||
if(!privateData) return;
|
if(!privateData) return;
|
||||||
|
|
||||||
privateData->thread.Terminate();
|
privateData->thread.Stop();
|
||||||
privateData->connection.Disconnect();
|
privateData->connection.Disconnect();
|
||||||
this->privateData->sendQueue.Clear();
|
this->privateData->sendQueue.Clear();
|
||||||
this->privateData->recieveQueue.Clear();
|
this->privateData->recieveQueue.Clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::Send(CustomProtocolObject& protocol)
|
void NetworkClient::Send(CustomProtocolObject& protocol)
|
||||||
|
|
|
@ -91,14 +91,14 @@ int Connection::Reconnect()
|
||||||
if(this->socket == -1 || this->socket == 0) InitiateSocket();
|
if(this->socket == -1 || this->socket == 0) InitiateSocket();
|
||||||
|
|
||||||
struct hostent *hostEnt;
|
struct hostent *hostEnt;
|
||||||
if((hostEnt = gethostbyname(lastConnectAddr.c_str())) == NULL)
|
if((hostEnt = gethostbyname(this->lastConnectAddr.c_str())) == NULL)
|
||||||
{
|
{
|
||||||
return WSAGetLastError();
|
return WSAGetLastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr_in server;
|
struct sockaddr_in server;
|
||||||
server.sin_family = AF_INET;
|
server.sin_family = AF_INET;
|
||||||
server.sin_port = htons(lastConnectPort);
|
server.sin_port = htons(this->lastConnectPort);
|
||||||
server.sin_addr.s_addr = *(unsigned long*) hostEnt->h_addr;
|
server.sin_addr.s_addr = *(unsigned long*) hostEnt->h_addr;
|
||||||
|
|
||||||
SetBlockingMode(true);
|
SetBlockingMode(true);
|
||||||
|
|
Loading…
Reference in New Issue