Author: mordante
Date: Sat Mar  1 23:30:29 2008
New Revision: 24185

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24185&view=rev
Log:
When a new unit is spawned when the attacker dies and the new unit has
a lower number of weapons then the weapon number used in the attack an 
wml_exception was thrown (bug #10926).

(The case of the defender dying was already fixed, retested to be sure.)

Modified:
    trunk/changelog
    trunk/src/actions.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=24185&r1=24184&r2=24185&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sat Mar  1 23:30:29 2008
@@ -39,6 +39,9 @@
    * fix a bug where the random map generator could place a keep on the border
      (bug #11150)
    * Fixed UI sounds toggle crash on Windows
+   * When a new unit is spawned when the attacker dies and the new unit has
+     a lower number of weapons then the weapon number used in the attack an 
+     wml_exception was thrown (bug #10926).
 
 Version 1.3.19:
  * map editor:

Modified: trunk/src/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=24185&r1=24184&r2=24185&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Sat Mar  1 23:30:29 2008
@@ -1322,7 +1322,11 @@
                                fire_event("attack_end");
                                DELAY_END_LEVEL(delayed_exception, 
game_events::fire("die",death_loc,defender_loc));
 
-                               refresh_bc();
+                               // Don't try to call refresh_bc() here the 
attacker or defender might have
+                               // been replaced by another unit, which might 
have a lower number of weapons.
+                               // In that case refresh_bc() will terminate 
with an invalid selected weapon.
+                               a_ = units_.find(attacker_);
+                               d_ = units_.find(defender_);
 
                                if(a_ == units_.end() || 
!death_loc.matches_unit(a_->second)) {
                                        // WML has invalidated the dying unit, 
abort


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

Reply via email to