pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/input axis_factory.cxx,1.11,1.12 butt


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/input axis_factory.cxx,1.11,1.12 button_factory.cxx,1.10,1.11 pointer_factory.cxx,1.8,1.9 scroller_factory.cxx,1.9,1.10
Date: 28 Sep 2002 19:31:08 -0000

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

Modified Files:
        axis_factory.cxx button_factory.cxx pointer_factory.cxx 
        scroller_factory.cxx 
Log Message:
made XMLhelper::get_prop more versatile (may have introduced bugs)


Index: axis_factory.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/axis_factory.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- axis_factory.cxx    10 Sep 2002 21:03:32 -0000      1.11
+++ axis_factory.cxx    28 Sep 2002 19:31:06 -0000      1.12
@@ -17,7 +17,6 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-#include <stdlib.h>
 #include "../xml_helper.hxx"
 #include "../pingus_error.hxx"
 #include "axis_factory.hxx"
@@ -61,13 +60,10 @@
 
 Axis* AxisFactory::button_axis (xmlNodePtr cur)
 {
-  char * angle_str = XMLhelper::get_prop(cur, "angle");
-  if (!angle_str)
+  float angle;
+  if (!XMLhelper::get_prop(cur, "angle", angle))
     PingusError::raise("ButtonAxis without angle parameter");
 
-  float angle = strtod(angle_str, reinterpret_cast<char**>(NULL));
-  xmlFree(angle_str);
-
   cur = XMLhelper::skip_blank(cur->children);
   Button* button1 = ButtonFactory::create(cur);   
 
@@ -84,45 +80,31 @@
 
 Axis* AxisFactory::joystick_axis (xmlNodePtr cur)
 {
-  char * angle_str = XMLhelper::get_prop(cur, "angle");
-  if (!angle_str)
+  float angle;
+  if (!XMLhelper::get_prop(cur, "angle", angle))
     PingusError::raise("JoystickAxis without angle parameter");
-
-  char * id_str    = XMLhelper::get_prop(cur, "id");
-  if (!id_str)
+    
+  int id;
+  if (!XMLhelper::get_prop(cur, "id", id))
     PingusError::raise("JoystickAxis without id parameter");
-
-  char * axis_str  = XMLhelper::get_prop(cur, "axis");
-  if (!axis_str)
+    
+  int axis;
+  if (!XMLhelper::get_prop(cur, "axis", axis))
     PingusError::raise("JoystickAxis without axis parameter");
 
-  float angle = strtod(angle_str, reinterpret_cast<char**>(NULL));
-  int   id    = strtol(id_str,    reinterpret_cast<char**>(NULL), 10);
-  int   axis  = strtol(axis_str,  reinterpret_cast<char**>(NULL), 10);
-
-  xmlFree(angle_str);
-  xmlFree(id_str);
-  xmlFree(axis_str);
-
   return new JoystickAxis(id, axis, angle);
 }
 
 Axis* AxisFactory::mouse_axis (xmlNodePtr cur)
 {
-  char * angle_str = XMLhelper::get_prop(cur, "angle");
-  if (!angle_str)
+  float angle;
+  if (!XMLhelper::get_prop(cur, "angle", angle))
     PingusError::raise("MouseAxis without angle parameter");
-
-  char * axis_str  = XMLhelper::get_prop(cur, "axis");
-  if (!axis_str)
+    
+  int axis;
+  if (!XMLhelper::get_prop(cur, "axis", axis))
     PingusError::raise("MouseAxis without axis parameter");
-
-  float angle = strtod(angle_str, reinterpret_cast<char**>(NULL));
-  int   axis  = strtol(axis_str,  reinterpret_cast<char**>(NULL), 10);
-
-  xmlFree(angle_str);
-  xmlFree(axis_str);
-
+  
   return new MouseAxis(axis, angle);
 }
 

Index: button_factory.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/button_factory.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- button_factory.cxx  10 Sep 2002 21:03:32 -0000      1.10
+++ button_factory.cxx  28 Sep 2002 19:31:06 -0000      1.11
@@ -17,7 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-#include <stdlib.h>
+#include <iostream>
 #include "../xml_helper.hxx"
 #include "../pingus_error.hxx"
 #include "button_factory.hxx"
@@ -76,44 +76,31 @@
 
 Button* ButtonFactory::joystick_button (xmlNodePtr cur)
 {
-  char * id_str = XMLhelper::get_prop(cur, "id");
-  if (!id_str)
+  int id;
+  if (!XMLhelper::get_prop(cur, "id", id))
     PingusError::raise("JoystickButton without id parameter");
-
-  char * button_str = XMLhelper::get_prop(cur, "button");
-  if (!button_str)
+    
+  int button;
+  if (!XMLhelper::get_prop(cur, "button", button))
     PingusError::raise("JoystickButton without button parameter");
 
-  int id     = strtol(id_str,     reinterpret_cast<char**>(NULL), 10);
-  int button = strtol(button_str, reinterpret_cast<char**>(NULL), 10);
-
-  xmlFree(id_str);
-  xmlFree(button_str);
-
   return new JoystickButton(id, button);
 }
 
 Button* ButtonFactory::key_button (xmlNodePtr cur)
 {
-  char * key_str = XMLhelper::get_prop(cur, "key");
-  if (!key_str)
+  std::string key;
+  if (!XMLhelper::get_prop(cur, "key", key))
     PingusError::raise("KeyButton without key parameter");
-
-  int key = KeyHelper::string_to_key(key_str);
-
-  xmlFree(key_str);
-
-  return new KeyButton(key);
+    
+  return new KeyButton(KeyHelper::string_to_key(key));
 }
 
 Button* ButtonFactory::mouse_button (xmlNodePtr cur)
 {
-  char * button_str = XMLhelper::get_prop(cur, "button");
-  if (!button_str)
+  int button;
+  if (!XMLhelper::get_prop(cur, "button", button))
     PingusError::raise("MouseButton without button parameter");
-
-  int button = strtol(button_str, reinterpret_cast<char**>(NULL), 10);
-  xmlFree(button_str);
 
   return new MouseButton(button);
 }

Index: pointer_factory.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/pointer_factory.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pointer_factory.cxx 10 Sep 2002 21:03:32 -0000      1.8
+++ pointer_factory.cxx 28 Sep 2002 19:31:06 -0000      1.9
@@ -17,7 +17,6 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-#include <stdlib.h>
 #include "../xml_helper.hxx"
 #include "../pingus_error.hxx"
 #include "axis_factory.hxx"
@@ -52,12 +51,9 @@
 
 Pointer* PointerFactory::axis_pointer (xmlNodePtr cur)
 {
-  char* speed_str = XMLhelper::get_prop(cur, "speed");
-  if (!speed_str)
+  float speed;
+  if (!XMLhelper::get_prop(cur, "speed", speed))
     PingusError::raise("AxisPointer without speed parameter");
-
-  float speed = strtod(speed_str, reinterpret_cast<char**>(NULL));
-  xmlFree(speed_str);
 
   std::vector<Axis*> axes;
   cur = cur->children;

Index: scroller_factory.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/scroller_factory.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- scroller_factory.cxx        10 Sep 2002 21:03:32 -0000      1.9
+++ scroller_factory.cxx        28 Sep 2002 19:31:06 -0000      1.10
@@ -72,12 +72,9 @@
 Scroller*
 ScrollerFactory::axis_scroller (xmlNodePtr cur)
 {
-  char * speed_str = XMLhelper::get_prop(cur, "speed");
-  if (!speed_str)
+  float speed;
+  if (!XMLhelper::get_prop(cur, "speed", speed))
     PingusError::raise("AxisScroller without speed parameter");
-  
-  float speed = strtod(speed_str, reinterpret_cast<char**>(NULL));
-  xmlFree(speed_str);
 
   std::vector<Axis*> axes;
   cur = cur->children;
@@ -100,20 +97,14 @@
 Scroller*
 ScrollerFactory::inverted_scroller (xmlNodePtr cur)
 {
-  char * invert_x_str = XMLhelper::get_prop(cur, "invert-x");
-  if (!invert_x_str)
+  bool invert_x;
+  if (!XMLhelper::get_prop(cur, "invert-x", invert_x))
     PingusError::raise("InvertedScroller without invert X parameter");
-  
-  char * invert_y_str = XMLhelper::get_prop(cur, "invert-y");
-  if (!invert_y_str)
+
+  bool invert_y;
+  if (!XMLhelper::get_prop(cur, "invert-y", invert_y))
     PingusError::raise("InvertedScroller without invert Y parameter");
-    
-  bool invert_x = strtol(invert_x_str, reinterpret_cast<char**>(NULL), 10);
-  bool invert_y = strtol(invert_x_str, reinterpret_cast<char**>(NULL), 10);
-  
-  xmlFree(invert_x_str);
-  xmlFree(invert_y_str);
-  
+
   Scroller* scroller;
   cur = XMLhelper::skip_blank(cur->children);
   scroller = create(cur);
@@ -124,19 +115,13 @@
 Scroller*
 ScrollerFactory::joystick_scroller (xmlNodePtr cur)
 {
-  char * id_str = XMLhelper::get_prop(cur, "id");
-  if (!id_str)
+  int id;
+  if (!XMLhelper::get_prop(cur, "id", id))
     PingusError::raise("JoystickScroller without id parameter");
-  
-  char * speed_str = XMLhelper::get_prop(cur, "speed");
-  if (!speed_str)
+    
+  float speed;
+  if (!XMLhelper::get_prop(cur, "speed", speed))
     PingusError::raise("JoystickScroller without speed parameter");
-
-  int   id    = strtol(id_str,    reinterpret_cast<char**>(NULL), 10);
-  float speed = strtod(speed_str, reinterpret_cast<char**>(NULL));
-  
-  xmlFree(id_str);
-  xmlFree(speed_str);
   
   return new JoystickScroller(id, speed);
 }
@@ -178,7 +163,6 @@
   return new PointerScroller(pointer, button);
 }
 
-}
+} // namespace Input
 
 /* EOF */
-





reply via email to

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