]> git.mxchange.org Git - flightgear.git/blob - src/MultiPlayer/multiplaymgr.hxx
Portability fix - use SimGear when available
[flightgear.git] / src / MultiPlayer / multiplaymgr.hxx
1 //////////////////////////////////////////////////////////////////////
2 //
3 // multiplaymgr.hpp
4 //
5 // Written by Duncan McCreanor, started February 2003.
6 // duncan.mccreanor@airservicesaustralia.com
7 //
8 // Copyright (C) 2003  Airservices Australia
9 // Copyright (C) 2005  Oliver Schroeder
10 //
11 // This program is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU General Public License as
13 // published by the Free Software Foundation; either version 2 of the
14 // License, or (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful, but
17 // WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 // General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // $Id$
26 //  
27 //////////////////////////////////////////////////////////////////////
28
29 #ifndef MULTIPLAYMGR_H
30 #define MULTIPLAYMGR_H
31
32 #define MULTIPLAYTXMGR_HID "$Id$"
33
34 #include "mpplayer.hxx"
35 #include "mpmessages.hxx"
36
37 #ifdef HAVE_CONFIG_H
38 #  include <config.h>
39 #endif
40
41 #include STL_STRING
42 SG_USING_STD(string);
43 #include <vector>
44 SG_USING_STD(vector);
45
46 #include <simgear/compiler.h>
47 #include <simgear/props/props.hxx>
48 #include <plib/netSocket.h>
49 #include <Main/globals.hxx>
50
51 // Maximum number of players that can exist at any time
52 // FIXME: use a list<mplayer> instead
53 #define MAX_PLAYERS 10
54
55 class FGMultiplayMgr 
56 {
57 public:
58     FGMultiplayMgr();
59     ~FGMultiplayMgr();
60     bool init(void);
61     void Close(void);
62     // transmitter
63     void SendMyPosition (const double lat, const double lon, const double alt,
64                          const double heading, const double roll, const double pitch,
65                          const double speedN, const double speedE, const double speedD,
66                          const double left_aileron, const double right_aileron, const double elevator, const double rudder,
67                          //const double rpms[6],
68                          const double rateH, const double rateR, const double rateP,
69                                                  const double accN, const double accE, const double accD
70                                                  );
71     void SendPropMessage (const string &property, SGPropertyNode::Type type, double value);
72     void SendTextMessage (const string &sMsgText) const;
73     // receiver
74     void ProcessData(void);
75     void ProcessPosMsg ( const char *Msg, netAddress & SenderAddress );
76     void ProcessChatMsg ( const char *Msg, netAddress & SenderAddress );
77     void ProcessPropMsg ( const char *Msg, netAddress & SenderAddress );
78     void Update(void);
79
80         /* getters/setters */
81         bool getSendAllProps();
82         void setSendAllProps(bool s);
83         bool send_all_props;
84
85 private:
86     typedef vector<MPPlayer*>           t_MPClientList;
87     typedef t_MPClientList::iterator    t_MPClientListIterator;
88     MPPlayer*       m_LocalPlayer;
89     netSocket*      m_DataSocket;
90     netAddress      m_Server;
91     bool            m_HaveServer;
92     bool            m_Initialised;
93     t_MPClientList  m_MPClientList;
94     string          m_RxAddress;
95     int             m_RxPort;
96     string          m_Callsign;
97 };
98
99 #endif
100