2006-02-09 12:29:05 +00:00
|
|
|
// 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
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-02-09 12:29:05 +00:00
|
|
|
|
|
|
|
#ifndef _FG_AIMultiplayer_HXX
|
|
|
|
#define _FG_AIMultiplayer_HXX
|
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
#include <map>
|
2006-02-09 12:29:05 +00:00
|
|
|
#include <string>
|
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
#include <MultiPlayer/mpmessages.hxx>
|
|
|
|
#include "AIBase.hxx"
|
2006-02-09 12:29:05 +00:00
|
|
|
|
|
|
|
class FGAIMultiplayer : public FGAIBase {
|
2006-02-17 09:43:33 +00:00
|
|
|
public:
|
|
|
|
FGAIMultiplayer();
|
|
|
|
virtual ~FGAIMultiplayer();
|
2006-05-18 16:59:04 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
virtual bool init();
|
|
|
|
virtual void bind();
|
|
|
|
virtual void unbind();
|
|
|
|
virtual void update(double dt);
|
2006-05-18 16:59:04 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
void addMotionInfo(const FGExternalMotionData& motionInfo, long stamp);
|
|
|
|
void setDoubleProperty(const std::string& prop, double val);
|
2006-05-18 16:59:04 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
void setCallSign(const string& callSign)
|
|
|
|
{ mCallSign = callSign; }
|
|
|
|
const char* getCallSign(void) const
|
|
|
|
{ return mCallSign.c_str(); }
|
2006-05-18 16:59:04 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
long getLastTimestamp(void) const
|
|
|
|
{ return mLastTimestamp; }
|
2006-02-09 12:29:05 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
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; }
|
2006-02-09 12:29:05 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
void addPropertyId(unsigned id, const char* name)
|
|
|
|
{ mPropertyMap[id] = props->getNode(name, true); }
|
2006-02-09 12:29:05 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
virtual const char* getTypeString(void) const { return "multiplayer"; }
|
2006-02-11 13:16:56 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
private:
|
2006-02-09 12:29:05 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
// Automatic sorting of motion data according to its timestamp
|
|
|
|
typedef std::map<double,FGExternalMotionData> MotionInfo;
|
|
|
|
MotionInfo mMotionInfo;
|
2006-05-18 16:59:04 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
// Map between the property id's from the multiplayers network packets
|
|
|
|
// and the property nodes
|
|
|
|
typedef std::map<unsigned, SGSharedPtr<SGPropertyNode> > PropertyMap;
|
|
|
|
PropertyMap mPropertyMap;
|
|
|
|
|
|
|
|
std::string mCallSign;
|
2006-05-18 16:59:04 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
double mTimeOffset;
|
|
|
|
bool mTimeOffsetSet;
|
2006-05-18 16:59:04 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
/// Properties which are for now exposed for testing
|
|
|
|
bool mAllowExtrapolation;
|
|
|
|
double mLagAdjustSystemSpeed;
|
2006-02-09 12:29:05 +00:00
|
|
|
|
2006-02-17 09:43:33 +00:00
|
|
|
long mLastTimestamp;
|
2006-05-18 16:59:04 +00:00
|
|
|
|
|
|
|
// Propertiies for tankers
|
|
|
|
SGPropertyNode* refuel_node;
|
|
|
|
bool isTanker;
|
|
|
|
bool contact; // set if this tanker is within fuelling range
|
2006-02-17 09:43:33 +00:00
|
|
|
};
|
2006-02-09 12:29:05 +00:00
|
|
|
|
|
|
|
#endif // _FG_AIMultiplayer_HXX
|