1 // mpmessages.hxx -- Message definitions for multiplayer communications
2 // within a multiplayer Flightgear
4 // Written by Duncan McCreanor, started February 2003.
5 // duncan.mccreanor@airservicesaustralia.com
7 // With minor additions be Vivian Meazza, January 2006
9 // Copyright (C) 2003 Airservices Australia
11 // This program is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU General Public License as
13 // published by the Free Software Foundation; either version 2 of the
14 // License, or (at your option) any later version.
16 // This program is distributed in the hope that it will be useful, but
17 // WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #define MPMESSAGES_HID "$Id$"
31 /****************************************************************
34 * Description: Each message used for multiplayer communications
35 * consists of a header and optionally a block of data. The combined
36 * header and data is sent as one IP packet.
38 ******************************************************************/
41 #include <simgear/compiler.h>
42 #include "tiny_xdr.hxx"
44 // magic value for messages
45 const uint32_t MSG_MAGIC = 0x46474653; // "FGFS"
47 const uint32_t PROTO_VER = 0x00010001; // 1.1
49 // Message identifiers
51 #define UNUSABLE_POS_DATA_ID 2
52 #define OLD_POS_DATA_ID 3
56 // XDR demands 4 byte alignment, but some compilers use8 byte alignment
57 // so it's safe to let the overall size of a network message be a
59 #define MAX_CALLSIGN_LEN 8
60 #define MAX_CHAT_MSG_LEN 256
61 #define MAX_MODEL_NAME_LEN 96
62 #define MAX_PROPERTY_LEN 52
64 /** Aircraft position message */
65 typedef xdr_data2_t xdrPosition[3];
66 typedef xdr_data_t xdrOrientation[4];
68 // Header for use with all messages sent
71 xdr_data_t Magic; // Magic Value
72 xdr_data_t Version; // Protocoll version
73 xdr_data_t MsgId; // Message identifier
74 xdr_data_t MsgLen; // absolute length of message
75 xdr_data_t ReplyAddress; // (player's receiver address
76 xdr_data_t ReplyPort; // player's receiver port
77 char Callsign[MAX_CALLSIGN_LEN]; // Callsign used by the player
83 char Text[MAX_CHAT_MSG_LEN]; // Text of chat message
89 char Model[MAX_MODEL_NAME_LEN]; // Name of the aircraft model
90 xdr_data_t time; // Time when this packet was generated
91 xdr_data_t timeusec; // Microsecs when this packet was generated
92 xdr_data2_t lat; // Position, orientation, speed
93 xdr_data2_t lon; // ...
94 xdr_data2_t alt; // ...
95 xdr_data2_t hdg; // ...
96 xdr_data2_t roll; // ...
97 xdr_data2_t pitch; // ...
98 xdr_data2_t speedN; // ...
99 xdr_data2_t speedE; // ...
100 xdr_data2_t speedD; // ...
101 xdr_data_t accN; // acceleration N
102 xdr_data_t accE; // acceleration E
103 xdr_data_t accD; // acceleration D
104 xdr_data_t left_aileron; // control positions
105 xdr_data_t right_aileron; // control positions
106 xdr_data_t elevator; // ...
107 xdr_data_t rudder; // ...
108 // xdr_data_t rpms[6]; // RPMs of all of the motors
109 xdr_data_t rateH; // Rate of change of heading
110 xdr_data_t rateR; // roll
111 xdr_data_t rateP; // and pitch
112 // xdr_data_t dummy; // pad message length
116 class T_PropertyMsg {
118 char property[MAX_PROPERTY_LEN]; // the property name
119 xdr_data_t type; // the type
120 xdr_data2_t val; // and value
121 // xdr_data2_t dummy; // pad message length