pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src pingu_holder.cxx,1.2,1.3


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src pingu_holder.cxx,1.2,1.3
Date: 17 Jun 2002 09:54:46 -0000

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

Modified Files:
        pingu_holder.cxx 
Log Message:
changed for loop to while in draw_offset since it's cleaner in this case


Index: pingu_holder.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_holder.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pingu_holder.cxx    13 Jun 2002 14:25:12 -0000      1.2
+++ pingu_holder.cxx    17 Jun 2002 09:54:44 -0000      1.3
@@ -34,8 +34,8 @@
 {
   // Deleting all Pingu objects
   std::cout << "PinguHolder: Deleting pingus" << std::endl;
-  for(std::vector<Pingu*>::iterator i = all_pingus.begin(); 
-      i != all_pingus.end(); ++i) 
+  for(std::vector<Pingu*>::iterator i = all_pingus.begin();
+      i != all_pingus.end(); ++i)
     delete *i;
 }
 
@@ -66,7 +66,9 @@
 void
 PinguHolder::draw_offset(int x_of, int y_of, float s)
 {
-  for(PinguIter pingu = pingus.begin(); pingu != pingus.end(); ++pingu)
+  PinguIter pingu = pingus.begin();
+  
+  while(pingu != pingus.end())
     {
       if ((*pingu)->get_status() == PS_DEAD)
        {
@@ -74,13 +76,11 @@
          // the correct possition, no memory hole since pingus will
          // keep track of the allocated Pingus
          pingu = pingus.erase(pingu);
-         pingu--;
        }
       else if ((*pingu)->get_status() == PS_EXITED) 
        {
          saved_pingus++;
          pingu = pingus.erase(pingu);
-         pingu--;        
        }
       else 
        {
@@ -88,11 +88,14 @@
          // all other pingus, for better visibility
          if (!(*pingu)->get_action())
            (*pingu)->draw_offset(x_of, y_of, s);
+         
+         // move to the next Pingu
+         pingu++;
        }
     }
 
   // We draw all actions here, so we have them above all others
-  for(PinguIter pingu = pingus.begin(); pingu != pingus.end(); pingu++)
+  for(pingu = pingus.begin(); pingu != pingus.end(); pingu++)
     {
       if ((*pingu)->get_action()) 
        (*pingu)->draw_offset(x_of, y_of, s);




reply via email to

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