From 17fececa9febd1af9a83ebf89afbe8839043a9c6 Mon Sep 17 00:00:00 2001 From: Durk Talsma Date: Fri, 29 Apr 2011 20:44:05 +0200 Subject: [PATCH] Some more work on AI/ATC user interaction integration: * Update AI aircraft object based on user position. * Process flightplan * Don't try to update the radar information for AIAircraft that don't have a valid manager pointer --- src/AIModel/AIAircraft.cxx | 7 ++++++- src/AIModel/AIAircraft.hxx | 1 + src/ATC/atc_mgr.cxx | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index c9b5b7208..811dbfe9a 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -165,7 +165,12 @@ void FGAIAircraft::setPerformance(const std::string& acclass) { handleATCRequests(); // ATC also has a word to say updateSecondaryTargetValues(); // target roll, vertical speed, pitch updateActualState(); - UpdateRadar(manager); + // We currently have one situation in which an AIAircraft object is used that is not attached to the + // AI manager. In this particular case, the AIAircraft is used to shadow the user's aircraft's behavior in the AI world. + // Since we perhaps don't want a radar entry of our own aircraft, the following conditional should probably be adequate + // enough + if (manager) + UpdateRadar(manager); checkVisibility(); } diff --git a/src/AIModel/AIAircraft.hxx b/src/AIModel/AIAircraft.hxx index ff7afad3e..e064acfc9 100644 --- a/src/AIModel/AIAircraft.hxx +++ b/src/AIModel/AIAircraft.hxx @@ -1,3 +1,4 @@ + // FGAIAircraft - AIBase derived class creates an AI aircraft // // Written by David Culp, started October 2003. diff --git a/src/ATC/atc_mgr.cxx b/src/ATC/atc_mgr.cxx index 6f526221a..917d25cbb 100644 --- a/src/ATC/atc_mgr.cxx +++ b/src/ATC/atc_mgr.cxx @@ -149,6 +149,7 @@ void FGATCManager::init() { fp->restart(); + fp->setLeg(leg); ai_ac.SetFlightPlan(fp); if (controller) { controller->announcePosition(ai_ac.getID(), fp, fp->getCurrentWaypoint()->routeIndex, @@ -186,6 +187,13 @@ void FGATCManager::update ( double time ) { altitude, time); //string airport = fgGetString("/sim/presets/airport-id"); //FGAirport *apt = FGAirport::findByIdent(airport); + // AT this stage we should update the flightplan, so that waypoint incrementing is conducted as well as leg loading. + ai_ac.setLatitude(latitude); + ai_ac.setLongitude(longitude); + ai_ac.setAltitude(altitude); + ai_ac.setHeading(heading); + ai_ac.setSpeed(speed); + ai_ac.update(time); controller->render(); //cerr << "Adding groundnetWork to the scenegraph::update" << endl; } -- 2.39.2