Author: alink
Date: Mon Apr  6 01:08:59 2009
New Revision: 34572

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34572&view=rev
Log:
Fix the crash part of bug #13323: Attack plus dialog crashes Wesnoth
Thanks to Crab to have spotted the bad line

Modified:
    branches/1.6/src/mouse_events.cpp

Modified: branches/1.6/src/mouse_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/mouse_events.cpp?rev=34572&r1=34571&r2=34572&view=diff
==============================================================================
--- branches/1.6/src/mouse_events.cpp (original)
+++ branches/1.6/src/mouse_events.cpp Mon Apr  6 01:08:59 2009
@@ -654,8 +654,6 @@
 
                gui().draw();
 
-               const bool defender_human = 
teams_[defender->second.side()-1].is_human();
-
                
recorder.add_attack(attacker_loc,defender_loc,att.attack_num,def.attack_num);
 
                //MP_COUNTDOWN grant time bonus for attacking
@@ -667,12 +665,20 @@
                        //if the level ends due to a unit being killed, still 
see if
                        //either the attacker or defender should advance
                        dialogs::advance_unit(map_,units_,attacker_loc,gui());
+                       unit_map::const_iterator defu = 
units_.find(defender_loc);
+                       if (defu != units_.end()) {
+                               bool defender_human = 
teams_[defu->second.side()-1].is_human();
+                               
dialogs::advance_unit(map_,units_,defender_loc,gui(),!defender_human);
+                       }
+                       throw;
+               }
+
+               dialogs::advance_unit(map_,units_,attacker_loc,gui());
+               unit_map::const_iterator defu = units_.find(defender_loc);
+               if (defu != units_.end()) {
+                       bool defender_human = 
teams_[defu->second.side()-1].is_human();
                        
dialogs::advance_unit(map_,units_,defender_loc,gui(),!defender_human);
-                       throw;
-               }
-
-               dialogs::advance_unit(map_,units_,attacker_loc,gui());
-               
dialogs::advance_unit(map_,units_,defender_loc,gui(),!defender_human);
+               }
 
                check_victory(units_, teams_, gui());
 


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

Reply via email to