Author: silene
Date: Thu May  7 00:02:25 2009
New Revision: 35464

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35464&view=rev
Log:
Restored dysplay of attack options.

Modified:
    trunk/src/mouse_events.cpp
    trunk/src/mouse_events.hpp

Modified: trunk/src/mouse_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.cpp?rev=35464&r1=35463&r2=35464&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Thu May  7 00:02:25 2009
@@ -13,10 +13,13 @@
    See the COPYING file for more details.
 */
 
+#include "global.hpp"
+
 #include "mouse_events.hpp"
 
 #include "attack_prediction_display.hpp"
 #include "dialogs.hpp"
+#include "foreach.hpp"
 #include "game_end_exceptions.hpp"
 #include "game_events.hpp"
 #include "gettext.hpp"
@@ -696,21 +699,24 @@
        }
 }
 
-void mouse_handler::show_attack_options(unit_map::const_iterator /*u*/)
-{
-#if 0
-       team& current_team = teams_[team_num_-1];
-
-       if(u == units_.end() || u->second.attacks_left() == 0)
+void mouse_handler::show_attack_options(const unit_map::const_iterator &u)
+{
+       const team &current_team = teams_[team_num_ - 1];
+
+       if (u == units_.end() || u->second.attacks_left() == 0)
                return;
 
-       for(unit_map::const_iterator target = units_.begin(); target != 
units_.end(); ++target) {
-               if(current_team.is_enemy(target->second.side()) &&
-                       distance_between(target->first,u->first) == 1 && 
!target->second.incapacitated()) {
-                       current_paths_.routes[target->first] = paths::route();
-               }
-       }
-#endif
+       map_location adj[6];
+       get_adjacent_tiles(u->first, adj);
+       foreach (const map_location &loc, adj)
+       {
+               if (!map_.on_board(loc)) continue;
+               unit_map::const_iterator i = units_.find(loc);
+               if (i == units_.end()) continue;
+               const unit &target = i->second;
+               if (current_team.is_enemy(target.side()) && 
!target.incapacitated())
+                       current_paths_.destinations.insert(loc);
+       }
 }
 
 bool mouse_handler::unit_in_cycle(unit_map::const_iterator it)

Modified: trunk/src/mouse_events.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.hpp?rev=35464&r1=35463&r2=35464&view=diff
==============================================================================
--- trunk/src/mouse_events.hpp (original)
+++ trunk/src/mouse_events.hpp Thu May  7 00:02:25 2009
@@ -83,7 +83,7 @@
        bool attack_enemy(unit_map::iterator attacker, unit_map::iterator 
defender);
        // the real function but can throw bad_alloc
        bool attack_enemy_(unit_map::iterator attacker, unit_map::iterator 
defender);
-       void show_attack_options(unit_map::const_iterator u);
+       void show_attack_options(const unit_map::const_iterator &u);
        map_location current_unit_attacks_from(const map_location& loc);
        unit_map::const_iterator find_unit(const map_location& hex) const;
        unit_map::iterator find_unit(const map_location& hex);


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

Reply via email to