Messenger MAI bug fix: don't try to attack with escort unit without weapon

This one was a much more serious bug than the previous one, as it could
throw Wesnoth into an infinite loop.
This commit is contained in:
mattsc 2013-08-29 08:36:58 -07:00
parent 2f56734d4e
commit 14570a0a96

View file

@ -98,7 +98,15 @@ return {
local my_units = wesnoth.get_units{ side = wesnoth.current.side, formula = '$this_unit.attacks_left > 0',
{ "not", { id = unit.id } }
}
-- Eliminate units without attacks
for i = #my_units,1,-1 do
if (not H.get_child(my_units[i].__cfg, 'attack')) then
table.remove(my_units, i)
end
end
--print('#my_units', #my_units)
if (not my_units[1]) then return end
local my_attacks = AH.get_attacks(my_units, { simulate_combat = true })