]> git.mxchange.org Git - flightgear.git/blob - src/MultiPlayer/mpmessages.hxx
Mathias Fröhlich:
[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., 675 Mass Ave, Cambridge, MA 02139, 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 <stdint.h>
39 #include <plib/sg.h>
40
41 // Message identifiers
42 #define CHAT_MSG_ID 1
43 #define UNUSABLE_POS_DATA_ID 2
44 #define POS_DATA_ID 3
45 /* should be a multiple of 8! */
46 #define MAX_CALLSIGN_LEN 8
47 /** Header for use with all messages sent */
48 typedef struct {
49
50     /** Message identifier, multiple of 8! */
51     uint32_t MsgId;
52
53     /** Length of the message inclusive of this header */
54     uint32_t iMsgLen;
55
56     /** IP address for reply to message (player's receiver address) */
57     uint32_t lReplyAddress;
58
59     /** Port for replies (player's receiver port) */
60     uint32_t iReplyPort;
61
62     /** Callsign used by the player */
63     char sCallsign[MAX_CALLSIGN_LEN];
64
65 } T_MsgHdr;
66
67 #define MAX_CHAT_MSG_LEN 48
68 /** Chat message */
69 typedef struct {
70
71     /** Text of chat message */
72     char sText[MAX_CHAT_MSG_LEN];
73
74 } T_ChatMsg;
75
76 /* should be a multiple of 8! */
77 #define MAX_MODEL_NAME_LEN 48
78 /** Aircraft position message */
79 typedef struct {
80
81     /** Name of the aircraft model */
82     char sModel[MAX_MODEL_NAME_LEN];
83
84     /** Position data for the aircraft */
85     sgdVec3 PlayerPosition;
86     sgQuat PlayerOrientation;
87
88 } T_PositionMsg;
89
90
91 #endif
92
93