support decimal and hexadecimal
Stefan Schuermans

Stefan Schuermans commited on 2017-05-20 12:24:20
Showing 1 changed files, with 10 additions and 12 deletions.

... ...
@@ -54,25 +54,23 @@ bool cbEntity(const class dimeState * const state, class dimeEntity *entity,
54 54
   // get layer
55 55
   std::string strLayerName = entity->getLayerName();
56 56
   Layer * pLayer;
57
-  if (strLayerName == "video")
57
+  if (strLayerName == "video") {
58 58
     pLayer = &gLayerVideo;
59
-  else if (strLayerName == "pixel")
59
+  } else if (strLayerName == "pixel") {
60 60
     pLayer = &gLayerPixel;
61
-  else if (strLayerName == "network")
61
+  } else if (strLayerName == "network") {
62 62
     pLayer = &gLayerNetwork;
63
-  else if (strLayerName.substr(0, 6) == "cable ") {
64
-    unsigned int no = 0;
65
-    if (sscanf(strLayerName.substr(6).c_str(), "%x", &no) != 1)
66
-      no = 0; // cable 0 by default
63
+  } else if (strLayerName == "cable") {
64
+    pLayer = &gLayerCables[0];
65
+  } else if (strLayerName.substr(0, 6) == "cable ") {
66
+    unsigned int no = strtoul(strLayerName.substr(6).c_str(), NULL, 0);
67 67
     pLayer = &gLayerCables[no];
68 68
   } else if (strLayerName.substr(0, 12) == "distributor ") {
69
-    unsigned int no = 0;
70
-    if (sscanf(strLayerName.substr(12).c_str(), "%x", &no) != 1)
71
-      no = 0; // distributor 0 by default
69
+    unsigned int no = strtoul(strLayerName.substr(12).c_str(), NULL, 0);
72 70
     pLayer = &gLayerDistributors[no];
73
-  }
74
-  else
71
+  } else {
75 72
     return true;
73
+  }
76 74
 
77 75
   // get transformation matrix
78 76
   dimeMatrix matrix;
79 77