- sid = 0;
- repeat = false;
- leg = 10;
- gateId=0;
- taxiRoute = 0;
- start_time = start;
- bool useInitialWayPoint = true;
- bool useCurrentWayPoint = false;
- SGPath path( globals->get_fg_root() );
- path.append( "/AI/FlightPlans" );
- path.append( p );
-
- SGPropertyNode root;
- isValid = true;
- // This is a bit of a hack:
- // Normally the value of course will be used to evaluate whether
- // or not a waypoint will be used for midair initialization of
- // an AI aircraft. However, if a course value of 999 will be passed
- // when an update request is received, which will by definition always be
- // on the ground and should include all waypoints.
- if (course == 999)
- {
- useInitialWayPoint = false;
- useCurrentWayPoint = true;
- }
-
- if (path.exists())
- {
- try
- {
- readProperties(path.str(), &root);
-
- SGPropertyNode * node = root.getNode("flightplan");
-
- //pushBackWaypoint( init_waypoint );
- for (int i = 0; i < node->nChildren(); i++) {
- //cout << "Reading waypoint " << i << endl;
- FGAIWaypoint* wpt = new FGAIWaypoint;
- SGPropertyNode * wpt_node = node->getChild(i);
- wpt->setName (wpt_node->getStringValue("name", "END" ));
- wpt->setLatitude (wpt_node->getDoubleValue("lat", 0 ));
- wpt->setLongitude (wpt_node->getDoubleValue("lon", 0 ));
- wpt->setAltitude (wpt_node->getDoubleValue("alt", 0 ));
- wpt->setSpeed (wpt_node->getDoubleValue("ktas", 0 ));
- wpt->setCrossat (wpt_node->getDoubleValue("crossat", -10000 ));
- wpt->setGear_down (wpt_node->getBoolValue("gear-down", false ));
- wpt->setFlaps_down (wpt_node->getBoolValue("flaps-down", false ));
-
- if (wpt->getName() == "END") wpt->setFinished(true);
- else wpt->setFinished(false);
- pushBackWaypoint(wpt);
- } // of node loop
- wpt_iterator = waypoints.begin();
- } catch (const sg_exception &e) {
- SG_LOG(SG_AI, SG_WARN, "Error reading AI flight plan: " <<
- e.getMessage() << " from " << e.getOrigin());
- }