mail[Wesnoth-commits] r43832 - in /trunk/src/whiteboard: side_actions.cpp side_actions.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by gabrielmorin on July 02, 2010 - 06:22:
Author: gabba
Date: Fri Jul  2 06:22:35 2010
New Revision: 43832

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43832&view=rev
Log:
Whiteboard: move actions that don't finish to the end of the queue

Modified:
    trunk/src/whiteboard/side_actions.cpp
    trunk/src/whiteboard/side_actions.hpp

Modified: trunk/src/whiteboard/side_actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/side_actions.cpp?rev=43832&r1=43831&r2=43832&view=diff
==============================================================================
--- trunk/src/whiteboard/side_actions.cpp (original)
+++ trunk/src/whiteboard/side_actions.cpp Fri Jul  2 06:22:35 2010
@@ -57,14 +57,21 @@
        if (!actions_.empty() && validate_iterator(position))
        {
                size_t distance = std::distance(begin(), position);
-               action_ptr& action = *position;
+               action_ptr action = *position;
                bool finished = action->execute();
                if (finished)
                {
-                       remove_action(position);
-               }
-               validate_actions();
-               return begin() + distance;
+                       actions_.erase(position);
+                       validate_actions();
+                       return begin() + distance;
+               }
+               else
+               {
+                       actions_.erase(position);
+                       actions_.insert(end(), action);
+                       validate_actions();
+                       return end() - 1;
+               }
        }
        else
        {
@@ -143,7 +150,7 @@
                side_actions::iterator position;
                for (position = start_position; position != end(); ++position)
                {
-                       action_ptr& action = *position;
+                       action_ptr action = *position;
                        if (&action->get_unit() == &unit)
                        {
                                return position;
@@ -165,7 +172,7 @@
                side_actions::iterator position;
                for (position = start_position; position != begin() - 1; 
--position)
                {
-                       action_ptr& action = *position;
+                       action_ptr action = *position;
                        if (&action->get_unit() == &unit)
                        {
                                return position;
@@ -220,7 +227,7 @@
        if (actions_.empty() || !validate_iterator(position))
                return end();
 
-       const action_ptr& action = *position;
+       action_ptr action = *position;
        action_set::iterator after = actions_.erase(position);
        //be careful, previous iterators have just been invalidated by erase()
        action_set::iterator destination = after + increment;

Modified: trunk/src/whiteboard/side_actions.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/side_actions.hpp?rev=43832&r1=43831&r2=43832&view=diff
==============================================================================
--- trunk/src/whiteboard/side_actions.hpp (original)
+++ trunk/src/whiteboard/side_actions.hpp Fri Jul  2 06:22:35 2010
@@ -58,6 +58,7 @@
 
        /**
         * Executes the specified action, if it exists in the queue.
+        * If the action is not finished, it's moved at the end of the queue.
         * @return An iterator to the action itself if not finished, or else 
the next action in the queue.
         *         Returns end() if no actions remain.
         */




Related Messages


Powered by MHonArc, Updated Fri Jul 02 07:00:07 2010