diff --git a/Bin/DLL/NetworkAPI_x86D.pdb b/Bin/DLL/NetworkAPI_x86D.pdb deleted file mode 100644 index 32495041..00000000 Binary files a/Bin/DLL/NetworkAPI_x86D.pdb and /dev/null differ diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index cad0bd75..ebd2f715 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -43,7 +43,8 @@ namespace DanBias { ((Client::GameClientState::PlayerPos*)protocolData)->playerPos[i] = p[i].value.netFloat; } - gameClientState->Protocol(protocolData); + if(dynamic_cast(gameClientState)) + ((Client::GameState*)gameClientState)->Protocol(protocolData); delete protocolData; protocolData = NULL; break; @@ -51,11 +52,15 @@ namespace DanBias case protocol_Gamplay_ObjectPosition: protocolData = new Client::GameClientState::ObjPos; + ((Client::GameClientState::ObjPos*)protocolData)->object_ID = p[1].value.netInt; for(int i = 0; i< 16; i++) { - ((Client::GameClientState::ObjPos*)protocolData)->worldPos[i] = p[i].value.netFloat; + ((Client::GameClientState::ObjPos*)protocolData)->worldPos[i] = p[i+2].value.netFloat; } - gameClientState->Protocol(protocolData); + + if(dynamic_cast(gameClientState)) + ((Client::GameState*)gameClientState)->Protocol(protocolData); + delete protocolData; protocolData = NULL; break; @@ -79,9 +84,9 @@ namespace DanBias } public: - Client::GameClientState* gameClientState; + //Client::GameClientState* gameClientState; InputClass* inputObj; - MyRecieverObject* r; + MyRecieverObject* recieverObj; } data; #pragma endregion @@ -110,17 +115,17 @@ namespace DanBias prevTimeStamp = 0; QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp); - m_data->r = new MyRecieverObject; - m_data->r->nwClient = new Oyster::Network::NetworkClient(); - m_data->r->nwClient->Connect(desc.port, desc.IP); - if (!m_data->r->nwClient->IsConnected()) + m_data->recieverObj = new MyRecieverObject; + m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(); + m_data->recieverObj->nwClient->Connect(desc.port, desc.IP); + if (!m_data->recieverObj->nwClient->IsConnected()) { // failed to connect return DanBiasClientReturn_Error; } // Start in lobby state - m_data->gameClientState = new Client::LobbyState(); - m_data->gameClientState->Init(m_data->r->nwClient); + m_data->recieverObj->gameClientState = new Client::LobbyState(); + m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient); return DanBiasClientReturn_Sucess; @@ -237,27 +242,27 @@ namespace DanBias m_data->inputObj->Update(); DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same; - state = m_data->gameClientState->Update(deltaTime, m_data->inputObj); + state = m_data->recieverObj->gameClientState->Update(deltaTime, m_data->inputObj); if(state != Client::GameClientState::ClientState_Same) { - m_data->gameClientState->Release(); - delete m_data->gameClientState; - m_data->gameClientState = NULL; + m_data->recieverObj->gameClientState->Release(); + delete m_data->recieverObj->gameClientState; + m_data->recieverObj->gameClientState = NULL; switch (state) { case Client::GameClientState::ClientState_Lobby: - m_data->gameClientState = new Client::LobbyState(); + m_data->recieverObj->gameClientState = new Client::LobbyState(); break; case Client::GameClientState::ClientState_Game: - m_data->gameClientState = new Client::GameState(); + m_data->recieverObj->gameClientState = new Client::GameState(); break; default: return E_FAIL; break; } - m_data->gameClientState->Init(m_data->r->nwClient); // send game client + m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient); // send game client } return S_OK; @@ -275,15 +280,18 @@ namespace DanBias swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed)); SetWindowText(g_hWnd, title); - m_data->gameClientState->Render(); + m_data->recieverObj->gameClientState->Render(); return S_OK; } HRESULT DanBiasGame::CleanUp() { - m_data->gameClientState->Release(); - delete m_data->gameClientState; + m_data->recieverObj->gameClientState->Release(); + delete m_data->recieverObj->gameClientState; + m_data->recieverObj->nwClient->Disconnect(); + delete m_data->recieverObj->nwClient; + delete m_data->recieverObj; delete m_data->inputObj; delete m_data; diff --git a/Code/Game/DanBiasGame/GameClientState/C_Object.h b/Code/Game/DanBiasGame/GameClientState/C_Object.h index 8bfecdb9..18859930 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_Object.h +++ b/Code/Game/DanBiasGame/GameClientState/C_Object.h @@ -20,7 +20,7 @@ private: public: virtual void Init(ModelInitData modelInit) = 0; - virtual void setPos() = 0; + virtual void setPos(Oyster::Math::Float4x4 world) = 0; virtual void Render() = 0; virtual void Release() = 0; diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp index 686bbca9..a4ae4840 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp @@ -26,9 +26,9 @@ void C_DynamicObj::Init(ModelInitData modelInit) privData->model->WorldMatrix = modelInit.world; privData->model->Visible = modelInit.visible; } -void C_DynamicObj::setPos() +void C_DynamicObj::setPos(Oyster::Math::Float4x4 world) { - + privData->model->WorldMatrix = world; } void C_DynamicObj::Render() diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h index ca0f3b8c..e0ad3be3 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h @@ -14,7 +14,7 @@ public: C_DynamicObj(void); virtual ~C_DynamicObj(void); void Init(ModelInitData modelInit); - void setPos(); + void setPos(Oyster::Math::Float4x4 world); void Render(); void Release(); diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp index e47d98ef..5fb06d96 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp @@ -30,9 +30,9 @@ void C_Player::Init(ModelInitData modelInit) } -void C_Player::setPos() +void C_Player::setPos(Oyster::Math::Float4x4 world) { - + privData->model->WorldMatrix = world; } void C_Player::Render() diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h index 5d9c9d59..638bd856 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h @@ -15,7 +15,7 @@ public: C_Player(void); ~C_Player(void); void Init(ModelInitData modelInit); - void setPos(); + void setPos(Oyster::Math::Float4x4 world); void Render(); void Release(); diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp index 54c36c2a..f96ea56d 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp @@ -29,9 +29,9 @@ void C_StaticObj::Init(ModelInitData modelInit) privData->model->Visible = modelInit.visible; } -void C_StaticObj::setPos() +void C_StaticObj::setPos(Oyster::Math::Float4x4 world) { - + privData->model->WorldMatrix = world; } void C_StaticObj::Render() diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h index 768344f0..84fc0599 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h @@ -14,7 +14,7 @@ public: C_StaticObj(void); virtual ~C_StaticObj(void); void Init(ModelInitData modelInit); - void setPos(); + void setPos(Oyster::Math::Float4x4 world); void Render(); void Release(); diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp index b07ec6fa..5adc3962 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp @@ -27,9 +27,9 @@ void C_UIobject::Init(ModelInitData modelInit) privData->model->Visible = modelInit.visible; } -void C_UIobject::setPos() +void C_UIobject::setPos(Oyster::Math::Float4x4 world) { - + privData->model->WorldMatrix = world; } void C_UIobject::Render() diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h index 203b5398..e82b702f 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h @@ -14,7 +14,7 @@ namespace DanBias C_UIobject(void); virtual ~C_UIobject(void); void Init(ModelInitData modelInit); - void setPos(); + void setPos(Oyster::Math::Float4x4 world); void Render(); void Release(); diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h index 368fca6a..1082125a 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameClientState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -19,6 +19,7 @@ public: }; struct ObjPos :public ProtocolStruct { + int object_ID; float worldPos[16]; }; struct PlayerPos :public ProtocolStruct diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 588e6ab8..bbcd36a4 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -91,7 +91,6 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI case gameStateState_playing: // read server data // update objects - // Client.send(obj); { GameLogic::Protocol_PlayerMovement movePlayer; movePlayer.bForward = false; @@ -117,11 +116,15 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI if(KeyInput->IsKeyPressed(DIK_D)) { movePlayer.bStrafeRight = true; + } + + if (privData->nwClient->IsConnected()) + { + privData->nwClient->Send(movePlayer); } - - - privData->nwClient->Send(movePlayer); - + + // send event data + // if(KeyInput->IsKeyPressed(DIK_L)) privData->state = GameState::gameStateState_end; } @@ -169,12 +172,45 @@ void GameState::Protocol(ProtocolStruct* pos) else if((PlayerPos*)pos) PlayerPosProtocol((PlayerPos*)pos); } + +void DanBias::Client::GameState::Protocol( PlayerPos* pos ) +{ + Oyster::Math::Float4x4 world, translate; + + world = Oyster::Math::Float4x4::identity; + translate = Oyster::Math::Float4x4::identity; + translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(pos->playerPos[0],pos->playerPos[1],pos->playerPos[2])); + world = world * translate; + privData->object[0]->setPos( world ); +} + +void DanBias::Client::GameState::Protocol( ObjPos* pos ) +{ + Oyster::Math::Float4x4 world; + for(int i = 0; i<16; i++) + { + world[i] = pos->worldPos[i]; + } + privData->object[pos->object_ID]->setPos(world); +} + void GameState::PlayerPosProtocol(PlayerPos* pos) { + Oyster::Math::Float4x4 world, translate; + world = Oyster::Math::Float4x4::identity; + translate = Oyster::Math::Float4x4::identity; + translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(pos->playerPos[0],pos->playerPos[1],pos->playerPos[2] )); + world = translate; + privData->object[0]->setPos( world ); } void GameState::ObjectPosProtocol(ObjPos* pos) { - + Oyster::Math::Float4x4 world; + for(int i = 0; i<16; i++) + { + world[i] = pos->worldPos[i]; + } + privData->object[1]->setPos(world); } //void GameState::Protocol(LightPos pos); \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h index 05f9ac3d..5e185cef 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -32,6 +32,8 @@ public: bool Release()override; void Protocol(ProtocolStruct* pos)override; + void Protocol(PlayerPos* pos); + void Protocol(ObjPos* pos); void PlayerPosProtocol(PlayerPos* pos); void ObjectPosProtocol(ObjPos* pos); //void Protocol(LightPos pos); diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 7d5727b7..2c3873cb 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -5,7 +5,6 @@ #include #include - #include "DanBiasServerAPI.h" //#include "DanBiasGame.h" @@ -29,8 +28,8 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh } // Game client starter code goes here DanBias::DanBiasGameDesc gameDesc; - gameDesc.port = 1; - gameDesc.IP = "10.1010.303"; + gameDesc.port = 15151; + gameDesc.IP = "193.11.186.101"; gameDesc.hinst = hinst; gameDesc.nCmdShow = cmdShow; diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index 5619c8b2..2d2118bb 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -10,6 +10,7 @@ namespace GameLogic { struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject { + int object_ID; float worldMatrix[16]; // look at dir @@ -18,7 +19,8 @@ namespace GameLogic this->protocol[0].value = protocol_Gamplay_ObjectPosition; this->protocol[0].type = Oyster::Network::NetAttributeType_Int; - this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; this->protocol[3].type = Oyster::Network::NetAttributeType_Float; this->protocol[4].type = Oyster::Network::NetAttributeType_Float; @@ -34,18 +36,19 @@ namespace GameLogic this->protocol[14].type = Oyster::Network::NetAttributeType_Float; this->protocol[15].type = Oyster::Network::NetAttributeType_Float; this->protocol[16].type = Oyster::Network::NetAttributeType_Float; + this->protocol[17].type = Oyster::Network::NetAttributeType_Float; } Oyster::Network::CustomNetProtocol* GetProtocol() override { - this->protocol[1].value = worldMatrix[0]; + this->protocol[1].value = object_ID; this->protocol[2].value = worldMatrix[1]; this->protocol[3].value = worldMatrix[2]; - this->protocol[4].value = worldMatrix[3]; - this->protocol[5].value = worldMatrix[4]; + this->protocol[4].value = worldMatrix[3]; + this->protocol[5].value = worldMatrix[4]; this->protocol[6].value = worldMatrix[5]; - this->protocol[7].value = worldMatrix[6]; + this->protocol[7].value = worldMatrix[6]; this->protocol[8].value = worldMatrix[7]; this->protocol[9].value = worldMatrix[8]; this->protocol[10].value = worldMatrix[9]; diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index 4334b87a..35e66127 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -15,6 +15,7 @@ namespace GameLogic { struct Protocol_PlayerMovement :public Oyster::Network::CustomProtocolObject { + bool bForward; bool bBackward; bool bTurnLeft; @@ -25,8 +26,8 @@ namespace GameLogic Protocol_PlayerMovement() { this->protocol[0].value = protocol_Gamplay_PlayerNavigation; - this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; this->protocol[2].type = Oyster::Network::NetAttributeType_Bool; this->protocol[3].type = Oyster::Network::NetAttributeType_Bool; @@ -52,13 +53,14 @@ namespace GameLogic struct Protocol_PlayerPosition :public Oyster::Network::CustomProtocolObject { + float position[3]; // look at dir Protocol_PlayerPosition() { this->protocol[0].value = protocol_Gamplay_PlayerPosition; - this->protocol[0].type = Oyster::Network::NetAttributeType_Int; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Float; this->protocol[2].type = Oyster::Network::NetAttributeType_Float;