00001
00002
00003
00004
00005
00006
00007
00008 #ifndef STATE_H_
00009 #define STATE_H_
00010
00011
00012 namespace FastEcslent {
00013
00014 const int MaxMessageSize = 65536;
00015
00016 struct __attribute__((__packed__)) PackedHeader{
00017 unsigned char msgType;
00018 int millisecondsFromStart;
00019 int numberOfStructs;
00020 int sizeOfStruct;
00021 };
00022
00023 typedef struct PackedHeader Header;
00024
00025 enum MessageTypes {
00026 INFOMESSAGETYPE = 0,
00027 STATEMESSAGETYPE = 1,
00028 REQUESTINFOMESSAGETYPE = 2,
00029 REQUESTSHIPSTATUSMESSAGETYPE = 3,
00030 COMMANDENTITYMESSAGETYPE = 4,
00031 CREATEENTITYMESSAGETYPE = 5,
00032 REPOSITIONENTITYMESSAGETYPE = 6,
00033 SQUELCHMESSAGETYPE = 7,
00034 NUMBEROFMESSAGETYPES = 8
00035 };
00036
00037 struct __attribute__((__packed__)) PackedState{
00038 int id;
00039 float px, py, pz;
00040 float vx, vy, vz;
00041 float yaw;
00042 float rSpeed;
00043 float ds;
00044 float dh;
00045 unsigned short flags;
00046 };
00047
00048 typedef struct PackedState State;
00049
00050 struct __attribute__((__packed__)) PackedInfo {
00051 int id;
00052 char label[256];
00053 char type[256];
00054 float maxSpeed;
00055 float maxSpeedReverse;
00056 float length;
00057 float beam;
00058 float draft;
00059 int playerId;
00060 int side;
00061
00062 };
00063
00064 typedef struct PackedInfo Info;
00065
00066 struct __attribute__((__packed__)) PackedCommandEntity {
00067 int id;
00068 float dh;
00069 float ds;
00070 } ;
00071
00072 typedef struct PackedCommandEntity CommandEntity;
00073
00074 struct __attribute__((__packed__)) PackedCreateEntity{
00075 char label[256];
00076 char entType[256];
00077 float px, py, pz;
00078 float yaw;
00079 } ;
00080
00081 typedef struct PackedCreateEntity CreateEntity;
00082
00083 struct __attribute__((__packed__)) PackedRepositionEntity {
00084 int id;
00085 float px, py, pz;
00086 float vx, vy, vz;
00087 float yaw;
00088 char label[256];
00089 };
00090
00091 typedef struct PackedRepositionEntity RepositionEntity;
00092
00093 struct __attribute__((__packed__)) PackedMessage {
00094 Header head;
00095 char data[MaxMessageSize - sizeof(Header)];
00096 };
00097
00098 typedef struct PackedMessage Message;
00099
00100 const int MessageSize = sizeof(Message);
00101 const int HeaderSize = sizeof(Header);
00102 const int StateSize = sizeof(State);
00103 const int InfoSize = sizeof(Info);
00104 const int CommandEntitySize = sizeof(CommandEntity);
00105 const int CreateEntitySize = sizeof(CreateEntity);
00106 const int RepositionEntitySize = sizeof(RepositionEntity);
00107
00108 void printMessageHeader(Header h);
00109 void printMessageData(Message *m);
00110 void printMessage(Message *m);
00111 void printState(State *s);
00112
00113
00114 }
00115
00116 #endif