From cec27408966d688d822a1ea906ba011d8f26ccd1 Mon Sep 17 00:00:00 2001 From: dean11 Date: Tue, 18 Feb 2014 11:56:36 +0100 Subject: [PATCH] GameServer - Fixed minor miss with inheritance --- Code/Game/GameServer/GameSession.h | 2 ++ .../Implementation/GameSession_Gameplay.cpp | 27 +++++++++++++++++++ .../Implementation/GameSession_General.cpp | 9 ++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Code/Game/GameServer/GameSession.h b/Code/Game/GameServer/GameSession.h index 200bed9b..e6c8a4f9 100644 --- a/Code/Game/GameServer/GameSession.h +++ b/Code/Game/GameServer/GameSession.h @@ -65,6 +65,8 @@ namespace DanBias // Client event callback function void ClientEventCallback(Oyster::Network::NetEvent e) override; void ProcessClients() override; + bool Send(Oyster::Network::CustomNetProtocol& message) override; + bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID) override; //Sends a client to the owner, if param is NULL then all clients is sent void SendToOwner(DanBias::GameClient* obj); diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index c3319eb3..61ccf9c8 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -84,6 +84,33 @@ using namespace DanBias; } } } + bool GameSession::Send(Oyster::Network::CustomNetProtocol& message) + { + bool returnValue = false; + for (unsigned int i = 0; i < this->gClients.Size(); i++) + { + if(this->gClients[i]) + { + this->gClients[i]->GetClient()->Send(message); + returnValue = true; + } + } + + return returnValue; + + } + bool GameSession::Send(Oyster::Network::CustomNetProtocol& protocol, int ID) + { + for (unsigned int i = 0; i < this->gClients.Size(); i++) + { + if(this->gClients[i] && this->gClients[i]->GetClient()->GetID() == ID) + { + this->gClients[i]->GetClient()->Send(protocol); + return true; + } + } + return false; + } void GameSession::ObjectMove(GameLogic::IObjectData* movedObject) diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp index d0ad30f4..43f088dd 100644 --- a/Code/Game/GameServer/Implementation/GameSession_General.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp @@ -233,7 +233,14 @@ bool GameSession::Join(gClient gameClient) //TODO: Need to be able to get the current gameplay data from the logic, to sync it with the client { - + DynamicArray objects; + this->levelData->GetAllDynamicObjects(objects); + for (unsigned int i = 0; i < objects.Size(); i++) + { + //Protocol_ObjectPosition p(movedObject->GetPosition(), id); + Protocol_ObjectPositionRotation p(objects[i]->GetPosition(), objects[i]->GetRotation(), objects[i]->GetID()); + GameSession::gameSession->Send(p.GetProtocol()); + } } // Insert the new client to the update list