mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-30 01:47:13 +00:00
Fixed a crash when the attacker dies while performing a desparate attack.
The crash seemed only to happen under Windows but valgrind also complained (bug #10496)
This commit is contained in:
parent
0fabf930b2
commit
65c891c5b4
@ -44,6 +44,9 @@ Version 1.3.12+svn:
|
||||
* The MP server can send gzipped data depending on a hidden parameter
|
||||
which is off by default.
|
||||
* The campaign server sends and receives binary_wml.
|
||||
* fixed a crash when the attacker dies while performing a desparate attack.
|
||||
The crash seemed only to happen under Windows but valgrind also
|
||||
complained (bug #10496)
|
||||
|
||||
Version 1.3.12:
|
||||
* campaigns:
|
||||
|
14
src/ai.cpp
14
src/ai.cpp
@ -1071,7 +1071,19 @@ bool ai::do_combat(std::map<gamemap::location,paths>& possible_moves, const move
|
||||
}
|
||||
}
|
||||
|
||||
void ai_interface::attack_enemy(const location& u, const location& target, int weapon, int def_weapon)
|
||||
//! This function should be called to attack an enemy.
|
||||
//!
|
||||
//! @param u The location of the attacking unit. (Note this shouldn't
|
||||
//! be a reference since attack::attack() can invalidate the
|
||||
//! unit_map and references to the map are also invalid then.)
|
||||
//! @param target The location of the target unit. This unit must be in
|
||||
//! range of the attacking unit's weapon. (See note at param u.)
|
||||
//! @param weapon The number of the weapon (0-based) which should be used
|
||||
//! by the attacker. (It must be a valid weapon of the attacker.)
|
||||
//! @param def_weapon The number of the weapon (0-based) which should be used
|
||||
//! by the defender. (It must be a valid weapon of the defender.)
|
||||
void ai_interface::attack_enemy(const location u,
|
||||
const location target, int weapon, int def_weapon)
|
||||
{
|
||||
// Stop the user from issuing any commands while the unit is attacking
|
||||
const events::command_disabler disable_commands;
|
||||
|
@ -103,12 +103,7 @@ public:
|
||||
|
||||
protected:
|
||||
//! This function should be called to attack an enemy.
|
||||
//! 'attacking_unit': the location of the attacking unit
|
||||
//! 'target': the location of the target unit.
|
||||
// This unit must be in range of the attacking unit's weapon
|
||||
//! 'att_weapon': the number of the weapon (0-based) which should be used in the attack.
|
||||
//! This must be a valid weapon of the attacking unit.
|
||||
void attack_enemy(const location& attacking_unit, const location& target, int att_weapon, int def_weapon);
|
||||
void attack_enemy(const location u, const location target, int att_weapon, int def_weapon);
|
||||
|
||||
//! This function should be called to move a unit.
|
||||
//! Once the unit has been moved, its movement allowance is set to 0.
|
||||
|
@ -1026,6 +1026,8 @@ bool do_replay(game_display& disp, const gamemap& map, const game_data& gameinfo
|
||||
replay::throw_error("no destination/source found in attack\n");
|
||||
}
|
||||
|
||||
//we must get locations by value instead of by references, because the iterators
|
||||
//may become invalidated later
|
||||
const gamemap::location src(*source, game_events::get_state_of_game());
|
||||
const gamemap::location dst(*destination, game_events::get_state_of_game());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user