pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.21,1.22 obj


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.21,1.22 object_manager.cxx,1.19,1.20 object_manager.hxx,1.11,1.12 object_selector.cxx,1.5,1.6 object_selector.hxx,1.4,1.5
Date: 2 Jul 2002 10:42:41 -0000

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

Modified Files:
        editor_event.cxx object_manager.cxx object_manager.hxx 
        object_selector.cxx object_selector.hxx 
Log Message:
replaced std::list<shared_ptr> with std::vector<EditorObj*>

Index: editor_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor_event.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- editor_event.cxx    2 Jul 2002 09:14:20 -0000       1.21
+++ editor_event.cxx    2 Jul 2002 10:42:38 -0000       1.22
@@ -440,7 +440,7 @@
               i != selection->get_objects().end();
               i++)
            { 
-             if ((*j).get() == *i)
+             if (*j == *i)
                {
                  group->add (*i);
                  to_erase.push_back(*i);
@@ -472,7 +472,7 @@
       i != object_manager->editor_objs.end(); 
       ++i) 
     {
-      selection->add((*i).get());
+      selection->add(*i);
     }
 }
 
@@ -648,7 +648,7 @@
 {
   editor->save_tmp_level();
 
-  std::list<boost::shared_ptr<EditorObj> > objs;
+  EditorObjLst objs;
   try 
     {
       disable();
@@ -666,7 +666,7 @@
       
   if (!objs.empty ()) 
     {
-      for (std::list<boost::shared_ptr<EditorObj> >::iterator i = objs.begin 
(); i != objs.end (); i++)
+      for (ObjectManager::EditorObjIter i = objs.begin (); i != objs.end (); 
i++)
        object_manager->editor_objs.push_back(*i);
     } 
   else 

Index: object_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- object_manager.cxx  2 Jul 2002 09:21:03 -0000       1.19
+++ object_manager.cxx  2 Jul 2002 10:42:38 -0000       1.20
@@ -42,8 +42,8 @@
 using namespace Actions;
 
 /** */
-static bool EditorObj_z_pos_sorter (const boost::shared_ptr<EditorObj>& a, 
-                                   const boost::shared_ptr<EditorObj>& b)
+static bool EditorObj_z_pos_sorter (EditorObj* a, 
+                                   EditorObj* b)
 {
   return a->get_z_pos () < b->get_z_pos ();
 }
@@ -119,7 +119,7 @@
   //background->desc.res_name = "Textures/default";
 
   delete_all_objs();
-  editor_objs.push_back(boost::shared_ptr<EditorObj>(new StartPos(50, 50)));
+  editor_objs.push_back(new StartPos(50, 50));
 
   // Set some default actions
   actions = default_actions;
@@ -129,7 +129,9 @@
 void
 ObjectManager::delete_all_objs()
 {
-  // Fixme: Memory hole the pointers needs to be delete'd
+  for (EditorObjIter it = editor_objs.begin(); it != editor_objs.end(); ++it)
+    delete *it;
+
   editor_objs.clear();
 }
 
@@ -154,8 +156,8 @@
   //psm.parse (filename + ".psm");
   //psm.load_surfaces();
 
-  editor_objs.push_back(boost::shared_ptr<EditorObj>(new 
StartPos(plf->get_startx(), 
-                                                                 
plf->get_starty())));
+  editor_objs.push_back(new StartPos(plf->get_startx(), 
+                                    plf->get_starty()));
 
   vector<GroundpieceData>  temp_surfaces = plf->get_groundpieces();
   for (vector<GroundpieceData>::iterator i = temp_surfaces.begin();
@@ -169,20 +171,20 @@
   vector<WorldObjData*> temp_worldobj = plf->get_worldobjs_data();
 
   for (vector<GroundpieceData>::iterator i = temp_surfaces.begin(); i != 
temp_surfaces.end(); ++i) {
-    const list<boost::shared_ptr<EditorObj> > & temp = i->create_EditorObj();
+    const EditorObjLst& temp = i->create_EditorObj();
     editor_objs.insert(editor_objs.end(), temp.begin(), temp.end() );
   }
 
 
   for (vector<WeatherData>::iterator i = temp_weather.begin(); i != 
temp_weather.end(); ++i) {
-    const list<boost::shared_ptr<EditorObj> > & temp = i->create_EditorObj();
+    const EditorObjLst& temp = i->create_EditorObj();
     editor_objs.insert(editor_objs.end(), temp.begin(), temp.end() );
   }
 
   for (vector<WorldObjData*>::iterator i = temp_worldobj.begin();
        i != temp_worldobj.end();
        ++i) {
-    const list<boost::shared_ptr<EditorObj> > & temp = 
(*i)->create_EditorObj();
+    const EditorObjLst& temp = (*i)->create_EditorObj();
     editor_objs.insert(editor_objs.end(), temp.begin(), temp.end() );
   }
 
@@ -337,7 +339,7 @@
   EditorObjIter current;
   EditorObjIter prev;
   
-  current = std::find_if(editor_objs.begin(), editor_objs.end(), 
EditorObj_finder(obj));
+  current = std::find(editor_objs.begin(), editor_objs.end(), obj);
 
   if (current == editor_objs.begin()) 
     {
@@ -363,7 +365,7 @@
   EditorObjIter current;
   EditorObjIter next;
   
-  current = std::find_if (editor_objs.begin(), editor_objs.end(), 
EditorObj_finder(obj));
+  current = std::find (editor_objs.begin(), editor_objs.end(), obj);
   next    = current;
   next++;
   
@@ -411,7 +413,7 @@
 
   for (EditorObjIter it = editor_objs.begin(); it != editor_objs.end(); ++it)
     if ((*it)->is_in_rect(CL_Rect(x1, y1, x2, y2)))
-      retval.push_back(it->get ());
+      retval.push_back(*it);
       
   return retval;
 }
@@ -419,14 +421,15 @@
 void
 ObjectManager::add (EditorObj* obj)
 {
-  editor_objs.push_back (boost::shared_ptr<EditorObj>(obj));
+  editor_objs.push_back (obj);
 }
 
 void
 ObjectManager::erase (EditorObj* obj)
 {
-  editor_objs.erase(std::remove_if (editor_objs.begin(), editor_objs.end(), 
EditorObj_finder(obj)),
+  editor_objs.erase(std::remove (editor_objs.begin(), editor_objs.end(), obj),
                    editor_objs.end ());
+  delete obj;
 }
 
 void
@@ -434,8 +437,9 @@
 {
   for (std::vector<EditorObj*>::const_iterator i = objs.begin (); i != 
objs.end (); ++i)
     {
-      editor_objs.erase(std::remove_if (editor_objs.begin(), 
editor_objs.end(), EditorObj_finder(*i)),
+      editor_objs.erase(std::remove (editor_objs.begin(), editor_objs.end(), 
*i),
                        editor_objs.end ());
+      delete *i;
     }
 }
 
@@ -446,7 +450,7 @@
     {
       if ((*i)->is_over(pos))
        {
-         return i->get ();
+         return *i;
        }
     }
   
@@ -510,7 +514,7 @@
     {
       xmlNodePtr cur = doc->ROOT;
       WorldObjGroupData* group = new WorldObjGroupData (doc, cur);
-      const std::list<boost::shared_ptr<EditorObj> >& temp = 
group->create_EditorObj ();
+      const EditorObjLst& temp = group->create_EditorObj ();
       editor_objs.insert(editor_objs.end(),temp.begin(), temp.end());
       delete group;
     }

Index: object_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.hxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- object_manager.hxx  2 Jul 2002 09:14:20 -0000       1.11
+++ object_manager.hxx  2 Jul 2002 10:42:39 -0000       1.12
@@ -58,7 +58,7 @@
   std::string comment;
 
   /** All objects which are visible in the editor */ 
-  std::vector<boost::shared_ptr<EditorObj> > editor_objs;
+  std::vector<EditorObj*> editor_objs;
 
   /** This list contains all objects, which are in the current
       selection */
@@ -70,9 +70,8 @@
   PLF* plf;
   
 public:
-  typedef std::vector<boost::shared_ptr<EditorObj> >::iterator EditorObjIter;
-  typedef std::vector<boost::shared_ptr<EditorObj> >::reverse_iterator 
EditorObjRIter;
-  typedef std::vector<boost::shared_ptr<EditorObj> >::iterator CurrentObjIter;
+  typedef std::vector<EditorObj*>::iterator EditorObjIter;
+  typedef std::vector<EditorObj*>::reverse_iterator EditorObjRIter;
 
   ObjectManager();
   ~ObjectManager();

Index: object_selector.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_selector.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- object_selector.cxx 25 Jun 2002 12:20:33 -0000      1.5
+++ object_selector.cxx 2 Jul 2002 10:42:39 -0000       1.6
@@ -67,7 +67,7 @@
   
 /** FIXME: Ugly interface, the arguments should not be the offset, but
     instead the absolute position */
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_obj(int x_off, int y_off)
 {
 
@@ -82,7 +82,7 @@
   return select_obj_type();
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_trap()
 {
   TrapData trap;
@@ -127,7 +127,7 @@
          trap.type = "bumper";
          break;
        case CL_KEY_ESCAPE:
-         return std::list<boost::shared_ptr<EditorObj> >();
+         return EditorObjLst();
        }
       CL_System::keep_alive ();
       CL_System::sleep (20);
@@ -138,7 +138,7 @@
   return trap.create_EditorObj ();
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_groundpiece(const GroundpieceData::GPType & gptype)
 {
   GroundpieceData data;
@@ -153,15 +153,15 @@
       data.desc = ResDescriptor("resource:" + datafile, str);
       data.gptype = gptype;
 
-      std::list<boost::shared_ptr<EditorObj> > objs;
-      objs.push_back(boost::shared_ptr<EditorObj>(new 
EditorGroundpieceObj(data)));
+      EditorObjLst objs;
+      objs.push_back(new EditorGroundpieceObj(data));
       return objs;
     }
   
-  return std::list<boost::shared_ptr<EditorObj> >();
+  return EditorObjLst();
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_hotspot(const std::string& filename)
 {
   HotspotData data;
@@ -173,14 +173,14 @@
       data.desc = ResDescriptor("resource:" + filename, str);
       data.speed = -1;
 
-      std::list<boost::shared_ptr<EditorObj> > objs;
-      objs.push_back(boost::shared_ptr<EditorObj>(new EditorHotspot(data)));
+      EditorObjLst objs;
+      objs.push_back(new EditorHotspot(data));
       return objs;
     }
-  return std::list<boost::shared_ptr<EditorObj> >();
+  return EditorObjLst();
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_worldobj()
 {
   CL_Display::clear_display();
@@ -213,12 +213,12 @@
          return EditorInfoBox::create (pos);
          
        case CL_KEY_ESCAPE:
-         return std::list<boost::shared_ptr<EditorObj> >();
+         return EditorObjLst();
        }
     }
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_weather()
 {
   WeatherData weather;
@@ -245,12 +245,10 @@
        }
     }
   
-  std::list<boost::shared_ptr<EditorObj> > objs;
-  objs.push_back(boost::shared_ptr<EditorObj>(new WeatherObj(weather)));
-  return objs;
+  return weather.create_EditorObj ();
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_entrance()
 {
   EntranceData entrance;
@@ -297,7 +295,7 @@
   return entrance.create_EditorObj ();
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_exit()
 {
   string str;
@@ -309,16 +307,14 @@
   last_object = str;
 
   if (str.empty())
-    return std::list<boost::shared_ptr<EditorObj> >();
+    return EditorObjLst();
   
   data.desc = ResDescriptor("resource:exits", str);
   
-  std::list<boost::shared_ptr<EditorObj> > objs;
-  objs.push_back(boost::shared_ptr<EditorObj>(new ExitObj(data)));
-  return objs;
+  return data.create_EditorObj ();
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_liquid()
 {
   std::cout << "ObjectSelector::get_liquid() not implemented" << std::endl;
@@ -329,12 +325,10 @@
   data.width = 5;
   data.desc = ResDescriptor("Liquid/slime", "liquids", 
ResDescriptor::RD_RESOURCE);
 
-  std::list<boost::shared_ptr<EditorObj> > objs;
-  objs.push_back(boost::shared_ptr<EditorObj>(new LiquidObj(data)));
-  return objs;
+  return data.create_EditorObj ();
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_from_file()
 {
   CL_Display::clear_display();
@@ -371,9 +365,7 @@
            data.desc = ResDescriptor ("../../../../../../../../../../../" + 
file, 
                                       "", ResDescriptor::RD_FILE);
 
-           std::list<boost::shared_ptr<EditorObj> > objs;
-           objs.push_back(boost::shared_ptr<EditorObj>(new 
EditorHotspot(data)));
-           return objs;
+           return data.create_EditorObj();
          }
          break;
 
@@ -382,12 +374,12 @@
          break;
 
        case CL_KEY_ESCAPE:
-         return std::list<boost::shared_ptr<EditorObj> > (); 
+         return EditorObjLst (); 
        }
     }
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::select_obj_type()
 {
   bool exit_loop;
@@ -468,11 +460,11 @@
          break;
        }
     }
-  return std::list<boost::shared_ptr<EditorObj> > ();
+  return EditorObjLst ();
 }
 
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_prefab()
 {
   CL_DirectoryScanner dir;
@@ -505,10 +497,10 @@
          break;
        }
     }
-  return std::list<boost::shared_ptr<EditorObj> >();
+  return EditorObjLst();
 }
 
-std::list<boost::shared_ptr<EditorObj> >
+EditorObjLst
 ObjectSelector::get_background()
 {
   CL_Display::clear_display();
@@ -519,7 +511,7 @@
   font->print_left(20,110, _("4 - Thunderstorm Background"));
   Display::flip_display();
 
-  std::list<boost::shared_ptr<EditorObj> > lst;
+  EditorObjLst lst;
 
   bool exit_loop = false;
     
@@ -535,29 +527,22 @@
 
            if (!data.desc.res_name.empty())
              {
-               lst.push_back(boost::shared_ptr<EditorObj>
-                             (new EditorSurfaceBackground(data)));
+               lst = data.create_EditorObj ();
              }
            
          }
          exit_loop = true;
          break;
        case CL_KEY_2:
-         lst.push_back(boost::shared_ptr<EditorObj>
-                       (new EditorSolidColorBackground 
-                        (SolidColorBackgroundData ())));
+         lst = SolidColorBackgroundData ().create_EditorObj ();
          exit_loop = true;
          break;
        case CL_KEY_3:
-         lst.push_back(boost::shared_ptr<EditorObj>
-                       (new EditorStarfieldBackground 
-                        (StarfieldBackgroundData ())));
+         lst = StarfieldBackgroundData ().create_EditorObj ();
          exit_loop = true;
          break;
        case CL_KEY_4:
-         lst.push_back(boost::shared_ptr<EditorObj>
-                       (new EditorThunderstormBackground 
-                        (ThunderstormBackgroundData ())));
+         lst = ThunderstormBackgroundData ().create_EditorObj ();
          exit_loop = true;
          break;
        }

Index: object_selector.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_selector.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- object_selector.hxx 24 Jun 2002 23:31:24 -0000      1.4
+++ object_selector.hxx 2 Jul 2002 10:42:39 -0000       1.5
@@ -45,24 +45,24 @@
   ObjectSelector();
   ~ObjectSelector();
   
-  std::list<boost::shared_ptr<EditorObj> > select_obj_type();
+  EditorObjLst select_obj_type();
   std::string select_surface(std::vector<surface_obj>& sur_list);
   std::string select_surface(const std::string & resource_file);
   int    read_key();
   std::string read_string(const std::string &, const std::string &);
   
-  std::list<boost::shared_ptr<EditorObj> > get_obj(int, int);
-  std::list<boost::shared_ptr<EditorObj> > get_trap();
-  std::list<boost::shared_ptr<EditorObj> > get_groundpiece(const 
GroundpieceData::GPType & gptype);
-  std::list<boost::shared_ptr<EditorObj> > get_hotspot(const std::string&);
-  std::list<boost::shared_ptr<EditorObj> > get_entrance();
-  std::list<boost::shared_ptr<EditorObj> > get_exit();
-  std::list<boost::shared_ptr<EditorObj> > get_liquid();
-  std::list<boost::shared_ptr<EditorObj> > get_weather();
-  std::list<boost::shared_ptr<EditorObj> > get_worldobj();
-  std::list<boost::shared_ptr<EditorObj> > get_from_file();
-  std::list<boost::shared_ptr<EditorObj> > get_background();
-  std::list<boost::shared_ptr<EditorObj> > get_prefab();
+  EditorObjLst get_obj(int, int);
+  EditorObjLst get_trap();
+  EditorObjLst get_groundpiece(const GroundpieceData::GPType & gptype);
+  EditorObjLst get_hotspot(const std::string&);
+  EditorObjLst get_entrance();
+  EditorObjLst get_exit();
+  EditorObjLst get_liquid();
+  EditorObjLst get_weather();
+  EditorObjLst get_worldobj();
+  EditorObjLst get_from_file();
+  EditorObjLst get_background();
+  EditorObjLst get_prefab();
 };
 
 #endif




reply via email to

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