// FGAIMultiplayer - AIBase derived class creates an AI multiplayer aircraft // // Written by David Culp, started October 2003. // // Copyright (C) 2003 David P. Culp - davidculp2@comcast.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef _FG_AIMultiplayer_HXX #define _FG_AIMultiplayer_HXX #include #include #include #include "AIBase.hxx" class FGAIMultiplayer : public FGAIBase { public: FGAIMultiplayer(); virtual ~FGAIMultiplayer(); virtual bool init(); virtual void bind(); virtual void unbind(); virtual void update(double dt); void addMotionInfo(const FGExternalMotionData& motionInfo, long stamp); void setDoubleProperty(const std::string& prop, double val); void setCallSign(const string& callSign) { mCallSign = callSign; } const char* getCallSign(void) const { return mCallSign.c_str(); } long getLastTimestamp(void) const { return mLastTimestamp; } void setAllowExtrapolation(bool allowExtrapolation) { mAllowExtrapolation = allowExtrapolation; } bool getAllowExtrapolation(void) const { return mAllowExtrapolation; } void setLagAdjustSystemSpeed(double lagAdjustSystemSpeed) { if (lagAdjustSystemSpeed < 0) lagAdjustSystemSpeed = 0; mLagAdjustSystemSpeed = lagAdjustSystemSpeed; } double getLagAdjustSystemSpeed(void) const { return mLagAdjustSystemSpeed; } void addPropertyId(unsigned id, const char* name) { mPropertyMap[id] = props->getNode(name, true); } virtual const char* getTypeString(void) const { return "multiplayer"; } private: // Automatic sorting of motion data according to its timestamp typedef std::map MotionInfo; MotionInfo mMotionInfo; // Map between the property id's from the multiplayers network packets // and the property nodes typedef std::map > PropertyMap; PropertyMap mPropertyMap; std::string mCallSign; double mTimeOffset; bool mTimeOffsetSet; /// Properties which are for now exposed for testing bool mAllowExtrapolation; double mLagAdjustSystemSpeed; long mLastTimestamp; }; #endif // _FG_AIMultiplayer_HXX