]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIMultiplayer.hxx
Interim windows build fix
[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   double getplayerLag(void) const
62   { return playerLag; }
63
64   void setplayerLag(double mplayerLag)
65   {playerLag = mplayerLag; }
66
67   int getcompensateLag(void) const
68   { return compensateLag; }
69
70   void setcompensateLag(int mcompensateLag)
71   {compensateLag = mcompensateLag; }
72
73   SGPropertyNode* getPropertyRoot()
74   { return props; }
75
76   virtual const char* getTypeString(void) const { return "multiplayer"; }
77
78 private:
79
80   // Automatic sorting of motion data according to its timestamp
81   typedef std::map<double,FGExternalMotionData> MotionInfo;
82   MotionInfo mMotionInfo;
83
84   // Map between the property id's from the multiplayers network packets
85   // and the property nodes
86   typedef std::map<unsigned, SGSharedPtr<SGPropertyNode> > PropertyMap;
87   PropertyMap mPropertyMap;
88
89   double mTimeOffset;
90   bool mTimeOffsetSet;
91   double playerLag;
92   int compensateLag;
93   double lastUpdateTime;
94
95   /// Properties which are for now exposed for testing
96   bool mAllowExtrapolation;
97   double mLagAdjustSystemSpeed;
98
99   long mLastTimestamp;
100
101   // Properties for tankers
102   SGPropertyNode_ptr refuel_node;
103   bool isTanker;
104   bool contact;          // set if this tanker is within fuelling range
105   
106   // velocities/u,v,wbody-fps 
107   SGPropertyNode_ptr _uBodyNode;
108   SGPropertyNode_ptr _vBodyNode;
109   SGPropertyNode_ptr _wBodyNode;
110 };
111
112 #endif  // _FG_AIMultiplayer_HXX