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.15,1.16 pingu_hold


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src pingu_holder.cxx,1.15,1.16 pingu_holder.hxx,1.13,1.14 world.cxx,1.30,1.31 world.hxx,1.17,1.18
Date: 8 Oct 2002 00:09:57 -0000

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

Modified Files:
        pingu_holder.cxx pingu_holder.hxx world.cxx world.hxx 
Log Message:
- changed from list::iterator to pingu_id for the armageddon_count, that should 
be more robust

Index: pingu_holder.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_holder.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- pingu_holder.cxx    4 Oct 2002 16:54:04 -0000       1.15
+++ pingu_holder.cxx    8 Oct 2002 00:09:55 -0000       1.16
@@ -176,4 +176,10 @@
   return number_of_allowed;
 }
 
+unsigned int
+PinguHolder::get_end_id()
+{
+  return all_pingus.size();
+}
+
 /* EOF */

Index: pingu_holder.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_holder.hxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- pingu_holder.hxx    4 Oct 2002 16:54:04 -0000       1.13
+++ pingu_holder.hxx    8 Oct 2002 00:09:55 -0000       1.14
@@ -102,6 +102,9 @@
       dead or exited */
   Pingu* get_pingu(unsigned int id);
 
+  /** @return the id of the last pingu + 1 */
+  unsigned int get_end_id();
+
   // FIXME: Dirty cruft, needs cleanup
   std::list<Pingu*>::iterator  begin () { return pingus.begin (); }
   std::list<Pingu*>::iterator  end ()   { return pingus.end (); }

Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- world.cxx   4 Oct 2002 16:54:04 -0000       1.30
+++ world.cxx   8 Oct 2002 00:09:55 -0000       1.31
@@ -150,10 +150,23 @@
 {
   game_time->update ();
 
-  if (do_armageddon && armageddon_count != pingus->end())
+  if (do_armageddon)
     {
-      // The iterator here might be invalid
-      (*armageddon_count)->request_set_action(Bomber);
+      while (armageddon_count < pingus->get_end_id())
+        {
+          Pingu* pingu = pingus->get_pingu(armageddon_count);
+      
+          if (pingu && pingu->get_status() == PS_ALIVE)
+            {
+              pingu->request_set_action(Bomber);
+              break;
+            }
+          else
+            {
+              ++armageddon_count;
+            }
+        }
+      
       ++armageddon_count;
     }
     
@@ -206,8 +219,7 @@
 {
   PingusSound::play_sound ("sounds/goodidea.wav");
   do_armageddon = true;
-  // FIXME: Ugly to use iterator, since it can get invalid
-  armageddon_count = pingus->begin();
+  armageddon_count = 0;
 }
 
 ColMap*

Index: world.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.hxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- world.hxx   4 Oct 2002 16:54:04 -0000       1.17
+++ world.hxx   8 Oct 2002 00:09:55 -0000       1.18
@@ -65,7 +65,7 @@
 
   /** FIXME: ugly hack to iterate over all pingus and make bombers out
       of them, should use pingus_id instead */
-  std::list<Pingu*>::iterator armageddon_count;
+  unsigned int armageddon_count;
 
   std::vector<WorldObj*> world_obj;
   typedef std::vector<WorldObj*>::iterator WorldObjIter;





reply via email to

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