diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 9ef6f418..90a7843f 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -163,6 +163,7 @@ Global {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.ActiveCfg = Debug|Win32 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.Build.0 = Debug|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.ActiveCfg = Debug|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.Build.0 = Debug|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -240,6 +241,7 @@ Global {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.ActiveCfg = Debug|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.Build.0 = Debug|Win32 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.ActiveCfg = Debug|x64 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.Build.0 = Debug|x64 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Mixed Platforms.ActiveCfg = Release|Win32 diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index 1784ca35..76a7554e 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -72,7 +72,7 @@ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) - $(SolutionDir)..\External\Include\;$(IncludePath) + $(SolutionDir)Network/NetworkAPI;$(IncludePath) true @@ -106,7 +106,7 @@ Disabled DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)Game/GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories) Windows @@ -123,12 +123,12 @@ Disabled DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows true - OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies) + GameProtocols_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies) OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) @@ -142,14 +142,14 @@ true DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows true true true - OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) + GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) OysterGraphics_x86.dll;%(DelayLoadDLLs) @@ -163,14 +163,14 @@ true DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows true true true - OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) + GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) OysterGraphics_x86.dll;%(DelayLoadDLLs) @@ -181,6 +181,9 @@ {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} + + {460d625f-2ac9-4559-b809-0ba89ceaedf4} + {0ec83e64-230e-48ef-b08c-6ac9651b4f82} diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 64fc0bc4..e38b8cc9 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -5,7 +5,8 @@ #include "GameClientState/GameClientState.h" #include "GameClientState\GameState.h" #include "GameClientState\LobbyState.h" - +#include "PlayerProtocols.h" +#include "NetworkClient.h" #include "L_inputClass.h" #include "vld.h" @@ -19,6 +20,36 @@ namespace DanBias HWND DanBiasGame::g_hWnd = NULL; #pragma region Game Data + + + struct MyRecieverObject // :public PontusRecieverObject + { + Oyster::Network::NetworkClient nwClient; + + static void ProtocolRecieved(Network::CustomNetProtocol* p) + { + int pType = ((*p)[0]).value.netInt; + switch (pType) + { + case protocol_PlayerNavigation: + + break; + case protocol_PlayerPosition: + //int x = ((*p)[1]).value.netInt; + //int y = ((*p)[2]).value.netInt; + //int z = ((*p)[3]).value.netInt; + break; + + + case protocol_ObjectPosition: + // DanBiasGame::protocolRecived(); + break; + + default: + break; + } + } + }; class DanBiasGamePrivateData { @@ -35,12 +66,21 @@ namespace DanBias public: Client::GameClientState* gameClientState; InputClass* inputObj; + GameLogic::Protocol_PlayerMovement player_move; + //Oyster::Network::NetworkClient nwClient; + MyRecieverObject r; + // gameClient; } data; #pragma endregion - DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData(); + + DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData(); + void DanBiasGame::protocolRecived() + { + //m_data->gameClientState.setPos() + } //-------------------------------------------------------------------------------------- // Interface API functions //-------------------------------------------------------------------------------------- diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index fb81e23a..a95b6798 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -12,6 +12,7 @@ struct GameState::myData Oyster::Math3D::Float4x4 proj; C_Object* object[3]; int modelCount; + //Oyster::Network::NetworkClient* nwClient; gameStateState state; }privData; @@ -86,6 +87,8 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI case gameStateState_playing: // read server data // update objects + // Client.send(obj); + if(KeyInput->IsKeyPressed(DIK_L)) privData->state = GameState::gameStateState_end; break; diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h index 924caac7..deaafdb9 100644 --- a/Code/Game/DanBiasGame/Include/DanBiasGame.h +++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h @@ -54,6 +54,8 @@ namespace DanBias static HRESULT Update(float deltaTime); static HRESULT Render(float deltaTime); static HRESULT CleanUp(); + + static void protocolRecived(); private: static __int64 cntsPerSec; static __int64 prevTimeStamp; diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 28b89485..0440d973 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -4,8 +4,8 @@ #define NOMINMAX #include -#define DANBIAS_SERVER -//#define DANBIAS_CLIENT +//#define DANBIAS_SERVER +#define DANBIAS_CLIENT #if defined(DANBIAS_SERVER) diff --git a/Code/Game/GameProtocols/GameProtocols.vcxproj b/Code/Game/GameProtocols/GameProtocols.vcxproj index 629ecf72..a7ebcca0 100644 --- a/Code/Game/GameProtocols/GameProtocols.vcxproj +++ b/Code/Game/GameProtocols/GameProtocols.vcxproj @@ -154,6 +154,7 @@ + diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h new file mode 100644 index 00000000..32a86259 --- /dev/null +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -0,0 +1,67 @@ +#ifndef GAMELOGIC_PLAYER_PROTOCOLS_H +#define GAMELOGIC_PLAYER_PROTOCOLS_H + +#include +#include "ProtocolIdentificationID.h" + + + +namespace GameLogic +{ + struct Protocol_ObjectPosition :public Network::CustomProtocolObject + { + float worldMatrix[16]; + // look at dir + + Protocol_ObjectPosition() + { + this->protocol[0].value = protocol_PlayerPosition; + this->protocol[0].type = Network::NetAttributeType_Int; + + this->protocol[1].type = Network::NetAttributeType_Float; + this->protocol[2].type = Network::NetAttributeType_Float; + this->protocol[3].type = Network::NetAttributeType_Float; + this->protocol[4].type = Network::NetAttributeType_Float; + this->protocol[5].type = Network::NetAttributeType_Float; + this->protocol[6].type = Network::NetAttributeType_Float; + this->protocol[7].type = Network::NetAttributeType_Float; + this->protocol[8].type = Network::NetAttributeType_Float; + this->protocol[9].type = Network::NetAttributeType_Float; + this->protocol[10].type = Network::NetAttributeType_Float; + this->protocol[11].type = Network::NetAttributeType_Float; + this->protocol[12].type = Network::NetAttributeType_Float; + this->protocol[13].type = Network::NetAttributeType_Float; + this->protocol[14].type = Network::NetAttributeType_Float; + this->protocol[15].type = Network::NetAttributeType_Float; + this->protocol[16].type = Network::NetAttributeType_Float; + + } + Network::CustomNetProtocol* GetProtocol() override + { + + this->protocol[1].value = worldMatrix[0]; + this->protocol[2].value = worldMatrix[1]; + this->protocol[3].value = worldMatrix[2]; + this->protocol[4].value = worldMatrix[4]; + this->protocol[5].value = worldMatrix[5]; + this->protocol[6].value = worldMatrix[6]; + this->protocol[7].value = worldMatrix[7]; + this->protocol[8].value = worldMatrix[8]; + this->protocol[9].value = worldMatrix[9]; + this->protocol[10].value = worldMatrix[10]; + this->protocol[11].value = worldMatrix[11]; + this->protocol[12].value = worldMatrix[12]; + this->protocol[13].value = worldMatrix[13]; + this->protocol[14].value = worldMatrix[14]; + this->protocol[15].value = worldMatrix[15]; + this->protocol[16].value = worldMatrix[16]; + return &protocol; + } + + private: + Network::CustomNetProtocol protocol; + }; + +} + +#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H \ No newline at end of file diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index b091ba34..3375a87c 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -1,7 +1,7 @@ #ifndef GAMELOGIC_PLAYER_PROTOCOLS_H #define GAMELOGIC_PLAYER_PROTOCOLS_H -#include "CustomNetProtocol.h" +#include #include "ProtocolIdentificationID.h" @@ -20,24 +20,24 @@ namespace GameLogic Protocol_PlayerMovement() { - protocol[0]->value = ProtocolID = protocol_PlayerNavigation; + this->protocol[0].value = ProtocolID = protocol_PlayerNavigation; - protocol[0]->type = Network::NetAttributeType_Int; - protocol[1]->type = Network::NetAttributeType_Bool; - protocol[2]->type = Network::NetAttributeType_Bool; - protocol[3]->type = Network::NetAttributeType_Bool; - protocol[4]->type = Network::NetAttributeType_Bool; - protocol[5]->type = Network::NetAttributeType_Bool; - protocol[6]->type = Network::NetAttributeType_Bool; + this->protocol[0].type = Network::NetAttributeType_Int; + this->protocol[1].type = Network::NetAttributeType_Bool; + this->protocol[2].type = Network::NetAttributeType_Bool; + this->protocol[3].type = Network::NetAttributeType_Bool; + this->protocol[4].type = Network::NetAttributeType_Bool; + this->protocol[5].type = Network::NetAttributeType_Bool; + this->protocol[6].type = Network::NetAttributeType_Bool; } Network::CustomNetProtocol* GetProtocol() override { - protocol[1]->value = bForward; - protocol[2]->value = bBackward; - protocol[3]->value = bTurnLeft; - protocol[4]->value = bTurnRight; - protocol[5]->value = bStrafeRight; - protocol[6]->value = bStrafeRight; + this->protocol[1].value = bForward; + this->protocol[2].value = bBackward; + this->protocol[3].value = bTurnLeft; + this->protocol[4].value = bTurnRight; + this->protocol[5].value = bStrafeRight; + this->protocol[6].value = bStrafeRight; return &protocol; } @@ -45,6 +45,35 @@ namespace GameLogic private: Network::CustomNetProtocol protocol; }; + + struct Protocol_PlayerPosition :public Network::CustomProtocolObject + { + float position[3]; + // look at dir + + Protocol_PlayerPosition() + { + this->protocol[0].value = protocol_PlayerPosition; + this->protocol[0].type = Network::NetAttributeType_Int; + + this->protocol[1].type = Network::NetAttributeType_Float; + this->protocol[2].type = Network::NetAttributeType_Float; + this->protocol[3].type = Network::NetAttributeType_Float; + + } + Network::CustomNetProtocol* GetProtocol() override + { + + this->protocol[1].value = position[0]; + this->protocol[2].value = position[1]; + this->protocol[3].value = position[2]; + return &protocol; + } + + private: + Network::CustomNetProtocol protocol; + }; + } #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index 1af8c920..46a1b72f 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -3,6 +3,8 @@ /* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */ -#define protocol_PlayerNavigation 0; +#define protocol_PlayerNavigation 0 +#define protocol_PlayerPosition 1 +#define protocol_ObjectPosition 2 #endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H