battle_calcs.lua: avoid using formula= in SUFs
It’s slow for finding units with moves or attacks left. The alternative method of getting all units and then looping over the table with a condition is much faster.
This commit is contained in:
parent
19eff08fd7
commit
e87240c67f
1 changed files with 4 additions and 2 deletions
|
@ -1131,8 +1131,10 @@ function battle_calcs.get_attack_map_unit(unit, cfg)
|
|||
-- MP left off the map (for enemy pathfinding)
|
||||
local units_MP = {}
|
||||
if (unit.side ~= wesnoth.current.side) then
|
||||
units_MP = wesnoth.get_units { side = wesnoth.current.side, formula = '$this_unit.moves > 0' }
|
||||
for _,uMP in ipairs(units_MP) do wesnoth.extract_unit(uMP) end
|
||||
local all_units = wesnoth.get_units { side = wesnoth.current.side }
|
||||
for _,unit in ipairs(all_units) do
|
||||
if (unit.moves > 0) then table.insert(units_MP, unit) end
|
||||
end
|
||||
end
|
||||
|
||||
-- Find hexes the unit can reach
|
||||
|
|
Loading…
Add table
Reference in a new issue