pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata bumper_data.cxx,1.7,1.8


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata bumper_data.cxx,1.7,1.8 conveyor_belt_data.cxx,1.7,1.8 entrance_data.cxx,1.3,1.4 exit_data.cxx,1.4,1.5 guillotine_data.cxx,1.7,1.8 hammer_data.cxx,1.8,1.9 hotspot_data.cxx,1.3,1.4 laser_exit_data.cxx,1.7,1.8 liquid_data.cxx,1.5,1.6 smasher_data.cxx,1.7,1.8 solid_color_background_data.cxx,1.3,1.4 spike_data.cxx,1.7,1.8 spike_data.hxx,1.4,1.5 starfield_background_data.cxx,1.5,1.6surface_background_data.cxx,1.5,1.6 thunderstorm_background_data.cxx,1.3,1.4
Date: 18 Feb 2003 01:23:54 -0000

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

Modified Files:
        bumper_data.cxx conveyor_belt_data.cxx entrance_data.cxx 
        exit_data.cxx guillotine_data.cxx hammer_data.cxx 
        hotspot_data.cxx laser_exit_data.cxx liquid_data.cxx 
        smasher_data.cxx solid_color_background_data.cxx 
        spike_data.cxx spike_data.hxx starfield_background_data.cxx 
        surface_background_data.cxx thunderstorm_background_data.cxx 
Log Message:
used XMLFileReader/Writer a bit, might hae introduced a few bugs


Index: bumper_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/bumper_data.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- bumper_data.cxx     27 Sep 2002 18:36:41 -0000      1.7
+++ bumper_data.cxx     18 Feb 2003 01:23:52 -0000      1.8
@@ -20,6 +20,7 @@
 #include <iostream>
 #include "bumper_data.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/bumper_obj.hxx"
 #include "../worldobjs/bumper.hxx"
 #include "../pingus_resource.hxx"
@@ -30,20 +31,11 @@
 {
 }
 
-BumperData::BumperData (xmlDocPtr doc, xmlNodePtr cur) : 
surface(PingusResource::load_surface("Traps/bumper", "traps"))
+BumperData::BumperData (xmlDocPtr doc, xmlNodePtr cur) 
+  : surface(PingusResource::load_surface("Traps/bumper", "traps"))
 {
-  cur = cur->children;
-  while (cur)
-    {
-      XMLhelper::skip_blank(cur);
-
-      if (XMLhelper::equal_str(cur->name, "position")) 
-       {
-         pos = XMLhelper::parse_vector(doc, cur);
-       }
-       
-      cur = cur->next;
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
 }
 
 BumperData::BumperData (const BumperData& old) : WorldObjData(old),

Index: conveyor_belt_data.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/conveyor_belt_data.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- conveyor_belt_data.cxx      18 Feb 2003 00:15:32 -0000      1.7
+++ conveyor_belt_data.cxx      18 Feb 2003 01:23:52 -0000      1.8
@@ -18,7 +18,8 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <iostream>
-#include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
+#include "../xml_file_writer.hxx"
 #include "../editorobjs/conveyor_belt_obj.hxx"
 #include "../worldobjs/conveyor_belt.hxx"
 #include "conveyor_belt_data.hxx"
@@ -34,23 +35,10 @@
 
 ConveyorBeltData::ConveyorBeltData (xmlDocPtr doc, xmlNodePtr cur)
 {
-  cur = cur->children;
-  
-  XMLReader reader(doc, cur);
+  XMLFileReader reader(doc, cur);
   reader.read_vector("position", pos);
-       }
-      else if (XMLhelper::equal_str(cur->name, "width"))
-       {
-         width = XMLhelper::parse_int(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "speed"))
-       {
-         speed = XMLhelper::parse_int(doc, cur);
-       }
-      else
-       std::cout << "ConveyorBeltData::create (): Unhandled " << cur->name << 
std::endl;
-      cur = cur->next;
-    }
+  reader.read_int("width", width);
+  reader.read_float("speed", speed);
 }
 
 ConveyorBeltData::ConveyorBeltData (const ConveyorBeltData& old)
@@ -67,11 +55,12 @@
 void 
 ConveyorBeltData::write_xml (std::ostream& xml)
 {
-  xml << "  <worldobj type=\"conveyorbelt\">";
-  XMLhelper::write_vector_xml (xml, pos);
-  xml << "    <width>" << width << "</width>\n"
-      << "    <speed>" << speed << "</speed>\n"
-      << "  </worldobj>\n" << std::endl;
+  XMLFileWriter writer(xml);
+  writer.begin_section("worldobj", "type=\"conveyorbelt\"");
+  writer.write_vector("position", pos);
+  writer.write_int("width", width);
+  writer.write_float("speed", speed);
+  writer.end_section();
 }
 
 WorldObj* 

Index: entrance_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/entrance_data.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- entrance_data.cxx   30 Sep 2002 14:20:49 -0000      1.3
+++ entrance_data.cxx   18 Feb 2003 01:23:52 -0000      1.4
@@ -23,6 +23,7 @@
 #include "../pingus_error.hxx"
 #include "../string_converter.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "entrance_data.hxx"
 
 namespace WorldObjsData {
@@ -39,49 +40,23 @@
                                                             owner_id(0),
                                                             type("generic")
 {
-  cur = cur->children;  
-  while (cur)
-    {
-      if (xmlIsBlankNode(cur)) 
-       {
-         cur = cur->next;
-         continue;
-       }
-
-      if (XMLhelper::equal_str(cur->name, "type"))
-       {
-         XMLhelper::node_list_get_string(doc, cur->children, 1, type);
-       }
-      else if (XMLhelper::equal_str(cur->name, "owner-id"))
-       {
-         owner_id = XMLhelper::parse_int(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "position"))
-       {
-         pos = XMLhelper::parse_vector(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "release-rate"))
-       {
-         XMLhelper::node_list_get_string(doc, cur->children, 1, release_rate);
-       }
-      else if (XMLhelper::equal_str(cur->name, "direction"))
-       {
-         std::string direction_str;
-         XMLhelper::node_list_get_string(doc, cur->children, 1, direction_str);
+  XMLFileReader reader(doc,cur);
+  reader.read_string("type", type);
+  reader.read_int("owner-id", owner_id);
+  reader.read_vector("position", pos);
+  reader.read_int("release-rate", release_rate);
+  
+  std::string direction_str;
+  reader.read_string("directorion-rate", direction_str);
 
-         if (direction_str == "left")
-           direction = EntranceData::LEFT;
-         else if (direction_str == "right")
-           direction = EntranceData::RIGHT;
-         else if (direction_str == "misc")
-           direction = EntranceData::MISC;
-       }
-      else
-       {
-         printf("Unhandled: %s\n", (char*)cur->name);
-       }       
-      cur = cur->next; 
-    }
+  if (direction_str == "left")
+    direction = EntranceData::LEFT;
+  else if (direction_str == "right")
+    direction = EntranceData::RIGHT;
+  else if (direction_str == "misc")
+    direction = EntranceData::MISC;
+  else
+    direction = EntranceData::MISC;
 }
 
 EntranceData::EntranceData (const EntranceData& old) : WorldObjData(old),

Index: exit_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/exit_data.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- exit_data.cxx       28 Oct 2002 20:13:40 -0000      1.4
+++ exit_data.cxx       18 Feb 2003 01:23:52 -0000      1.5
@@ -20,6 +20,7 @@
 #include <iostream>
 #include "../string_converter.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/exit_obj.hxx"
 #include "../worldobjs/exit.hxx"
 #include "exit_data.hxx"
@@ -39,40 +40,10 @@
       std::cout << "XMLPLF: Use Old Pos Handling: " << use_old_pos_handling << 
std::endl;
     }
 
-  /* 
-     PropertyReader reader();
-
-     reader.reg_bool("use-old-pos-handling", false, OPTIONAL);
-     reader.reg_pos ("position", false, OPTIONAL);
-   */
-
-  cur = cur->children;
-  while (cur)
-    {
-      if (xmlIsBlankNode(cur)) 
-       {
-         cur = cur->next;
-         continue;
-       }
-      
-      if (XMLhelper::equal_str(cur->name, "position"))
-       {
-         pos = XMLhelper::parse_vector(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "surface"))
-       {
-         desc = XMLhelper::parse_surface(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "owner-id"))
-       {
-         owner_id = XMLhelper::parse_int(doc, cur);
-       }
-      else
-       {
-         std::cout << "XMLPLF: Unhandled exit tag: " << (char*)cur->name << 
std::endl;
-       }
-      cur = cur->next; 
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
+  reader.read_desc("surface", desc);
+  reader.read_int("owner-id", owner_id);
 }
 
 ExitData::ExitData (const ExitData& old) : WorldObjData(old),

Index: guillotine_data.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/guillotine_data.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- guillotine_data.cxx 27 Sep 2002 18:36:41 -0000      1.7
+++ guillotine_data.cxx 18 Feb 2003 01:23:52 -0000      1.8
@@ -20,6 +20,7 @@
 #include <iostream>
 #include "guillotine_data.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/guillotine_obj.hxx"
 #include "../worldobjs/guillotine.hxx"
 #include "../pingus_resource.hxx"
@@ -37,20 +38,8 @@
   if (cur->name)
     std::cout << reinterpret_cast<const char*>(cur->name) << std::endl;
       
-  cur = cur->children;
-  while (cur)
-    {
-      XMLhelper::skip_blank(cur);
-
-      if (XMLhelper::equal_str(cur->name, "position")) 
-       {
-         pos = XMLhelper::parse_vector(doc, cur);
-       }
-      else
-       std::cout << reinterpret_cast<const char*>(cur->name) << std::endl;
-         
-      cur = cur->next;
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
 }
 
 GuillotineData::GuillotineData (const GuillotineData& old) : WorldObjData(old),

Index: hammer_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/hammer_data.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- hammer_data.cxx     1 Oct 2002 23:40:19 -0000       1.8
+++ hammer_data.cxx     18 Feb 2003 01:23:52 -0000      1.9
@@ -20,6 +20,7 @@
 #include <iostream>
 #include "hammer_data.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/hammer_obj.hxx"
 #include "../worldobjs/hammer.hxx"
 #include "../pingus_resource.hxx"
@@ -32,18 +33,8 @@
 
 HammerData::HammerData (xmlDocPtr doc, xmlNodePtr cur)
 {
-  cur = cur->children;
-  while (cur)
-    {
-      XMLhelper::skip_blank(cur);
-
-      if (XMLhelper::equal_str(cur->name, "position")) 
-       {
-         pos = XMLhelper::parse_vector(doc, cur);
-       }
-         
-      cur = cur->next;
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
 }
 
 HammerData::HammerData (const HammerData& old) 

Index: hotspot_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/hotspot_data.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- hotspot_data.cxx    27 Sep 2002 18:36:41 -0000      1.3
+++ hotspot_data.cxx    18 Feb 2003 01:23:52 -0000      1.4
@@ -21,6 +21,7 @@
 #include "../editorobjs/hotspot_obj.hxx"
 #include "../worldobjs/hotspot.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "hotspot_data.hxx"
 
 namespace WorldObjsData {
@@ -42,37 +43,11 @@
 
 HotspotData::HotspotData (xmlDocPtr doc, xmlNodePtr cur)
 {
-  cur = cur->children;
-  while (cur)
-    {
-      if (xmlIsBlankNode(cur)) 
-       {
-         cur = cur->next;
-         continue;
-       }
-      
-      if (XMLhelper::equal_str(cur->name, "surface"))
-       {
-         desc = XMLhelper::parse_surface(doc, cur);
-       } 
-      else if (XMLhelper::equal_str(cur->name, "position")) 
-       {
-         pos = XMLhelper::parse_vector(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "speed")) 
-       {
-         speed = XMLhelper::parse_int(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "parallax"))
-       {
-         para = XMLhelper::parse_int(doc, cur);
-       }
-      else
-       {
-         std::cout << "XMLPLF: parse_hotspot: Unhandled: " << cur->name << 
std::endl;
-       }
-      cur = cur->next;
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
+  reader.read_desc("surface", desc);
+  reader.read_int("speed", speed);
+  reader.read_float("parallax", para);
 }
 
 HotspotData::HotspotData (const HotspotData& old) : WorldObjData(old),

Index: laser_exit_data.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/laser_exit_data.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- laser_exit_data.cxx 27 Sep 2002 18:36:41 -0000      1.7
+++ laser_exit_data.cxx 18 Feb 2003 01:23:52 -0000      1.8
@@ -20,6 +20,7 @@
 #include <iostream>
 #include "laser_exit_data.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/laser_exit_obj.hxx"
 #include "../worldobjs/laser_exit.hxx"
 #include "../pingus_resource.hxx"
@@ -32,18 +33,8 @@
 
 LaserExitData::LaserExitData (xmlDocPtr doc, xmlNodePtr cur) : 
surface(PingusResource::load_surface("Traps/laser_exit", "traps"))
 {
-  cur = cur->children;
-  while (cur)
-    {
-      XMLhelper::skip_blank(cur);
-
-      if (XMLhelper::equal_str(cur->name, "position")) 
-       {
-         pos = XMLhelper::parse_vector(doc, cur);
-       }
-         
-      cur = cur->next;
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
 }
 
 LaserExitData::LaserExitData (const LaserExitData& old) : WorldObjData(old),

Index: liquid_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/liquid_data.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- liquid_data.cxx     2 Oct 2002 19:20:19 -0000       1.5
+++ liquid_data.cxx     18 Feb 2003 01:23:52 -0000      1.6
@@ -22,6 +22,7 @@
 #include "../worldobjs/liquid.hxx"
 #include "../string_converter.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "liquid_data.hxx"
 
 namespace WorldObjsData {
@@ -45,30 +46,11 @@
       std::cout << "XMLPLF: Use Old Width Handling: " << old_width_handling << 
std::endl;
     }
 
-  cur = cur->children;
-  while (cur)
-    {
-      if (xmlIsBlankNode(cur)) 
-       {
-         cur = cur->next;
-         continue;
-       }
-
-      if (XMLhelper::equal_str(cur->name, "position"))
-       pos = XMLhelper::parse_vector(doc, cur);
-      else if (XMLhelper::equal_str(cur->name, "surface"))
-       desc = XMLhelper::parse_surface(doc, cur);
-      else if (XMLhelper::equal_str(cur->name, "speed"))
-       speed = XMLhelper::parse_int(doc, cur);
-      else if (XMLhelper::equal_str(cur->name, "width"))
-       width = XMLhelper::parse_int(doc, cur);
-      else
-       {
-         std::cout << "XMLPLF::parse_liquid: Unhandled: " << cur->name << 
std::endl;
-       }       
-
-      cur = cur->next;
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
+  reader.read_desc("surface", desc);
+  reader.read_int("speed", speed);
+  reader.read_int("width", width);
 }
 
 LiquidData::LiquidData (const LiquidData& old) : WorldObjData(old),

Index: smasher_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/smasher_data.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- smasher_data.cxx    27 Sep 2002 18:36:41 -0000      1.7
+++ smasher_data.cxx    18 Feb 2003 01:23:52 -0000      1.8
@@ -20,6 +20,7 @@
 #include <iostream>
 #include "smasher_data.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/smasher_obj.hxx"
 #include "../worldobjs/smasher.hxx"
 #include "../pingus_resource.hxx"
@@ -32,18 +33,8 @@
 
 SmasherData::SmasherData (xmlDocPtr doc, xmlNodePtr cur) : 
surface(PingusResource::load_surface("Traps/smasher", "traps"))
 {
-  cur = cur->children;
-  while (cur)
-    {
-      XMLhelper::skip_blank(cur);
-
-      if (XMLhelper::equal_str(cur->name, "position")) 
-       {
-         pos = XMLhelper::parse_vector(doc, cur);
-       }
-         
-      cur = cur->next;
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
 }
 
 SmasherData::SmasherData (const SmasherData& old) : WorldObjData(old),

Index: solid_color_background_data.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/solid_color_background_data.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- solid_color_background_data.cxx     27 Sep 2002 18:36:41 -0000      1.3
+++ solid_color_background_data.cxx     18 Feb 2003 01:23:52 -0000      1.4
@@ -18,7 +18,8 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <iostream>
-#include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
+#include "../xml_file_writer.hxx"
 #include "../editorobjs/solid_color_background_obj.hxx"
 #include "../worldobjs/solid_color_background.hxx"
 #include "solid_color_background_data.hxx"
@@ -27,25 +28,8 @@
 
 SolidColorBackgroundData::SolidColorBackgroundData (xmlDocPtr doc, xmlNodePtr 
cur)
 {
-  cur = cur->children;
-  while (cur)
-    {
-      if (xmlIsBlankNode(cur)) 
-       {
-         cur = cur->next;
-         continue;
-       }
-
-      if (XMLhelper::equal_str(cur->name, "color"))
-       {
-         color = XMLhelper::parse_color (doc, cur);
-       }
-      else
-       {
-         std::cout << "SolidColorBackground: Unhandled tag: " << cur->name << 
std::endl;
-       }
-      cur = cur->next;
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_color("color", color);
 }
 
 SolidColorBackgroundData::SolidColorBackgroundData (const 
SolidColorBackgroundData& old)
@@ -58,7 +42,10 @@
 void
 SolidColorBackgroundData::write_xml (std::ostream& xml)
 {
-  xml << "<worldobj type=\"solidcolor-background\"></worldobj>" << std::endl;
+  XMLFileWriter writer(xml);
+  writer.begin_section("worldobj", "type=\"solidcolor-background\"");
+  writer.write_color("color", color);
+  writer.end_section();
 }
 
 WorldObj* 

Index: spike_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/spike_data.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- spike_data.cxx      27 Sep 2002 18:36:41 -0000      1.7
+++ spike_data.cxx      18 Feb 2003 01:23:52 -0000      1.8
@@ -20,6 +20,7 @@
 #include <iostream>
 #include "spike_data.hxx"
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/spike_obj.hxx"
 #include "../worldobjs/spike.hxx"
 #include "../pingus_resource.hxx"
@@ -30,20 +31,11 @@
 {
 }
 
-SpikeData::SpikeData (xmlDocPtr doc, xmlNodePtr cur) : 
surface(PingusResource::load_surface("Traps/spike", "traps"))
+SpikeData::SpikeData (xmlDocPtr doc, xmlNodePtr cur)
+  : surface(PingusResource::load_surface("Traps/spike", "traps"))
 {
-  cur = cur->children;
-  while (cur)
-    {
-      XMLhelper::skip_blank(cur);
-
-      if (XMLhelper::equal_str(cur->name, "position")) 
-       {
-         pos = XMLhelper::parse_vector(doc, cur);
-       }
-         
-      cur = cur->next;
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
 }
 
 SpikeData::SpikeData (const SpikeData& old) : WorldObjData(old),

Index: spike_data.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjsdata/spike_data.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- spike_data.hxx      28 Sep 2002 11:52:27 -0000      1.4
+++ spike_data.hxx      18 Feb 2003 01:23:52 -0000      1.5
@@ -28,7 +28,8 @@
 
 namespace WorldObjsData {
 
-class SpikeData : public WorldObjData {
+class SpikeData : public WorldObjData 
+{
 public:
   CL_Surface  surface;
   Vector   pos;

Index: starfield_background_data.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/starfield_background_data.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- starfield_background_data.cxx       28 Sep 2002 19:31:07 -0000      1.5
+++ starfield_background_data.cxx       18 Feb 2003 01:23:52 -0000      1.6
@@ -18,7 +18,7 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <iostream>
-#include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/starfield_background_obj.hxx"
 #include "../worldobjs/starfield_background.hxx"
 #include "starfield_background_data.hxx"
@@ -34,48 +34,23 @@
 
 StarfieldBackgroundData::StarfieldBackgroundData (const 
StarfieldBackgroundData& old)
   : WorldObjData(old),
-     small_stars_count(old. small_stars_count),
+    small_stars_count(old. small_stars_count),
     middle_stars_count(old.middle_stars_count),
-     large_stars_count(old. large_stars_count)
+    large_stars_count(old. large_stars_count)
 {
 }
  
 StarfieldBackgroundData::StarfieldBackgroundData (xmlDocPtr doc, xmlNodePtr 
cur)
 {
-   small_stars_count = 100;
+  small_stars_count = 100;
   middle_stars_count = 50;
-   large_stars_count = 25;
+  large_stars_count = 25;
 
-  cur = cur->children;
 
-  while (cur)
-    {
-      if (xmlIsBlankNode(cur)) 
-       {
-         cur = cur->next;
-         continue;
-       }
-      
-      if (XMLhelper::equal_str(cur->name, "small-stars"))
-       {
-         XMLhelper::get_prop(cur, "count", small_stars_count);
-       }
-      else if (XMLhelper::equal_str(cur->name, "middle-stars"))
-       {
-         XMLhelper::get_prop(cur, "count", middle_stars_count);
-       }
-      else if (XMLhelper::equal_str(cur->name, "large-stars"))
-       {
-         XMLhelper::get_prop(cur, "count", large_stars_count);
-       }
-      else
-       {
-         std::cout << "StarfildBackgroundData:create: Unhandled tag: " << 
cur->name << std::endl;
-       } 
-      cur = cur->next;
-    }
-    
-  UNUSED_ARG(doc);
+  XMLFileReader reader(doc, cur);
+  reader.read_int("small-stars", small_stars_count);
+  reader.read_int("middle-stars", middle_stars_count);
+  reader.read_int("large-stars", large_stars_count);
 }
 
 void 

Index: surface_background_data.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/surface_background_data.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- surface_background_data.cxx 12 Oct 2002 00:22:56 -0000      1.5
+++ surface_background_data.cxx 18 Feb 2003 01:23:52 -0000      1.6
@@ -19,6 +19,7 @@
 
 #include <iostream>
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/surface_background_obj.hxx"
 #include "../worldobjs/surface_background.hxx"
 #include "surface_background_data.hxx"
@@ -78,57 +79,21 @@
 {
   pos.z = -150;
 
-  cur = cur->children;  
-  while (cur)
-    {
-      if (xmlIsBlankNode(cur)) 
-       {
-         cur = cur->next;
-         continue;
-       }
+  XMLFileReader reader(doc, cur);
 
-      if (XMLhelper::equal_str(cur->name, "surface"))
-       {
-         desc = XMLhelper::parse_surface(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "color"))
-       {
-         color = XMLhelper::parse_color(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "para-x"))
-       {
-         para_x = XMLhelper::parse_float(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "para-y"))
-       {
-         para_y = XMLhelper::parse_float(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "scroll-x"))
-       {
-         scroll_x = XMLhelper::parse_float(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "scroll-y"))
-       {
-         scroll_y = XMLhelper::parse_float(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "stretch-x"))
-       {
-         stretch_x = XMLhelper::parse_bool(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "stretch-y"))
-       {
-         stretch_y = XMLhelper::parse_bool(doc, cur);
-       }
-      else if (XMLhelper::equal_str(cur->name, "position"))
-       {
-         pos = XMLhelper::parse_vector(doc, cur);  
-       }
-      else
-       {
-         std::cout << "XMLPLF::parse_background(): Unhandled: " << cur->name 
<< std::endl;
-       }
-      cur = cur->next;
-    }      
+  reader.read_desc("surface", desc);
+  reader.read_color("color", color);
+
+  reader.read_float("para-x", para_x);
+  reader.read_float("para-y", para_y);
+
+  reader.read_float("scroll-x", scroll_x);
+  reader.read_float("scroll-y", scroll_y);
+  
+  reader.read_bool("stretch-x", stretch_x);
+  reader.read_bool("stretch-y", stretch_y);
+
+  reader.read_vector("position", pos);
 }
 
 WorldObj* 

Index: thunderstorm_background_data.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/worldobjsdata/thunderstorm_background_data.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- thunderstorm_background_data.cxx    27 Sep 2002 18:36:42 -0000      1.3
+++ thunderstorm_background_data.cxx    18 Feb 2003 01:23:52 -0000      1.4
@@ -19,6 +19,7 @@
 
 #include <iostream>
 #include "../xml_helper.hxx"
+#include "../xml_file_reader.hxx"
 #include "../editorobjs/thunderstorm_background_obj.hxx"
 #include "../worldobjs/thunderstorm_background.hxx"
 #include "thunderstorm_background_data.hxx"
@@ -40,20 +41,8 @@
 
 ThunderstormBackgroundData::ThunderstormBackgroundData (xmlDocPtr doc, 
xmlNodePtr cur)
 {
-  cur = cur->children; 
-  while (cur)
-    {
-      if (xmlIsBlankNode(cur)) {
-       cur = cur->next;
-       continue;
-      }
-
-      if (XMLhelper::equal_str(cur->name, "position")) {
-       pos = XMLhelper::parse_vector (doc, cur);
-      } else {
-       std::cout << "ThunderstormBackgroundData::create(xmlDocPtr doc, 
xmlNodePtr cur) error" << std::endl;
-      }
-    }
+  XMLFileReader reader(doc, cur);
+  reader.read_vector("position", pos);
 }
 
 WorldObj* 





reply via email to

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