]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/generic.cxx
Fix crashes (activating the route-manager) with a default GPS.
[flightgear.git] / src / Network / generic.cxx
index a91f7835eba45a8a2d56d5427b6d20eebfa509ee..423d2be189b28ffec2de641415dc99ab3b1bdcfb 100644 (file)
@@ -240,8 +240,8 @@ bool FGGeneric::gen_message_ascii() {
 
         case FG_DOUBLE:
             val = _out_message[i].offset +
-                _out_message[i].prop->getFloatValue() * _out_message[i].factor;
-            snprintf(tmp, 255, _out_message[i].format.c_str(), (float)val);
+                _out_message[i].prop->getDoubleValue() * _out_message[i].factor;
+            snprintf(tmp, 255, _out_message[i].format.c_str(), (double)val);
             break;
 
         default: // SG_STRING
@@ -467,25 +467,24 @@ bool FGGeneric::process() {
                 }
             }
         } else {
-            do {
-                if (!binary_mode) {
-                    length = io->readline( buf, FG_MAX_MSG_SIZE );
-                    if ( length > 0 ) {
-                        parse_message();
-                    }
-                } else {
-                    length = io->read( buf, binary_record_length );
-                    if ( length == binary_record_length ) {
-                        parse_message();
-                    } else if ( length > 0 ) {
-                        SG_LOG( SG_IO, SG_ALERT,
-                            "Generic protocol: Received binary "
-                            "record of unexpected size, expected: "
-                            << binary_record_length << " but received: "
-                            << length);
-                    }
+            if (!binary_mode) {
+                while ((length = io->readline( buf, FG_MAX_MSG_SIZE )) > 0 ) {
+                    parse_message();
                 }
-            } while ( length == binary_record_length );
+            } else {
+                while ((length = io->read( buf, binary_record_length )) 
+                          == binary_record_length ) {
+                    parse_message();
+                }
+
+                if ( length > 0 ) {
+                    SG_LOG( SG_IO, SG_ALERT,
+                        "Generic protocol: Received binary "
+                        "record of unexpected size, expected: "
+                        << binary_record_length << " but received: "
+                        << length);
+                }
+            }
         }
     }
     return true;