pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src world.hxx,1.6,1.7 world.cxx,1.15,1.16


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src world.hxx,1.6,1.7 world.cxx,1.15,1.16
Date: 22 Aug 2002 02:17:22 -0000

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

Modified Files:
        world.hxx world.cxx 
Log Message:
replaced std::list by std::vector

Index: world.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- world.hxx   16 Aug 2002 13:03:35 -0000      1.6
+++ world.hxx   22 Aug 2002 02:17:19 -0000      1.7
@@ -21,6 +21,7 @@
 #define HEADER_PINGUS_WORLD_HXX
 
 #include <list>
+#include <vector>
 #include <string>
 #include "pingus.hxx"
 
@@ -73,8 +74,9 @@
   /// The time you have to finish a level
   int exit_time;
 
-  std::list<WorldObj*> * world_obj;
-
+  std::vector<WorldObj*> world_obj;
+  typedef std::vector<WorldObj*>::iterator WorldObjIter;
+  
   // These pointers hold objects and must be deleted
   ParticleHolder* particle_holder;
   PinguHolder*    pingus;

Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- world.cxx   22 Aug 2002 00:36:30 -0000      1.15
+++ world.cxx   22 Aug 2002 02:17:19 -0000      1.16
@@ -36,9 +36,6 @@
 using boost::shared_ptr;
 using Pingus::Actions::Bomber;
 
-typedef std::list<WorldObj*>::iterator WorldObjIter;
-
-
 static 
 bool WorldObj_less (WorldObj* a, WorldObj* b) 
 {
@@ -59,7 +56,6 @@
 
 World::World(PLF* arg_plf)
   : game_time (new GameTime (game_speed)),
-    world_obj (new std::list<WorldObj*>),
     particle_holder (new ParticleHolder()),
     pingus (new PinguHolder()),
     plf (arg_plf),
@@ -87,11 +83,10 @@
 {
   delete particle_holder;
   
-  for (WorldObjIter it = world_obj->begin(); it != world_obj->end(); ++it) {
+  for (WorldObjIter it = world_obj.begin(); it != world_obj.end(); ++it) {
     delete *it;
   }
   
-  delete world_obj;
   delete game_time;
 }
 
@@ -104,7 +99,7 @@
   y_of += y1;
 
   //unsigned int time = CL_System::get_time (); 
-  for(WorldObjIter obj = world_obj->begin(); obj != world_obj->end(); ++obj)
+  for(WorldObjIter obj = world_obj.begin(); obj != world_obj.end(); ++obj)
     {
       //unsigned int time = CL_System::get_time (); 
       (*obj)->draw_offset(x_of, y_of, s);
@@ -145,7 +140,7 @@
   // Let the pingus catch each other and
   // Let the traps catch the pingus and
   // Let the exit catch the pingus
-  for(WorldObjIter obj = world_obj->begin(); obj != world_obj->end(); ++obj)
+  for(WorldObjIter obj = world_obj.begin(); obj != world_obj.end(); ++obj)
     {
       // catch_pingu() is now done in relevant update() if WorldObj
       // needs to catch pingus.
@@ -178,7 +173,7 @@
   gfx_map = new PingusSpotMap(plf);
   colmap = gfx_map->get_colmap();
 
-  world_obj->push_back (gfx_map);
+  world_obj.push_back (gfx_map);
 }
 
 void
@@ -191,7 +186,7 @@
       i != weather_d.end();
       ++i)
     {
-      world_obj->push_back(WeatherGenerator::create(*i));
+      world_obj.push_back(WeatherGenerator::create(*i));
     }
 
   for (vector<WorldObjData*>::iterator i = worldobj_d.begin ();
@@ -200,25 +195,16 @@
     {
       WorldObj* obj = (*i)->create_WorldObj ();
       if (obj)
-       world_obj->push_back(obj);
+       world_obj.push_back(obj);
     }
 
-   world_obj->push_back(pingus);
+   world_obj.push_back(pingus);
 
-  // After all objects are in world_obj, sort them to there z_pos
-#ifdef WIN32
-  //FIXME: ingo: This is a workaround around the std::list::sort()
-  //FIXME: problem under MSVC6. This is copy&paste from an usenet
-  //FIXME: article, so it might work or not, never tested it.
-// world_obj->sort(std::greater<CWorldObjPtr>());
-#else
-   world_obj->sort(WorldObj_less);
-#endif
-  // FIXME: If the above thing causes throuble under windows we could
-  // use a vector instead of a list and use stable_sort() instead.
+   //world_obj->sort(WorldObj_less);
+   std::stable_sort (world_obj.begin (), world_obj.end (), WorldObj_less);
 
   // Drawing all world objs to the colmap
-  for(WorldObjIter obj = world_obj->begin(); obj != world_obj->end(); ++obj)
+  for(WorldObjIter obj = world_obj.begin(); obj != world_obj.end(); ++obj)
     (*obj)->draw_colmap();
 
   // Setup the gravity force





reply via email to

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