]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_menu_fog.cpp
Make yasim accept the launchbar and hook properties. They are not tied to anything...
[flightgear.git] / src / FDM / UIUCModel / uiuc_menu_fog.cpp
1 /**********************************************************************
2                                                                        
3  FILENAME:     uiuc_menu_fog.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  reads input data for specified aircraft and creates 
8                approporiate data storage space
9
10 ----------------------------------------------------------------------
11
12  STATUS:       alpha version
13
14 ----------------------------------------------------------------------
15
16  REFERENCES:   based on "menu reader" format of Michael Selig
17
18 ----------------------------------------------------------------------
19
20  HISTORY:      04/04/2003   initial release
21                06/30/2003   (RD) replaced istrstream with istringstream
22                             to get rid of the annoying warning about
23                             using the strstream header
24
25 ----------------------------------------------------------------------
26
27  AUTHOR(S):    Robert Deters      <rdeters@uiuc.edu>
28                Michael Selig      <m-selig@uiuc.edu>
29
30 ----------------------------------------------------------------------
31
32  VARIABLES:
33
34 ----------------------------------------------------------------------
35
36  INPUTS:       n/a
37
38 ----------------------------------------------------------------------
39
40  OUTPUTS:      n/a
41
42 ----------------------------------------------------------------------
43
44  CALLED BY:    uiuc_menu()
45
46 ----------------------------------------------------------------------
47
48  CALLS TO:     check_float() if needed
49                d_2_to_3() if needed
50                d_1_to_2() if needed
51                i_1_to_2() if needed
52                d_1_to_1() if needed
53
54  ----------------------------------------------------------------------
55
56  COPYRIGHT:    (C) 2003 by Michael Selig
57
58  This program is free software; you can redistribute it and/or
59  modify it under the terms of the GNU General Public License
60  as published by the Free Software Foundation.
61
62  This program is distributed in the hope that it will be useful,
63  but WITHOUT ANY WARRANTY; without even the implied warranty of
64  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
65  GNU General Public License for more details.
66
67  You should have received a copy of the GNU General Public License
68  along with this program; if not, write to the Free Software
69  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
70  USA or view http://www.gnu.org/copyleft/gpl.html.
71
72 **********************************************************************/
73
74 #include <simgear/compiler.h>
75
76 #if defined( __MWERKS__ )
77 // -dw- optimizer chokes (big-time) trying to optimize humongous
78 // loop/switch statements
79 #pragma optimization_level 0
80 #endif
81
82 #include <cstdlib>
83 #include <string>
84 #include STL_IOSTREAM
85
86 #include "uiuc_menu_fog.h"
87
88 SG_USING_STD(cerr);
89 SG_USING_STD(cout);
90 SG_USING_STD(endl);
91
92 #ifndef _MSC_VER
93 SG_USING_STD(exit);
94 #endif
95
96 void parse_fog( const string& linetoken2, const string& linetoken3,
97                 const string& linetoken4, const string& linetoken5, 
98                 const string& linetoken6, const string& linetoken7, 
99                 const string& linetoken8, const string& linetoken9,
100                 const string& linetoken10, const string& aircraft_directory,
101                 LIST command_line ) {
102   double token_value;
103   int token_value_convert1;
104   istringstream token3(linetoken3.c_str());
105   istringstream token4(linetoken4.c_str());
106   istringstream token5(linetoken5.c_str());
107   istringstream token6(linetoken6.c_str());
108   istringstream token7(linetoken7.c_str());
109   istringstream token8(linetoken8.c_str());
110   istringstream token9(linetoken9.c_str());
111   istringstream token10(linetoken10.c_str());
112
113     switch(fog_map[linetoken2])
114       {
115       case fog_segments_flag:
116         {
117           if (check_float(linetoken3))
118             token3 >> token_value_convert1;
119           else
120             uiuc_warnings_errors(1, *command_line);
121           
122           if (token_value_convert1 < 1 || token_value_convert1 > 100)
123             uiuc_warnings_errors(1, *command_line);
124           
125           fog_field = true;
126           fog_point_index = 0;
127           delete[] fog_time;
128           delete[] fog_value;
129           fog_segments = token_value_convert1;
130           fog_time = new double[fog_segments+1];
131           fog_time[0] = 0.0;
132           fog_value = new int[fog_segments+1];
133           fog_value[0] = 0;
134           
135           break;
136         }
137       case fog_point_flag:
138         {
139           if (check_float(linetoken3))
140             token3 >> token_value;
141           else
142             uiuc_warnings_errors(1, *command_line);
143           
144           if (token_value < 0.1)
145             uiuc_warnings_errors(1, *command_line);
146           
147           if (check_float(linetoken4))
148             token4 >> token_value_convert1;
149           else
150             uiuc_warnings_errors(1, *command_line);
151           
152           if (token_value_convert1 < -1000 || token_value_convert1 > 1000)
153             uiuc_warnings_errors(1, *command_line);
154           
155           if (fog_point_index == fog_segments || fog_point_index == -1)
156             uiuc_warnings_errors(1, *command_line);
157           
158           fog_point_index++;
159           fog_time[fog_point_index] = token_value;
160           fog_value[fog_point_index] = token_value_convert1;
161           
162           break;
163         }
164       default:
165         {
166           if (ignore_unknown_keywords) {
167             // do nothing
168           } else {
169             // print error message
170             uiuc_warnings_errors(2, *command_line);
171           }
172           break;
173         }
174       };
175 }