equal
deleted
inserted
replaced
112 mp.y:= (p1.y + p2.y) div 2; |
112 mp.y:= (p1.y + p2.y) div 2; |
113 |
113 |
114 // don't process too short segments or those which are too close to map borders |
114 // don't process too short segments or those which are too close to map borders |
115 if (p1.x = NTPX) |
115 if (p1.x = NTPX) |
116 or (dab < minDistance * 3) |
116 or (dab < minDistance * 3) |
117 or (mp.x < LongInt(leftX) + mapBorderMargin) |
117 or (mp.x < leftX + mapBorderMargin) |
118 or (mp.x > LongInt(rightX) - mapBorderMargin) |
118 or (mp.x > rightX - mapBorderMargin) |
119 or (mp.y < LongInt(topY) + mapBorderMargin) |
119 or (mp.y < LongInt(topY) + mapBorderMargin) |
120 or (mp.y > LongInt(LAND_HEIGHT) - mapBorderMargin) |
120 or (mp.y > LongInt(LAND_HEIGHT) - mapBorderMargin) |
121 then |
121 then |
122 begin |
122 begin |
123 newPoint:= p1; |
123 newPoint:= p1; |
126 |
126 |
127 // find distances to map borders |
127 // find distances to map borders |
128 if a <> 0 then |
128 if a <> 0 then |
129 begin |
129 begin |
130 // left border |
130 // left border |
131 iy:= (LongInt(leftX) + mapBorderMargin - mp.x) * b div a + mp.y; |
131 iy:= (leftX + mapBorderMargin - mp.x) * b div a + mp.y; |
132 d:= DistanceI(mp.x - leftX - mapBorderMargin, mp.y - iy).Round; |
132 d:= DistanceI(mp.x - leftX - mapBorderMargin, mp.y - iy).Round; |
133 t1:= a * (mp.x - mapBorderMargin) + b * (mp.y - iy); |
133 t1:= a * (mp.x - mapBorderMargin) + b * (mp.y - iy); |
134 if t1 > 0 then distL:= d else distR:= d; |
134 if t1 > 0 then distL:= d else distR:= d; |
135 |
135 |
136 // right border |
136 // right border |
137 iy:= (LongInt(rightX) - mapBorderMargin - mp.x) * b div a + mp.y; |
137 iy:= (rightX - mapBorderMargin - mp.x) * b div a + mp.y; |
138 d:= DistanceI(mp.x - rightX + mapBorderMargin, mp.y - iy).Round; |
138 d:= DistanceI(mp.x - rightX + mapBorderMargin, mp.y - iy).Round; |
139 if t1 > 0 then distR:= d else distL:= d; |
139 if t1 > 0 then distR:= d else distL:= d; |
140 end else |
140 end else |
141 begin |
141 begin |
142 distL:= LAND_WIDTH + LAND_HEIGHT; |
142 distL:= LAND_WIDTH + LAND_HEIGHT; |