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 unbind();
38 virtual void update(double dt);
40 void addMotionInfo(const FGExternalMotionData& motionInfo, long stamp);
41 void setDoubleProperty(const std::string& prop, double val);
43 long getLastTimestamp(void) const
44 { return mLastTimestamp; }
46 void setAllowExtrapolation(bool allowExtrapolation)
47 { mAllowExtrapolation = allowExtrapolation; }
48 bool getAllowExtrapolation(void) const
49 { return mAllowExtrapolation; }
50 void setLagAdjustSystemSpeed(double lagAdjustSystemSpeed)
52 if (lagAdjustSystemSpeed < 0)
53 lagAdjustSystemSpeed = 0;
54 mLagAdjustSystemSpeed = lagAdjustSystemSpeed;
56 double getLagAdjustSystemSpeed(void) const
57 { return mLagAdjustSystemSpeed; }
59 void addPropertyId(unsigned id, const char* name)
60 { mPropertyMap[id] = props->getNode(name, true); }
62 virtual const char* getTypeString(void) const { return "multiplayer"; }
66 // Automatic sorting of motion data according to its timestamp
67 typedef std::map<double,FGExternalMotionData> MotionInfo;
68 MotionInfo mMotionInfo;
70 // Map between the property id's from the multiplayers network packets
71 // and the property nodes
72 typedef std::map<unsigned, SGSharedPtr<SGPropertyNode> > PropertyMap;
73 PropertyMap mPropertyMap;
78 /// Properties which are for now exposed for testing
79 bool mAllowExtrapolation;
80 double mLagAdjustSystemSpeed;
84 // Propertiies for tankers
85 SGPropertyNode_ptr refuel_node;
87 bool contact; // set if this tanker is within fuelling range
90 #endif // _FG_AIMultiplayer_HXX