]> git.mxchange.org Git - flightgear.git/blobdiff - src/Input/fgjs.cxx
Fixed minor memory leak on joystick reload.
[flightgear.git] / src / Input / fgjs.cxx
index 7e1bf790d88252f8bcdc586af511c3624ba70207..f1930b0e389ca552e72c1b06e4d75b305be405ad 100644 (file)
 
 #include <simgear/compiler.h>
 
+#ifdef _WIN32
+#  include <winsock2.h>
+#endif
+
 #include <math.h>
 
-#include STL_IOSTREAM
-#include STL_FSTREAM
-#include STL_STRING
+#include <iostream>
+#include <fstream>
+#include <string>
 
-SG_USING_STD(fstream);
-SG_USING_STD(cout);
-SG_USING_STD(cin);
-SG_USING_STD(endl);
-SG_USING_STD(ios);
-SG_USING_STD(string);
+using std::fstream;
+using std::cout;
+using std::cin;
+using std::endl;
+using std::ios;
+using std::string;
 
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/sgstream.hxx>
 #include <simgear/structure/exception.hxx>
+#include <simgear/props/props_io.hxx>
 
 #include <Main/fg_io.hxx>
 #include <Main/fg_props.hxx>
@@ -53,6 +58,7 @@ SG_USING_STD(string);
 
 #include "jsinput.h"
 
+using simgear::PropertyList;
 
 bool confirmAnswer() {
     char answer;
@@ -76,6 +82,8 @@ int main( int argc, char *argv[] ) {
             cout << "Usage:" << endl;
             cout << "  --help\t\t\tShow this help" << endl;
             exit(0);
+       } else if (strncmp("--fg-root=", argv[i], 10) == 0) {
+           // used later
         } else {
             cout << "Unknown option \"" << argv[i] << "\"" << endl;
             exit(0);
@@ -129,8 +137,8 @@ int main( int argc, char *argv[] ) {
         cout << e.getFormattedMessage ();
     }
 
-    vector<SGPropertyNode_ptr> axes = templatetree->getChildren("axis");
-    for(vector<SGPropertyNode_ptr>::iterator iter = axes.begin(); iter != axes.end(); iter++) {
+    PropertyList axes = templatetree->getChildren("axis");
+    for(PropertyList::iterator iter = axes.begin(); iter != axes.end(); iter++) {
         cout << "Move the control you wish to use for " << (*iter)->getStringValue("desc")
              << " " << (*iter)->getStringValue("direction") << endl;
         cout << "Pressing a button skips this axis" << endl;
@@ -157,8 +165,8 @@ int main( int argc, char *argv[] ) {
         cout << endl;
     }
 
-    vector<SGPropertyNode_ptr> buttons = templatetree->getChildren("button");
-    for(vector<SGPropertyNode_ptr>::iterator iter = buttons.begin(); iter != buttons.end(); iter++) {
+    PropertyList buttons = templatetree->getChildren("button");
+    for(PropertyList::iterator iter = buttons.begin(); iter != buttons.end(); iter++) {
         cout << "Press the button you wish to use for " << (*iter)->getStringValue("desc") << endl;
         cout << "Moving a joystick axis skips this button" << endl;
         fflush( stdout );
@@ -204,6 +212,7 @@ int main( int argc, char *argv[] ) {
     delete jsi;
     delete[] xfs;
     delete jss;
+    delete[] jstree;
 
     return 1;
 }
@@ -256,20 +265,9 @@ static string fgScanForOption( const string& option, const string& path ) {
     int len = option.length();
 
     in >> skipcomment;
-#ifndef __MWERKS__
     while ( ! in.eof() ) {
-#else
-    char c = '\0';
-    while ( in.get(c) && c != '\0' ) {
-        in.putback(c);
-#endif
         string line;
-
-#if defined( macintosh )
-        getline( in, line, '\r' );
-#else
         getline( in, line, '\n' );
-#endif
 
         // catch extraneous (DOS) line ending character
         if ( line[line.length() - 1] < 32 ) {
@@ -341,9 +339,9 @@ string getFGRoot ( int argc, char **argv ) {
     // find fg-root any other way.
     if ( root.empty() ) {
 #if defined( __CYGWIN__ )
-        root = "/FlightGear";
-#elif defined( WIN32 )
-        root = "\\FlightGear";
+        root = "../data";
+#elif defined( _WIN32 )
+        root = "..\\data";
 #elif defined(OSX_BUNDLE)
         /* the following code looks for the base package directly inside
             the application bundle. This can be changed fairly easily by