hedgewars/uLandGenTemplateBased.pas
changeset 10564 0cb20aa8877a
parent 10562 3388822b3914
child 11175 e1a098f950a9
equal deleted inserted replaced
10562:3388822b3914 10564:0cb20aa8877a
    16 var i: LongInt;
    16 var i: LongInt;
    17 begin
    17 begin
    18     with Template do
    18     with Template do
    19         begin
    19         begin
    20         pa.Count:= BasePointsCount;
    20         pa.Count:= BasePointsCount;
    21         for i:= 0 to LongInt(pred(pa.Count)) do
    21         for i:= 0 to pred(LongInt(pa.Count)) do
    22             begin
    22             begin
    23             pa.ar[i].x:= BasePoints^[i].x + LongInt(GetRandom(BasePoints^[i].w));
    23             pa.ar[i].x:= BasePoints^[i].x + LongInt(GetRandom(BasePoints^[i].w));
    24             if pa.ar[i].x <> NTPX then
    24             if pa.ar[i].x <> NTPX then
    25                 pa.ar[i].x:= pa.ar[i].x + ((LAND_WIDTH - Template.TemplateWidth) div 2);
    25                 pa.ar[i].x:= pa.ar[i].x + ((LAND_WIDTH - Template.TemplateWidth) div 2);
    26             pa.ar[i].y:= BasePoints^[i].y + LongInt(GetRandom(BasePoints^[i].h)) + LAND_HEIGHT - LongInt(Template.TemplateHeight)
    26             pa.ar[i].y:= BasePoints^[i].y + LongInt(GetRandom(BasePoints^[i].h)) + LAND_HEIGHT - LongInt(Template.TemplateHeight)
   172         if t2 > 0 then distR:= min(d, distR) else distL:= min(d, distL);
   172         if t2 > 0 then distR:= min(d, distR) else distL:= min(d, distL);
   173     end;
   173     end;
   174 
   174 
   175     // now go through all other segments
   175     // now go through all other segments
   176     fp:= pa.ar[0];
   176     fp:= pa.ar[0];
   177     for i:= 0 to pa.Count - 2 do
   177     for i:= 0 to LongInt(pa.Count) - 2 do
   178         if pa.ar[i].x = NTPX then
   178         if pa.ar[i].x = NTPX then
   179             fp:= pa.ar[i + 1]
   179             fp:= pa.ar[i + 1]
   180         else if (i <> si) then
   180         else if (i <> si) then
   181         begin
   181         begin
   182         p4:= pa.ar[i + 1];
   182         p4:= pa.ar[i + 1];
   208                 end;
   208                 end;
   209             end;
   209             end;
   210         end;
   210         end;
   211 
   211 
   212     // go through all points, including fill points
   212     // go through all points, including fill points
   213     for i:= 0 to Pred(pa.Count + fillPointsCount) do
   213     for i:= 0 to Pred(LongInt(pa.Count + fillPointsCount)) do
   214         // if this point isn't on current segment
   214         // if this point isn't on current segment
   215         if (si <> i) and (i <> si + 1) and (pa.ar[i].x <> NTPX) then
   215         if (si <> i) and (i <> si + 1) and (pa.ar[i].x <> NTPX) then
   216         begin
   216         begin
   217             // also check intersection with rays through pa.ar[i] if this point is good
   217             // also check intersection with rays through pa.ar[i] if this point is good
   218             t1:= (p1.x - pa.ar[i].x) * b - a * (p1.y - pa.ar[i].y);
   218             t1:= (p1.x - pa.ar[i].x) * b - a * (p1.y - pa.ar[i].y);
   292 begin
   292 begin
   293     newPoint.x:= 0;
   293     newPoint.x:= 0;
   294     newPoint.y:= 0;
   294     newPoint.y:= 0;
   295     i:= 0;
   295     i:= 0;
   296 
   296 
   297     while i < pa.Count - 1 do
   297     while i < LongInt(pa.Count) - 1 do
   298     begin
   298     begin
   299         FindPoint(i, fillPointsCount, newPoint, pa);
   299         FindPoint(i, fillPointsCount, newPoint, pa);
   300 
   300 
   301         if (newPoint.x <> pa.ar[i].x) or (newPoint.y <> pa.ar[i].y) then
   301         if (newPoint.x <> pa.ar[i].x) or (newPoint.y <> pa.ar[i].y) then
   302         begin
   302         begin