X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FTraffic%2FTrafficMgr.cxx;h=dc2444fbaa373834b93ffc76f57fd1b74c5ce805;hb=dba4a69e2c8af28145929d0ce6de837f1ec7fe87;hp=5abcc755c6e63f8af6b3ca36dbfc0f783275e54a;hpb=a99ea1c7b5fb0ba69810bbad9b6aca8b4cdc116b;p=flightgear.git diff --git a/src/Traffic/TrafficMgr.cxx b/src/Traffic/TrafficMgr.cxx index 5abcc755c..dc2444fba 100644 --- a/src/Traffic/TrafficMgr.cxx +++ b/src/Traffic/TrafficMgr.cxx @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -70,6 +71,7 @@ #include "TrafficMgr.hxx" using std::sort; +using std::strcmp; /****************************************************************************** * TrafficManager @@ -119,7 +121,7 @@ void FGTrafficManager::init() { SGPath currFile = currACDir; currFile.append(dent2->d_name); - SG_LOG(SG_GENERAL, SG_INFO, "Scanning " << currFile.str() << " for traffic"); + SG_LOG(SG_GENERAL, SG_DEBUG, "Scanning " << currFile.str() << " for traffic"); readXML(currFile.str(),*this); } } @@ -128,8 +130,7 @@ void FGTrafficManager::init() } ulCloseDir(d); } - time_t now = time(NULL) + fgGetLong("/sim/time/warp"); - + currAircraft = scheduledAircraft.begin(); currAircraftClosest = scheduledAircraft.begin(); } @@ -141,11 +142,16 @@ void FGTrafficManager::update(double /*dt*/) if (scheduledAircraft.size() == 0) { return; } + + SGVec3d userCart = SGVec3d::fromGeod(SGGeod::fromDeg( + fgGetDouble("/position/longitude-deg"), + fgGetDouble("/position/latitude-deg"))); + if(currAircraft == scheduledAircraft.end()) { currAircraft = scheduledAircraft.begin(); } - if (!((*currAircraft)->update(now))) + if (!((*currAircraft)->update(now, userCart))) { // NOTE: With traffic manager II, this statement below is no longer true // after proper initialization, we shouldnt get here. @@ -377,62 +383,60 @@ void FGTrafficManager::startElement (const char * name, const XMLAttributes &at void FGTrafficManager::endElement (const char * name) { //cout << "End element " << name << endl; - string element(name); - string value = elementValueStack.back(); - elementValueStack.pop_back(); + const string& value = elementValueStack.back(); - if (element == string("model")) + if (!strcmp(name, "model")) mdl = value; - else if (element == string("livery")) + else if (!strcmp(name, "livery")) livery = value; - else if (element == string("home-port")) + else if (!strcmp(name, "home-port")) homePort = value; - else if (element == string("registration")) + else if (!strcmp(name, "registration")) registration = value; - else if (element == string("airline")) + else if (!strcmp(name, "airline")) airline = value; - else if (element == string("actype")) + else if (!strcmp(name, "actype")) acType = value; - else if (element == string("required-aircraft")) + else if (!strcmp(name, "required-aircraft")) requiredAircraft = value; - else if (element == string("flighttype")) + else if (!strcmp(name, "flighttype")) flighttype = value; - else if (element == string("radius")) + else if (!strcmp(name, "radius")) radius = atoi(value.c_str()); - else if (element == string("offset")) + else if (!strcmp(name, "offset")) offset = atoi(value.c_str()); - else if (element == string("performance-class")) + else if (!strcmp(name, "performance-class")) m_class = value; - else if (element == string("heavy")) + else if (!strcmp(name, "heavy")) { if(value == string("true")) heavy = true; else heavy = false; } - else if (element == string("callsign")) + else if (!strcmp(name, "callsign")) callsign = value; - else if (element == string("fltrules")) + else if (!strcmp(name, "fltrules")) fltrules = value; - else if (element == string("port")) + else if (!strcmp(name, "port")) port = value; - else if (element == string("time")) + else if (!strcmp(name, "time")) timeString = value; - else if (element == string("departure")) + else if (!strcmp(name, "departure")) { departurePort = port; departureTime = timeString; } - else if (element == string("cruise-alt")) + else if (!strcmp(name, "cruise-alt")) cruiseAlt = atoi(value.c_str()); - else if (element == string("arrival")) + else if (!strcmp(name, "arrival")) { arrivalPort = port; arrivalTime = timeString; } - else if (element == string("repeat")) + else if (!strcmp(name, "repeat")) repeat = value; - else if (element == string("flight")) + else if (!strcmp(name, "flight")) { // We have loaded and parsed all the information belonging to this flight // so we temporarily store it. @@ -478,7 +482,7 @@ void FGTrafficManager::endElement (const char * name) { requiredAircraft)); requiredAircraft = ""; } - else if (element == string("aircraft")) + else if (!strcmp(name, "aircraft")) { int proportion = (int) (fgGetDouble("/sim/traffic-manager/proportion") * 100); int randval = rand() & 100; @@ -534,6 +538,7 @@ void FGTrafficManager::endElement (const char * name) { << score); score = 0; } + elementValueStack.pop_back(); } void FGTrafficManager::data (const char * s, int len) {