]> git.mxchange.org Git - flightgear.git/blob - src/ATC/AIPlane.cxx
Oops - let some DOS line endings creep in - quickly get rid of them before Erik notic...
[flightgear.git] / src / ATC / AIPlane.cxx
1 // FGAIPlane - abstract base class for an AI plane
2 //
3 // Written by David Luff, started 2002.
4 //
5 // Copyright (C) 2002  David C. Luff - david.luff@nottingham.ac.uk
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 /*****************************************************************
22 *
23 * WARNING - Curt has some ideas about AI traffic so anything in here
24 * may get rewritten or scrapped.  Contact Curt curt@flightgear.org 
25 * before spending any time or effort on this code!!!
26 *
27 ******************************************************************/
28
29 #include <Main/globals.hxx>
30 #include <Main/fg_props.hxx>
31 //#include <Scenery/scenery.hxx>
32 //#include <simgear/constants.h>
33 #include <simgear/math/point3d.hxx>
34 //#include <simgear/math/sg_geodesy.hxx>
35 //#include <simgear/misc/sg_path.hxx>
36 #include <math.h>
37 #include <string>
38 SG_USING_STD(string);
39
40
41 #include "AIPlane.hxx"
42 #include "ATCdisplay.hxx"
43
44 FGAIPlane::~FGAIPlane() {
45 }
46
47 void FGAIPlane::Update(double dt) {
48 }
49
50 void FGAIPlane::Bank(double angle) {
51         // This *should* bank us smoothly to any angle
52         if(fabs(roll - angle) > 0.6) {
53                 roll -= ((roll - angle)/fabs(roll - angle));  
54         }
55 }
56
57 // Duplication of Bank(0.0) really - should I cut this?
58 void FGAIPlane::LevelWings(void) {
59         // bring the plane back to level smoothly (this should work to come out of either bank)
60         if(fabs(roll) > 0.6) {
61                 roll -= (roll/fabs(roll));
62         }
63 }
64
65 void FGAIPlane::Transmit(string msg) {
66         double user_freq0 = fgGetDouble("/radios/comm[0]/frequencies/selected-mhz");
67         //double user_freq0 = ("/radios/comm[0]/frequencies/selected-mhz");
68         //comm1 is not used yet.
69         
70         if(freq == user_freq0) {
71                 // we are on the same frequency, so check distance to the user plane
72                 if(1) {
73                         // For now (testing) assume in range !!!
74                         // TODO - implement range checking
75                         globals->get_ATC_display()->RegisterSingleMessage(msg, 0);
76                 }
77         }
78 }