CleverRaven/Cataclysm-DDA — pull request #6633 by BevapDin (2014-03-14 11:52:42+00:00)
Title: Attempt to fix the cougar leap bug

This removes the visibility check for the leap target before calculating the clear path.

What "might" have been is this (I've never been able to reproduce it):
During sunset/sunrise the natural light level (see `game::light_level`) might be anything from 1 to 60. `monster::vision_range` uses that light level and reduces it further based on the monster flags. For cougars it is reduced by 10 because of the flag `MF_VIS50`. This can result in a vision range of below 3, which means the the check will fail for some possible points.

That in turn means `blocked_path` is not changed and remains `false`. The next if clause will check the visibility of the leap target again, but this time with `game::light_level` as range parameter. This might now succeed (because the MF_VIS50 penalty is not applied here). And `blocked_path` is still `false`.

That would allow the monster to take that path.

Disclaimer: I've never witnessed that bug.

I've moved the easier checks (is_empty, rl_dist, sees) before the path checking "for speed" (won't be much). Also there is only one visibility check there anymore.

----

And there is another possible bug: the code sets `best` to `rl_dist(g->u, x, y)` when else were it uses `rl_dist(target, x, y)` (see second commit).