Google-Code-Fork / tibiaapi

Automatically exported from code.google.com/p/tibiaapi
MIT License
0 stars 0 forks source link

Improvement for Location.IsAdjacentTo #141

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Taking a look at the implementation of this function, you can tell it will
only return true for the tiles that are adjacent to the North, East, South
and West... which means it will disregard (returning false) the tiles
adjacent to the NW, NE, SE and SE. IMHO, those tiles are also adjacent to
the Location object at hand.

The distance from those tiles can be calculated as the square root of 1
squared plus one squared, which is the square root of 2, resulting in
something like 1.414213562. So, a value of 1.42 as maximum distance should
do the trick.

Original issue reported on code.google.com by ing.cabr...@gmail.com on 30 Apr 2009 at 2:03

GoogleCodeExporter commented 9 years ago
> 2 should work, right?

Original comment by oliviata...@gmail.com on 1 May 2009 at 3:59

GoogleCodeExporter commented 9 years ago
Sorry, wrong account. Checking for distance < 2 should work.

Original comment by ian320 on 1 May 2009 at 4:00

GoogleCodeExporter commented 9 years ago
Yes, < 2 is fine, but not <= 2.

Original comment by ing.cabr...@gmail.com on 1 May 2009 at 5:04

GoogleCodeExporter commented 9 years ago
Actually, since the DistanceTo method just calculates the x-distance and 
y-distance
and returns the greater of the two, the IsAdjacentTo method should work as 
expected.
DistanceTo doesn't work the way we intuitively think it does though, so maybe 
that is
an issue.

Original comment by ian320 on 6 May 2009 at 4:03

GoogleCodeExporter commented 9 years ago
Fixed in r658.

Original comment by ian320 on 6 May 2009 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by ian320 on 6 May 2009 at 4:13