From bde6c86fce992c41c9905470dae4d1f3d69f59b3 Mon Sep 17 00:00:00 2001
From: curt <curt>
Date: Tue, 28 Nov 2000 23:38:24 +0000
Subject: [PATCH] Parse route files by Durk Talsma.

---
 src/Main/options.cxx | 29 +++++++++++++++++++++++++++++
 src/Main/options.hxx |  1 +
 2 files changed, 30 insertions(+)

diff --git a/src/Main/options.cxx b/src/Main/options.cxx
index 4cb994fb8..851f5bf83 100644
--- a/src/Main/options.cxx
+++ b/src/Main/options.cxx
@@ -619,6 +619,32 @@ bool FGOptions::parse_wp( const string& arg ) {
 }
 
 
+// Parse --flight-plan=[file]
+bool FGOptions::parse_flightplan(const string& arg)
+{
+    fg_gzifstream infile(arg.c_str());
+    if (!infile) {
+	return false;
+    }
+    while ( true ) {
+	string line;
+#ifdef GETLINE_NEEDS_TERMINATOR
+	getline( infile, line, '\n' );
+#elif defined( macintosh )
+	getline( infile, line, '\r' );
+#else
+	getline( infile, line );
+#endif
+	if ( infile.eof() ) {
+	    break;
+	}
+	parse_wp(line);
+    }
+
+    return true;
+}
+
+
 // Parse a single option
 int FGOptions::parse_option( const string& arg ) {
     // General Options
@@ -940,6 +966,8 @@ int FGOptions::parse_option( const string& arg ) {
     // $$$ end - added VS Renganathan, 14 Oct 2K
     } else if ( arg.find( "--wp=" ) != string::npos ) {
 	parse_wp( arg.substr( 5 ) );
+    } else if ( arg.find( "--flight-plan=") != string::npos) {
+	parse_flightplan ( arg.substr (14) );
     } else {
 	FG_LOG( FG_GENERAL, FG_ALERT, "Unknown option '" << arg << "'" );
 	return FG_OPTIONS_ERROR;
@@ -1215,6 +1243,7 @@ void FGOptions::usage ( void ) {
     cout << "\t\tYou can specify multiple waypoints (a route) with multiple"
 	 << endl;
     cout << "\t\tinstances of --wp=" << endl;
+    cout << "\t--flight-plan=[file]: Read all waypoints from [file]" <<endl;
 }
 
 
diff --git a/src/Main/options.hxx b/src/Main/options.hxx
index d38e9ae65..e0ff8eed3 100644
--- a/src/Main/options.hxx
+++ b/src/Main/options.hxx
@@ -404,6 +404,7 @@ private:
     double parse_fov( const string& arg );
     bool parse_channel( const string& type, const string& channel_str );
     bool parse_wp( const string& arg );
+    bool parse_flightplan(const string& arg);
 };