GL - only client with server update server. Update recieverfunction

This commit is contained in:
lindaandersson 2014-01-30 15:20:35 +01:00
parent 2bb2d0cd56
commit 0aa39275e3
5 changed files with 13 additions and 9 deletions

View File

@ -8,6 +8,7 @@
#include "GameClientState\LoginState.h" #include "GameClientState\LoginState.h"
#include <Protocols.h> #include <Protocols.h>
#include "NetworkClient.h" #include "NetworkClient.h"
#include <GameServerAPI.h>
#include "../WindowManager/WindowShell.h" #include "../WindowManager/WindowShell.h"
#include "L_inputClass.h" #include "L_inputClass.h"
@ -38,6 +39,7 @@ namespace DanBias
InputClass* inputObj; InputClass* inputObj;
Utility::WinTimer* timer; Utility::WinTimer* timer;
GameRecieverObject* recieverObj; GameRecieverObject* recieverObj;
bool serverOwner;
} data; } data;
#pragma endregion #pragma endregion
@ -62,13 +64,8 @@ namespace DanBias
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
m_data->recieverObj = new GameRecieverObject; m_data->recieverObj = new GameRecieverObject;
/*m_data->recieverObj->Connect(desc.port, desc.IP); m_data->serverOwner = false;
if (!m_data->recieverObj->IsConnected())
{
// failed to connect
return DanBiasClientReturn_Error;
}*/
// Start in lobby state // Start in lobby state
m_data->recieverObj->gameClientState = new Client::LoginState(); m_data->recieverObj->gameClientState = new Client::LoginState();
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj)) if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj))
@ -133,8 +130,13 @@ namespace DanBias
HRESULT DanBiasGame::Update(float deltaTime) HRESULT DanBiasGame::Update(float deltaTime)
{ {
m_data->recieverObj->Update();
m_data->inputObj->Update(); m_data->inputObj->Update();
if(m_data->serverOwner)
{
DanBias::GameServerAPI::ServerUpdate();
}
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same; DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
state = m_data->recieverObj->gameClientState->Update(deltaTime, m_data->inputObj); state = m_data->recieverObj->gameClientState->Update(deltaTime, m_data->inputObj);
@ -147,6 +149,8 @@ namespace DanBias
switch (state) switch (state)
{ {
case Client::GameClientState::ClientState_LobbyCreated:
m_data->serverOwner = true;
case Client::GameClientState::ClientState_Lobby: case Client::GameClientState::ClientState_Lobby:
m_data->recieverObj->gameClientState = new Client::LobbyState(); m_data->recieverObj->gameClientState = new Client::LobbyState();
break; break;

View File

@ -53,6 +53,7 @@ public:
{ {
ClientState_Login, ClientState_Login,
ClientState_Lobby, ClientState_Lobby,
ClientState_LobbyCreated,
ClientState_Game, ClientState_Game,
ClientState_Same, ClientState_Same,
}; };

View File

@ -144,7 +144,6 @@ bool GameState::InitCamera(Oyster::Math::Float3 startPos)
GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput) GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
{ {
DanBias::GameServerAPI::ServerUpdate();
switch (privData->state) switch (privData->state)
{ {
case gameStateState_loading: case gameStateState_loading:

View File

@ -87,7 +87,7 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key
// update animation // update animation
// send data to server // send data to server
// check data from server // check data from server
DanBias::GameServerAPI::ServerUpdate();
if( KeyInput->IsKeyPressed(DIK_G)) if( KeyInput->IsKeyPressed(DIK_G))
{ {

View File

@ -103,7 +103,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key
// failed to connect // failed to connect
return ClientState_Same; return ClientState_Same;
} }
return ClientState_Lobby; return ClientState_LobbyCreated;
} }
// join game // join game
if( KeyInput->IsKeyPressed(DIK_J)) if( KeyInput->IsKeyPressed(DIK_J))