OSDN Git Service

Coordinates::Distance()を修正。 / Fix Coordinates::Distance().
[deeangband/Deeangband-new.git] / Deeangband / Coordinates.cpp
index 78c4108..ea8496d 100644 (file)
@@ -72,12 +72,12 @@ namespace Deeangband
 
        int Coordinates::Distance(Coordinates a, Coordinates b)
        {
-               return (int)sqrt((double)((a.GetX() - b.GetX()) * (a.GetX() - b.GetX())+ (a.GetY() - b.GetY()) * (a.GetY() - b.GetY())));
+               return (int)sqrt((double)((a.GetX() - b.GetX()) * (a.GetX() - b.GetX()) + (a.GetY() - b.GetY()) * (a.GetY() - b.GetY())) - 0.5f);
        }
 
        int Coordinates::Distance(int x1, int y1, int x2, int y2)
        {
-               return (int)sqrt((double)((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
+               return (int)sqrt((double)((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) - 0.5f);
        }
 
        int Coordinates::Distance(Coordinates a)