Author: tschmitz
Date: Sun Jul 24 23:41:27 2011
New Revision: 50398

URL: http://svn.gna.org/viewcvs/wesnoth?rev=50398&view=rev
Log:
Whiteboard execution now halts if a unit is sighted on the last hex of a move.

Modified:
    trunk/src/actions.cpp
    trunk/src/actions.hpp
    trunk/src/mouse_events.cpp
    trunk/src/mouse_events.hpp
    trunk/src/whiteboard/move.cpp

Modified: trunk/src/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=50398&r1=50397&r2=50398&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Sun Jul 24 23:41:27 2011
@@ -2344,7 +2344,8 @@
                 replay* move_recorder, undo_list* undo_stack,
                 bool show_move,
                 map_location *next_unit, bool continue_move,
-                bool should_clear_shroud, bool is_replay)
+                bool should_clear_shroud, bool is_replay,
+                bool* units_sighted_result)
 {
        assert(route.empty() == false);
 
@@ -2549,6 +2550,9 @@
 
        assert(steps.size() <= route.size());
 
+       if(units_sighted_result)
+               *units_sighted_result = !seen_units.empty();
+
        // If we can't get all the way there and have to set a go-to.
        if(steps.size() != route.size() && discovered_unit == false) {
                if(seen_units.empty() == false) {

Modified: trunk/src/actions.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.hpp?rev=50398&r1=50397&r2=50398&view=diff
==============================================================================
--- trunk/src/actions.hpp (original)
+++ trunk/src/actions.hpp Sun Jul 24 23:41:27 2011
@@ -401,13 +401,15 @@
  * a goto order will be set.
  * If move_recorder is not NULL, the move will be recorded in it.
  * If undos is not NULL, undo information will be added.
+ * If units_sighted_result is not NULL, it will indicate whether a sighting 
occurred.
  */
 size_t move_unit(move_unit_spectator* move_spectator,
        const std::vector<map_location> &steps,
                                replay* move_recorder, undo_list* undos,
                                bool show_move,
                                map_location *next_unit = NULL,
-                               bool continue_move = false, bool 
should_clear_shroud=true, bool is_replay=false);
+                               bool continue_move = false, bool 
should_clear_shroud=true, bool is_replay=false,
+                               bool* units_sighted_result = NULL);
 
 /** Function which recalculates the fog. */
 void recalculate_fog(int side);

Modified: trunk/src/mouse_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.cpp?rev=50398&r1=50397&r2=50398&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Sun Jul 24 23:41:27 2011
@@ -716,7 +716,7 @@
        return finished_moves;
 }
 
-bool mouse_handler::move_unit_along_route(pathfind::marked_route const& route, 
map_location* next_unit, bool check_shroud)
+bool mouse_handler::move_unit_along_route(pathfind::marked_route const& route, 
map_location* next_unit, bool check_shroud, bool* sighted_result)
 {
        const std::vector<map_location> steps = route.steps;
        if(steps.empty()) {
@@ -725,7 +725,7 @@
 
        size_t moves = 0;
        try {
-                       moves = ::move_unit(NULL, steps, &recorder, 
resources::undo_stack, true, next_unit, false, check_shroud);
+               moves = ::move_unit(NULL, steps, &recorder, 
resources::undo_stack, true, next_unit, false, check_shroud, false, 
sighted_result);
        } catch(end_turn_exception&) {
                cursor::set(cursor::NORMAL);
                gui().invalidate_game_status();

Modified: trunk/src/mouse_events.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.hpp?rev=50398&r1=50397&r2=50398&view=diff
==============================================================================
--- trunk/src/mouse_events.hpp (original)
+++ trunk/src/mouse_events.hpp Sun Jul 24 23:41:27 2011
@@ -70,7 +70,8 @@
        // wrapper to catch bad_alloc so this should be called
        void attack_enemy(const map_location& attacker_loc, const map_location& 
defender_loc, int choice);
 
-       bool move_unit_along_route(pathfind::marked_route const& route, 
map_location* next_unit, bool check_shroud);
+       // output arg: sighted_result: if not NULL, indicates whether a "unit 
sighted" occurred
+       bool move_unit_along_route(pathfind::marked_route const& route, 
map_location* next_unit, bool check_shroud, bool* sighted_result = NULL);
 
 protected:
        /**

Modified: trunk/src/whiteboard/move.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/move.cpp?rev=50398&r1=50397&r2=50398&view=diff
==============================================================================
--- trunk/src/whiteboard/move.cpp (original)
+++ trunk/src/whiteboard/move.cpp Sun Jul 24 23:41:27 2011
@@ -230,11 +230,12 @@
 
        map_location final_location;
        bool steps_finished;
+       bool enemy_sighted;
        {
                events::mouse_handler& mouse_handler = 
resources::controller->get_mouse_handler_base();
                team const& owner_team = resources::teams->at(team_index());
                try {
-                       steps_finished = 
mouse_handler.move_unit_along_route(*route_, &final_location, 
owner_team.auto_shroud_updates());
+                       steps_finished = 
mouse_handler.move_unit_along_route(*route_, &final_location, 
owner_team.auto_shroud_updates(), &enemy_sighted);
                } catch (end_turn_exception&) {
                        set_arrow_brightness(ARROW_BRIGHTNESS_STANDARD);
                        throw; // we rely on the caller to delete this action
@@ -255,8 +256,16 @@
        {
                if (steps_finished && route_->steps.back() == final_location) 
//reached destination
                {
-                       // Everything went smoothly
-                       result = action::SUCCESS;
+                       if(enemy_sighted)
+                       {
+                               LOG_WB << "Move completed, but interrupted on 
final hex. Halting.\n";
+                               //reset to a single-hex path, just in case 
*this is a wb::attack
+                               arrow_.reset();
+                               route_->steps = 
std::vector<map_location>(1,route_->steps.back());
+                               result = action::PARTIAL;
+                       }
+                       else // Everything went smoothly
+                               result = action::SUCCESS;
                }
                else // Move was interrupted, probably by enemy unit sighted
                {


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to