mail[Wesnoth-commits] r33196 - /trunk/src/mouse_events.cpp


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

Header


Content

Posted by alinktomine on March 01, 2009 - 04:16:
Author: alink
Date: Sun Mar  1 04:16:27 2009
New Revision: 33196

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33196&view=rev
Log:
Continue to simplify the code of move+attack

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=33196&r1=33195&r2=33196&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Sun Mar  1 04:16:27 2009
@@ -365,9 +365,8 @@
        //see if we're trying to do a attack or move-and-attack
        if(!browse && !commands_disabled && attack_from.valid()) {
                if (attack_from == selected_hex_) { //no move needed
-                       if (attack_enemy(u, clicked_u) == false) {
-                               return false;
-                       }
+                       attack_enemy(u, clicked_u);
+                       return false;
                }
                else if (move_unit_along_current_route(false, true)) {//move 
the unit without updating shroud
                        // a WML event could have invalidated both attacker 
and defender
@@ -375,12 +374,15 @@
                        u = find_unit(attack_from);
                        unit_map::iterator enemy = find_unit(hex);
                        if(u != units_.end() && u->second.side() == team_num_ 
&&
-                               enemy != units_.end() && 
current_team().is_enemy(enemy->second.side()) && 
!enemy->second.incapacitated()) {
+                               enemy != units_.end() && 
current_team().is_enemy(enemy->second.side()) && 
!enemy->second.incapacitated()
+                               && !commands_disabled) {
 
                                // reselect the unit to make the attacker's 
stats appear during the attack dialog
                                gui().select_hex(attack_from);
 
-                               if(!commands_disabled && 
attack_enemy(u,enemy) == false) {
+                               if(attack_enemy(u,enemy)) { // Fight !!
+                                       return false;
+                               } else { //canceled attack, undo the move
                                        undo_ = true;
                                        selected_hex_ = src;
                                        gui().select_hex(src);
@@ -388,23 +390,17 @@
                                        gui().highlight_reach(current_paths_);
                                        return false;
                                }
-                               else //attack == true
-                               {
-                                       // execute the move stored in the 
undo stack
-                                       // this will update shroud, trigger 
sighted event and redraw
-                                       clear_undo_stack();
-                                       return false;
-                               }
-                       }
-               }
-
-               if(check_shroud && clear_shroud(gui(), map_, units_, teams_, 
team_num_ - 1)) {
-                       clear_undo_stack();
-                       gui().invalidate_all();
-                       gui().draw();
-               }
-
-               return false;
+                       }
+                       else {  // the attack is not valid anymore, abort
+                               return false;
+                       }
+                       
+               }
+               else { // interrupted move
+                       // we assume that move_unit() did the cleaning
+                       // (update shroud/fog, clear undo if needed)
+                       return false;
+               }
        }
 
        //otherwise we're trying to move to a hex
@@ -416,9 +412,9 @@
                gui().unhighlight_reach();
                move_unit_along_current_route(check_shroud);
        } else if (!attackmove_) {
+               // we select a (maybe empty) hex
                // we block selection during attack+move (because motion is 
blocked)
                // FIXME: deal with selected event when commands_disabled
-               // we select a (maybe empty) hex
                select_hex(hex, browse);
        }
        return false;




Related Messages


Powered by MHonArc, Updated Sun Mar 01 04:40:12 2009