Danbias/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp

182 lines
3.2 KiB
C++
Raw Normal View History

2013-12-12 09:33:59 +01:00
#include <GameProtocols.h>
#include "GameSession.h"
#include <PostBox\PostBox.h>
#include "ClientObject.h"
2013-12-12 09:33:59 +01:00
2013-12-19 10:21:03 +01:00
#include "DynamicObject.h"
#include "CollisionManager.h"
#include "GameLogicStates.h"
2013-12-12 09:33:59 +01:00
#define ERIK
using namespace Utility::DynamicMemory;
using namespace Oyster::Network;
using namespace Oyster;
2013-12-12 09:33:59 +01:00
namespace DanBias
{
GameSession::GameSession()
{
}
GameSession::~GameSession()
{
}
void GameSession::Run(const GameSessionDescription& desc)
{
}
void GameSession::AttachClient(SmartPointer<ClientObject> client, Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box )
{
this->Init();
}
////private: //overriden NetworkSession functions
void GameSession::Close()
{
}
SmartPointer<ClientObject> GameSession::DetachClient(NetworkClient* client)
{
return SmartPointer<ClientObject>();
}
SmartPointer<ClientObject> GameSession::DetachClient(ClientObject* client)
{
return SmartPointer<ClientObject>();
}
SmartPointer<ClientObject> GameSession::DetachClient(short ID)
{
return SmartPointer<ClientObject>();
}
void GameSession::Send(::CustomNetProtocol& protocol)
{
}
void GameSession::Send(CustomNetProtocol& protocol, int ID)
{
}
void GameSession::SetPostbox(IPostBox<NetworkSession::NetEvent> *box)
{
}
void GameSession::CloseSession(NetworkSession* clientDestination)
{
}
////private: //overriden Threading functions
void GameSession::ThreadEntry()
{
}
void GameSession::ThreadExit()
{
}
bool GameSession::DoWork ( )
{
this->ParseEvents();
this->Frame();
return true;
}
2013-12-19 10:21:03 +01:00
////private:
void GameSession::Init()
{
#ifdef ERIK
EricLogicInitFunc();
#else
#endif
}
void GameSession::Frame()
{
#ifdef ERIK
EricLogicFrameFunc();
#else
#endif
}
void GameSession::ParseEvents()
{
if(this->box && !this->box->IsEmpty())
{
NetEvent &e = this->box->Fetch();
#ifdef ERIK
EricsLogicTestingProtocalRecieved(e.reciever, e.protocol);
#else
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
short f = e.protocol[0].value.netShort;
switch (f)
{
default:
break;
}
#endif
}
}
#pragma region TESTING
2013-12-19 10:22:32 +01:00
2013-12-19 10:21:03 +01:00
using namespace GameLogic;
void ConvertToMovement(ClientObject* reciever, CustomNetProtocol& inputToConvert);
2013-12-19 10:31:59 +01:00
//VARIABLES GOES HERE
int i = 0;
2013-12-19 10:21:03 +01:00
DynamicObject* objectBox;
void GameSession::EricLogicInitFunc()
{
2013-12-19 10:31:59 +01:00
//CollisionManager::BoxCollision(0,0);
2013-12-19 10:21:03 +01:00
2013-12-19 10:31:59 +01:00
//objectBox = new DynamicObject(CollisionManager::BoxCollision, OBJECT_TYPE::OBJECT_TYPE_BOX);
}
void GameSession::EricLogicFrameFunc()
{
}
void GameSession::EricsLogicTestingProtocalRecieved(ClientObject* reciever, CustomNetProtocol& protocol)
{
2013-12-19 10:31:59 +01:00
2013-12-19 10:21:03 +01:00
switch (protocol[protocol_ID_INDEX].value.netShort)
{
2013-12-19 10:31:59 +01:00
case protocol_Gameplay_PlayerNavigation:
2013-12-19 10:21:03 +01:00
ConvertToMovement(reciever, protocol);
break;
}
}
2013-12-19 10:21:03 +01:00
void ConvertToMovement(ClientObject* reciever,CustomNetProtocol& inputToConvert)
{
if (inputToConvert[1].value.netBool == true)
{
reciever->Logic_Object()->Move(PLAYER_MOVEMENT::PLAYER_MOVEMENT_FORWARD);
}
if (inputToConvert[2].value.netBool == true)
{
reciever->Logic_Object()->Move(PLAYER_MOVEMENT::PLAYER_MOVEMENT_BACKWARD);
}
2013-12-19 10:31:59 +01:00
}
#pragma endregion
2013-12-12 09:33:59 +01:00
}//End namespace DanBias
2013-12-12 09:33:59 +01:00