diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 64526c0b..de790e8a 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -8,6 +8,7 @@ #include "GameClientState\LoginState.h" #include #include "NetworkClient.h" +#include #include "../WindowManager/WindowShell.h" #include "L_inputClass.h" @@ -38,6 +39,7 @@ namespace DanBias InputClass* inputObj; Utility::WinTimer* timer; GameRecieverObject* recieverObj; + bool serverOwner; } data; #pragma endregion @@ -62,13 +64,8 @@ namespace DanBias return DanBiasClientReturn_Error; 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 m_data->recieverObj->gameClientState = new Client::LoginState(); if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj)) @@ -133,8 +130,13 @@ namespace DanBias HRESULT DanBiasGame::Update(float deltaTime) { + m_data->recieverObj->Update(); m_data->inputObj->Update(); + if(m_data->serverOwner) + { + DanBias::GameServerAPI::ServerUpdate(); + } DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same; state = m_data->recieverObj->gameClientState->Update(deltaTime, m_data->inputObj); @@ -147,6 +149,8 @@ namespace DanBias switch (state) { + case Client::GameClientState::ClientState_LobbyCreated: + m_data->serverOwner = true; case Client::GameClientState::ClientState_Lobby: m_data->recieverObj->gameClientState = new Client::LobbyState(); break; diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h index 28a671ba..a369233a 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameClientState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -53,6 +53,7 @@ public: { ClientState_Login, ClientState_Lobby, + ClientState_LobbyCreated, ClientState_Game, ClientState_Same, }; diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 2e04959d..ee069919 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -144,7 +144,6 @@ bool GameState::InitCamera(Oyster::Math::Float3 startPos) GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput) { - DanBias::GameServerAPI::ServerUpdate(); switch (privData->state) { case gameStateState_loading: diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index 260bf1be..938add5f 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -87,7 +87,7 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key // update animation // send data to server // check data from server - DanBias::GameServerAPI::ServerUpdate(); + if( KeyInput->IsKeyPressed(DIK_G)) { diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp index 8fa4936d..cd1e4663 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp @@ -103,7 +103,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key // failed to connect return ClientState_Same; } - return ClientState_Lobby; + return ClientState_LobbyCreated; } // join game if( KeyInput->IsKeyPressed(DIK_J))