fgms 0.11.8
The
FlightGear MultiPlayer Server
project
mpmessages.hxx
Go to the documentation of this file.
1 /**
2  * @file mpmessages.hxx
3  * @author Duncan McCreanor
4  *
5  * @brief Message definitions for multiplayer communications
6  * within multiplayer Flightgear
7  *
8  * - Each message used for multiplayer communications consists of a header
9  * and optionally a block of data.
10  * - The combined header and data is sent as one IP packet, \ref xdr encoded.
11  * @note
12  * XDR demands 4 byte alignment, but some compilers use 8 byte
13  * alignment, so it's safe to let the overall size of a network
14  * message be a multiple of 8!
15  */
16 
17 //
18 // Written by Duncan McCreanor, started February 2003.
19 // duncan.mccreanor@airservicesaustralia.com
20 //
21 // Copyright (C) 2003 Airservices Australia
22 //
23 // This program is free software; you can redistribute it and/or
24 // modify it under the terms of the GNU General Public License as
25 // published by the Free Software Foundation; either version 2 of the
26 // License, or (at your option) any later version.
27 //
28 // This program is distributed in the hope that it will be useful, but
29 // WITHOUT ANY WARRANTY; without even the implied warranty of
30 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 // General Public License for more details.
32 //
33 // You should have received a copy of the GNU General Public License
34 // along with this program; if not, write to the Free Software
35 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36 //
37 
38 #ifndef MPMESSAGES_H
39 #define MPMESSAGES_H
40 
41 #include <vector>
42 #include <simgear/compiler.h>
43 #include <simgear/math/SGMath.hxx>
44 #include "tiny_xdr.hxx"
45 
46 /** @brief The `Magic` value for message (currently FGFS). The magic is at
47  * the start of every packet and is used for packet validation.
48  */
49 const uint32_t MSG_MAGIC = 0x46474653; // "FGFS"
50 
51 /** @brief The MP protocol version that is send with each packet
52  * (currently 1.1).
53  */
54 const uint32_t PROTO_VER = 0x00010001; // 1.1
55 
56 /** @brief ID of a "position" message, and the most trafficked */
57 #define POS_DATA_ID 7
58 
59 /** @brief Maximum length of a callsign */
60 #define MAX_CALLSIGN_LEN 8
61 
62 /** @brief Maximum length of a chat message
63  */
64 #define MAX_CHAT_MSG_LEN 256
65 
66 /** @brief Maximum length of a model name, eg /model/x17/aero-123.xml */
67 #define MAX_MODEL_NAME_LEN 96
68 
69 /** @brief Maximum length of property */
70 #define MAX_PROPERTY_LEN 52
71 
72 
73 /**
74  * @struct T_MsgHdr
75  * @brief The header sent as the first part of all mp message packets.
76  *
77  * The header is expected to have the correct ::MSG_MAGIC and ::PROTO_VER
78  * and is checked upon in FG_SERVER::PacketIsValid
79  */
80 struct T_MsgHdr
81 {
82  /** @brief Magic Value */
84  /** @brief Protocol version */
86  /** @brief Message identifier */
88  /** @brief Absolute length of message */
90  /** @brief Player's receiver address
91  * @deprecated Not used in current implementation
92  * set to zero
93  */
95  /** @brief Player's receiver port
96  * @deprecated Not used in current implementation
97  * set to zero
98  */
100  /** @brief Callsign used by the player */
102 };
103 
104 /**
105  * @struct T_PositionMsg
106  * @brief A Position Message
107  */
109 {
110  /** @brief Name of the aircraft model */
112  /** @brief Time when this packet was generated */
114  /** @brief Time when this packet was generated */
116  /** @brief Position wrt the earth centered frame */
118  /** @brief Orientation wrt the earth centered frame, stored in
119  * the angle axis representation where the angle is coded into
120  * the axis length
121  */
123  /** @brief Linear velocity wrt the earth centered frame measured in
124  * the earth centered frame
125  */
127  /** @brief Angular velocity wrt the earth centered frame measured in
128  * the earth centered frame
129  */
131  /** @brief Linear acceleration wrt the earth centered frame measured
132  * in the earth centered frame
133  */
135  /** @brief Angular acceleration wrt the earth centered frame measured
136  * in the earth centered frame
137  */
139 };
140 
141 /**
142  * @struct T_PropertyMsg
143  * @brief Property Message
144  */
146 {
149 };
150 
151 /**
152  * @struct FGFloatPropertyData
153  * @brief Property Data
154  */
156 {
157  unsigned id;
158  float value;
159 };
160 
161 /** @brief Motion Message */
163 {
164  /**
165  * @brief Simulation time when this packet was generated
166  */
167  double time;
168  // the artificial lag the client should stay behind the average
169  // simulation time to arrival time difference
170  // FIXME: should be some 'per model' instead of 'per packet' property
171  double lag;
172  /**
173  * Position wrt the earth centered frame
174  */
176  /** @brief Orientation wrt the earth centered frame */
178  /**
179  * @brief Linear velocity wrt the earth centered frame measured in
180  * the earth centered frame
181  */
183  /**
184  * @brief Angular velocity wrt the earth centered frame measured in the earth centered frame
185  */
187  /** @brief Linear acceleration wrt the earth centered frame measured in the earth centered frame */
189  /** @brief Angular acceleration wrt the earth centered frame measured in the earth centered frame */
191  /** @brief The set of properties recieved for this timeslot */
192  std::vector<FGFloatPropertyData> properties;
193 };
194 
195 #endif
xdr_data_t linearAccel[3]
Linear acceleration wrt the earth centered frame measured in the earth centered frame.
Definition: mpmessages.hxx:134
uint32_t xdr_data_t
4 Bytes
Definition: tiny_xdr.hxx:38
The header sent as the first part of all mp message packets.
Definition: mpmessages.hxx:80
SGVec3f angularAccel
Angular acceleration wrt the earth centered frame measured in the earth centered frame.
Definition: mpmessages.hxx:190
Motion Message.
Definition: mpmessages.hxx:162
SGVec3f angularVel
Angular velocity wrt the earth centered frame measured in the earth centered frame.
Definition: mpmessages.hxx:186
SGVec3f linearAccel
Linear acceleration wrt the earth centered frame measured in the earth centered frame.
Definition: mpmessages.hxx:188
xdr_data_t id
Definition: mpmessages.hxx:147
char Name[MAX_CALLSIGN_LEN]
Callsign used by the player.
Definition: mpmessages.hxx:101
uint64_t xdr_data2_t
8 Bytes
Definition: tiny_xdr.hxx:41
Tiny XDR implementation for flightgear.
double time
Simulation time when this packet was generated.
Definition: mpmessages.hxx:167
xdr_data_t value
Definition: mpmessages.hxx:148
xdr_data_t angularAccel[3]
Angular acceleration wrt the earth centered frame measured in the earth centered frame.
Definition: mpmessages.hxx:138
xdr_data2_t lag
Time when this packet was generated.
Definition: mpmessages.hxx:115
SGVec3f linearVel
Linear velocity wrt the earth centered frame measured in the earth centered frame.
Definition: mpmessages.hxx:182
std::vector< FGFloatPropertyData > properties
The set of properties recieved for this timeslot.
Definition: mpmessages.hxx:192
Property Message.
Definition: mpmessages.hxx:145
const uint32_t MSG_MAGIC
The Magic value for message (currently FGFS). The magic is at the start of every packet and is used f...
Definition: mpmessages.hxx:49
const uint32_t PROTO_VER
The MP protocol version that is send with each packet (currently 1.1).
Definition: mpmessages.hxx:54
xdr_data2_t position[3]
Position wrt the earth centered frame.
Definition: mpmessages.hxx:117
SGQuatf orientation
Orientation wrt the earth centered frame.
Definition: mpmessages.hxx:177
xdr_data2_t time
Time when this packet was generated.
Definition: mpmessages.hxx:113
xdr_data_t MsgLen
Absolute length of message.
Definition: mpmessages.hxx:89
xdr_data_t ReplyPort
Player's receiver port.
Definition: mpmessages.hxx:99
float SGQuatf[4]
Definition: SGMath.hxx:7
xdr_data_t angularVel[3]
Angular velocity wrt the earth centered frame measured in the earth centered frame.
Definition: mpmessages.hxx:130
xdr_data_t ReplyAddress
Player's receiver address.
Definition: mpmessages.hxx:94
#define MAX_MODEL_NAME_LEN
Maximum length of a model name, eg /model/x17/aero-123.xml.
Definition: mpmessages.hxx:67
xdr_data_t linearVel[3]
Linear velocity wrt the earth centered frame measured in the earth centered frame.
Definition: mpmessages.hxx:126
xdr_data_t Version
Protocol version.
Definition: mpmessages.hxx:85
xdr_data_t orientation[3]
Orientation wrt the earth centered frame, stored in the angle axis representation where the angle is ...
Definition: mpmessages.hxx:122
Property Data.
Definition: mpmessages.hxx:155
double SGVec3d[3]
Definition: SGMath.hxx:6
A Position Message.
Definition: mpmessages.hxx:108
xdr_data_t MsgId
Message identifier.
Definition: mpmessages.hxx:87
xdr_data_t Magic
Magic Value.
Definition: mpmessages.hxx:83
char Model[MAX_MODEL_NAME_LEN]
Name of the aircraft model.
Definition: mpmessages.hxx:111
float SGVec3f[3]
Definition: SGMath.hxx:5
#define MAX_CALLSIGN_LEN
Maximum length of a callsign.
Definition: mpmessages.hxx:60