ai_helper.move_unit_out_of_way: prevent potential for divide-by-zero
dx = dy = 0 is a perfectly acceptable choice of values when there is no preferred direction.
This commit is contained in:
parent
7f7217cf15
commit
09e3891668
1 changed files with 1 additions and 1 deletions
|
@ -1464,7 +1464,7 @@ function ai_helper.move_unit_out_of_way(ai, unit, cfg)
|
|||
local dx, dy
|
||||
if cfg.dx and cfg.dy then
|
||||
local r = math.sqrt(cfg.dx * cfg.dx + cfg.dy * cfg.dy)
|
||||
dx, dy = cfg.dx / r, cfg.dy / r
|
||||
if (r ~= 0) then dx, dy = cfg.dx / r, cfg.dy / r end
|
||||
end
|
||||
|
||||
local reach = wesnoth.find_reach(unit, cfg)
|
||||
|
|
Loading…
Add table
Reference in a new issue