]> git.mxchange.org Git - flightgear.git/blob - src/MultiPlayer/multiplayrxmgr.hxx
Cygwin doesn't handle endianness properly at the moment, try a different approach.
[flightgear.git] / src / MultiPlayer / multiplayrxmgr.hxx
1 // multiplayrxmgr.hxx -- routines for receiving multiplayer data
2 //                       for Flghtgear
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 MULTIPLAYRXMGR_H
25 #define MULTIPLAYRXMGR_H
26
27 #define MULTIPLAYRXMGR_HID "$Id$"
28
29
30 #include "mpplayer.hxx"
31 #include "mpmessages.hxx"
32
33 #include STL_STRING
34 SG_USING_STD(string);
35
36 #include <simgear/compiler.h>
37 #include <plib/netSocket.h>
38
39 // Maximum number of players that can exist at any time
40 #define MAX_PLAYERS 10
41
42 /****************************************************************
43 * @version $Id$
44 *
45 * Description: The multiplay rx manager is responsible for
46 * receiving and processing data from other players.
47
48 * Data from remote players is read from the network and processed
49 * via calling ProcessData. The models for the remote player are
50 * positioned onto the scene by calling Update.
51 *
52 *******************************************************************/
53 class FGMultiplayRxMgr {
54 public:
55
56     /** Constructor */
57     FGMultiplayRxMgr();
58
59     /** Destructor. */
60     ~FGMultiplayRxMgr();
61
62     /** Initialises the multiplayer receiver.
63     * @return True if initialisation succeeds, else false
64     */
65     bool init(void);
66
67     /** Initiates processing of any data waiting at the rx socket.
68     */
69     void ProcessData(void);
70     void ProcessPosMsg ( const char *Msg );
71     void ProcessChatMsg ( const char *Msg );
72
73     /** Updates the model positions for the players
74     */
75     void Update(void);
76
77     /** Closes the multiplayer manager. Stops any further player packet processing.
78     */
79     void Close(void);
80
81
82 private:
83
84
85     /** Holds the players that exist in the game */
86     MPPlayer *m_Player[MAX_PLAYERS];
87
88     /** Socket for receiving data from the server or another player */
89     netSocket *mDataRxSocket;
90
91     /** True if multiplay receive is initialised */
92     bool m_bInitialised;
93
94     /** Receive address for multiplayer messages */
95     string m_sRxAddress;
96
97     /** Receive port for multiplayer messages */
98     int m_iRxPort;
99
100     /** Local player's callsign */
101     string m_sCallsign;
102
103 };
104
105 #endif
106
107
108