]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIShip.hxx
Optimise NavCache airport query
[flightgear.git] / src / AIModel / AIShip.hxx
index c15b45731b311ff5d453f1790d21dd6f01184012..009b735f58311f92944ee7d0c03d9832e2dc52c6 100644 (file)
-// FGAIShip - AIBase derived class creates an AI ship\r
-//\r
-// Written by David Culp, started November 2003.\r
-// with major amendments and additions by Vivian Meazza, 2004 - 2007 \r
-//\r
-// Copyright (C) 2003  David P. Culp - davidculp2@comcast.net\r
-//\r
-// This program is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU General Public License as\r
-// published by the Free Software Foundation; either version 2 of the\r
-// License, or (at your option) any later version.\r
-//\r
-// This program is distributed in the hope that it will be useful, but\r
-// WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-// General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU General Public License\r
-// along with this program; if not, write to the Free Software\r
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
-\r
-#ifndef _FG_AISHIP_HXX\r
-#define _FG_AISHIP_HXX\r
-\r
-#include "AIBase.hxx"\r
-#include "AIFlightPlan.hxx"\r
-#include <simgear/scene/material/mat.hxx>\r
-\r
-class FGAIManager;\r
-\r
-class FGAIShip : public FGAIBase {\r
-\r
-public:\r
-\r
-    FGAIShip(object_type ot = otShip);\r
-    virtual ~FGAIShip();\r
-\r
-    virtual void readFromScenario(SGPropertyNode* scFileNode);\r
-\r
-    virtual bool init(bool search_in_AI_path=false);\r
-    virtual void bind();\r
-    virtual void unbind();\r
-    virtual void update(double dt);\r
-    void setFlightPlan(FGAIFlightPlan* f);\r
-//    void setName(const string&);\r
-    void setRudder(float r);\r
-    void setRoll(double rl);\r
-    void ProcessFlightPlan( double dt);\r
-    void AccelTo(double speed);\r
-    void PitchTo(double angle);\r
-    void RollTo(double angle);\r
-    void YawTo(double angle);\r
-    void ClimbTo(double altitude);\r
-    void TurnTo(double heading);\r
-    void setCurrName(const string&);\r
-    void setNextName(const string&);\r
-    void setPrevName(const string&);\r
-    void setLeadAngleGain(double g);\r
-    void setLeadAngleLimit(double l);\r
-    void setLeadAngleProp(double p);\r
-    void setRudderConstant(double rc);\r
-    void setSpeedConstant(double sc);\r
-    void setFixedTurnRadius(double ft);\r
-    void setTunnel(bool t);\r
-    void setInitialTunnel(bool t);\r
-\r
-    void setWPNames();\r
-    void setWPPos();\r
-    double sign(double x);\r
-\r
-    bool _hdg_lock;\r
-    bool _serviceable;\r
-    bool _waiting;\r
-    bool _new_waypoint;\r
-    bool _tunnel, _initial_tunnel;\r
-    bool _restart;\r
-\r
-    virtual const char* getTypeString(void) const { return "ship"; }\r
-    double _rudder_constant, _speed_constant, _hdg_constant, _limit ;\r
-    double _elevation_m, _elevation_ft;\r
-    double _missed_range, _tow_angle, _wait_count, _missed_count,_wp_range;\r
-    double _dt_count, _next_run;\r
-\r
-    FGAIFlightPlan::waypoint* prev; // the one behind you\r
-    FGAIFlightPlan::waypoint* curr; // the one ahead\r
-    FGAIFlightPlan::waypoint* next; // the next plus 1\r
-\r
-protected:\r
-\r
-//    string _name; // The name of this ship.\r
-\r
-private:\r
-\r
-\r
-\r
-    virtual void reinit() { init(); }\r
-\r
-    void setRepeat(bool r);\r
-    void setRestart(bool r);\r
-    void setMissed(bool m);\r
-\r
-    void setServiceable(bool s);\r
-    void Run(double dt);\r
-    void setStartTime(const string&);\r
-    void setUntilTime(const string&);\r
-    //void setWPPos();\r
-    void setWPAlt();\r
-    void setXTrackError();\r
-\r
-    SGGeod wppos;\r
-\r
-    const SGMaterial* _material;\r
-\r
-    double getRange(double lat, double lon, double lat2, double lon2) const;\r
-    double getCourse(double lat, double lon, double lat2, double lon2) const;\r
-    double getDaySeconds();\r
-    double processTimeString(const string& time);\r
-\r
-    bool initFlightPlan();\r
-    bool advanceFlightPlan (double elapsed_sec, double day_sec);\r
-\r
-    float _rudder, _tgt_rudder;\r
-\r
-    double _roll_constant, _roll_factor;\r
-    double _sp_turn_radius_ft, _rd_turn_radius_ft, _fixed_turn_radius;\r
-    double _old_range, _range_rate;\r
-    double _missed_time_sec;\r
-    double _start_sec;\r
-    double _day;\r
-    double _lead_angle;\r
-    double _lead_angle_gain, _lead_angle_limit, _proportion;\r
-    double _course;\r
-    double _xtrack_error;\r
-    double _curr_alt, _prev_alt;\r
-\r
-    string _prev_name, _curr_name, _next_name;\r
-    string _path;\r
-    string _start_time, _until_time;\r
-\r
-    bool _repeat;\r
-    bool _fp_init;\r
-    bool _missed;\r
-   \r
-\r
-};\r
-\r
-#endif  // _FG_AISHIP_HXX\r
+// FGAIShip - AIBase derived class creates an AI ship
+//
+// Written by David Culp, started November 2003.
+// with major amendments and additions by Vivian Meazza, 2004 - 2007 
+//
+// 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_AISHIP_HXX
+#define _FG_AISHIP_HXX
+
+#include "AIBase.hxx"
+#include "AIFlightPlan.hxx"
+#include <simgear/scene/material/mat.hxx>
+
+class FGAIManager;
+
+class FGAIShip : public FGAIBase {
+
+public:
+
+    FGAIShip(object_type ot = otShip);
+    virtual ~FGAIShip();
+
+    virtual void readFromScenario(SGPropertyNode* scFileNode);
+
+    virtual bool init(bool search_in_AI_path=false);
+    virtual void bind();
+    virtual void update(double dt);
+    virtual void reinit();
+
+    void setFlightPlan(FGAIFlightPlan* f);
+    void setRudder(float r);
+    void setRoll(double rl);
+    void ProcessFlightPlan( double dt);
+    void AccelTo(double speed);
+    void PitchTo(double angle);
+    void RollTo(double angle);
+    void YawTo(double angle);
+    void ClimbTo(double altitude);
+    void TurnTo(double heading);
+    void setCurrName(const std::string&);
+    void setNextName(const std::string&);
+    void setPrevName(const std::string&);
+    void setLeadAngleGain(double g);
+    void setLeadAngleLimit(double l);
+    void setLeadAngleProp(double p);
+    void setRudderConstant(double rc);
+    void setSpeedConstant(double sc);
+    void setFixedTurnRadius(double ft);
+    void setRollFactor(double rf);
+
+    void setTunnel(bool t);
+    void setInitialTunnel(bool t);
+
+    void setWPNames();
+    void setWPPos();
+
+    double sign(double x);
+
+    bool _hdg_lock;
+    bool _serviceable;
+    bool _waiting;
+    bool _new_waypoint;
+    bool _tunnel, _initial_tunnel;
+    bool _restart;
+
+    virtual const char* getTypeString(void) const { return "ship"; }
+    double _rudder_constant, _speed_constant, _hdg_constant, _limit ;
+    double _elevation_m, _elevation_ft;
+    double _missed_range, _tow_angle, _wait_count, _missed_count,_wp_range;
+    double _dt_count, _next_run;
+
+    FGAIWaypoint* prev; // the one behind you
+    FGAIWaypoint* curr; // the one ahead
+    FGAIWaypoint* next; // the next plus 1
+
+protected:
+
+private:
+
+
+    void setRepeat(bool r);
+    void setRestart(bool r);
+    void setMissed(bool m);
+
+    void setServiceable(bool s);
+    void Run(double dt);
+    void setStartTime(const std::string&);
+    void setUntilTime(const std::string&);
+    //void setWPPos();
+    void setWPAlt();
+    void setXTrackError();
+
+    SGGeod wppos;
+
+    double getRange(double lat, double lon, double lat2, double lon2) const;
+    double getCourse(double lat, double lon, double lat2, double lon2) const;
+    double getDaySeconds();
+    double processTimeString(const std::string& time);
+
+    bool initFlightPlan();
+    bool advanceFlightPlan (double elapsed_sec, double day_sec);
+
+    float _rudder, _tgt_rudder;
+
+    double _roll_constant, _roll_factor;
+    double _sp_turn_radius_ft, _rd_turn_radius_ft, _fixed_turn_radius;
+    double _old_range, _range_rate;
+    double _missed_time_sec;
+    double _start_sec;
+    double _day;
+    double _lead_angle;
+    double _lead_angle_gain, _lead_angle_limit, _proportion;
+    double _course;
+    double _xtrack_error;
+    double _curr_alt, _prev_alt;
+
+    std::string _prev_name, _curr_name, _next_name;
+    std::string _path;
+    std::string _start_time, _until_time;
+
+    bool _repeat;
+    bool _fp_init;
+    bool _missed;
+   
+
+};
+
+#endif  // _FG_AISHIP_HXX