diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 6bb56251..5dea4581 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -5,9 +5,7 @@ #include "GameClientState/GameClientState.h" #include "GameClientState\GameState.h" #include "GameClientState\LobbyState.h" -#include "PlayerProtocols.h" -#include "ControlProtocols.h" -#include "GameProtocols.h" +#include #include "NetworkClient.h" #include "../WindowManager/WindowShell.h" @@ -279,6 +277,7 @@ namespace DanBias delete m_data->recieverObj->gameClientState; m_data->recieverObj->nwClient->Disconnect(); delete m_data->recieverObj->nwClient; + delete m_data->timer; 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 18859930..1b87174b 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_Object.h +++ b/Code/Game/DanBiasGame/GameClientState/C_Object.h @@ -8,6 +8,7 @@ namespace DanBias struct ModelInitData { + int id; std::wstring modelPath; Oyster::Math::Float4x4 world; bool visible; @@ -24,5 +25,6 @@ public: virtual void Render() = 0; virtual void Release() = 0; + virtual int GetId() = 0; };};}; #endif diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp index a4ae4840..f47fc9fe 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp @@ -5,6 +5,7 @@ struct C_DynamicObj::myData { myData(){} Oyster::Graphics::Model::Model *model; + int ID; // light // sound // effect @@ -39,4 +40,8 @@ void C_DynamicObj::Release() { Oyster::Graphics::API::DeleteModel(privData->model); delete privData; +} +int C_DynamicObj::GetId() +{ + return privData->ID; } \ 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 index e0ad3be3..ee25a992 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h @@ -18,5 +18,6 @@ public: void Render(); void Release(); + int GetId(); };};}; #endif diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp index 5fb06d96..86acaf4b 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp @@ -8,6 +8,7 @@ struct C_Player::myData Oyster::Math3D::Float4x4 view; Oyster::Math3D::Float4x4 proj; Oyster::Graphics::Model::Model *model; + int ID; }privData; C_Player::C_Player(void) @@ -44,3 +45,7 @@ void C_Player::Release() Oyster::Graphics::API::DeleteModel(privData->model); delete privData; } +int C_Player::GetId() +{ + return privData->ID; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h index 638bd856..794bf51a 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h @@ -19,6 +19,7 @@ public: void Render(); void Release(); + int GetId(); };};}; #endif diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp index f96ea56d..c5f2e119 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp @@ -7,6 +7,7 @@ struct C_StaticObj::myData { myData(){} Oyster::Graphics::Model::Model *model; + int ID; // light // sound // effect @@ -42,4 +43,8 @@ void C_StaticObj::Release() { Oyster::Graphics::API::DeleteModel(privData->model); delete privData; +} +int C_StaticObj::GetId() +{ + return privData->ID; } \ 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 index 84fc0599..799c0982 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h @@ -18,5 +18,6 @@ public: void Render(); void Release(); + int GetId(); };};}; #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 index 5adc3962..226d8ca7 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp @@ -5,9 +5,8 @@ using namespace DanBias::Client; struct C_UIobject::myData { myData(){} - Oyster::Math3D::Float4x4 view; - Oyster::Math3D::Float4x4 proj; Oyster::Graphics::Model::Model *model; + int ID; }privData; C_UIobject::C_UIobject(void) @@ -40,4 +39,8 @@ void C_UIobject::Release() { Oyster::Graphics::API::DeleteModel(privData->model); delete privData; +} +int C_UIobject::GetId() +{ + return privData->ID; } \ 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 index e82b702f..b41fb047 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h @@ -18,5 +18,6 @@ namespace DanBias void Render(); void Release(); + int GetId(); };};}; #endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index cc129620..97004d50 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -2,9 +2,7 @@ #include "DllInterfaces/GFXAPI.h" #include "C_obj/C_Player.h" #include "C_obj/C_DynamicObj.h" -#include "PlayerProtocols.h" -#include "ControlProtocols.h" -#include "GameProtocols.h" +#include #include "NetworkClient.h" @@ -15,7 +13,7 @@ struct GameState::myData myData(){} Oyster::Math3D::Float4x4 view; Oyster::Math3D::Float4x4 proj; - C_Object* object[3]; + std::vector object; int modelCount; Oyster::Network::NetworkClient* nwClient; gameStateState state; @@ -59,15 +57,17 @@ bool GameState::LoadModels(std::wstring mapFile) modelData.visible = true; modelData.modelPath = L"..\\Content\\worldDummy"; // load models - privData->object[0] = new C_Player(); - privData->object[0]->Init(modelData); + C_Object* obj = new C_Player(); + privData->object.push_back(obj); + privData->object[privData->object.size() -1 ]->Init(modelData); Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2)); modelData.world = modelData.world * translate; modelData.modelPath = L"..\\Content\\worldDummy"; - privData->object[1] = new C_DynamicObj(); - privData->object[1]->Init(modelData); + obj = new C_DynamicObj(); + privData->object.push_back(obj); + privData->object[privData->object.size() -1 ]->Init(modelData); return true; } bool GameState::InitCamera(Oyster::Math::Float3 startPos) @@ -174,7 +174,7 @@ bool GameState::Render() } bool GameState::Release() { - for (int i = 0; i < privData->modelCount; i++) + for (int i = 0; i < privData->object.size(); i++) { privData->object[i]->Release(); delete privData->object[i]; @@ -209,7 +209,11 @@ void GameState::Protocol( ObjPos* pos ) { world[i] = pos->worldPos[i]; } - privData->object[pos->object_ID]->setPos(world); + for (int i = 0; i < privData->object.size(); i++) + { + if(privData->object[i]->GetId() == pos->object_ID) + privData->object[i]->setPos(world); + } } void GameState::Protocol( NewObj* pos ) @@ -224,45 +228,29 @@ void GameState::Protocol( NewObj* pos ) modelData.world = world; modelData.visible = true; + modelData.id = pos->object_ID; //not sure if this is good parsing rom char* to wstring const char* path = pos->path; modelData.modelPath = std::wstring(path, path + strlen(path)); // load models - privData->object[pos->object_ID] = new C_Player(); - privData->object[pos->object_ID]->Init(modelData); -} + C_Object* player = new C_Player(); + player->Init(modelData); + + privData->object.push_back(player); -void GameState::Protocol( KeyInput* pos ) -{ - bool key = false; - for (int i = 0; i < 6; i++) - { - key = pos->key[i]; - } } void DanBias::Client::GameState::Protocol( RemoveObj* obj ) { - privData->object[obj->object_ID]->Release( ); -} - -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++) + for (int i = 0; i < privData->object.size(); i++) { - world[i] = pos->worldPos[i]; + if(privData->object[i]->GetId() == obj->object_ID) + { + privData->object.at(i)->Release(); + privData->object.erase(privData->object.begin() + i ); + } } - privData->object[1]->setPos(world); + //privData->object[obj->object_ID]->Release( ); } + //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 bc0e8dba..4de73a39 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -34,11 +34,8 @@ public: void Protocol(ProtocolStruct* pos)override; void Protocol(PlayerPos* pos); void Protocol(ObjPos* pos); - void Protocol(KeyInput* pos); void Protocol( NewObj* pos ); void Protocol(RemoveObj* obj); - void PlayerPosProtocol(PlayerPos* pos); - void ObjectPosProtocol(ObjPos* pos); //void Protocol(LightPos pos); }; }; diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj index a7eed03c..fec9d7dd 100644 --- a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj +++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj @@ -110,8 +110,8 @@ Windows true - DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs) - DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies) + DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -126,8 +126,8 @@ Windows true - DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) - DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies) + DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -146,8 +146,8 @@ true true true - DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) - DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) + DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) + DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) @@ -166,8 +166,8 @@ true true true - DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) - DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) + DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) + DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 13c67323..84995e47 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -18,7 +18,8 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh DanBias::DanBiasGameDesc gameDesc; gameDesc.port = 15151; //gameDesc.IP = "193.11.184.196"; - gameDesc.IP = "127.0.0.1"; + gameDesc.IP = "193.11.186.101"; + //gameDesc.IP = "127.0.0.1"; gameDesc.hinst = hinst; gameDesc.nCmdShow = cmdShow; diff --git a/Code/Game/DanBiasServer/DanBiasServer.vcxproj b/Code/Game/DanBiasServer/DanBiasServer.vcxproj index ba66aea0..3af47da2 100644 --- a/Code/Game/DanBiasServer/DanBiasServer.vcxproj +++ b/Code/Game/DanBiasServer/DanBiasServer.vcxproj @@ -107,8 +107,7 @@ Level3 Disabled DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - - + $(SolutionDir)Game\GameLogic\ Windows @@ -124,8 +123,7 @@ Level3 Disabled DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - - + $(SolutionDir)Game\GameLogic\ Windows @@ -143,8 +141,7 @@ true true DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - - + $(SolutionDir)Game\GameLogic\ Windows @@ -164,8 +161,7 @@ true true DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - - + $(SolutionDir)Game\GameLogic\ Windows diff --git a/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp b/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp index 9e270ebf..e6f43842 100644 --- a/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp @@ -93,6 +93,7 @@ namespace DanBias return true; } +#ifndef ERIK ////private: bool GameSession::Init(GameSessionDescription& desc) { @@ -106,6 +107,7 @@ namespace DanBias this->clients.Push(desc.clients[i]); } + return true; } void GameSession::Frame() @@ -166,5 +168,96 @@ namespace DanBias } } +#else +#include "DynamicObject.h" +//#include "CollisionManager.h" +//#include "GameLogicStates.h" +//#include + + /* + using namespace GameLogic; + //VARIABLES GOES HERE + DynamicObject* objectBox; + + bool GameSession::Init(GameSessionDescription& desc) + { + if(desc.clients.Size() == 0) return false; + this->box = new PostBox(); + this->owner = desc.owner; + for (unsigned int i = 0; i < desc.clients.Size(); i++) + { + desc.clients[i]->SetPostbox(this->box); + this->clients.Push(desc.clients[i]); + } + + CollisionManager::BoxCollision(0,0); + + objectBox = new DynamicObject(CollisionManager::BoxCollision, OBJECT_TYPE::OBJECT_TYPE_BOX); + + Protocol_CreateObject objectCreation; + objectCreation.object_ID = objectBox->GetID(); + objectCreation.path = "crate"; + Oyster::Math::Float4x4 worldMat = objectBox->GetRigidBody()->GetOrientation(); + + for (int i = 0; i < 16; i++) + { + objectCreation.worldMatrix[i] = worldMat[i]; + } + + for (int i = 0; i < clients.Size(); i++) + { + clients[i]->NetClient_Object()->Send(objectCreation); + } + + return true; + } + void GameSession::Frame() + { + } + void GameSession::ParseEvents() + { + if(this->box && !this->box->IsEmpty()) + { + NetEvent &e = this->box->Fetch(); + + if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return; + + ParseProtocol(e.protocol, *e.reciever); + } + } + void GameSession::ParseProtocol(Oyster::Network::CustomNetProtocol& p, DanBias::ClientObject& c) + { + switch (p[0].value.netShort) + { + case protocol_Gamplay_PlayerNavigation: + { + if(p[1].value.netBool) //bool bForward; + c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD); + if(p[2].value.netBool) //bool bBackward; + c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD); + if(p[5].value.netBool) //bool bStrafeRight; + c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT); + if(p[6].value.netBool) //bool bStrafeLeft; + c.Logic_Object()->Move(GameLogic::PLAYER_MOVEMENT_LEFT); + } + break; + case protocol_Gamplay_PlayerMouseMovement: + + break; + case protocol_Gamplay_PlayerPosition: + + break; + case protocol_Gamplay_CreateObject: + + break; + case protocol_Gamplay_ObjectPosition: + + break; + } + } + */ + +#endif + }//End namespace DanBias diff --git a/Code/Game/GameLogic/DynamicObject.h b/Code/Game/GameLogic/DynamicObject.h index b8709a52..6a2263c9 100644 --- a/Code/Game/GameLogic/DynamicObject.h +++ b/Code/Game/GameLogic/DynamicObject.h @@ -3,8 +3,9 @@ ////////////////////////////////////////////////// #ifndef DYNAMICOBJECT_H #define DYNAMICOBJECT_H -#include "Object.h" #include "GameLogicDef.h" +#include "Object.h" + namespace GameLogic {