]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/AIPlane.cxx
Roy Vegard Ovesen:
[flightgear.git] / src / ATC / AIPlane.cxx
index 91434828db9c75eeaf63927b90dd7f5f85f68e13..1faef86787e4a2d76c099aeacfa0b9e349a5b026 100644 (file)
@@ -44,6 +44,7 @@ FGAIPlane::FGAIPlane() {
        playing = false;
        voiceOK = false;
        vPtr = NULL;
+       track = 0.0;
        _tgtTrack = 0.0;
        _trackSet = false;
        _tgtRoll = 0.0;
@@ -91,7 +92,12 @@ void FGAIPlane::Update(double dt) {
                _max_count = 5.0;               // FIXME - hardwired length of message - need to calculate it!
                
                //cout << "Transmission = " << pending_transmission << '\n';
-               if(freq == user_freq0 || freq == user_freq1) {
+
+               // The radios dialog seems to set slightly imprecise freqs, eg 118.099998
+               // The eplison stuff below is a work-around
+               double eps0 = fabs(freq - user_freq0);
+               double eps1 = fabs(freq - user_freq1);
+               if(eps0 < 0.002 || eps1 < 0.002) {
                        //cout << "Transmitting..." << endl;
                        // we are on the same frequency, so check distance to the user plane
                        if(1) {
@@ -124,6 +130,7 @@ void FGAIPlane::Update(double dt) {
                while((track - _tgtTrack) > 180.0) track -= 360.0;
                double turn_time = 60.0;
                track += (360.0 / turn_time) * dt * (_tgtTrack > track ? 1.0 : -1.0);
+               // TODO - bank a bit less for small turns.
                Bank(25.0 * (_tgtTrack > track ? 1.0 : -1.0));
                if(fabs(track - _tgtTrack) < 2.0) {             // TODO - might need to optimise the delta there - it's on the large (safe) side atm.
                        track = _tgtTrack;