GL - connect to server, need right IP

This commit is contained in:
Linda Andersson 2013-12-16 09:55:51 +01:00
parent fa1473455f
commit b60166a6e8
3 changed files with 20 additions and 14 deletions

View File

@ -31,40 +31,38 @@ namespace DanBias
{ {
int pType = p[0].value.netInt; int pType = p[0].value.netInt;
Client::GameClientState::ProtocolStruct* protocol; Client::GameClientState::ProtocolStruct* protocolData;
switch (pType) switch (pType)
{ {
case protocol_PlayerNavigation: case protocol_PlayerNavigation:
break; break;
case protocol_PlayerPosition: case protocol_PlayerPosition:
protocol = new Client::GameClientState::PlayerPos; protocolData = new Client::GameClientState::PlayerPos;
for(int i = 0; i< 3; i++) for(int i = 0; i< 3; i++)
{ {
((Client::GameClientState::PlayerPos*)protocol)->playerPos[i] = p[i].value.netFloat; ((Client::GameClientState::PlayerPos*)protocolData)->playerPos[i] = p[i].value.netFloat;
} }
gameClientState->Protocol(protocol); gameClientState->Protocol(protocolData);
delete protocol; delete protocolData;
protocol = NULL; protocolData = NULL;
break; break;
case protocol_ObjectPosition: case protocol_ObjectPosition:
protocol = new Client::GameClientState::ObjPos; protocolData = new Client::GameClientState::ObjPos;
for(int i = 0; i< 16; i++) for(int i = 0; i< 16; i++)
{ {
((Client::GameClientState::ObjPos*)protocol)->worldPos[i] = p[i].value.netFloat; ((Client::GameClientState::ObjPos*)protocolData)->worldPos[i] = p[i].value.netFloat;
} }
gameClientState->Protocol(protocol); gameClientState->Protocol(protocolData);
delete protocol; delete protocolData;
protocol = NULL; protocolData = NULL;
break; break;
default: default:
break; break;
} }
} }
}; };
class DanBiasGamePrivateData class DanBiasGamePrivateData
@ -114,6 +112,12 @@ namespace DanBias
m_data->r = new MyRecieverObject; m_data->r = new MyRecieverObject;
m_data->r->nwClient = new Oyster::Network::NetworkClient(); m_data->r->nwClient = new Oyster::Network::NetworkClient();
m_data->r->nwClient->Connect(desc.port, desc.IP);
if (!m_data->r->nwClient->IsConnected())
{
// failed to connect
return DanBiasClientReturn_Error;
}
// Start in lobby state // Start in lobby state
m_data->gameClientState = new Client::LobbyState(); m_data->gameClientState = new Client::LobbyState();
m_data->gameClientState->Init(m_data->r->nwClient); m_data->gameClientState->Init(m_data->r->nwClient);

View File

@ -29,6 +29,7 @@ namespace DanBias
{ {
//Stuff goes here... //Stuff goes here...
int port; int port;
const char* IP;
HINSTANCE hinst; HINSTANCE hinst;
int nCmdShow; int nCmdShow;

View File

@ -30,6 +30,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
// Game client starter code goes here // Game client starter code goes here
DanBias::DanBiasGameDesc gameDesc; DanBias::DanBiasGameDesc gameDesc;
gameDesc.port = 1; gameDesc.port = 1;
gameDesc.IP = "10.1010.303";
gameDesc.hinst = hinst; gameDesc.hinst = hinst;
gameDesc.nCmdShow = cmdShow; gameDesc.nCmdShow = cmdShow;