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(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 SGPropertyNode* getPropertyRoot()
65 virtual const char* getTypeString(void) const { return "multiplayer"; }
69 // Automatic sorting of motion data according to its timestamp
70 typedef std::map<double,FGExternalMotionData> MotionInfo;
71 MotionInfo mMotionInfo;
73 // Map between the property id's from the multiplayers network packets
74 // and the property nodes
75 typedef std::map<unsigned, SGSharedPtr<SGPropertyNode> > PropertyMap;
76 PropertyMap mPropertyMap;
81 double lastUpdateTime;
83 /// Properties which are for now exposed for testing
84 bool mAllowExtrapolation;
85 double mLagAdjustSystemSpeed;
89 // Propertiies for tankers
90 SGPropertyNode_ptr refuel_node;
92 bool contact; // set if this tanker is within fuelling range
95 #endif // _FG_AIMultiplayer_HXX