mail[Wesnoth-commits] r44514 - in /trunk/src/whiteboard: attack.cpp manager.cpp move.cpp


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

Header


Content

Posted by gabrielmorin on July 22, 2010 - 02:32:
Author: gabba
Date: Thu Jul 22 02:32:28 2010
New Revision: 44514

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44514&view=rev
Log:
Whiteboard: transform move/attack to use pathfind::marked_route internally, 
step 5.

Modified:
    trunk/src/whiteboard/attack.cpp
    trunk/src/whiteboard/manager.cpp
    trunk/src/whiteboard/move.cpp

Modified: trunk/src/whiteboard/attack.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/attack.cpp?rev=44514&r1=44513&r2=44514&view=diff
==============================================================================
--- trunk/src/whiteboard/attack.cpp (original)
+++ trunk/src/whiteboard/attack.cpp Thu Jul 22 02:32:28 2010
@@ -40,7 +40,7 @@
 
 std::ostream& attack::print(std::ostream& s) const
 {
-       s << boost::static_pointer_cast<wb::move const>(shared_from_this()) 
<< " and attacking (" << get_target_hex() << ")";
+       s << boost::static_pointer_cast<wb::move>(shared_from_this()) << " 
and attacking (" << get_target_hex() << ")";
        return s;
 }
 

Modified: trunk/src/whiteboard/manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=44514&r1=44513&r2=44514&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Thu Jul 22 02:32:28 2010
@@ -273,20 +273,19 @@
                        return;
                }
                pathfind::marked_route::mark_map::const_iterator w = 
route.marks.find(hex);
-               if(w != route.marks.end() && w->second.turns == 1)
+               //We only accept an end-of-first-turn or a capture mark if 
this is the move's last hex.
+               if(w != route.marks.end() && (w->second.turns == 1 || 
w->second.capture))
                {
                        cancel = true;
                }
        }
 
-       if (route.steps.empty() || route.steps.size() < 2)
-       {
-               route_.reset(new pathfind::marked_route()); //empty route
-       }
-       else if (selected_unit_)
+       route_.reset(new pathfind::marked_route(route));
+
+       if (route_->steps.size() >= 2 && selected_unit_)
        {
                assert(selected_unit_->side() == 
resources::screen->viewing_side());
-               route_.reset(new pathfind::marked_route(route));
+
                //NOTE: route_.steps.back() = dst, and route_.steps.front() = 
src
 
                if (!move_arrow_)
@@ -358,7 +357,7 @@
                fake_unit_ptr fake_unit;
 
                map_location source_hex;
-               if (route_)
+               if (route_ && !route_->steps.empty())
                {
                        move_arrow = arrow_ptr(move_arrow_);
                        fake_unit = fake_unit_ptr(fake_unit_);
@@ -372,11 +371,13 @@
                {
                        move_arrow.reset(new arrow);
                        source_hex = attack_from;
+                       route_.reset(new pathfind::marked_route);
+                       // We'll pass as parameter a one-hex route with no 
marks.
+                       route_->steps.push_back(attack_from);
                }
 
                unit* attacking_unit = find_future_unit(source_hex);
                assert(attacking_unit);
-
 
                int weapon_choice = 
resources::controller->get_mouse_handler_base().show_attack_dialog(
                                        attacking_unit->get_location(), 
target_hex);

Modified: trunk/src/whiteboard/move.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/move.cpp?rev=44514&r1=44513&r2=44514&view=diff
==============================================================================
--- trunk/src/whiteboard/move.cpp (original)
+++ trunk/src/whiteboard/move.cpp Thu Jul 22 02:32:28 2010
@@ -73,9 +73,11 @@
   fake_unit_(fake_unit),
   valid_(true)
 {
-       assert(!route_->steps.empty());
-       source_hex_ = route_->steps.front();
-       dest_hex_ = route_->steps.back();
+       if(!route_->steps.empty())
+       {
+               source_hex_ = route_->steps.front();
+               dest_hex_ = route_->steps.back();
+       }
 
        unit_ = resources::whiteboard->find_future_unit(source_hex_);
        assert(unit_);




Related Messages


Powered by MHonArc, Updated Thu Jul 22 02:40:14 2010