]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel_io.cxx
Fixed a bug report from Frederic Bouvier:
[flightgear.git] / src / Cockpit / panel_io.cxx
index d7707d68793973fc8112f0a6f46c23eaeed6d61c..efb51216fa9f007cb14867e3111e141ca5723e1b 100644 (file)
@@ -26,6 +26,8 @@
 #  include <windows.h>
 #endif
 
+#include <string.h>            // for strcmp()
+
 #include <simgear/compiler.h>
 #include <simgear/misc/exception.hxx>
 
@@ -288,14 +290,14 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
   string propName = node->getStringValue("property", "");
   SGPropertyNode * target = 0;
 
-  if (type == "") {
+  if (type.empty()) {
     SG_LOG( SG_COCKPIT, SG_ALERT,
             "No type supplied for transformation " << name
             << " assuming \"rotation\"" );
     type = "rotation";
   }
 
-  if (propName != (string)"") {
+  if (!propName.empty()) {
     target = fgGetNode(propName.c_str(), true);
   }
 
@@ -313,7 +315,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
     t->table = new SGInterpTable();
     for(int i = 0; i < trans_table->nChildren(); i++) {
       const SGPropertyNode * node = trans_table->getChild(i);
-      if (string(node->getName()) == "entry") {
+      if (!strcmp(node->getName(), "entry")) {
        double ind = node->getDoubleValue("ind", 0.0);
        double dep = node->getDoubleValue("dep", 0.0);
        SG_LOG( SG_COCKPIT, SG_INFO, "Adding interpolation entry "
@@ -390,7 +392,7 @@ readTextChunk (const SGPropertyNode * node)
   string format = node->getStringValue("format");
 
                                // Default to literal text.
-  if (type == "") {
+  if (type.empty()) {
     SG_LOG( SG_COCKPIT, SG_INFO, "No type provided for text chunk " << name
             << " assuming \"literal\"");
     type = "literal";
@@ -465,7 +467,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
     h = int(h * h_scale);
 
 
-  if (type == "") {
+  if (type.empty()) {
     SG_LOG( SG_COCKPIT, SG_ALERT,
             "No type supplied for layer " << name
             << " assuming \"texture\"" );
@@ -485,7 +487,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
     for (int i = 0; i < node->nChildren(); i++) {
       const SGPropertyNode * child = node->getChild(i);
       cerr << "Trying child " << child->getName() << endl;
-      if (string(child->getName()) == "layer") {
+      if (!strcmp(child->getName(), "layer")) {
        cerr << "succeeded!" << endl;
        ((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale));
       }
@@ -516,7 +518,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
       int nChunks = chunk_group->nChildren();
       for (int i = 0; i < nChunks; i++) {
        const SGPropertyNode * node = chunk_group->getChild(i);
-       if (string(node->getName()) == "chunk") {
+       if (!strcmp(node->getName(), "chunk")) {
          FGTextLayer::Chunk * chunk = readTextChunk(node);
          if (chunk != 0)
            tlayer->addChunk(chunk);
@@ -548,7 +550,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
       layer = new FGMagRibbon(w, h);
     }
 
-    else if (layerclass == "") {
+    else if (layerclass.empty()) {
       SG_LOG( SG_COCKPIT, SG_ALERT, "No class provided for built-in layer "
               << name );
       return 0;
@@ -576,7 +578,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
     int nTransformations = trans_group->nChildren();
     for (int i = 0; i < nTransformations; i++) {
       const SGPropertyNode * node = trans_group->getChild(i);
-      if (string(node->getName()) == "transformation") {
+      if (!strcmp(node->getName(), "transformation")) {
        FGPanelTransformation * t = readTransformation(node, w_scale, h_scale);
        if (t != 0)
          layer->addTransformation(t);
@@ -645,7 +647,7 @@ readInstrument (const SGPropertyNode * node)
     int nActions = action_group->nChildren();
     for (int i = 0; i < nActions; i++) {
       const SGPropertyNode * node = action_group->getChild(i);
-      if (string(node->getName()) == "action") {
+      if (!strcmp(node->getName(), "action")) {
        FGPanelAction * action = readAction(node, w_scale, h_scale);
        if (action != 0)
          instrument->addAction(action);
@@ -664,7 +666,7 @@ readInstrument (const SGPropertyNode * node)
     int nLayers = layer_group->nChildren();
     for (int i = 0; i < nLayers; i++) {
       const SGPropertyNode * node = layer_group->getChild(i);
-      if (string(node->getName()) == "layer") {
+      if (!strcmp(node->getName(), "layer")) {
        FGInstrumentLayer * layer = readLayer(node, w_scale, h_scale);
        if (layer != 0)
          instrument->addLayer(layer);
@@ -715,7 +717,7 @@ readPanel (const SGPropertyNode * root)
   // Assign the background texture, if any, or a bogus chequerboard.
   //
   string bgTexture = root->getStringValue("background");
-  if (bgTexture == "")
+  if (bgTexture.empty())
     bgTexture = "FOO";
   panel->setBackground(FGTextureManager::createTexture(bgTexture.c_str()));
   SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << bgTexture );
@@ -724,48 +726,48 @@ readPanel (const SGPropertyNode * root)
   // Get multibackground if any...
   //
   string mbgTexture = root->getStringValue("multibackground[0]");
-  if (mbgTexture != (string)"") {
+  if (!mbgTexture.empty()) {
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 0);
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[1]");
-    if (mbgTexture == "")
+    if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 1);
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[2]");
-    if (mbgTexture == "")
+    if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 2);
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[3]");
-    if (mbgTexture == "")
+    if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 3);
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[4]");
-    if (mbgTexture == "")
+    if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 4);
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[5]");
-    if (mbgTexture == "")
+    if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 5);
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[6]");
-    if (mbgTexture == "")
+    if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 6);
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[7]");
-    if (mbgTexture == "")
+    if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 7);
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
@@ -783,7 +785,7 @@ readPanel (const SGPropertyNode * root)
     int nInstruments = instrument_group->nChildren();
     for (int i = 0; i < nInstruments; i++) {
       const SGPropertyNode * node = instrument_group->getChild(i);
-      if (string(node->getName()) == "instrument") {
+      if (!strcmp(node->getName(), "instrument")) {
        FGPanelInstrument * instrument = readInstrument(node);
        if (instrument != 0)
          panel->addInstrument(instrument);