]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/generic.cxx
Revert "Fix compilation problem with MSVC 2012"
[flightgear.git] / src / Network / generic.cxx
index 930a070849bf03121409f1513d55989e9afee4c2..21f048c65ff20dd0088e04f8a912e51a983b932f 100644 (file)
@@ -1,4 +1,4 @@
-// generic.cxx -- generic protocal class
+// generic.cxx -- generic protocol class
 //
 // Written by Curtis Olson, started November 1999.
 //
@@ -34,6 +34,7 @@
 #include <simgear/misc/stdint.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/props/props_io.hxx>
+#include <simgear/math/SGMath.hxx>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
@@ -41,7 +42,7 @@
 #include <Main/util.hxx>
 #include "generic.hxx"
 
-FGGeneric::FGGeneric(vector<string> tokens) : exitOnError(false)
+FGGeneric::FGGeneric(vector<string> tokens) : exitOnError(false), initOk(false)
 {
     size_t configToken;
     if (tokens[1] == "socket") {
@@ -52,9 +53,9 @@ FGGeneric::FGGeneric(vector<string> tokens) : exitOnError(false)
         configToken = 6; 
     }
 
-    if (configToken >= tokens.size()) {
+    if ((configToken >= tokens.size())||(tokens[ configToken ] == "")) {
        SG_LOG(SG_NETWORK, SG_ALERT,
-              "Not enough tokens passed for generic protocol");
+              "Not enough tokens passed for generic '" << tokens[1] << "' protocol. ");
        return;
     }
 
@@ -65,6 +66,7 @@ FGGeneric::FGGeneric(vector<string> tokens) : exitOnError(false)
     if (direction != "in" && direction != "out" && direction != "bi") {
         SG_LOG(SG_NETWORK, SG_ALERT, "Unsuported protocol direction: "
                << direction);
+        return;
     }
 
     reinit();
@@ -175,6 +177,7 @@ bool FGGeneric::gen_message_binary() {
             /* FIXME padding for alignment? Something like: 
              * length += (strlength % 4 > 0 ? sizeof(int32_t) - strlength % 4 : 0;
              */
+            break;
         }
     }
 
@@ -329,6 +332,7 @@ bool FGGeneric::parse_message_binary(int length) {
         default: // SG_STRING
             SG_LOG( SG_IO, SG_ALERT, "Generic protocol: "
                     "Ignoring unsupported binary input chunk type.");
+            break;
         }
     }
     
@@ -377,6 +381,7 @@ bool FGGeneric::parse_message_ascii(int length) {
 
         default: // SG_STRING
             _in_message[i].prop->setStringValue(p1);
+            break;
         }
 
         p1 = p2;
@@ -553,6 +558,8 @@ FGGeneric::reinit()
             }
         }
     }
+
+    initOk = true;
 }