X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FTraffic%2FSchedule.cxx;h=a47dfd2ca3493c2485be2d0b1181736b07747e0d;hb=070dba29f9390806457206c2660f2daebd3d847c;hp=9f793945018bdfe3e27e478e7ec71747437959ae;hpb=81cd33e2fa9b5930784d3aed920eea0e3038e7f7;p=flightgear.git diff --git a/src/Traffic/Schedule.cxx b/src/Traffic/Schedule.cxx index 9f7939450..a47dfd2ca 100644 --- a/src/Traffic/Schedule.cxx +++ b/src/Traffic/Schedule.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,8 @@ #include "SchedFlight.hxx" #include "TrafficMgr.hxx" +using std::string; + /****************************************************************************** * the FGAISchedule class contains data members and code to maintain a * schedule of Flights for an artificially controlled aircraft. @@ -326,14 +329,28 @@ bool FGAISchedule::update(time_t now, const SGVec3d& userCart) bool FGAISchedule::validModelPath(const std::string& modelPath) { - SGPath mp(globals->get_fg_root()); - SGPath mp_ai = mp; + return (resolveModelPath(modelPath) != SGPath()); +} - mp.append(modelPath); - mp_ai.append("AI"); - mp_ai.append(modelPath); +SGPath FGAISchedule::resolveModelPath(const std::string& modelPath) +{ + BOOST_FOREACH(SGPath aiPath, globals->get_data_paths("AI")) { + aiPath.append(modelPath); + if (aiPath.exists()) { + return aiPath; + } + } + + // check aircraft dirs + BOOST_FOREACH(std::string aircraftPath, globals->get_aircraft_paths()) { + SGPath mp(aircraftPath); + mp.append(modelPath); + if (mp.exists()) { + return mp; + } + } - return mp.exists() || mp_ai.exists(); + return SGPath(); } bool FGAISchedule::createAIAircraft(FGScheduledFlight* flight, double speedKnots, time_t deptime) @@ -341,20 +358,7 @@ bool FGAISchedule::createAIAircraft(FGScheduledFlight* flight, double speedKnots FGAirport* dep = flight->getDepartureAirport(); FGAirport* arr = flight->getArrivalAirport(); string flightPlanName = dep->getId() + "-" + arr->getId() + ".xml"; - SG_LOG(SG_AI, SG_INFO, "Traffic manager: Creating AIModel from:" << flightPlanName); - - // Only allow traffic to be created when the model path (or the AI version of mp) exists - SGPath mp(globals->get_fg_root()); - SGPath mp_ai = mp; - - mp.append(modelPath); - mp_ai.append("AI"); - mp_ai.append(modelPath); - - if (!mp.exists() && !mp_ai.exists()) { - SG_LOG(SG_AI, SG_WARN, "TrafficManager: Could not load model " << mp_ai.str()); - return true; - } + SG_LOG(SG_AI, SG_DEBUG, "Traffic manager: Creating AIModel from:" << flightPlanName); aiAircraft = new FGAIAircraft(this); aiAircraft->setPerformance(acType, m_class); //"jet_transport";