From 2dde8547b7481df1279e784944786aaa4b66a5f9 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 17:12:38 +0100 Subject: [PATCH] Server poking --- .../GameClientState/LobbyAdminState.cpp | 16 +++--- .../GameClientState/LobbyState.cpp | 16 +++--- .../GameClientState/NetLoadState.cpp | 50 +++++++++---------- .../GameClientState/NetLoadState.h | 2 + Code/Game/GameProtocols/LobbyProtocols.h | 34 ++++++++++--- .../GameProtocols/ProtocolIdentificationID.h | 7 +-- Code/Game/GameServer/GameLobby.h | 2 +- .../GameLobby_ProtocolParser.cpp | 6 +-- Code/Game/aDanBiasGameLauncher/Launcher.cpp | 2 +- 9 files changed, 77 insertions(+), 58 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp index 9416f01e..c157226e 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp @@ -120,14 +120,14 @@ void LobbyAdminState::DataRecieved( NetEventprivData = new MyData(); this->privData->nextState = GameClientState::ClientState_Same; - //this->privData->nwClient = nwClient; needed? + this->privData->nwClient = nwClient; + this->privData->loading = false; // we may assume that nwClient is properly connected to the server - - - this->privData->nextState = GameClientState::ClientState_Main; + // signals querry to server for loading instructions + nwClient->Send( Protocol_QuerryGameType() ); return true; } @@ -63,24 +65,20 @@ void NetLoadState::ChangeState( ClientState next ) void NetLoadState::DataRecieved( NetEvent e ) { - CustomNetProtocol data = e.args.data.protocol; - short ID = data[0].value.netShort; // fetching the id data. + // fetching the id data. + short ID = e.args.data.protocol[0].value.netShort; - //if( ProtocolIsGameplay(ID) ) - //{ - // switch(ID) - // { - // //case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */ - // default: break; - // } - //} - //else if( ProtocolIsGeneral(ID) ) - //{ - // switch( ID ) - // { - // case protocol_General_Status: break; /** @todo TODO: implement */ - // case protocol_General_Text: break; /** @todo TODO: implement */ - // default: break; - // } - //} -} \ No newline at end of file + if( ID == protocol_Lobby_CreateGame && !this->privData->loading ) + { + this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName ); + } +} + +void NetLoadState::LoadGame( const ::std::string &fileName ) +{ + this->privData->loading = true; + + // TODO: ask Sam about level loader + + this->privData->nextState = ClientState::ClientState_Game; +} diff --git a/Code/Game/DanBiasGame/GameClientState/NetLoadState.h b/Code/Game/DanBiasGame/GameClientState/NetLoadState.h index e2688a4e..ff2d1acc 100644 --- a/Code/Game/DanBiasGame/GameClientState/NetLoadState.h +++ b/Code/Game/DanBiasGame/GameClientState/NetLoadState.h @@ -26,6 +26,8 @@ namespace DanBias private: struct MyData; ::Utility::DynamicMemory::UniquePointer privData; + + void LoadGame( const ::std::string &fileName ); }; } } diff --git a/Code/Game/GameProtocols/LobbyProtocols.h b/Code/Game/GameProtocols/LobbyProtocols.h index b57245ba..8e94ff51 100644 --- a/Code/Game/GameProtocols/LobbyProtocols.h +++ b/Code/Game/GameProtocols/LobbyProtocols.h @@ -21,6 +21,24 @@ namespace GameLogic { + struct Protocol_QuerryGameType :public Oyster::Network::CustomProtocolObject + { + public: + Protocol_QuerryGameType() + { + this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short; + this->protocol[0].value = protocol_Lobby_QuerryGameType; + } + + ::Oyster::Network::CustomNetProtocol GetProtocol() override + { + return this->protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject { short clientID; // The unuiqe id reprsenting a specific client @@ -30,7 +48,7 @@ namespace GameLogic Protocol_LobbyCreateGame() { int c = 0; - this->protocol[c].value = protocol_Lobby_Create; + this->protocol[c].value = protocol_Lobby_CreateGame; this->protocol[c++].type = Oyster::Network::NetAttributeType_Short; this->protocol[c++].type = Oyster::Network::NetAttributeType_Short; @@ -43,7 +61,7 @@ namespace GameLogic Protocol_LobbyCreateGame(short _clientID, std::string name, float world[16]) { int c = 0; - this->protocol[c].value = protocol_Lobby_Create; + this->protocol[c].value = protocol_Lobby_CreateGame; this->protocol[c++].type = Oyster::Network::NetAttributeType_Short; this->protocol[c++].type = Oyster::Network::NetAttributeType_Short; @@ -92,14 +110,14 @@ namespace GameLogic Protocol_LobbyStartGame() { - this->protocol[0].value = protocol_Lobby_Start; + this->protocol[0].value = protocol_Lobby_StartGame; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Float; seconds = 0; } Protocol_LobbyStartGame(float _seconds) { - this->protocol[0].value = protocol_Lobby_Start; + this->protocol[0].value = protocol_Lobby_StartGame; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Float; seconds = _seconds; @@ -119,17 +137,17 @@ namespace GameLogic }; - struct Protocol_LobbyLogin :public Oyster::Network::CustomProtocolObject + struct Protocol_LobbyJoinGame :public Oyster::Network::CustomProtocolObject { // Login stuff - Protocol_LobbyLogin() + Protocol_LobbyJoinGame() { - this->protocol[0].value = protocol_Lobby_Join; + this->protocol[0].value = protocol_Lobby_JoinGame; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Short; } - Protocol_LobbyLogin(Oyster::Network::CustomNetProtocol& p) + Protocol_LobbyJoinGame(Oyster::Network::CustomNetProtocol& p) { } diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index f9033d5b..c0e19104 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -27,13 +27,14 @@ /********* LOBBY PROTOCOLS ***************************************************************************************************/ /***********[ 200 - 299 ]***********/ #define protocol_LobbyMIN 200 -#define protocol_Lobby_Create 200 -#define protocol_Lobby_Start 201 -#define protocol_Lobby_Join 202 +#define protocol_Lobby_CreateGame 200 +#define protocol_Lobby_StartGame 201 +#define protocol_Lobby_JoinGame 202 #define protocol_Lobby_Login 203 #define protocol_Lobby_Refresh 204 #define protocol_Lobby_ClientData 205 #define protocol_Lobby_GameData 206 +#define protocol_Lobby_QuerryGameType 207 #define protocol_LobbyMAX 299 diff --git a/Code/Game/GameServer/GameLobby.h b/Code/Game/GameServer/GameLobby.h index 94cb0e3c..812d1360 100644 --- a/Code/Game/GameServer/GameLobby.h +++ b/Code/Game/GameServer/GameLobby.h @@ -40,7 +40,7 @@ namespace DanBias //void LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Create: void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start: //void LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Join: - void LobbyLogin(GameLogic::Protocol_LobbyLogin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login: + void LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login: void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh: void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData: void LobbyMainData(GameLogic::Protocol_LobbyClientData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData: diff --git a/Code/Game/GameServer/Implementation/GameLobby_ProtocolParser.cpp b/Code/Game/GameServer/Implementation/GameLobby_ProtocolParser.cpp index 93986650..07ae1f20 100644 --- a/Code/Game/GameServer/Implementation/GameLobby_ProtocolParser.cpp +++ b/Code/Game/GameServer/Implementation/GameLobby_ProtocolParser.cpp @@ -15,11 +15,11 @@ void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClie break; //case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c); //break; - case protocol_Lobby_Start: this->LobbyStartGame (Protocol_LobbyStartGame (p), c); + case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c); break; //case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c); //break; - case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyLogin (p), c); + case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyJoinGame (p), c); break; case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c); break; @@ -82,7 +82,7 @@ void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Ne // // } // //} //} -void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyLogin& p, Oyster::Network::NetworkClient* c) +void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c) { } diff --git a/Code/Game/aDanBiasGameLauncher/Launcher.cpp b/Code/Game/aDanBiasGameLauncher/Launcher.cpp index f05f021d..74af84d5 100644 --- a/Code/Game/aDanBiasGameLauncher/Launcher.cpp +++ b/Code/Game/aDanBiasGameLauncher/Launcher.cpp @@ -38,7 +38,7 @@ void ClientFnc() gameDesc.IP = "127.0.0.1"; //gameDesc.IP = "194.47.150.184"; - if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Sucess) + if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Success) { DanBias::DanBiasGame::Run(); DanBias::DanBiasGame::Release();