1 // FGAIMultiplayer - AIBase derived class creates an AI multiplayer aircraft
3 // Written by David Culp, started October 2003.
5 // Copyright (C) 2003 David P. Culp - davidculp2@comcast.net
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.
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.
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.
21 #ifndef _FG_AIMultiplayer_HXX
22 #define _FG_AIMultiplayer_HXX
27 #include <MultiPlayer/mpmessages.hxx>
30 class FGAIMultiplayer : public FGAIBase {
33 virtual ~FGAIMultiplayer();
35 virtual bool init(bool search_in_AI_path=false);
37 virtual void update(double dt);
39 void addMotionInfo(FGExternalMotionData& motionInfo, long stamp);
40 void setDoubleProperty(const std::string& prop, double val);
42 long getLastTimestamp(void) const
43 { return mLastTimestamp; }
45 void setAllowExtrapolation(bool allowExtrapolation)
46 { mAllowExtrapolation = allowExtrapolation; }
47 bool getAllowExtrapolation(void) const
48 { return mAllowExtrapolation; }
49 void setLagAdjustSystemSpeed(double lagAdjustSystemSpeed)
51 if (lagAdjustSystemSpeed < 0)
52 lagAdjustSystemSpeed = 0;
53 mLagAdjustSystemSpeed = lagAdjustSystemSpeed;
55 double getLagAdjustSystemSpeed(void) const
56 { return mLagAdjustSystemSpeed; }
58 void addPropertyId(unsigned id, const char* name)
59 { mPropertyMap[id] = props->getNode(name, true); }
61 double getplayerLag(void) const
64 void setplayerLag(double mplayerLag)
65 {playerLag = mplayerLag; }
67 int getcompensateLag(void) const
68 { return compensateLag; }
70 void setcompensateLag(int mcompensateLag)
71 {compensateLag = mcompensateLag; }
73 SGPropertyNode* getPropertyRoot()
76 virtual const char* getTypeString(void) const { return "multiplayer"; }
80 // Automatic sorting of motion data according to its timestamp
81 typedef std::map<double,FGExternalMotionData> MotionInfo;
82 MotionInfo mMotionInfo;
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;
93 double lastUpdateTime;
95 /// Properties which are for now exposed for testing
96 bool mAllowExtrapolation;
97 double mLagAdjustSystemSpeed;
101 // Properties for tankers
102 SGPropertyNode_ptr refuel_node;
104 bool contact; // set if this tanker is within fuelling range
106 // velocities/u,v,wbody-fps
107 SGPropertyNode_ptr _uBodyNode;
108 SGPropertyNode_ptr _vBodyNode;
109 SGPropertyNode_ptr _wBodyNode;
112 #endif // _FG_AIMultiplayer_HXX