]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_io.cxx
Added code to put aircraft at the end of the runway closest to the desired
[flightgear.git] / src / Main / fg_io.cxx
index c3859db6e754f8e9ab55602416c0b192a5fb3df7..24383e7a1b20d5dfacab786d3d1153398108dff2 100644 (file)
@@ -132,49 +132,56 @@ static FGProtocol *parse_port_config( const string& config )
     FG_LOG( FG_IO, FG_INFO, "  hertz = " << hertz );
 
     if ( medium == "serial" ) {
-       SGSerial *ch = new SGSerial;
-       io->set_io_channel( ch );
-
        // device name
        end = config.find(",", begin);
        if ( end == string::npos ) {
            return NULL;
        }
     
-       ch->set_device( config.substr(begin, end - begin) );
+       string device = config.substr(begin, end - begin);
        begin = end + 1;
-       FG_LOG( FG_IO, FG_INFO, "  device = " << ch->get_device() );
+       FG_LOG( FG_IO, FG_INFO, "  device = " << device );
 
        // baud
-       ch->set_baud( config.substr(begin) );
-       FG_LOG( FG_IO, FG_INFO, "  baud = " << ch->get_baud() );
+       string baud = config.substr(begin);
+       FG_LOG( FG_IO, FG_INFO, "  baud = " << baud );
 
+       SGSerial *ch = new SGSerial( device, baud );
        io->set_io_channel( ch );
     } else if ( medium == "file" ) {
-       SGFile *ch = new SGFile;
-       io->set_io_channel( ch );
-
        // file name
-       ch->set_file_name( config.substr(begin) );
-       FG_LOG( FG_IO, FG_INFO, "  file name = " << ch->get_file_name() );
-    } else if ( medium == "socket" ) {
-       SGSocket *ch = new SGSocket;
-       io->set_io_channel( ch );
+       string file = config.substr(begin);
+       FG_LOG( FG_IO, FG_INFO, "  file name = " << file );
 
+       SGFile *ch = new SGFile( file );
+       io->set_io_channel( ch );
+    } else if ( medium == "socket" ) {
        // hostname
        end = config.find(",", begin);
        if ( end == string::npos ) {
            return NULL;
        }
     
-       ch->set_hostname( config.substr(begin, end - begin) );
+       string hostname = config.substr(begin, end - begin);
        begin = end + 1;
-       FG_LOG( FG_IO, FG_INFO, "  hostname = " << ch->get_hostname() );
+       FG_LOG( FG_IO, FG_INFO, "  hostname = " << hostname );
 
-       // port
-       ch->set_port_str( config.substr(begin) );
-       FG_LOG( FG_IO, FG_INFO, "  port string = " << ch->get_port_str() );
+       // port string
+       end = config.find(",", begin);
+       if ( end == string::npos ) {
+           return NULL;
+       }
+    
+       string port = config.substr(begin, end - begin);
+       begin = end + 1;
+       FG_LOG( FG_IO, FG_INFO, "  port string = " << port );
 
+       // socket style
+       string style_str = config.substr(begin);
+       FG_LOG( FG_IO, FG_INFO, "  style string = " << style_str );
+       
+       SGSocket *ch = new SGSocket( hostname, port, style_str );
+       io->set_io_channel( ch );
     }
 
     return io;