]> git.mxchange.org Git - flightgear.git/blob - src/MultiPlayer/multiplaymgr.hxx
Update Mac configure script for new ALUT scheme; support --with-alut-framework.
[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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24 //
25 // $Id$
26 //  
27 //////////////////////////////////////////////////////////////////////
28
29 #ifndef MULTIPLAYMGR_H
30 #define MULTIPLAYMGR_H
31
32 #define MULTIPLAYTXMGR_HID "$Id$"
33
34 #include "mpmessages.hxx"
35
36 #ifdef HAVE_CONFIG_H
37 #  include <config.h>
38 #endif
39
40 #include <string>
41 using std::string;
42 #include <vector>
43 using std::vector;
44
45 #include <simgear/compiler.h>
46 #include <simgear/props/props.hxx>
47 #include <plib/netSocket.h>
48 #include <Main/globals.hxx>
49
50 #include <AIModel/AIMultiplayer.hxx>
51
52 struct FGExternalMotionInfo;
53
54 class FGMultiplayMgr 
55 {
56 public:
57
58   struct IdPropertyList {
59     unsigned id;
60     const char* name;
61     simgear::props::Type type;
62   };
63   static const IdPropertyList sIdPropertyList[];
64   static const unsigned numProperties;
65
66   static const IdPropertyList* findProperty(unsigned id);
67   
68   FGMultiplayMgr();
69   ~FGMultiplayMgr();
70   bool init(void);
71   void Close(void);
72   // transmitter
73   void SendMyPosition(const FGExternalMotionData& motionInfo);
74   void SendTextMessage(const string &sMsgText);
75   // receiver
76   void Update(void);
77   
78 private:
79   union MsgBuf;
80   FGAIMultiplayer* addMultiplayer(const std::string& callsign,
81                                   const std::string& modelName);
82   FGAIMultiplayer* getMultiplayer(const std::string& callsign);
83   void FillMsgHdr(T_MsgHdr *MsgHdr, int iMsgId, unsigned _len = 0u);
84   void ProcessPosMsg(const MsgBuf& Msg, const netAddress& SenderAddress,
85                      long stamp);
86   void ProcessChatMsg(const MsgBuf& Msg, const netAddress& SenderAddress);
87
88   /// maps from the callsign string to the FGAIMultiplayer
89   typedef std::map<std::string, osg::ref_ptr<FGAIMultiplayer> > MultiPlayerMap;
90   MultiPlayerMap mMultiPlayerMap;
91
92   netSocket* mSocket;
93   netAddress mServer;
94   bool mHaveServer;
95   bool mInitialised;
96   string mCallsign;
97 };
98
99 #endif
100