]> git.mxchange.org Git - flightgear.git/blob - src/MultiPlayer/mpmessages.hxx
Don't restore initial screen geometry because there is nothing in fg_os* to resize...
[flightgear.git] / src / MultiPlayer / mpmessages.hxx
1 // mpmessages.hxx -- Message definitions for multiplayer communications
2 // within a multiplayer Flightgear
3 //
4 // Written by Duncan McCreanor, started February 2003.
5 // duncan.mccreanor@airservicesaustralia.com
6 //
7 // Copyright (C) 2003  Airservices Australia
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22 //
23
24 #ifndef MPMESSAGES_H
25 #define MPMESSAGES_H
26
27 #define MPMESSAGES_HID "$Id$"
28
29 /****************************************************************
30 * @version $Id$
31 *
32 * Description: Each message used for multiplayer communications
33 * consists of a header and optionally a block of data. The combined
34 * header and data is sent as one IP packet.
35 *
36 ******************************************************************/
37
38 #include <vector>
39
40 #include <plib/sg.h>
41 #include <simgear/compiler.h>
42 #include <simgear/math/SGMath.hxx>
43 #include "tiny_xdr.hxx"
44
45 // magic value for messages
46 const uint32_t MSG_MAGIC = 0x46474653;  // "FGFS"
47 // protocoll version
48 const uint32_t PROTO_VER = 0x00010001;  // 1.1
49
50 // Message identifiers
51 #define CHAT_MSG_ID             1
52 #define UNUSABLE_POS_DATA_ID    2
53 #define OLD_OLD_POS_DATA_ID     3
54 #define OLD_POS_DATA_ID         4
55 #define OLD_PROP_MSG_ID         5
56 #define RESET_DATA_ID           6
57 #define POS_DATA_ID             7
58
59 // XDR demands 4 byte alignment, but some compilers use8 byte alignment
60 // so it's safe to let the overall size of a network message be a 
61 // multiple of 8!
62 #define MAX_CALLSIGN_LEN        8
63 #define MAX_CHAT_MSG_LEN        256
64 #define MAX_MODEL_NAME_LEN      96
65 #define MAX_PROPERTY_LEN        52
66
67 // Header for use with all messages sent 
68 struct T_MsgHdr {
69     xdr_data_t  Magic;                  // Magic Value
70     xdr_data_t  Version;                // Protocoll version
71     xdr_data_t  MsgId;                  // Message identifier 
72     xdr_data_t  MsgLen;                 // absolute length of message
73     xdr_data_t  ReplyAddress;           // (player's receiver address
74     xdr_data_t  ReplyPort;              // player's receiver port
75     char Callsign[MAX_CALLSIGN_LEN];    // Callsign used by the player
76 };
77
78 // Chat message 
79 struct T_ChatMsg {
80     char Text[MAX_CHAT_MSG_LEN];       // Text of chat message
81 };
82
83 // Position message
84 struct T_PositionMsg {
85     char Model[MAX_MODEL_NAME_LEN];    // Name of the aircraft model
86
87     // Time when this packet was generated
88     xdr_data2_t time;
89     xdr_data2_t lag;
90
91     // position wrt the earth centered frame
92     xdr_data2_t position[3];
93     // orientation wrt the earth centered frame, stored in the angle axis
94     // representation where the angle is coded into the axis length
95     xdr_data_t orientation[3];
96
97     // linear velocity wrt the earth centered frame measured in
98     // the earth centered frame
99     xdr_data_t linearVel[3];
100     // angular velocity wrt the earth centered frame measured in
101     // the earth centered frame
102     xdr_data_t angularVel[3];
103
104     // linear acceleration wrt the earth centered frame measured in
105     // the earth centered frame
106     xdr_data_t linearAccel[3];
107     // angular acceleration wrt the earth centered frame measured in
108     // the earth centered frame
109     xdr_data_t angularAccel[3];
110 };
111
112 // Property message
113 struct T_PropertyMsg {
114     xdr_data_t id;
115     xdr_data_t value;
116 };
117
118 struct FGFloatPropertyData {
119   unsigned id;
120   float value;
121 };
122
123 // Position message
124 struct FGExternalMotionData {
125   // simulation time when this packet was generated
126   double time;
127   // the artificial lag the client should stay behind the average
128   // simulation time to arrival time diference
129   // FIXME: should be some 'per model' instead of 'per packet' property
130   double lag;
131   
132   // position wrt the earth centered frame
133   SGVec3d position;
134   // orientation wrt the earth centered frame
135   SGQuatf orientation;
136   
137   // linear velocity wrt the earth centered frame measured in
138   // the earth centered frame
139   SGVec3f linearVel;
140   // angular velocity wrt the earth centered frame measured in
141   // the earth centered frame
142   SGVec3f angularVel;
143   
144   // linear acceleration wrt the earth centered frame measured in
145   // the earth centered frame
146   SGVec3f linearAccel;
147   // angular acceleration wrt the earth centered frame measured in
148   // the earth centered frame
149   SGVec3f angularAccel;
150   
151   // The set of properties recieved for this timeslot
152   std::vector<FGFloatPropertyData> properties;
153 };
154
155 #endif