diff --git a/Bin/Content/Shaders/DebugVertex.cso b/Bin/Content/Shaders/DebugVertex.cso deleted file mode 100644 index 4783f8a6..00000000 Binary files a/Bin/Content/Shaders/DebugVertex.cso and /dev/null differ diff --git a/Bin/Content/Shaders/TextureDebug.cso b/Bin/Content/Shaders/TextureDebug.cso deleted file mode 100644 index 6a324d8d..00000000 Binary files a/Bin/Content/Shaders/TextureDebug.cso and /dev/null differ diff --git a/Bin/DLL/DanBiasServer_x64.pdb b/Bin/DLL/DanBiasServer_x64.pdb new file mode 100644 index 00000000..4a457347 Binary files /dev/null and b/Bin/DLL/DanBiasServer_x64.pdb differ diff --git a/Bin/DLL/NetworkAPI_x64.pdb b/Bin/DLL/NetworkAPI_x64.pdb new file mode 100644 index 00000000..2aa321fb Binary files /dev/null and b/Bin/DLL/NetworkAPI_x64.pdb differ diff --git a/Bin/DLL/NetworkAPI_x64D.pdb b/Bin/DLL/NetworkAPI_x64D.pdb new file mode 100644 index 00000000..39a6662a Binary files /dev/null and b/Bin/DLL/NetworkAPI_x64D.pdb differ diff --git a/Bin/DLL/NetworkAPI_x86.pdb b/Bin/DLL/NetworkAPI_x86.pdb new file mode 100644 index 00000000..aacce35f Binary files /dev/null and b/Bin/DLL/NetworkAPI_x86.pdb differ diff --git a/Bin/DLL/NetworkAPI_x86D.pdb b/Bin/DLL/NetworkAPI_x86D.pdb new file mode 100644 index 00000000..39d11475 Binary files /dev/null and b/Bin/DLL/NetworkAPI_x86D.pdb differ diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 315bd416..894caec6 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -196,6 +196,7 @@ Global {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32 diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index c4ad8f96..ff05bc23 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -192,26 +192,26 @@ - + + + + - - - - - + + + + - - diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 1729708d..15e799bf 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -30,41 +30,39 @@ namespace DanBias void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& p) override { - int pType = p[0].value.netInt; - Client::GameClientState::ProtocolStruct* protocol; - switch (pType) - { - case protocol_PlayerNavigation: + int pType = p[0].value.netInt; + Client::GameClientState::ProtocolStruct* protocolData; + switch (pType) + { + case protocol_PlayerNavigation: - break; - case protocol_PlayerPosition: - protocol = new Client::GameClientState::PlayerPos; - for(int i = 0; i< 3; i++) - { - ((Client::GameClientState::PlayerPos*)protocol)->playerPos[i] = p[i].value.netFloat; - } - gameClientState->Protocol(protocol); - delete protocol; - protocol = NULL; - break; + break; + case protocol_PlayerPosition: + protocolData = new Client::GameClientState::PlayerPos; + for(int i = 0; i< 3; i++) + { + ((Client::GameClientState::PlayerPos*)protocolData)->playerPos[i] = p[i].value.netFloat; + } + gameClientState->Protocol(protocolData); + delete protocolData; + protocolData = NULL; + break; - case protocol_ObjectPosition: - protocol = new Client::GameClientState::ObjPos; - for(int i = 0; i< 16; i++) - { - ((Client::GameClientState::ObjPos*)protocol)->worldPos[i] = p[i].value.netFloat; - } - gameClientState->Protocol(protocol); - delete protocol; - protocol = NULL; - break; - - default: - break; - } - + case protocol_ObjectPosition: + protocolData = new Client::GameClientState::ObjPos; + for(int i = 0; i< 16; i++) + { + ((Client::GameClientState::ObjPos*)protocolData)->worldPos[i] = p[i].value.netFloat; + } + gameClientState->Protocol(protocolData); + delete protocolData; + protocolData = NULL; + break; + default: + break; + } } }; class DanBiasGamePrivateData @@ -112,12 +110,18 @@ namespace DanBias prevTimeStamp = 0; QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp); - - // Start in lobby state - m_data->gameClientState = new Client::LobbyState(); - m_data->gameClientState->Init(); 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()) + { + // failed to connect + return DanBiasClientReturn_Error; + } + // Start in lobby state + m_data->gameClientState = new Client::LobbyState(); + m_data->gameClientState->Init(m_data->r->nwClient); + return DanBiasClientReturn_Sucess; } @@ -253,7 +257,7 @@ namespace DanBias return E_FAIL; break; } - m_data->gameClientState->Init(); // send game client + m_data->gameClientState->Init(m_data->r->nwClient); // send game client } return S_OK; diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp new file mode 100644 index 00000000..686bbca9 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp @@ -0,0 +1,42 @@ +#include "C_DynamicObj.h" +#include "DllInterfaces/GFXAPI.h" +using namespace DanBias::Client; +struct C_DynamicObj::myData +{ + myData(){} + Oyster::Graphics::Model::Model *model; + // light + // sound + // effect +}privData; +C_DynamicObj::C_DynamicObj(void) +{ +} + + +C_DynamicObj::~C_DynamicObj(void) +{ + +} +void C_DynamicObj::Init(ModelInitData modelInit) +{ + // load models + privData = new myData(); + privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); + privData->model->WorldMatrix = modelInit.world; + privData->model->Visible = modelInit.visible; +} +void C_DynamicObj::setPos() +{ + +} + +void C_DynamicObj::Render() +{ + Oyster::Graphics::API::RenderModel(*(privData->model)); +} +void C_DynamicObj::Release() +{ + Oyster::Graphics::API::DeleteModel(privData->model); + delete privData; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h new file mode 100644 index 00000000..ca0f3b8c --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h @@ -0,0 +1,22 @@ +#ifndef DANBIAS_CLIENT_CDYNAMICOBJECT_H +#define DANBIAS_CLIENT_CDYNAMICOBJECT_H +#include "../C_Object.h" +namespace DanBias +{ + namespace Client + { +class C_DynamicObj : public C_Object +{ +private: + struct myData; + myData* privData; +public: + C_DynamicObj(void); + virtual ~C_DynamicObj(void); + void Init(ModelInitData modelInit); + void setPos(); + + void Render(); + void Release(); +};};}; +#endif diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp new file mode 100644 index 00000000..e47d98ef --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp @@ -0,0 +1,46 @@ +#include "C_Player.h" +#include "DllInterfaces/GFXAPI.h" +using namespace DanBias::Client; + +struct C_Player::myData +{ + myData(){} + Oyster::Math3D::Float4x4 view; + Oyster::Math3D::Float4x4 proj; + Oyster::Graphics::Model::Model *model; +}privData; + +C_Player::C_Player(void) +{ +} + + +C_Player::~C_Player(void) +{ + +} + +void C_Player::Init(ModelInitData modelInit) +{ + // load models + privData = new myData(); + privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); + privData->model->WorldMatrix = modelInit.world; + privData->model->Visible = modelInit.visible; + + +} +void C_Player::setPos() +{ + +} + +void C_Player::Render() +{ + Oyster::Graphics::API::RenderModel(*(privData->model)); +} +void C_Player::Release() +{ + Oyster::Graphics::API::DeleteModel(privData->model); + delete privData; +} diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h new file mode 100644 index 00000000..5d9c9d59 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h @@ -0,0 +1,25 @@ +#ifndef DANBIAS_CLIENT_CPLAYER_H +#define DANBIAS_CLIENT_CPLAYER_H +#include "../C_Object.h" +namespace DanBias +{ + namespace Client + { +class C_Player : public C_Object +{ +private: + struct myData; + myData* privData; + //Oyster::Graphics:: LIght +public: + C_Player(void); + ~C_Player(void); + void Init(ModelInitData modelInit); + void setPos(); + + void Render(); + void Release(); + +};};}; +#endif + diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp new file mode 100644 index 00000000..54c36c2a --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp @@ -0,0 +1,45 @@ + +#include "C_StaticObj.h" +#include "DllInterfaces/GFXAPI.h" +using namespace DanBias::Client; + +struct C_StaticObj::myData +{ + myData(){} + Oyster::Graphics::Model::Model *model; + // light + // sound + // effect +}privData; +C_StaticObj::C_StaticObj(void) +{ +} + + +C_StaticObj::~C_StaticObj(void) +{ + +} +void C_StaticObj::Init(ModelInitData modelInit) +{ + // load models + privData = new myData(); + privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); + privData->model->WorldMatrix = modelInit.world; + privData->model->Visible = modelInit.visible; + +} +void C_StaticObj::setPos() +{ + +} + +void C_StaticObj::Render() +{ + Oyster::Graphics::API::RenderModel(*(privData->model)); +} +void C_StaticObj::Release() +{ + Oyster::Graphics::API::DeleteModel(privData->model); + delete privData; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h new file mode 100644 index 00000000..768344f0 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h @@ -0,0 +1,22 @@ +#ifndef DANBIAS_CLIENT_CSTATICOBJECT_H +#define DANBIAS_CLIENT_CSTATICOBJECT_H +#include "../C_Object.h" +namespace DanBias +{ + namespace Client + { +class C_StaticObj : public C_Object +{ +private: + struct myData; + myData* privData; +public: + C_StaticObj(void); + virtual ~C_StaticObj(void); + void Init(ModelInitData modelInit); + void setPos(); + + void Render(); + void Release(); +};};}; +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp new file mode 100644 index 00000000..b07ec6fa --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp @@ -0,0 +1,43 @@ +#include "C_UIobject.h" +#include "DllInterfaces/GFXAPI.h" +using namespace DanBias::Client; + +struct C_UIobject::myData +{ + myData(){} + Oyster::Math3D::Float4x4 view; + Oyster::Math3D::Float4x4 proj; + Oyster::Graphics::Model::Model *model; +}privData; + +C_UIobject::C_UIobject(void) +{ +} + + +C_UIobject::~C_UIobject(void) +{ +} +void C_UIobject::Init(ModelInitData modelInit) +{ + // load models + privData = new myData(); + privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); + privData->model->WorldMatrix = modelInit.world; + privData->model->Visible = modelInit.visible; + +} +void C_UIobject::setPos() +{ + +} + +void C_UIobject::Render() +{ + Oyster::Graphics::API::RenderModel(*(privData->model)); +} +void C_UIobject::Release() +{ + Oyster::Graphics::API::DeleteModel(privData->model); + delete privData; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h new file mode 100644 index 00000000..203b5398 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h @@ -0,0 +1,22 @@ +#ifndef DANBIAS_CLIENT_CUIOBJECT_H +#define DANBIAS_CLIENT_CUIOBJECT_H +#include "../C_Object.h" +namespace DanBias +{ + namespace Client + { + class C_UIobject : public C_Object + { + private: + struct myData; + myData* privData; + public: + C_UIobject(void); + virtual ~C_UIobject(void); + void Init(ModelInitData modelInit); + void setPos(); + + void Render(); + void Release(); +};};}; +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h index 4e0d723b..368fca6a 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameClientState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -3,6 +3,7 @@ #define NOMINMAX #include "L_inputClass.h" +#include "NetworkClient.h" namespace DanBias { @@ -42,7 +43,7 @@ public: public: GameClientState(void); virtual ~GameClientState(void); - virtual bool Init() = 0; + virtual bool Init(Oyster::Network::NetworkClient* nwClient) = 0; virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0; virtual bool Render() = 0; virtual bool Release() = 0; diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 64b1babb..588e6ab8 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -1,7 +1,7 @@ #include "GameState.h" #include "DllInterfaces/GFXAPI.h" -#include "Obj/C_Player.h" -#include "Obj/C_DynamicObj.h" +#include "C_obj/C_Player.h" +#include "C_obj/C_DynamicObj.h" #include "NetworkClient.h" #include "PlayerProtocols.h" @@ -28,11 +28,12 @@ GameState::~GameState(void) { } -bool GameState::Init() +bool GameState::Init(Oyster::Network::NetworkClient* nwClient) { // load models privData = new myData(); privData->state = gameStateState_loading; + privData->nwClient = nwClient; privData->state = LoadGame(); return true; } @@ -92,12 +93,37 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI // update objects // Client.send(obj); { - GameLogic::Protocol_PlayerMovement movePlayer; - - //privData->nwClient->Send(movePlayer); + GameLogic::Protocol_PlayerMovement movePlayer; + movePlayer.bForward = false; + movePlayer.bBackward = false; + movePlayer.bStrafeLeft = false; + movePlayer.bStrafeRight = false; + movePlayer.bTurnLeft = false; + movePlayer.bTurnRight = false; - if(KeyInput->IsKeyPressed(DIK_L)) - privData->state = GameState::gameStateState_end; + + if(KeyInput->IsKeyPressed(DIK_W)) + { + movePlayer.bForward = true; + } + if(KeyInput->IsKeyPressed(DIK_S)) + { + movePlayer.bBackward = true; + } + if(KeyInput->IsKeyPressed(DIK_A)) + { + movePlayer.bStrafeLeft = true; + } + if(KeyInput->IsKeyPressed(DIK_D)) + { + movePlayer.bStrafeRight = true; + } + + + privData->nwClient->Send(movePlayer); + + if(KeyInput->IsKeyPressed(DIK_L)) + privData->state = GameState::gameStateState_end; } break; case gameStateState_end: diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h index 26ec0caa..05f9ac3d 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -22,7 +22,7 @@ private: public: GameState(void); ~GameState(void); - bool Init(); + bool Init(Oyster::Network::NetworkClient* nwClient); GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput) override; bool LoadModels(std::wstring mapFile) ; bool InitCamera(Oyster::Math::Float3 startPos) ; diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index 8d54bd24..2c07c27f 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -1,9 +1,9 @@ #include "LobbyState.h" #include "DllInterfaces/GFXAPI.h" #include "OysterMath.h" -#include "Obj/C_Player.h" -#include "Obj/C_StaticObj.h" -#include "Obj/C_DynamicObj.h" +#include "C_obj/C_Player.h" +#include "C_obj/C_StaticObj.h" +#include "C_obj/C_DynamicObj.h" using namespace DanBias::Client; @@ -28,7 +28,7 @@ LobbyState::~LobbyState(void) } -bool LobbyState::Init() +bool LobbyState::Init(Oyster::Network::NetworkClient* nwClient) { privData = new myData(); diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.h b/Code/Game/DanBiasGame/GameClientState/LobbyState.h index c00a3b8f..e7cb7b8c 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.h +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.h @@ -17,7 +17,7 @@ private: public: LobbyState(void); ~LobbyState(void); - bool Init(); + bool Init(Oyster::Network::NetworkClient* nwClient); bool LoadModels(std::wstring file); bool InitCamera(Oyster::Math::Float3 startPos); ClientState Update(float deltaTime, InputClass* KeyInput); diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h index a8d1a96f..f146f343 100644 --- a/Code/Game/DanBiasGame/Include/DanBiasGame.h +++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h @@ -1,7 +1,7 @@ #ifndef DANBIASGAME_DANBIASGAME_H #define DANBIASGAME_DANBIASGAME_H -#define DANBIAS_CLIENT_L +#define DANBIAS_CLIENT #if defined (DANBIAS_GAME_DLL_EXPORT) #define DANBIAS_GAME_DLL __declspec(dllexport) @@ -29,6 +29,7 @@ namespace DanBias { //Stuff goes here... int port; + const char* IP; HINSTANCE hinst; int nCmdShow; diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 8fd73cec..8ae0f29c 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -22,7 +22,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh DanBias::DanBiasServerAPI::Run(); DanBias::DanBiasServerAPI::Release(); } -#elif defined(DANBIAS_CLIENT_L) +#elif defined(DANBIAS_CLIENT) if(SetDllDirectory(L"..\\DLL") == FALSE) { return cmdShow; @@ -30,6 +30,7 @@ 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.hinst = hinst; gameDesc.nCmdShow = cmdShow; diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp index e7edddd4..97033790 100644 --- a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp @@ -18,25 +18,26 @@ namespace DanBias void MainLobby::Frame() { - if(!this->box.IsEmpty()) - { - NetEvent &e = this->box.Fetch(); - ParseEvent(e); - } + ParseEvents(); } //////// Private - void MainLobby::ParseEvent(NetEvent& e) + void MainLobby::ParseEvents() { - static const short i = MAXSHORT; - if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return; - - short f = e.protocol[0].value.netShort; - - switch (f) + if(!this->box.IsEmpty()) { - default: - break; + NetEvent &e = this->box.Fetch(); + + if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return; + + short f = e.protocol[0].value.netShort; + + switch (f) + { + default: + + break; + } } } diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h index 8e8b520a..c78f70e2 100644 --- a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h @@ -15,7 +15,7 @@ namespace DanBias void Frame(); private: - void ParseEvent(NetEvent& e); + void ParseEvents(); }; }//End namespace DanBias diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index d620af81..f0464ffc 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -25,7 +25,7 @@ namespace GameLogic Protocol_PlayerMovement() { - this->protocol[0].value = ProtocolID = protocol_PlayerNavigation; + this->protocol[0].value = ProtocolID = protocol_Gamplay_PlayerNavigation; this->protocol[0].type = Oyster::Network::NetAttributeType_Int; this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; @@ -58,7 +58,7 @@ namespace GameLogic Protocol_PlayerPosition() { - this->protocol[0].value = protocol_PlayerPosition; + this->protocol[0].value = protocol_Gamplay_PlayerPosition; this->protocol[0].type = Oyster::Network::NetAttributeType_Int; this->protocol[1].type = Oyster::Network::NetAttributeType_Float; diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index 09f1aeed..cb90fa7f 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -7,15 +7,15 @@ /* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */ -#define protocol_PlayerNavigation 0 -#define protocol_PlayerPosition 1 -#define protocol_ObjectPosition 2 +#define protocol_Gamplay_PlayerNavigation 0 +#define protocol_Gamplay_PlayerPosition 1 +#define protocol_Gamplay_ObjectPosition 2 -#define protocol_Lobby_Msg 60 +#define protocol_Lobby_Msg 100 -#define protocol_General_Disconnect 100 -#define protocol_General_Ping 101 +#define protocol_General_Disconnect 200 +#define protocol_General_Ping 201 -#define PROTOCOL_TEST 1000 +#define PROTOCOL_TEST 1000 #endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H diff --git a/Code/Misc/PostBox/PostBox.h b/Code/Misc/PostBox/PostBox.h index c01eeead..1e8dfb74 100644 --- a/Code/Misc/PostBox/PostBox.h +++ b/Code/Misc/PostBox/PostBox.h @@ -54,7 +54,7 @@ namespace Oyster template bool PostBox::IsEmpty() { - return !messages.IsEmpty(); + return messages.IsEmpty(); } } diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index aed1046f..e99ab502 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -49,6 +49,7 @@ struct ClientDataContainer callbackType = NetworkProtocolCallbackType_Unknown; sendPostBox = new PostBox(); connection.SetBlockingMode(false); + connection.InitiateClient(); } ClientDataContainer(IThreadObject* o, unsigned int socket ) :connection(socket), ID(currID++) @@ -56,6 +57,7 @@ struct ClientDataContainer InitWinSock(); callbackType = NetworkProtocolCallbackType_Unknown; sendPostBox = new PostBox(); + connection.InitiateClient(); connection.SetBlockingMode(false); } ~ClientDataContainer() diff --git a/Code/Network/NetworkDependencies/Connection.cpp b/Code/Network/NetworkDependencies/Connection.cpp index 567cd894..84a0cbcc 100644 --- a/Code/Network/NetworkDependencies/Connection.cpp +++ b/Code/Network/NetworkDependencies/Connection.cpp @@ -177,6 +177,7 @@ int Connection::SetBlockingMode(bool blocking) return WSAGetLastError(); } + //Success return 0; } diff --git a/Code/Network/NetworkDependencies/ThreadedClient.cpp b/Code/Network/NetworkDependencies/ThreadedClient.cpp index 204b26c3..fc652f7f 100644 --- a/Code/Network/NetworkDependencies/ThreadedClient.cpp +++ b/Code/Network/NetworkDependencies/ThreadedClient.cpp @@ -84,7 +84,7 @@ int ThreadedClient::Recv() { int errorCode = -1; - SmartPointer temp = new OysterByte; + OysterByte temp; errorCode = this->connection->Recieve(temp); if(errorCode == 0) diff --git a/Code/Network/OysterNetworkClient/ClientMain.cpp b/Code/Network/OysterNetworkClient/ClientMain.cpp index 2274fb5e..31e499cc 100644 --- a/Code/Network/OysterNetworkClient/ClientMain.cpp +++ b/Code/Network/OysterNetworkClient/ClientMain.cpp @@ -18,9 +18,6 @@ using namespace Oyster::Network; using namespace Utility; using namespace Utility::DynamicMemory; -void chat(ThreadedClient &client); -void PrintOutMessage(ProtocolSet* set); - void proc(CustomNetProtocol& protocol) { @@ -44,11 +41,14 @@ int main() errorCode = client.Connect(15151, "127.0.0.1"); client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function); - if(errorCode != 0) + if(errorCode != 1) { - wstring errorTest = GetErrorMessage(errorCode); - wcout << "errorMessage: " << errorTest << endl; + printf("%d", errorCode); + cout << "FAILED" << endl; } + //client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function); + + cout << "Done" << endl; while(1) { diff --git a/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj b/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj index f4a69e17..bc491966 100644 --- a/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj +++ b/Code/Network/OysterNetworkClient/OysterNetworkClient.vcxproj @@ -70,28 +70,28 @@ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath);C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) - $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\NetworkAPI;$(SolutionDir)..\Bin\DLL;C:\Program Files (x86)\Visual Leak Detector\lib\Win32 + $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\NetworkAPI;$(SolutionDir)..\Bin\DLL;C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(OutDir)..\DLL\ $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath);$(OutDir)..\DLL\ $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath);$(OutDir)..\DLL\ $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath);$(OutDir)..\DLL\ @@ -116,6 +116,7 @@ true + NetworkAPI_$(PlatformShortName)D.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) @@ -131,6 +132,7 @@ true true true + NetworkAPI_$(PlatformShortName)D.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) @@ -146,6 +148,7 @@ true true true + NetworkAPI_$(PlatformShortName)D.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) diff --git a/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj b/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj index 335b889c..089427f7 100644 --- a/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj +++ b/Code/Network/OysterNetworkServer/OysterNetworkServer.vcxproj @@ -66,32 +66,32 @@ - $(SolutionDir)..\External\Lib\$(ProjectName)\ + $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath);$(OutDir)..\DLL\ - $(SolutionDir)..\External\Lib\$(ProjectName)\ + $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath);$(OutDir)..\DLL\ - $(SolutionDir)..\External\Lib\$(ProjectName)\ + $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath);$(OutDir)..\DLL\ - $(SolutionDir)..\External\Lib\$(ProjectName)\ + $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath);$(OutDir)..\DLL\ @@ -104,6 +104,7 @@ true + NetworkAPI_$(PlatformShortName)D.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) diff --git a/Code/Network/OysterNetworkServer/ServerMain.cpp b/Code/Network/OysterNetworkServer/ServerMain.cpp index 52624ca6..7f78bc78 100644 --- a/Code/Network/OysterNetworkServer/ServerMain.cpp +++ b/Code/Network/OysterNetworkServer/ServerMain.cpp @@ -2,16 +2,44 @@ #include #include #include "../NetworkDependencies/WinsockFunctions.h" +#include "../NetworkAPI/NetworkServer.h" +using namespace Oyster::Network; using namespace std; +void proc(NetworkClient client) +{ + cout << "Hej" << endl; +} + int main() { - if(!InitWinSock()) + NetworkServer server; + Oyster::Network::NetworkServer::INIT_DESC desc; + desc.port = 15151; + desc.callbackType = NetworkClientCallbackType_Function; + desc.recvObj = proc; + + if(!server.Init(desc)) { - cout << "errorMessage: unable to start winsock" << endl; + cout << "Init failed" << endl; + return 0; } + if(!server.Start()) + { + cout << "Start failed" << endl; + return 0; + } + + cout << "Server started" << endl; + + while(1) + { + + } + + system("pause"); return 0;