Small rewrite of waypoints parsing fix to move global list to the globals.hxx
file.
This commit is contained in:
parent
4a41f96631
commit
be7e5e4990
4 changed files with 64 additions and 89 deletions
|
@ -140,7 +140,7 @@ SG_USING_STD(string);
|
||||||
class Sound;
|
class Sound;
|
||||||
|
|
||||||
extern const char *default_root;
|
extern const char *default_root;
|
||||||
extern string_list waypoints;
|
|
||||||
|
|
||||||
#ifdef FG_USE_CLOUDS_3D
|
#ifdef FG_USE_CLOUDS_3D
|
||||||
SkySceneLoader *sgCloud3d;
|
SkySceneLoader *sgCloud3d;
|
||||||
|
@ -1002,43 +1002,23 @@ static bool fgSetPosFromFix( const string& id ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool parseWaypoints()
|
static bool parseWaypoints()
|
||||||
|
{
|
||||||
|
string_list *waypoints = globals->get_initial_waypoints();
|
||||||
|
if (waypoints)
|
||||||
{
|
{
|
||||||
vector<string>::iterator i;
|
vector<string>::iterator i;
|
||||||
for (i = waypoints.begin();
|
for (i = waypoints->begin();
|
||||||
i != waypoints.end();
|
i != waypoints->end();
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
NewWaypoint(*i);
|
NewWaypoint(*i);
|
||||||
// string arg = *i;
|
}
|
||||||
// string id, alt_str;
|
// Now were done using the way points we can deallocate the
|
||||||
// double alt = 0.0;
|
// memory they used
|
||||||
|
while (waypoints->begin() != waypoints->end())
|
||||||
// string::size_type pos = arg.find( "@" );
|
waypoints->pop_back();
|
||||||
// if ( pos != string::npos ) {
|
delete waypoints;
|
||||||
// id = arg.substr( 0, pos );
|
globals->set_initial_waypoints(0);
|
||||||
// alt_str = arg.substr( pos + 1 );
|
|
||||||
// cout << "id str = " << id << " alt str = " << alt_str << endl;
|
|
||||||
// alt = atof( alt_str.c_str() );
|
|
||||||
// if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) {
|
|
||||||
// alt *= SG_FEET_TO_METER;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// id = arg;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// FGAirport a;
|
|
||||||
// if ( fgFindAirportID( id, &a ) ) {
|
|
||||||
// FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager");
|
|
||||||
// SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
|
|
||||||
// rm->add_waypoint( wp );
|
|
||||||
|
|
||||||
// //return true;
|
|
||||||
// } else {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // waypoints.begin() = waypoints.erase(waypoints.begin());
|
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,8 @@ FGGlobals::FGGlobals() :
|
||||||
channel_options_list( NULL ),
|
channel_options_list( NULL ),
|
||||||
scenery( NULL ),
|
scenery( NULL ),
|
||||||
tile_mgr( NULL ),
|
tile_mgr( NULL ),
|
||||||
io( new FGIO )
|
io( new FGIO ),
|
||||||
|
initial_waypoints(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +88,11 @@ FGGlobals::~FGGlobals()
|
||||||
delete props;
|
delete props;
|
||||||
delete commands;
|
delete commands;
|
||||||
delete io;
|
delete io;
|
||||||
|
|
||||||
|
// make sure only to delete the initial waypoints list if it acually
|
||||||
|
// still exists.
|
||||||
|
if (initial_waypoints)
|
||||||
|
delete initial_waypoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,10 @@ private:
|
||||||
// list of serial port-like configurations
|
// list of serial port-like configurations
|
||||||
string_list *channel_options_list;
|
string_list *channel_options_list;
|
||||||
|
|
||||||
|
// A list of initial waypoints that are read from the command line
|
||||||
|
// and or flight-plan file during initialization
|
||||||
|
string_list *initial_waypoints;
|
||||||
|
|
||||||
// FlightGear scenery manager
|
// FlightGear scenery manager
|
||||||
FGScenery *scenery;
|
FGScenery *scenery;
|
||||||
|
|
||||||
|
@ -327,6 +331,14 @@ public:
|
||||||
channel_options_list = l;
|
channel_options_list = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline string_list *get_initial_waypoints () {
|
||||||
|
return initial_waypoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void set_initial_waypoints (string_list *list) {
|
||||||
|
initial_waypoints = list;
|
||||||
|
}
|
||||||
|
|
||||||
inline FGScenery * get_scenery () const { return scenery; }
|
inline FGScenery * get_scenery () const { return scenery; }
|
||||||
inline void set_scenery ( FGScenery *s ) { scenery = s; }
|
inline void set_scenery ( FGScenery *s ) { scenery = s; }
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,6 @@ SG_USING_NAMESPACE(std);
|
||||||
|
|
||||||
#define NEW_DEFAULT_MODEL_HZ 120
|
#define NEW_DEFAULT_MODEL_HZ 120
|
||||||
|
|
||||||
string_list waypoints;
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
FG_OPTIONS_OK = 0,
|
FG_OPTIONS_OK = 0,
|
||||||
|
@ -543,34 +541,11 @@ add_channel( const string& type, const string& channel_str ) {
|
||||||
// Parse --wp=ID[@alt]
|
// Parse --wp=ID[@alt]
|
||||||
static bool
|
static bool
|
||||||
parse_wp( const string& arg ) {
|
parse_wp( const string& arg ) {
|
||||||
//string id, alt_str;
|
string_list *waypoints = globals->get_initial_waypoints();
|
||||||
//double alt = 0.0;
|
if (!waypoints)
|
||||||
//
|
waypoints = new string_list;
|
||||||
//string::size_type pos = arg.find( "@" );
|
waypoints->push_back(arg);
|
||||||
//if ( pos != string::npos ) {
|
globals->set_initial_waypoints(waypoints);
|
||||||
//id = arg.substr( 0, pos );
|
|
||||||
//alt_str = arg.substr( pos + 1 );
|
|
||||||
//// cout << "id str = " << id << " alt str = " << alt_str << endl;
|
|
||||||
//alt = atof( alt_str.c_str() );
|
|
||||||
//if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) {
|
|
||||||
// alt *= SG_FEET_TO_METER;
|
|
||||||
//}
|
|
||||||
//} else {
|
|
||||||
//id = arg;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//FGAirport a;
|
|
||||||
//if ( fgFindAirportID( id, &a ) ) {
|
|
||||||
// FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager");
|
|
||||||
//SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
|
|
||||||
//rm->add_waypoint( wp );
|
|
||||||
//
|
|
||||||
//return true;
|
|
||||||
//} else {
|
|
||||||
//return false;
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
waypoints.push_back(arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -578,6 +553,9 @@ parse_wp( const string& arg ) {
|
||||||
static bool
|
static bool
|
||||||
parse_flightplan(const string& arg)
|
parse_flightplan(const string& arg)
|
||||||
{
|
{
|
||||||
|
string_list *waypoints = globals->get_initial_waypoints();
|
||||||
|
if (!waypoints)
|
||||||
|
waypoints = new string_list;
|
||||||
sg_gzifstream in(arg.c_str());
|
sg_gzifstream in(arg.c_str());
|
||||||
if ( !in.is_open() ) {
|
if ( !in.is_open() ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -599,10 +577,9 @@ parse_flightplan(const string& arg)
|
||||||
if ( in.eof() ) {
|
if ( in.eof() ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//parse_wp(line);
|
waypoints->push_back(line);
|
||||||
waypoints.push_back(line);
|
|
||||||
}
|
}
|
||||||
|
globals->set_initial_waypoints(waypoints);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue