]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/atis.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / ATC / atis.cxx
index 27f2200c429ce2a857889b6f2a0c9fb68ff14621..0021875dc2740f4f69b28bff5e21b8c52008cea9 100644 (file)
@@ -32,9 +32,7 @@
 SG_USING_STD(string);
 
 #include STL_IOSTREAM
-#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
 SG_USING_STD(cout);
-#endif
 
 //#include <simgear/debug/logstream.hxx>
 //#include <simgear/misc/sgstream.hxx>
@@ -52,27 +50,24 @@ SG_USING_STD(cout);
 #include <Airports/runways.hxx>
 
 #include "atis.hxx"
-#include "atislist.hxx"
+#include "commlist.hxx"
+//#include "atislist.hxx"
 #include "ATCdisplay.hxx"
 #include "ATCutils.hxx"
 #include "ATCmgr.hxx"
 
 // Constructor
-FGATIS::FGATIS()
-: type(0),
-lon(0.0), lat(0.0),
-elev(0.0),
-x(0.0), y(0.0), z(0.0),
-freq(0),
-range(0),
+FGATIS::FGATIS() :
 display(false),
 displaying(false),
-ident(""),
-name(""),
 transmission(""),
 trans_ident(""),
-atis_failed(false)
+atis_failed(false),
+refname("atis")
+//type(ATIS)
 {
+       vPtr = globals->get_ATC_mgr()->GetVoicePointer(ATIS);
+       voiceOK = (vPtr == NULL ? false : true);
 }
 
 // Destructor
@@ -80,7 +75,7 @@ FGATIS::~FGATIS() {
 }
 
 // Main update function - checks whether we are displaying or not the correct message.
-void FGATIS::Update() {
+void FGATIS::Update(double dt) {
        if(display) {
                if(displaying) {
                        // Check if we need to update the message
@@ -90,14 +85,14 @@ void FGATIS::Update() {
                        // We need to get and display the message
                        UpdateTransmission();
                        //cout << "ATIS.CXX - calling ATCMgr to render transmission..." << endl;
-                       globals->get_ATC_mgr()->Render(transmission, true);
+                       Render(transmission, refname, true);
                        displaying = true;
                }
        } else {
                // We shouldn't be displaying
                if(displaying) {
                        //cout << "ATIS.CXX - calling NoRender()..." << endl;
-                       globals->get_ATC_mgr()->NoRender();
+                       NoRender(refname);
                        displaying = false;
                }
        }
@@ -137,7 +132,7 @@ void FGATIS::UpdateTransmission() {
        hours = atoi((time_str.substr(1,2)).c_str());   //Warning - this is fragile if the 
        //time string format changes
        //cout << "In atis.cxx, hours = " << hours << endl;
-       phonetic_id = current_atislist->GetCallSign(ident, hours, 0);
+       phonetic_id = current_commlist->GetCallSign(ident, hours, 0);
        phonetic_id_string = GetPhoneticIdent(phonetic_id);
        transmission += " ";
        transmission += phonetic_id_string;
@@ -148,22 +143,20 @@ void FGATIS::UpdateTransmission() {
        transmission = transmission + " / Weather " + ConvertNumToSpokenDigits((time_str.substr(0,3) + "00")) + " hours zulu";
        
        // Get the temperature
-       // (Hardwire it for now since the global property returns the temperature at the current altitude
-       //temperature = fgGetDouble("/environment/weather/temperature-K");
+       int temp;
        #ifdef FG_WEATHERCM
-       sprintf(buf, "%i", int(stationweather.Temperature - 273.15));
+       temp = int(stationweather.Temperature - 273.15);
        #else
+       temp = (int)stationweather.get_temperature_degc();
+       #endif
+       
        // HACK ALERT - at the moment the new environment subsystem returns bogus temperatures
        // FIXME - take out this hack when this gets fixed upstream
-       int temp = (int)stationweather.get_temperature_degc();
        if((temp < -50) || (temp > 60)) {
                temp = 15;
        }
-       // original:
-       //sprintf(buf, "%d", int(stationweather.get_temperature_degc()));
-       // hack:
-       sprintf(buf, "%d", temp);
-       #endif
+
+       sprintf(buf, "%i", abs(temp));
        transmission += " / Temperature ";
        if(temp < 0) {
                transmission += "minus ";
@@ -259,6 +252,8 @@ void FGATIS::UpdateTransmission() {
        double speed = stationweather.get_wind_speed_kt();
        double hdg = stationweather.get_wind_from_heading_deg();
        if (speed == 0) {
+               hdg = 270;      // This forces West-facing rwys to be used in no-wind situations
+                               // which is consistent with Flightgear's initial setup.
                transmission += " / Winds_light_and_variable";
        } else {
                // FIXME: get gust factor in somehow