From ba6f7114b516d59f0e41021bb805f5407fae59fd Mon Sep 17 00:00:00 2001 From: Linda Andersson Date: Thu, 19 Dec 2013 11:58:42 +0100 Subject: [PATCH 1/4] GL - added id in object, vector --- .../DanBiasGame/GameClientState/C_Object.h | 2 + .../GameClientState/C_obj/C_DynamicObj.cpp | 5 ++ .../GameClientState/C_obj/C_DynamicObj.h | 1 + .../GameClientState/C_obj/C_Player.cpp | 5 ++ .../GameClientState/C_obj/C_Player.h | 1 + .../GameClientState/C_obj/C_StaticObj.cpp | 5 ++ .../GameClientState/C_obj/C_StaticObj.h | 1 + .../GameClientState/C_obj/C_UIobject.cpp | 7 ++- .../GameClientState/C_obj/C_UIobject.h | 1 + .../DanBiasGame/GameClientState/GameState.cpp | 62 ++++++++----------- .../DanBiasGame/GameClientState/GameState.h | 3 - Code/Game/DanBiasLauncher/Launcher.cpp | 7 ++- 12 files changed, 56 insertions(+), 44 deletions(-) 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 1ee9ac8b..5a98758b 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -15,7 +15,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 +59,17 @@ bool GameState::LoadModels(std::wstring mapFile) modelData.visible = true; modelData.modelPath = L"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"crate"; - 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 +176,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 +211,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 +230,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/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 6b82da2a..76597e77 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -5,8 +5,8 @@ #include #include -#include "DanBiasServerAPI.h" -//#include "DanBiasGame.h" +//#include "DanBiasServerAPI.h" +#include "DanBiasGame.h" int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow) @@ -29,7 +29,8 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh // Game client starter code goes here DanBias::DanBiasGameDesc gameDesc; gameDesc.port = 15151; - gameDesc.IP = "193.11.184.196"; + //gameDesc.IP = "193.11.184.196"; //Erik + gameDesc.IP = "193.11.186.101"; gameDesc.hinst = hinst; gameDesc.nCmdShow = cmdShow; From ecf1c5fc368441b0f79a73c8d06093a3528c5087 Mon Sep 17 00:00:00 2001 From: Linda Andersson Date: Thu, 19 Dec 2013 14:32:52 +0100 Subject: [PATCH 2/4] GL - delete timer --- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 2c8aba55..453cb29d 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -277,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; From f4232ca0b406da930c09b640e845adc4e802215b Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 20 Dec 2013 08:59:46 +0100 Subject: [PATCH 3/4] gamplay code in gamesession --- Code/Game/DanBiasServer/DanBiasServer.vcxproj | 12 +-- .../ServerObjects/GameSession.cpp | 91 ++++++++++++++++++- Code/Game/GameLogic/DynamicObject.h | 3 +- 3 files changed, 95 insertions(+), 11 deletions(-) diff --git a/Code/Game/DanBiasServer/DanBiasServer.vcxproj b/Code/Game/DanBiasServer/DanBiasServer.vcxproj index 3e315b49..7c505fcf 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 a8a8bd19..58f04c31 100644 --- a/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp @@ -95,6 +95,7 @@ namespace DanBias return true; } +#ifndef ERIK ////private: bool GameSession::Init(GameSessionDescription& desc) { @@ -107,6 +108,7 @@ namespace DanBias this->clients.Push(desc.clients[i]); } + return true; } void GameSession::Frame() @@ -156,9 +158,94 @@ namespace DanBias } } -#ifdef ERIK +#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 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 { From 606cb10f8b1051373058dc8a22b997df2622b4eb Mon Sep 17 00:00:00 2001 From: Linda Andersson Date: Fri, 20 Dec 2013 09:04:18 +0100 Subject: [PATCH 4/4] GL - removed server include from gameLancher --- .../Game/DanBiasLauncher/DanBiasLauncher.vcxproj | 16 ++++++++-------- Code/Game/DanBiasLauncher/Launcher.cpp | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) 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 f738bc80..84995e47 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -17,8 +17,9 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh // Game client starter code goes here DanBias::DanBiasGameDesc gameDesc; gameDesc.port = 15151; - gameDesc.IP = "193.11.184.196"; - gameDesc.IP = "127.0.0.1"; + //gameDesc.IP = "193.11.184.196"; + gameDesc.IP = "193.11.186.101"; + //gameDesc.IP = "127.0.0.1"; gameDesc.hinst = hinst; gameDesc.nCmdShow = cmdShow;