]> git.mxchange.org Git - flightgear.git/blob - src/MultiPlayer/mpmessages.hxx
Frederic: MSVC doesn't have stdint.h. I just copied the code found in net_gui.hxx...
[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 #ifdef HAVE_STDINT_H
39 # include <stdint.h>
40 #elif defined( _MSC_VER ) || defined(__MINGW32__) || defined(sun)
41 typedef signed short     int16_t;
42 typedef signed int       int32_t;
43 typedef unsigned short   uint16_t;
44 typedef unsigned int     uint32_t;
45 #else
46 # error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
47 #endif
48 #include <plib/sg.h>
49
50 // Message identifiers
51 #define CHAT_MSG_ID 1
52 #define UNUSABLE_POS_DATA_ID 2
53 #define POS_DATA_ID 3
54 /* should be a multiple of 8! */
55 #define MAX_CALLSIGN_LEN 8
56 /** Header for use with all messages sent */
57 typedef struct {
58
59     /** Message identifier, multiple of 8! */
60     uint32_t MsgId;
61
62     /** Length of the message inclusive of this header */
63     uint32_t iMsgLen;
64
65     /** IP address for reply to message (player's receiver address) */
66     uint32_t lReplyAddress;
67
68     /** Port for replies (player's receiver port) */
69     uint32_t iReplyPort;
70
71     /** Callsign used by the player */
72     char sCallsign[MAX_CALLSIGN_LEN];
73
74 } T_MsgHdr;
75
76 #define MAX_CHAT_MSG_LEN 48
77 /** Chat message */
78 typedef struct {
79
80     /** Text of chat message */
81     char sText[MAX_CHAT_MSG_LEN];
82
83 } T_ChatMsg;
84
85 /* should be a multiple of 8! */
86 #define MAX_MODEL_NAME_LEN 48
87 /** Aircraft position message */
88 typedef struct {
89
90     /** Name of the aircraft model */
91     char sModel[MAX_MODEL_NAME_LEN];
92
93     /** Position data for the aircraft */
94     sgdVec3 PlayerPosition;
95     sgQuat PlayerOrientation;
96
97 } T_PositionMsg;
98
99
100 #endif
101
102