GL - trying to send move protocol

This commit is contained in:
Linda Andersson 2013-12-17 10:07:46 +01:00
parent 3ee25f0112
commit 5d1d64bebb
7 changed files with 44 additions and 36 deletions

View File

@ -52,9 +52,10 @@ namespace DanBias
case protocol_Gamplay_ObjectPosition:
protocolData = new Client::GameClientState::ObjPos;
((Client::GameClientState::ObjPos*)protocolData)->object_ID = p[1].value.netInt;
for(int i = 0; i< 16; i++)
{
((Client::GameClientState::ObjPos*)protocolData)->worldPos[i] = p[i].value.netFloat;
((Client::GameClientState::ObjPos*)protocolData)->worldPos[i] = p[i+2].value.netFloat;
}
if(dynamic_cast<Client::GameState*>(gameClientState))

View File

@ -19,6 +19,7 @@ public:
};
struct ObjPos :public ProtocolStruct
{
int object_ID;
float worldPos[16];
};
struct PlayerPos :public ProtocolStruct

View File

@ -91,7 +91,6 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
case gameStateState_playing:
// read server data
// update objects
// Client.send(obj);
{
GameLogic::Protocol_PlayerMovement movePlayer;
movePlayer.bForward = false;
@ -117,12 +116,15 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
if(KeyInput->IsKeyPressed(DIK_D))
{
movePlayer.bStrafeRight = true;
}
if (privData->nwClient->IsConnected())
{
privData->nwClient->Send(movePlayer);
}
//PlayerPos* posPlayer;
//Protocol(posPlayer);
privData->nwClient->Send(movePlayer);
// send event data
//
if(KeyInput->IsKeyPressed(DIK_L))
privData->state = GameState::gameStateState_end;
}
@ -177,8 +179,8 @@ void DanBias::Client::GameState::Protocol( PlayerPos* pos )
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;
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(pos->playerPos[0],pos->playerPos[1],pos->playerPos[2]));
world = world * translate;
privData->object[0]->setPos( world );
}
@ -189,7 +191,7 @@ void DanBias::Client::GameState::Protocol( ObjPos* pos )
{
world[i] = pos->worldPos[i];
}
privData->object[1]->setPos(world);
privData->object[pos->object_ID]->setPos(world);
}
void GameState::PlayerPosProtocol(PlayerPos* pos)

View File

@ -5,7 +5,6 @@
#include <Windows.h>
#include <vld.h>
//#include "DanBiasServerAPI.h"
#include "DanBiasGame.h"

View File

@ -10,15 +10,17 @@ namespace GameLogic
{
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
{
int object_ID;
float worldMatrix[16];
// look at dir
Protocol_ObjectPosition()
{
this->protocol[0].value = protocol_PlayerPosition;
this->protocol[0].value = protocol_Gamplay_ObjectPosition;
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
@ -34,27 +36,29 @@ namespace GameLogic
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
this->protocol[15].type = Oyster::Network::NetAttributeType_Float;
this->protocol[16].type = Oyster::Network::NetAttributeType_Float;
this->protocol[17].type = Oyster::Network::NetAttributeType_Float;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = worldMatrix[0];
this->protocol[1].value = object_ID;
this->protocol[2].value = worldMatrix[1];
this->protocol[3].value = worldMatrix[2]; //Forgot?
this->protocol[4].value = worldMatrix[4]; //Forgot?
this->protocol[5].value = worldMatrix[5];
this->protocol[6].value = worldMatrix[6];
this->protocol[7].value = worldMatrix[7];
this->protocol[8].value = worldMatrix[8];
this->protocol[9].value = worldMatrix[9];
this->protocol[10].value = worldMatrix[10];
this->protocol[11].value = worldMatrix[11];
this->protocol[12].value = worldMatrix[12];
this->protocol[13].value = worldMatrix[13];
this->protocol[14].value = worldMatrix[14];
this->protocol[15].value = worldMatrix[15];
this->protocol[16].value = worldMatrix[16];
this->protocol[3].value = worldMatrix[2];
this->protocol[4].value = worldMatrix[3];
this->protocol[5].value = worldMatrix[4];
this->protocol[6].value = worldMatrix[5];
this->protocol[7].value = worldMatrix[6];
this->protocol[8].value = worldMatrix[7];
this->protocol[9].value = worldMatrix[8];
this->protocol[10].value = worldMatrix[9];
this->protocol[11].value = worldMatrix[10];
this->protocol[12].value = worldMatrix[11];
this->protocol[13].value = worldMatrix[12];
this->protocol[14].value = worldMatrix[13];
this->protocol[15].value = worldMatrix[14];
this->protocol[16].value = worldMatrix[15];
this->protocol[17].value = worldMatrix[16];
return &protocol;
}

View File

@ -15,7 +15,7 @@ namespace GameLogic
{
struct Protocol_PlayerMovement :public Oyster::Network::CustomProtocolObject
{
int ProtocolID;
bool bForward;
bool bBackward;
bool bTurnLeft;
@ -25,9 +25,9 @@ namespace GameLogic
Protocol_PlayerMovement()
{
this->protocol[0].value = ProtocolID = protocol_Gamplay_PlayerNavigation;
this->protocol[0].value = protocol_Gamplay_PlayerNavigation;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
@ -53,13 +53,14 @@ namespace GameLogic
struct Protocol_PlayerPosition :public Oyster::Network::CustomProtocolObject
{
float position[3];
// look at dir
Protocol_PlayerPosition()
{
this->protocol[0].value = protocol_Gamplay_PlayerPosition;
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;

View File

@ -10,15 +10,15 @@ using namespace Oyster::Network;
Connection::Connection()
{
this->socket = -1;
bool stillSending = false;
bool closed = true;
this->stillSending = false;
this->closed = true;
}
Connection::Connection(int socket)
{
this->socket = socket;
bool stillSending = false;
bool closed = true;
this->stillSending = true;
this->closed = false;
}
Connection::~Connection()