]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/tower.hxx
I had hoped that gmtime's lack of thread-safety wouldn't bite us. It does.
[flightgear.git] / src / ATC / tower.hxx
index f06faeb56455c0eeab74e4844c4ae750bea3647b..aaaf5387b8ace7e2c6454a15d1cfbb4ed429b28a 100644 (file)
@@ -60,7 +60,8 @@ enum tower_callback_type {
        USER_REQUEST_VFR_ARRIVAL_TOUCH_AND_GO = 4,
        USER_REPORT_3_MILE_FINAL = 5,
        USER_REPORT_DOWNWIND = 6,
-       USER_REPORT_RWY_VACATED = 7
+       USER_REPORT_RWY_VACATED = 7,
+       USER_REPORT_GOING_AROUND = 8
 };
 
 // TODO - need some differentiation of IFR and VFR traffic in order to give the former priority.
@@ -94,7 +95,8 @@ public:
        bool finalAcknowledged;
        bool rwyVacatedReported;
        bool rwyVacatedAcknowledged;
-       bool instructedToGoAround;      // set true if told by tower to go around
+       bool goAroundReported;          // set true if plane informs tower that it's going around.
+       bool instructedToGoAround;      // set true if plane told by tower to go around.
        bool onRwy;             // is physically on the runway
        bool nextOnRwy;         // currently projected by tower to be the next on the runway
        
@@ -135,6 +137,8 @@ public:
        // eg "Cessna Charlie Foxtrot Golf Foxtrot Sierra eight miles South of the airport for full stop with Bravo"
        // This function probably only called via user interaction - AI planes will have an overloaded function taking a planerec.
        void VFRArrivalContact(string ID, LandingType opt = AIP_LT_UNKNOWN);
+       // For the AI planes...
+       void VFRArrivalContact(PlaneRec plane, FGAIPlane* requestee, LandingType lt = AIP_LT_UNKNOWN);
        
        void RequestDepartureClearance(string ID);      
        void ReportFinal(string ID);
@@ -142,10 +146,10 @@ public:
        void ReportOuterMarker(string ID);
        void ReportMiddleMarker(string ID);
        void ReportInnerMarker(string ID);
-       void ReportGoingAround(string ID);
        void ReportRunwayVacated(string ID);
        void ReportReadyForDeparture(string ID);
        void ReportDownwind(string ID);
+       void ReportGoingAround(string ID);
        
        // Contact tower when at a hold short for departure - for now we'll assume plane - maybe vehicles might want to cross runway eventually?
        void ContactAtHoldShort(PlaneRec plane, FGAIPlane* requestee, tower_traffic_type operation);
@@ -154,6 +158,9 @@ public:
        // CAUTION - currently it is assumed that this plane's callsign is unique - it is up to AIMgr to generate unique callsigns.
        void RegisterAIPlane(PlaneRec plane, FGAIPlane* ai, tower_traffic_type op, PatternLeg lg = LEG_UNKNOWN);
        
+       // Deregister and remove an AI plane.
+       void DeregisterAIPlane(string id);
+       
        // Public interface to the active runway - this will get more complex 
        // in the future and consider multi-runway use, airplane weight etc.
        inline string GetActiveRunway() { return activeRwy; }
@@ -161,11 +168,7 @@ public:
        // Get the pattern direction of the active rwy.
        inline int GetPatternDirection() { return rwy.patternDirection; }
        
-       inline void SetDisplay() { display = true; }
-       inline void SetNoDisplay() { display = false; }
-       
        inline string get_trans_ident() { return trans_ident; }
-       inline atc_type GetType() { return TOWER; }
        
        inline FGGround* GetGroundPtr() { return ground; }
        
@@ -184,13 +187,18 @@ private:
        // Respond to a transmission
        void Respond();
        
+       void ProcessRunwayVacatedReport(TowerPlaneRec* t);
+       void ProcessDownwindReport(TowerPlaneRec* t);
+       
+       // Remove all options from the user dialog choice
+       void RemoveAllUserDialogOptions();
+       
+       // Periodic checks on the various traffic.
        void CheckHoldList(double dt);
-
        void CheckCircuitList(double dt);
-       
        void CheckRunwayList(double dt);
-
        void CheckApproachList(double dt);
+       void CheckDepartureList(double dt);
        
        // Currently this assumes we *are* next on the runway and doesn't check for planes about to land - 
        // this should be done prior to calling this function.
@@ -199,6 +207,9 @@ private:
        // Find a pointer to plane of callsign ID within the internal data structures
        TowerPlaneRec* FindPlane(string ID);
        
+       // Remove and delete all instances of a plane with a given ID
+       void RemovePlane(string ID);
+       
        // Figure out if a given position lies on the active runway
        // Might have to change when we consider more than one active rwy.
        bool OnActiveRunway(Point3D pt);
@@ -234,9 +245,6 @@ private:
        unsigned int update_count;      // Convienince counter for speading computational load over several updates
        unsigned int update_count_max;  // ditto.
        
-       bool display;           // Flag to indicate whether we should be outputting to the ATC display.
-       bool displaying;                // Flag to indicate whether we are outputting to the ATC display.
-       
        double timeSinceLastDeparture;  // Time in seconds since last departure from active rwy.
        bool departed;  // set true when the above needs incrementing with time, false when it doesn't.
        
@@ -292,8 +300,14 @@ private:
        tower_plane_rec_list_type trafficList;  // TODO - needs to be expandable to more than one rwy
        tower_plane_rec_list_iterator trafficListItr;
        
+       // List of planes that have vacated the runway inbound but not yet handed off to ground
+       tower_plane_rec_list_type vacatedList;
+       tower_plane_rec_list_iterator vacatedListItr;
+       
        // Returns true if successful
        bool RemoveFromTrafficList(string id);
+       bool RemoveFromAppList(string id);
+       bool RemoveFromRwyList(string id);
        
        // Return the ETA of plane no. list_pos (1-based) in the traffic list.
        // i.e. list_pos = 1 implies next to use runway.
@@ -304,6 +318,9 @@ private:
        bool AddToTrafficList(TowerPlaneRec* t, bool holding = false);
        
        bool AddToCircuitList(TowerPlaneRec* t);
+       
+       // Add to vacated list only if not already present
+       void AddToVacatedList(TowerPlaneRec* t);
 
        // Ground can be separate or handled by tower in real life.
        // In the program we will always use a separate FGGround class, but we need to know
@@ -311,6 +328,9 @@ private:
        bool separateGround;    // true if ground control is separate
        FGGround* ground;       // The ground control associated with this airport.
        
+       bool _departureControlled;      // true if we need to hand off departing traffic to departure control
+       //FGDeparture* _departure;      // The relevant departure control (once we've actually written it!)
+       
        // for failure modeling
        string trans_ident;             // transmitted ident
        bool tower_failed;              // tower failed?