diff options
author | Retro-Junk | 2016-10-01 15:03:00 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-10-01 14:48:06 +0200 |
commit | e61cb2285f33656ebeafd76e0cd7f74f0f2dd965 (patch) | |
tree | 867415481620864253fea40b7ff4d4e857cff62e | |
parent | 342c9cdc36d1e94e0edd1ad022c99040fdc89198 (diff) | |
download | scummvm-rg350-e61cb2285f33656ebeafd76e0cd7f74f0f2dd965.tar.gz scummvm-rg350-e61cb2285f33656ebeafd76e0cd7f74f0f2dd965.tar.bz2 scummvm-rg350-e61cb2285f33656ebeafd76e0cd7f74f0f2dd965.zip |
FULLPIPE: Fix MctlGraph::getNearestLink
-rw-r--r-- | engines/fullpipe/motion.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index 744032353e..331799f9b5 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -2735,16 +2735,16 @@ MovGraphLink *MctlGraph::getNearestLink(int x, int y) { double n1y = lnk->_graphSrc->_y; double n2x = lnk->_graphDst->_x; double n2y = lnk->_graphDst->_y; - double n1dx = n1x - x; + double n1dx = x - n1x; double n1dy = n1y - y; double dst1 = sqrt(n1dy * n1dy + n1dx * n1dx); double coeff1 = ((n1y - n2y) * n1dy + (n2x - n1x) * n1dx) / lnk->_length / dst1; double dst3 = coeff1 * dst1; double dst2 = sqrt(1.0 - coeff1 * coeff1) * dst1; - if (coeff1 * dst1 < 0.0) { + if (dst3 < 0.0) { dst3 = 0.0; - dst2 = sqrt(n1dy * n1dy + n1dx * n1dx); + dst2 = sqrt((n1x - x) * (n1x - x) + (n1y - y) * (n1y - y)); } if (dst3 > lnk->_length) { dst3 = lnk->_length; |