From e68001da0e71b3805e7b92ffee061355ed9a7028 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Thu, 19 Dec 2013 11:46:11 +0100 Subject: [PATCH] testing updated message to client about object creation, message to client about player movement --- .../ServerObjects/GameSession.cpp | 40 +++++++++++++++++-- Code/Game/GameProtocols/ObjectProtocols.h | 2 +- Code/GamePhysics/PhysicsAPI.h | 4 +- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp b/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp index e8896878..8a5f54e5 100644 --- a/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp @@ -143,9 +143,25 @@ using namespace GameLogic; void GameSession::EricLogicInitFunc() { - //CollisionManager::BoxCollision(0,0); + 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); + } - //objectBox = new DynamicObject(CollisionManager::BoxCollision, OBJECT_TYPE::OBJECT_TYPE_BOX); } void GameSession::EricLogicFrameFunc() { @@ -153,13 +169,31 @@ using namespace GameLogic; } void GameSession::EricsLogicTestingProtocalRecieved(ClientObject* reciever, CustomNetProtocol& protocol) { - + bool moved = false; switch (protocol[protocol_ID_INDEX].value.netShort) { case protocol_Gameplay_PlayerNavigation: ConvertToMovement(reciever, protocol); + moved = true; break; } + + if (moved) + { + + Protocol_ObjectPosition playerMovement; + + Oyster::Math::Float4x4 worldMat = reciever->Logic_Object()->GetRigidBody()->GetOrientation(); + playerMovement.object_ID = reciever->Logic_Object()->GetID(); + for (int i = 0; i < 16; i++) + { + playerMovement.worldMatrix[i] = worldMat[i]; + } + + reciever->NetClient_Object()->Send(playerMovement); + } + + } diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index 9cac85be..7ba023b1 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -11,7 +11,7 @@ namespace GameLogic struct Protocol_CreateObject :public Oyster::Network::CustomProtocolObject { int object_ID; - char path[255]; + char *path; float worldMatrix[16]; diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index 84a3d639..04d0d3f1 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -232,10 +232,12 @@ namespace Oyster protected: virtual ~API() {} }; - + + //! The root interface for all physical representations processable by the engine. class PHYSICS_DLL_USAGE ICustomBody { + public: enum SubscriptMessage {