hedgewars/uGearsRender.pas
changeset 14924 e28ff0f1aca2
parent 14783 bbec6b28d072
child 14949 8b53cb1c0ada
equal deleted inserted replaced
14923:d82b54399e7e 14924:e28ff0f1aca2
   504                 ty:= round(ly);
   504                 ty:= round(ly);
   505                 hx:= tx;
   505                 hx:= tx;
   506                 hy:= ty;
   506                 hy:= ty;
   507                 wraps:= 0;
   507                 wraps:= 0;
   508                 inWorldBounds := ((ty and LAND_HEIGHT_MASK) or (tx and LAND_WIDTH_MASK)) = 0;
   508                 inWorldBounds := ((ty and LAND_HEIGHT_MASK) or (tx and LAND_WIDTH_MASK)) = 0;
   509                 while inWorldBounds and ((Land[ty, tx] and lfAll) = 0) do
   509                 while (inWorldBounds and ((Land[ty, tx] and lfAll) = 0)) or (not inWorldBounds) do
   510                     begin
   510                     begin
   511                     if wraps > cMaxLaserSightWraps then
   511                     if wraps > cMaxLaserSightWraps then
   512                         break;
   512                         break;
   513                     lx:= lx + ax;
   513                     lx:= lx + ax;
   514                     ly:= ly + ay;
   514                     ly:= ly + ay;
   515                     tx:= round(lx);
   515                     tx:= round(lx);
   516                     ty:= round(ly);
   516                     ty:= round(ly);
   517                     // reached edge of land.
   517                     // reached edge of land.
   518                     if ((ty and LAND_HEIGHT_MASK) <> 0) then
   518                     if ((ty and LAND_HEIGHT_MASK) <> 0) and (((ty < LAND_HEIGHT) and (ay < 0)) or ((ty >= TopY) and (ay > 0))) then
   519                         begin
   519                         begin
   520                         // assume infinite beam. Extend it way out past camera
   520                         // assume infinite beam. Extend it way out past camera
   521                         tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2));
   521                         tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2));
   522                         ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2));
   522                         ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2));
   523                         break;
   523                         break;
   536                             end
   536                             end
   537                         else if (WorldEdge = weBounce) then
   537                         else if (WorldEdge = weBounce) then
   538                             // just stop
   538                             // just stop
   539                             break;
   539                             break;
   540 
   540 
   541                     if ((tx and LAND_WIDTH_MASK) <> 0) then
   541                     if ((tx and LAND_WIDTH_MASK) <> 0) and (((ax > 0) and (tx >= RightX)) or ((ax < 0) and (tx <= LeftX))) then
   542                         begin
   542                         begin
   543                         if (WorldEdge <> weWrap) and (WorldEdge <> weBounce) then
   543                         if (WorldEdge <> weWrap) and (WorldEdge <> weBounce) then
   544                             // assume infinite beam. Extend it way out past camera
   544                             // assume infinite beam. Extend it way out past camera
   545                             begin
   545                             begin
   546                             tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2));
   546                             tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2));
   547                             ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2));
   547                             ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2));
   548                             end;
   548                             end;
   549                         break;
   549                         break;
   550                         end;
   550                         end;
       
   551                     inWorldBounds := ((ty and LAND_HEIGHT_MASK) or (tx and LAND_WIDTH_MASK)) = 0;
   551                     end;
   552                     end;
   552 
   553 
   553                 DrawLineWrapped(hx, hy, tx, ty, 1.0, (sign*m) < 0, wraps, $FF, $00, $00, $C0);
   554                 DrawLineWrapped(hx, hy, tx, ty, 1.0, (sign*m) < 0, wraps, $FF, $00, $00, $C0);
   554                 end;
   555                 end;
   555 
   556