Author: alink
Date: Thu Apr 19 13:50:59 2007
New Revision: 16933
URL: http://svn.gna.org/viewcvs/wesnoth?rev=16933&view=rev
Log:
In mouse_motion, spare some find_unit by re-using previous results
Modified:
trunk/src/mouse_events.cpp
Modified: trunk/src/mouse_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.cpp?rev=16933&r1=16932&r2=16933&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Thu Apr 19 13:50:59 2007
@@ -766,8 +766,8 @@
//see if we should show the normal cursor, the movement cursor,
or
//the attack cursor
- const unit_map::const_iterator selected_unit =
find_unit(selected_hex_);
- const unit_map::const_iterator mouseover_unit =
find_unit(new_hex);
+ const unit_map::iterator selected_unit =
find_unit(selected_hex_);
+ const unit_map::iterator mouseover_unit = find_unit(new_hex);
gamemap::location attack_from;
if(selected_unit != units_.end() && mouseover_unit !=
units_.end()) {
@@ -797,15 +797,23 @@
(*gui_).set_route(NULL);
}
- const gamemap::location& dest = attack_from.valid() ?
attack_from : new_hex;
- const unit_map::const_iterator dest_un = find_unit(dest);
+ gamemap::location dest;
+ unit_map::const_iterator dest_un;
+ if (attack_from.valid()) {
+ dest = attack_from;
+ dest_un = find_unit(dest);
+ } else {
+ dest = new_hex;
+ dest_un = mouseover_unit;
+ }
+
if(dest == selected_hex_ || dest_un != units_.end()) {
current_route_.steps.clear();
(*gui_).set_route(NULL);
} else if(!current_paths_.routes.empty() &&
map_.on_board(selected_hex_) &&
map_.on_board(new_hex)) {
- unit_map::const_iterator un = find_unit(selected_hex_);
+ unit_map::const_iterator un = selected_unit;
if((new_hex != last_hex_ || attack_from.valid()) && un
!= units_.end() && !un->second.incapacitated()) {
current_route_ = get_route(un, dest,
current_team());
@@ -815,7 +823,7 @@
}
}
- unit_map::iterator un = find_unit(new_hex);
+ unit_map::iterator un = mouseover_unit;
if(un != units_.end() && current_paths_.routes.empty() &&
!(*gui_).fogged(un->first.x,un->first.y)) {
if (un->second.side() != team_num_) {
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits