]> git.mxchange.org Git - simgear.git/commitdiff
Merge commit 'refs/merge-requests/9' of git://gitorious.org/fg/simgear into merge...
authorThorstenB <brehmt@gmail.com>
Sun, 28 Aug 2011 12:10:11 +0000 (14:10 +0200)
committerThorstenB <brehmt@gmail.com>
Sun, 28 Aug 2011 12:10:11 +0000 (14:10 +0200)
simgear/io/raw_socket.cxx
simgear/props/props_io.cxx
simgear/sound/sample_openal.hxx

index aaa7d871fb0722f52d3c451223d2d119fa93a5cf..d972c14531e4f5b292600cf0519bd901818ee0d8 100644 (file)
@@ -115,17 +115,33 @@ void IPAddress::set ( const char* host, int port )
     return;
   }
   
-  struct addrinfo* result = NULL;
-  int err = getaddrinfo(host, NULL, NULL /* no hints */, &result);
+  struct addrinfo hints;
+  memset(&hints, 0, sizeof(struct addrinfo));
+  hints.ai_family = AF_INET;
+  
+  struct addrinfo* result0 = NULL;
+  int err = getaddrinfo(host, NULL, &hints, &result0);
   if (err) {
     SG_LOG(SG_IO, SG_WARN, "getaddrinfo failed for '" << host << "' : " << gai_strerror(err));
-  } else if (result->ai_addrlen != getAddrLen()) {
-    SG_LOG(SG_IO, SG_ALERT, "mismatch in socket address sizes");
   } else {
-    memcpy(addr, result->ai_addr, result->ai_addrlen);
-  }
-  
-  freeaddrinfo(result);
+      struct addrinfo* result;
+      for (result = result0; result != NULL; result = result->ai_next) {
+          if (result->ai_family != AF_INET) { // only accept IP4 for the moment
+              continue;
+          }
+          
+          if (result->ai_addrlen != getAddrLen()) {
+              SG_LOG(SG_IO, SG_ALERT, "mismatch in socket address sizes: got " <<
+                  result->ai_addrlen << ", expected " << getAddrLen());
+              continue;
+          }
+          
+          memcpy(addr, result->ai_addr, result->ai_addrlen);
+          break;
+      } // of getaddrinfo results iteration
+  } // of getaddrinfo succeeded
+
+  freeaddrinfo(result0);
   addr->sin_port = htons (port); // fix up port after getaddrinfo
 }
 
index 9fea449730bf94122e3eea9c23c826b4eae5de68..0877390e8b2387eb28db66910ea0083b5c207e4c 100644 (file)
@@ -21,6 +21,7 @@
 #include <simgear/math/SGMath.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/xml/easyxml.hxx>
+#include <simgear/misc/ResourceManager.hxx>
 
 #include "props.hxx"
 #include "props_io.hxx"
@@ -170,12 +171,15 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
                                // Check for an include.
     attval = atts.getValue("include");
     if (attval != 0) {
-      SGPath path(SGPath(_base).dir());
-      path.append(attval);
       try {
-       readProperties(path.str(), _root, 0, _extended);
+          SGPath path = simgear::ResourceManager::instance()->findPath(attval, SGPath(_base).dir());
+          if (path.isNull())
+          {
+              throw sg_io_exception("Cannot open file", sg_location(attval));
+          }
+          readProperties(path.str(), _root, 0, _extended);
       } catch (sg_io_exception &e) {
-       setException(e);
+          setException(e);
       }
     }
 
@@ -242,12 +246,15 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
     bool omit = false;
     attval = atts.getValue("include");
     if (attval != 0) {
-      SGPath path(SGPath(_base).dir());
-      path.append(attval);
       try {
-       readProperties(path.str(), node, 0, _extended);
+          SGPath path = simgear::ResourceManager::instance()->findPath(attval, SGPath(_base).dir());
+          if (path.isNull())
+          {
+              throw sg_io_exception("Cannot open file", sg_location(attval));
+          }
+          readProperties(path.str(), node, 0, _extended);
       } catch (sg_io_exception &e) {
-       setException(e);
+          setException(e);
       }
 
       attval = atts.getValue("omit-node");
index b2afba4f33fd1da89f138e491b038e115d0625dc..b5267bb10ca1963d8ddcf2e4bf8e759168f79326 100644 (file)
@@ -118,7 +118,7 @@ public:
      * @param _loop Define whether this sound should be played in a loop.
      */
     void play( bool loop = false ) {
-        _playing = true; _loop = loop; _changed = true;
+        _playing = true; _loop = loop; _changed = true; _static_changed = true;
     }
 
     /**