]> git.mxchange.org Git - flightgear.git/blob - src/ATC/AIMgr.cxx
Added constructor to ATCData struct
[flightgear.git] / src / ATC / AIMgr.cxx
1 // AIMgr.cxx - implementation of FGAIMgr 
2 // - a global management class for FlightGear generated AI traffic
3 //
4 // Written by David Luff, started March 2002.
5 //
6 // Copyright (C) 2002  David C Luff - david.luff@nottingham.ac.uk
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 #include <Main/fgfs.hxx>
23 #include <Main/fg_props.hxx>
24
25 #include <list>
26
27 #include "AIMgr.hxx"
28 #include "AILocalTraffic.hxx"
29
30 SG_USING_STD(list);
31
32
33 FGAIMgr::FGAIMgr() {
34 }
35
36 FGAIMgr::~FGAIMgr() {
37 }
38
39 void FGAIMgr::init() {
40         // Hard wire some local traffic for now.
41         // This is regardless of location and hence *very* ugly but it is a start.
42         FGAILocalTraffic* local_traffic = new FGAILocalTraffic;
43         //local_traffic->Init("KEMT", IN_PATTERN, TAKEOFF_ROLL);
44         local_traffic->Init("KEMT");
45         local_traffic->FlyCircuits(1, true);    // Fly 2 circuits with touch & go in between
46         ai_list.push_back(local_traffic);
47 }
48
49 void FGAIMgr::bind() {
50 }
51
52 void FGAIMgr::unbind() {
53 }
54
55 void FGAIMgr::update(double dt) {
56         // Don't update any planes for first 50 runs through - this avoids some possible initialisation anomalies
57         static int i = 0;
58         if(i < 50) {
59                 i++;
60                 return;
61         }
62         
63         // Traverse the list of active planes and run all their update methods
64         // TODO - spread the load - not all planes should need updating every frame.
65         // Note that this will require dt to be calculated for each plane though
66         // since they rely on it to calculate distance travelled.
67         ai_list_itr = ai_list.begin();
68         while(ai_list_itr != ai_list.end()) {
69                 (*ai_list_itr)->Update(dt);
70                 ++ai_list_itr;
71         }
72 }