]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIShip.cxx
fix a segmentation fault situation that is exposed at least on IRIX (but not Linux).
[flightgear.git] / src / AIModel / AIShip.cxx
index d9fc379fe3092e24448ce362578cfe7c5c50c59f..32950ba65eb1445be5f6cc28035785aa044bd9fd 100644 (file)
 
 FGAIShip::FGAIShip(FGAIManager* mgr) {
    manager = mgr;
+   _type_str = "ship";
+   _otype = otShip;
+
    hdg_lock = false;
    rudder = 0.0;
-   _type_str = "ship";
 }
 
 FGAIShip::~FGAIShip() {
@@ -55,28 +57,24 @@ void FGAIShip::unbind() {
 
 void FGAIShip::update(double dt) {
 
+   FGAIBase::update(dt);
    Run(dt);
    Transform();
-   FGAIBase::update(dt);
 }
 
 
 
 void FGAIShip::Run(double dt) {
 
+   if (fp) ProcessFlightPlan(dt);
+
    double turn_radius_ft;
    double turn_circum_ft;
    double speed_north_deg_sec;
    double speed_east_deg_sec;
-   double ft_per_deg_lon;
-   double ft_per_deg_lat;
    double dist_covered_ft;
    double alpha;
 
-   // get size of a degree at this latitude
-   ft_per_deg_lat = 366468.96 - 3717.12 * cos(pos.lat()/SG_RADIANS_TO_DEGREES);
-   ft_per_deg_lon = 365228.16 * cos(pos.lat() / SG_RADIANS_TO_DEGREES);
-
    // adjust speed
    double speed_diff = tgt_speed - speed;
    if (fabs(speed_diff) > 0.1) {
@@ -165,3 +163,12 @@ double FGAIShip::sign(double x) {
   if ( x < 0.0 ) { return -1.0; }
   else { return 1.0; }
 }
+
+void FGAIShip::setFlightPlan(FGAIFlightPlan* f) {
+  fp = f;
+}
+
+void FGAIShip::ProcessFlightPlan(double dt) {
+  // not implemented yet
+}
+