Danbias/Code/Game/GameProtocols/ObjectProtocols.h

158 lines
5.7 KiB
C
Raw Normal View History

2013-12-19 10:22:32 +01:00
#ifndef GAMELOGIC_OBJECT_PROTOCOLS_H
#define GAMELOGIC_OBJECT_PROTOCOLS_H
#include <CustomNetProtocol.h>
#include "ProtocolIdentificationID.h"
namespace GameLogic
{
2013-12-18 12:18:01 +01:00
struct Protocol_CreateObject :public Oyster::Network::CustomProtocolObject
{
int object_ID;
char *path;
2013-12-18 12:18:01 +01:00
float worldMatrix[16];
Protocol_CreateObject()
{
2013-12-18 15:28:47 +01:00
this->protocol[0].value = protocol_Gameplay_CreateObject;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
2013-12-18 12:18:01 +01:00
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
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;
this->protocol[18].type = Oyster::Network::NetAttributeType_Float;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = path;
this->protocol[3].value = worldMatrix[1];
this->protocol[4].value = worldMatrix[2];
this->protocol[5].value = worldMatrix[3];
this->protocol[6].value = worldMatrix[4];
this->protocol[7].value = worldMatrix[5];
this->protocol[8].value = worldMatrix[6];
this->protocol[9].value = worldMatrix[7];
this->protocol[10].value = worldMatrix[8];
this->protocol[11].value = worldMatrix[9];
this->protocol[12].value = worldMatrix[10];
this->protocol[13].value = worldMatrix[11];
this->protocol[14].value = worldMatrix[12];
this->protocol[15].value = worldMatrix[13];
this->protocol[16].value = worldMatrix[14];
this->protocol[17].value = worldMatrix[15];
this->protocol[18].value = worldMatrix[16];
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
2013-12-13 12:02:49 +01:00
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
{
2013-12-17 10:07:46 +01:00
int object_ID;
float worldMatrix[16];
// look at dir
Protocol_ObjectPosition()
{
2013-12-18 15:28:47 +01:00
this->protocol[0].value = protocol_Gameplay_ObjectPosition;
2013-12-13 12:02:49 +01:00
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
2013-12-17 10:07:46 +01:00
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
2013-12-13 12:02:49 +01:00
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
this->protocol[15].type = Oyster::Network::NetAttributeType_Float;
this->protocol[16].type = Oyster::Network::NetAttributeType_Float;
2013-12-17 10:07:46 +01:00
this->protocol[17].type = Oyster::Network::NetAttributeType_Float;
}
2013-12-19 15:35:49 +01:00
Protocol_ObjectPosition(float m[16])
{
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
}
2013-12-13 12:02:49 +01:00
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
2013-12-17 10:07:46 +01:00
this->protocol[1].value = object_ID;
this->protocol[2].value = worldMatrix[1];
2013-12-17 10:07:46 +01:00
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;
2013-12-19 15:35:49 +01:00
}
private:
2013-12-13 12:02:49 +01:00
Oyster::Network::CustomNetProtocol protocol;
};
2013-12-18 15:28:47 +01:00
struct Protocol_RemoveObject :public Oyster::Network::CustomProtocolObject
{
int object_ID;
Protocol_RemoveObject()
{
this->protocol[0].value = protocol_Gameplay_RemoveObject;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = object_ID;
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H