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.cc,1.72,1.73


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src World.cc,1.72,1.73
Date: 10 Jun 2002 10:28:53 -0000

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

Modified Files:
        World.cc 
Log Message:
fixed std::list::sort for MSVC6

Index: World.cc
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/World.cc,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- World.cc    9 Jun 2002 14:28:03 -0000       1.72
+++ World.cc    10 Jun 2002 10:28:50 -0000      1.73
@@ -43,14 +43,23 @@
 using namespace std;
 using boost::shared_ptr;
 
-// Structure for the sorting algorithm (stable_sort)
-struct WorldObj_less
+static 
+bool WorldObj_less (shared_ptr<WorldObj>& a, shared_ptr<WorldObj>& b) 
 {
-  bool operator() (shared_ptr<WorldObj>& a, shared_ptr<WorldObj>& b) const 
-  {
-    return a->get_z_pos () < b->get_z_pos ();
-  }
-};
+  return a->get_z_pos () < b->get_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.
+typedef shared_ptr<WorldObj>& CWorldObjPtr;
+template<>
+bool std::greater<CWorldObjPtr>::operator()(shared_ptr<WorldObj>& a, 
shared_ptr<WorldObj>& b) const
+{
+  return WorldObj_less (a, b);
+} 
+#endif
 
 World::World(PLF* arg_plf)
   : particle_holder (new ParticleHolder()),
@@ -202,9 +211,12 @@
 
   // After all objects are in world_obj, sort them to there z_pos
 #ifdef WIN32
-  // FIXME: Insert something here which will sort a list under 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());
+  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.




reply via email to

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