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 // Copyright (C) 2003 Airservices Australia
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #define MPMESSAGES_HID "$Id$"
29 /****************************************************************
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.
36 ******************************************************************/
38 #include <simgear/compiler.h>
39 #include "tiny_xdr.hpp"
42 // magic value for messages
43 const uint32_t MSG_MAGIC = 0x46474653; // "FGFS"
45 const uint32_t PROTO_VER = 0x00010001; // 1.1
47 // Message identifiers
49 #define UNUSABLE_POS_DATA_ID 2
52 // XDR demands 4 byte alignment, but some compilers use8 byte alignment
53 // so it's safe to let the overall size of a netmork message be a
55 #define MAX_CALLSIGN_LEN 8
56 #define MAX_CHAT_MSG_LEN 48
57 #define MAX_MODEL_NAME_LEN 48
59 /** Aircraft position message */
60 typedef xdr_data2_t xdrPosition[3];
61 typedef xdr_data_t xdrOrientation[4];
63 // Header for use with all messages sent
66 xdr_data_t Magic; // Magic Value
67 xdr_data_t Version; // Protocoll version
68 xdr_data_t MsgId; // Message identifier
69 xdr_data_t MsgLen; // absolue length of message
70 xdr_data_t ReplyAddress; // (player's receiver address
71 xdr_data_t ReplyPort; // player's receiver port
72 char Callsign[MAX_CALLSIGN_LEN]; // Callsign used by the player
78 char Text[MAX_CHAT_MSG_LEN]; // Text of chat message
84 char Model[MAX_MODEL_NAME_LEN]; // Name of the aircraft model
85 xdrPosition PlayerPosition; // players position
86 xdrOrientation PlayerOrientation; // players orientation