]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/generic.cxx
Don't restore initial screen geometry because there is nothing in fg_os* to resize...
[flightgear.git] / src / Network / generic.cxx
index 66e0fac19ed37c3d941c2ff5d868d603b860e37f..89c9c91eca94a072d689c1e6f300b470723a46c0 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Written by Curtis Olson, started November 1999.
 //
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 1999  Curtis L. Olson - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
 
 #include <string.h>            // strstr()
 #include <stdlib.h>            // strtod(), atoi()
@@ -59,11 +62,13 @@ FGGeneric::FGGeneric(string& config) {
 
     _out_message.clear();
     SGPropertyNode *output = root.getNode("generic/output");
-    read_config(output, _out_message);
+    if (output)
+        read_config(output, _out_message);
 
     _in_message.clear();
     SGPropertyNode *input = root.getNode("generic/input");
-    read_config(input, _in_message);
+    if (input)
+        read_config(input, _in_message);
 }
 
 FGGeneric::~FGGeneric() {
@@ -126,13 +131,16 @@ bool FGGeneric::gen_message() {
 bool FGGeneric::parse_message() {
     char *p2, *p1 = buf;
     double val;
-    int i = 0;
+    int i = -1;
 
-    while (p1 && strcmp(p1, line_separator.c_str())) {
+    while ((++i < (int)_in_message.size()) &&
+           p1 && strcmp(p1, line_separator.c_str())) {
 
         p2 = strstr(p1, var_separator.c_str());
-        if (p2)
-            *(p2++) = 0;
+        if (p2) {
+            *p2 = 0;
+            p2 += var_separator.length();
+        }
 
         switch (_in_message[i].type) {
         case FG_INT:
@@ -141,7 +149,7 @@ bool FGGeneric::parse_message() {
             break;
 
         case FG_BOOL:
-            _in_message[i].prop->setBoolValue( atoi(p1) != 0 );
+            _in_message[i].prop->setBoolValue( atof(p1) != 0.0 );
             break;
 
         case FG_DOUBLE:
@@ -154,7 +162,6 @@ bool FGGeneric::parse_message() {
         }
 
         p1 = p2;
-        i++;
     }
     
     return true;