# HG changeset patch # User Wuzzy # Date 1602456379 -7200 # Node ID ff18f99f3f5dda0392daf87e13261b9221e9f8bf # Parent bbcf037af2f224aa10583656ac4790dd0b115dfd Fix laser sight wrapping sometimes wrapping too often diff -r bbcf037af2f2 -r ff18f99f3f5d hedgewars/uGearsRender.pas --- a/hedgewars/uGearsRender.pas Thu Oct 08 20:38:19 2020 +0200 +++ b/hedgewars/uGearsRender.pas Mon Oct 12 00:46:19 2020 +0200 @@ -549,8 +549,9 @@ ly:= ly + ay; tx:= round(lx); ty:= round(ly); - // reached edge of land. - if ((ty and LAND_HEIGHT_MASK) <> 0) and (((ty < LAND_HEIGHT) and (ay < 0)) or ((ty >= TopY) and (ay > 0))) then + // reached top edge of land mask + if ((ty and LAND_HEIGHT_MASK) <> 0) and (((ty < LAND_HEIGHT) and (ay < 0)) or ((ty >= TopY) and (ay > 0))) and + (WorldEdge <> weWrap) and (WorldEdge <> weBounce) then begin // assume infinite beam. Extend it way out past camera tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2)); @@ -573,16 +574,16 @@ // just stop break; - if ((tx and LAND_WIDTH_MASK) <> 0) and (((ax > 0) and (tx >= RightX)) or ((ax < 0) and (tx <= LeftX))) then + // reached horizontal edge of land mask + if ((tx and LAND_WIDTH_MASK) <> 0) and (((ax > 0) and (tx >= RightX)) or ((ax < 0) and (tx <= LeftX))) and + (WorldEdge <> weWrap) and (WorldEdge <> weBounce) then begin - if (WorldEdge <> weWrap) and (WorldEdge <> weBounce) then - // assume infinite beam. Extend it way out past camera - begin - tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2)); - ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2)); - end; + // assume infinite beam. Extend it way out past camera + tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2)); + ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2)); break; end; + inWorldBounds := ((ty and LAND_HEIGHT_MASK) or (tx and LAND_WIDTH_MASK)) = 0; end;