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 CREATEENTITYREQUESTMESSAGETYPE = 20,
00037 CREATEENTITYRESPONSEMESSAGETYPE = 21,
00038 CREATEENTITYCANCELMESSAGETYPE = 22,
00039 CREATEENTITYPAUSEMESSAGETYPE = 23,
00040
00041 LOBBYSERVERTYPE = 30,
00042 LOBBYJOINREQUESTTYPE = 31,
00043 LOBBYJOINRESPONSETYPE = 32,
00044 LOBBYGAMESTARTTYPE = 33,
00045 LOBBYSLOTSWAPTYPE = 34,
00046 LOBBYEXITTYPE = 35,
00047
00048 MINERALPATCHIDREQUESTTYPE = 40,
00049 MINERALPATCHIDRESPONSETYPE = 41
00050 };
00051
00052 struct __attribute__((__packed__)) PackedReqInfo{
00053 int id;
00054 };
00055
00056 typedef struct PackedReqInfo ReqInfo;
00057
00058 struct __attribute__((__packed__)) PackedState{
00059 int id;
00060 int hp;
00061 float timeLeftToBirth;
00062 float px, py, pz;
00063 float vx, vy, vz;
00064 float yaw;
00065 float rSpeed;
00066 float ds;
00067 float dh;
00068 int flag;
00069 };
00070
00071 typedef struct PackedState State;
00072
00073 struct __attribute__((__packed__)) PackedInfo {
00074 int id;
00075 char label[256];
00076 char type[256] ;
00077 float maxSpeed;
00078 float maxSpeedReverse;
00079 float length;
00080 float beam;
00081 float draft;
00082 int playerId;
00083 int side;
00084
00085 };
00086
00087 typedef struct PackedInfo Info;
00088
00089 struct __attribute__((__packed__)) PackedCommandEntity {
00090 int id;
00091 float dh;
00092 float ds;
00093 } ;
00094
00095 typedef struct PackedCommandEntity CommandEntity;
00096
00097 struct __attribute__((__packed__)) PackedSquelchEntity {
00098 int id;
00099 } ;
00100
00101 typedef struct PackedSquelchEntity SquelchEntity;
00102
00103 struct __attribute__((__packed__)) PackedCreateEntity{
00104 char label[256];
00105 char entType[256];
00106 float px, py, pz;
00107 float yaw;
00108 } ;
00109
00110 typedef struct PackedCreateEntity CreateEntity;
00111
00112 struct __attribute__((__packed__)) PackedCreateEntityRequest{
00113 int builderid;
00114 int entType;
00115 int side;
00116 int player;
00117 float px, py, pz;
00118 float yaw;
00119 } ;
00120
00121 typedef struct PackedCreateEntityRequest CreateEntityRequest;
00122
00123 struct __attribute__((__packed__)) PackedCreateEntityCancel{
00124 int builderid;
00125 int builtid;
00126 } ;
00127
00128 typedef struct PackedCreateEntityCancel CreateEntityCancel;
00129
00130 struct __attribute__((__packed__)) PackedCreatePause{
00131 int builderid;
00132 int builtid;
00133 } ;
00134
00135 typedef struct PackedCreatePause CreateEntityPause;
00136
00137 struct __attribute__((__packed__)) PackedCreateEntityResponse{
00138 int builderid;
00139 int builtid;
00140 } ;
00141
00142 typedef struct PackedCreateEntityResponse CreateEntityResponse;
00143
00144 struct __attribute__((__packed__)) PackedRepositionEntity {
00145 int id;
00146 float px, py, pz;
00147 float vx, vy, vz;
00148 float yaw;
00149 char label[256];
00150 };
00151
00152 typedef struct PackedRepositionEntity RepositionEntity;
00153
00154 struct __attribute__((__packed__)) PackedLobbyServer {
00155 int port;
00156 char name[64];
00157 unsigned int ip;
00158 int side;
00159 int player;
00160 int slot;
00161 char isHost;
00162 };
00163
00164 typedef struct PackedLobbyServer LobbyServer;
00165
00166 struct __attribute__((__packed__)) PackedLobbyJoinRequest {
00167 int port;
00168 unsigned int serverIP;
00169 unsigned int clientIP;
00170 char clientName[64];
00171 };
00172
00173 typedef struct PackedLobbyJoinRequest LobbyJoinRequest;
00174
00175 struct __attribute__((__packed__)) PackedLobbyJoinResponse {
00176 int port;
00177 unsigned int serverIP;
00178 unsigned int clientIP;
00179 int side;
00180 int player;
00181 };
00182
00183 typedef struct PackedLobbyJoinResponse LobbyJoinResponse;
00184
00185 struct __attribute__((__packed__)) PackedLobbyGameStart {
00186 int port;
00187 unsigned int serverIP;
00188 };
00189
00190 typedef struct PackedLobbyGameStart LobbyGameStart;
00191
00192 struct __attribute__((__packed__)) PackedLobbyExit {
00193 unsigned int serverIP;
00194 unsigned int clientIP;
00195 int port;
00196 };
00197
00198 typedef struct PackedLobbyExit LobbyExit;
00199
00200 struct __attribute__((__packed__)) PackedLobbySlotSwap {
00201 unsigned int serverIP;
00202 unsigned int newpos;
00203 unsigned int oldpos;
00204 unsigned int newside;
00205 unsigned int newplayer;
00206 int port;
00207 };
00208
00209 typedef struct PackedLobbySlotSwap LobbySlotSwap;
00210
00211 struct __attribute__((__packed__)) PackedMineralPatchIDRequest {
00212 int mineralid;
00213 };
00214
00215 typedef struct PackedMineralPatchIDRequest MineralPatchIDRequest;
00216
00217 struct __attribute__((__packed__)) PackedMineralPatchIDResponse {
00218 int mineralid;
00219 int patchid;
00220 };
00221
00222 typedef struct PackedMineralPatchIDResponse MineralPatchIDResponse;
00223
00224 struct __attribute__((__packed__)) PackedMessage {
00225 Header head;
00226 char data[MaxMessageSize - sizeof(Header)];
00227 };
00228
00229 typedef struct PackedMessage Message;
00230
00231 const int MessageSize = sizeof(Message);
00232 const int HeaderSize = sizeof(Header);
00233 const int StateSize = sizeof(State) - sizeof(unsigned short);
00234 const int ReqInfoSize = sizeof(ReqInfo);
00235 const int InfoSize = sizeof(Info);
00236 const int CommandEntitySize = sizeof(CommandEntity);
00237 const int CreateEntitySize = sizeof(CreateEntity);
00238 const int CreateEntityRequestSize = sizeof(CreateEntityRequest);
00239 const int CreateEntityResponseSize = sizeof(CreateEntityResponse);
00240 const int CreateEntityCancelSize = sizeof(CreateEntityCancel);
00241 const int CreateEntityPauseSize = sizeof(CreateEntityPause);
00242 const int RepositionEntitySize = sizeof(RepositionEntity);
00243 const int SquelchEntitySize = sizeof(SquelchEntity);
00244
00245 const int LobbyServerSize = sizeof(LobbyServer);
00246 const int LobbyJoinRequestSize = sizeof(LobbyJoinRequest);
00247 const int LobbyJoinResponseSize= sizeof(LobbyJoinResponse);
00248 const int LobbyGameStartSize = sizeof(LobbyGameStart);
00249 const int LobbyExitSize = sizeof(LobbyExit);
00250 const int LobbySlotSwapSize = sizeof(LobbySlotSwap);
00251
00252 const int MineralPatchIDRequestSize = sizeof(MineralPatchIDRequest);
00253 const int MineralPatchIDResponseSize = sizeof(MineralPatchIDResponse);
00254
00255 void printMessageHeader(Header h);
00256 void printMessageData(Message *m);
00257 void printMessage(Message *m);
00258 void printState(State *s);
00259
00260
00261 }
00262
00263 #endif