pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src/worldmap graph.cxx,1.8,1.9 node_data.


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/worldmap graph.cxx,1.8,1.9 node_data.cxx,1.7,1.8 stat.cxx,1.10,1.11
Date: 28 Sep 2002 19:31:09 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/worldmap
In directory dark:/tmp/cvs-serv23571/worldmap

Modified Files:
        graph.cxx node_data.cxx stat.cxx 
Log Message:
made XMLhelper::get_prop more versatile (may have introduced bugs)


Index: graph.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/graph.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- graph.cxx   28 Sep 2002 11:52:26 -0000      1.8
+++ graph.cxx   28 Sep 2002 19:31:06 -0000      1.9
@@ -133,14 +133,8 @@
 void
 Graph::parse_music (xmlNodePtr cur)
 {
-  char* file = XMLhelper::get_prop(cur, "file");
-
-  if (file)
-    music = file;
-  else
-    {
-      std::cout << "Graph: No music file given" << std::endl;
-    }
+  if (!XMLhelper::get_prop(cur, "file", music))
+    std::cout << "Graph: No music file given" << std::endl;
 }
 
 ResDescriptor 

Index: node_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/node_data.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- node_data.cxx       28 Sep 2002 11:52:26 -0000      1.7
+++ node_data.cxx       28 Sep 2002 19:31:06 -0000      1.8
@@ -99,9 +99,9 @@
        }
       else if (XMLhelper::equal_str(cur->name, "level"))
        {
-         char* level = XMLhelper::get_prop(cur, "name");
-         if (level)
-           node->levelname = std::string("levels/") + level;
+         std::string level;
+         if (XMLhelper::get_prop(cur, "name", level))
+           node->levelname = "levels/" + level;
          else
            std::cout << "PingusWorldMapGraph::parse_node: no levelname given" 
<< std::endl;
        }
@@ -151,12 +151,9 @@
 NodeData*
 NodeData::create(xmlDocPtr doc, xmlNodePtr cur)
 {
-  NodeData* node = new NodeData ();
+  NodeData* node = new NodeData();
   
-  char* id = XMLhelper::get_prop(cur, "id");
-  if (id)
-    node->id = StringConverter::to_int (id);
-  else
+  if (!XMLhelper::get_prop(cur, "id", node->id))
     std::cout << "PingusWorldMapGraph::parse_node: no node id given" << 
std::endl;
 
   /* Accesibility should probally be placed on the links?!
@@ -181,9 +178,9 @@
        }
       else if (XMLhelper::equal_str(cur->name, "link"))
        {
-         char* id = XMLhelper::get_prop(cur, "id");
-         if (id)
-           node->links.push_back(StringConverter::to_int (id));
+         int id;
+         if (XMLhelper::get_prop(cur, "id", id))
+           node->links.push_back(id);
          else
            std::cout << "PingusWorldMapGraph::parse_node: no id given" << 
std::endl;       
        }
@@ -221,19 +218,16 @@
        }
       else if (XMLhelper::equal_str(cur->name, "worldmap"))
        {
-         char* link_node = XMLhelper::get_prop(cur, "linknode");
-         if (link_node)
-           from_string (link_node, node->link_node);
-         else
+         if (!XMLhelper::get_prop(cur, "linknode", node->link_node))
            std::cout << "PingusWorldMapGraph::parse_tube: no node 'linknode' 
given" << std::endl;
 
          node->worldmap = XMLhelper::parse_string (doc, cur);
        }
       else if (XMLhelper::equal_str(cur->name, "link"))
        {
-         char* id = XMLhelper::get_prop(cur, "id");
-         if (id)
-           node->links.push_back(StringConverter::to_int (id));
+         int id;
+         if (XMLhelper::get_prop(cur, "id", id))
+           node->links.push_back(id);
          else
            std::cout << "PingusWorldMapGraph::parse_node: no id given" << 
std::endl;       
        }

Index: stat.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/stat.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- stat.cxx    27 Sep 2002 11:26:49 -0000      1.10
+++ stat.cxx    28 Sep 2002 19:31:06 -0000      1.11
@@ -118,35 +118,15 @@
 PingusWorldMapStat::parse_node (xmlNodePtr cur)
 {
   PingusWorldMapNodeStat node;
-  char* id         = XMLhelper::get_prop(cur, "id");
-  char* accessible = XMLhelper::get_prop(cur, "accessible");
-  char* finished   = XMLhelper::get_prop(cur, "finished");
-  char* checksum   = XMLhelper::get_prop(cur, "checksum");
-
-  //std::cout << "Parsing node: " << cur->name << std::endl;
-
-  if (id) {
-    from_string (id, node.id);
-    xmlFree(id);
-  } else {
+  if (!XMLhelper::get_prop(cur, "id", node.id))
     std::cout << "PingusWorldMapStat: id missing" << std::endl;
-  }
-  
-  if (accessible) {
-    node.accessible = StringConverter::to_int (accessible);
-    xmlFree(accessible);    
-  }
-  
-  if (finished) {
-    node.finished = StringConverter::to_int (finished);
-    xmlFree(finished);  
-  }
-  
-  if (checksum) {
-    //node.checksum = StringConverter::to_int (checksum);
-    xmlFree(checksum);
-  }
 
+  //std::cout << "Parsing node: " << cur->name << std::endl;
+    
+  XMLhelper::get_prop(cur, "accessible", node.accessible);
+  XMLhelper::get_prop(cur, "finished", node.finished);
+  //XMLhelper::get_prop(cur, "checksum", node.checksum);
+    
   stats[node.id] = node;
 }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]