]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIMultiplayer.hxx
commradio: improvements for atis speech
[flightgear.git] / src / AIModel / AIMultiplayer.hxx
1 // FGAIMultiplayer - AIBase derived class creates an AI multiplayer aircraft
2 //
3 // Written by David Culp, started October 2003.
4 //
5 // Copyright (C) 2003  David P. Culp - davidculp2@comcast.net
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #ifndef _FG_AIMultiplayer_HXX
22 #define _FG_AIMultiplayer_HXX
23
24 #include <map>
25 #include <string>
26
27 #include <MultiPlayer/mpmessages.hxx>
28 #include "AIBase.hxx"
29
30 class FGAIMultiplayer : public FGAIBase {
31 public:
32   FGAIMultiplayer();
33   virtual ~FGAIMultiplayer();
34
35   virtual bool init(bool search_in_AI_path=false);
36   virtual void bind();
37   virtual void update(double dt);
38
39   void addMotionInfo(FGExternalMotionData& motionInfo, long stamp);
40   void setDoubleProperty(const std::string& prop, double val);
41
42   long getLastTimestamp(void) const
43   { return mLastTimestamp; }
44
45   void setAllowExtrapolation(bool allowExtrapolation)
46   { mAllowExtrapolation = allowExtrapolation; }
47   bool getAllowExtrapolation(void) const
48   { return mAllowExtrapolation; }
49   void setLagAdjustSystemSpeed(double lagAdjustSystemSpeed)
50   {
51     if (lagAdjustSystemSpeed < 0)
52       lagAdjustSystemSpeed = 0;
53     mLagAdjustSystemSpeed = lagAdjustSystemSpeed;
54   }
55   double getLagAdjustSystemSpeed(void) const
56   { return mLagAdjustSystemSpeed; }
57
58   void addPropertyId(unsigned id, const char* name)
59   { mPropertyMap[id] = props->getNode(name, true); }
60
61   SGPropertyNode* getPropertyRoot()
62   { return props; }
63
64   virtual const char* getTypeString(void) const { return "multiplayer"; }
65
66 private:
67
68   // Automatic sorting of motion data according to its timestamp
69   typedef std::map<double,FGExternalMotionData> MotionInfo;
70   MotionInfo mMotionInfo;
71
72   // Map between the property id's from the multiplayers network packets
73   // and the property nodes
74   typedef std::map<unsigned, SGSharedPtr<SGPropertyNode> > PropertyMap;
75   PropertyMap mPropertyMap;
76
77   double mTimeOffset;
78   bool mTimeOffsetSet;
79
80   double lastUpdateTime;
81
82   /// Properties which are for now exposed for testing
83   bool mAllowExtrapolation;
84   double mLagAdjustSystemSpeed;
85
86   long mLastTimestamp;
87
88   // Properties for tankers
89   SGPropertyNode_ptr refuel_node;
90   bool isTanker;
91   bool contact;          // set if this tanker is within fuelling range
92   
93   // velocities/u,v,wbody-fps 
94   SGPropertyNode_ptr _uBodyNode;
95   SGPropertyNode_ptr _vBodyNode;
96   SGPropertyNode_ptr _wBodyNode;
97 };
98
99 #endif  // _FG_AIMultiplayer_HXX