]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/trafficcontrol.cxx
Fix MSVC compilation
[flightgear.git] / src / ATC / trafficcontrol.cxx
index c8657ba1d0e910c678a3abac7c9481ad8607a812..57f718812ce242bbf680a8eb9371ffd278e3b3fa 100644 (file)
@@ -248,7 +248,7 @@ bool FGTrafficRecord::isOpposing (FGGroundNetwork *net, FGTrafficRecord &other,
       
        for (intVecIterator i = intentions.begin(); i != intentions.end(); i++)
        {
-         if (opp = net->findSegment(other.currentPos)->opposite())
+         if ((opp = net->findSegment(other.currentPos)->opposite()))
            {
              if ((*i) > 0)
                if (opp->getIndex() == net->findSegment(*i)->getIndex())
@@ -267,7 +267,7 @@ bool FGTrafficRecord::isOpposing (FGGroundNetwork *net, FGTrafficRecord &other,
                {  
                  // cerr << "Current segment 1 " << (*i) << endl;
                  if ((*i) > 0) {
-                   if (opp = net->findSegment(*i)->opposite())
+                   if ((opp = net->findSegment(*i)->opposite()))
                      {
                        if (opp->getIndex() == 
                            net->findSegment(*j)->getIndex())
@@ -318,9 +318,9 @@ FGATCInstruction::FGATCInstruction()
   changeAltitude = false;
   resolveCircularWait = false;
 
-  double speed   = 0;
-  double heading = 0;
-  double alt     = 0;
+  speed   = 0;
+  heading = 0;
+  alt     = 0;
 }
 
 bool FGATCInstruction::hasInstruction()
@@ -379,13 +379,14 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
          }
     string text;
     string taxiFreqStr;
-    char buffer[7];
     double heading = 0;
     string activeRunway;
     string fltType;
     string rwyClass;
     string SID;
+    string transponderCode;
     FGAIFlightPlan *fp;
+    string fltRules;
     switch (msgId) {
           case MSG_ANNOUNCE_ENGINE_START:
                text = sender + ". Ready to Start up";
@@ -416,8 +417,11 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
                    SID = "fly runway heading ";
                }
                //snprintf(buffer, 7, "%3.2f", heading);
+               fltRules = rec->getAircraft()->getTrafficRef()->getFlightRules();
+               transponderCode = genTransponderCode(fltRules);
+               rec->getAircraft()->SetTransponderCode(transponderCode);
                text = receiver + ". Start-up approved. " + atisInformation + " correct, runway " + activeRunway
-                       + ", " + SID + ", squawk BBBB. " +
+                       + ", " + SID + ", squawk " + transponderCode + ". " +
                       "For push-back and taxi clearance call " + taxiFreqStr + ". " + sender + " control.";
                break;
           case MSG_DENY_ENGINE_START:
@@ -432,8 +436,9 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
                }
                taxiFreqStr = formatATCFrequency3_2(taxiFreq);
                activeRunway = rec->getAircraft()->GetFlightPlan()->getRunway();
+               transponderCode = rec->getAircraft()->GetTransponderCode();
                text = receiver + ". Start-up approved. " + atisInformation + " correct, runway " +
-                      activeRunway + ", " + SID + ", squawk BBBB. " +
+                      activeRunway + ", " + SID + ", squawk " + transponderCode + ". " +
                       "For push-back and taxi clearance call " + taxiFreqStr + ". " + sender;
                break;
            default:
@@ -461,6 +466,16 @@ string FGATCController::formatATCFrequency3_2(int freq) {
     return string(buffer);
 }
 
+string FGATCController::genTransponderCode(string fltRules) {
+    if (fltRules == "VFR") {
+        return string("1200");
+    } else {
+        char buffer[5];
+        snprintf(buffer, 5, "%d%d%d%d", rand() % 8, rand() % 8,rand() % 8, rand() % 8);
+        return string(buffer);
+    }
+}
+
 /***************************************************************************
  * class FGTowerController
  *