diff -r 89e8d6d05dfa -r a888e649bea2 hedgewars/uLandGenTemplateBased.pas --- a/hedgewars/uLandGenTemplateBased.pas Sat Nov 15 09:43:21 2014 -0500 +++ b/hedgewars/uLandGenTemplateBased.pas Sat Nov 15 22:19:38 2014 +0300 @@ -149,7 +149,7 @@ if t1 > 0 then distL:= d else distR:= d; // right border - iy:= (rightX - mapBorderMargin - mp.x) * b div a + mp.y; + iy:= (LongInt(rightX) - mapBorderMargin - mp.x) * b div a + mp.y; d:= DistanceI(mp.x - rightX + mapBorderMargin, mp.y - iy).Round; if t1 > 0 then distR:= d else distL:= d; end else