]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/yasim-test.cpp
FGPUIDialog: fix reading from already free'd memory.
[flightgear.git] / src / FDM / YASim / yasim-test.cpp
index e63a9125ac55224f554a95bbf2b0408a454999e9..87b834e53b1d51d017d3603c1c4fc0d96200eb6c 100644 (file)
@@ -1,5 +1,8 @@
 #include <stdio.h>
 
+#include <cstring>
+#include <cstdlib>
+
 #include <simgear/props/props.hxx>
 #include <simgear/xml/easyxml.hxx>
 
 #include "Airplane.hpp"
 
 using namespace yasim;
+using std::string;
 
 // Stubs.  Not needed by a batch program, but required to link.
 bool fgSetFloat (const char * name, float val) { return false; }
 bool fgSetBool(char const * name, bool val) { return false; }
 bool fgGetBool(char const * name, bool def) { return false; }
+bool fgSetString(char const * name, char const * str) { return false; }
 SGPropertyNode* fgGetNode (const char * path, bool create) { return 0; }
 SGPropertyNode* fgGetNode (const char * path, int i, bool create) { return 0; }
 float fgGetFloat (const char * name, float defaultValue) { return 0; }
@@ -29,11 +34,11 @@ static const float KTS2MPS = 0.514444444444;
 // numbers: "aoa lift drag LD" (aoa in degrees, lift and drag in
 // G's).  You can use this in gnuplot like so (assuming the output is
 // in a file named "dat":
-//
-// plot "dat" using 1:2 with lines title 'lift', \ 
-//      "dat" using 1:3 with lines title 'drag', \ 
-//      "dat" using 1:4 with lines title 'LD'
-//
+/*
+ plot "dat" using 1:2 with lines title 'lift', \ 
+      "dat" using 1:3 with lines title 'drag', \ 
+      "dat" using 1:4 with lines title 'LD'
+*/
 void yasim_graph(Airplane* a, float alt, float kts)
 {
     Model* m = a->getModel();
@@ -81,7 +86,7 @@ int main(int argc, char** argv)
         readXML(file, *fdm);
     } catch (const sg_exception &e) {
         printf("XML parse error: %s (%s)\n",
-               e.getFormattedMessage().c_str(), e.getOrigin().c_str());
+               e.getFormattedMessage().c_str(), e.getOrigin());
     }
 
     // ... and run
@@ -92,8 +97,8 @@ int main(int argc, char** argv)
     if(!a->getFailureMsg() && argc > 2 && strcmp(argv[2], "-g") == 0) {
         float alt = 5000, kts = 100;
         for(int i=3; i<argc; i++) {
-            if     (strcmp(argv[i], "-a") == 0) alt = atof(argv[++i]);
-            else if(strcmp(argv[i], "-s") == 0) kts = atof(argv[++i]);
+            if     (std::strcmp(argv[i], "-a") == 0) alt = std::atof(argv[++i]);
+            else if(std::strcmp(argv[i], "-s") == 0) kts = std::atof(argv[++i]);
             else return usage();
         }
         yasim_graph(a, alt, kts);