]> git.mxchange.org Git - simgear.git/commitdiff
Add helper method for optional stg values
authorChristian Schmitt <chris@ilovelinux.de>
Tue, 12 Jun 2012 07:10:26 +0000 (09:10 +0200)
committerAnders Gidenstam <anders@gidenstam.org>
Tue, 12 Jun 2012 19:04:22 +0000 (21:04 +0200)
Anders Gidenstam: Style and indentation.

simgear/scene/tgdb/ReaderWriterSTG.cxx

index 5b58262b66abbc602fa91d7c047a13654e2ed355..14318bcf2b7a2c9f720eec358b9dfad5c606a375 100644 (file)
@@ -60,6 +60,19 @@ static SGBucket bucketIndexFromFileName(const std::string& fileName)
   return SGBucket(index);
 }
 
+static bool hasOptionalValue(sg_gzifstream &in)
+{
+    while ( (in.peek() != '\n') && (in.peek() != '\r')
+            && isspace(in.peek()) ) {
+        in.get();
+    }
+    if ( isdigit(in.peek()) || (in.peek() == '-') ){
+        return true;
+    } else {
+        return false;
+    }
+}
+
 ReaderWriterSTG::ReaderWriterSTG()
 {
     supportsExtension("stg", "SimGear stg database format");
@@ -287,12 +300,7 @@ ReaderWriterSTG::readStgFile(const std::string& absoluteFileName,
                 matrix.preMultRotate(osg::Quat(SGMiscd::deg2rad(hdg),
                                                osg::Vec3(0, 0, 1)));
 
-                while ( (in.peek() != '\n') && (in.peek() != '\r') &&
-                        (in.peek() != '-')  && isspace(in.peek()) ) {
-                   in.get();
-                }
-
-                if (isdigit(in.peek()) || (in.peek() == '-')){
+                if ( hasOptionalValue(in) ){
                     double pitch(0.0), roll(0.0);
                     in >> pitch >> roll;