hedgewars/uLandGraphics.pas
branchqmlfrontend
changeset 10515 7705784902e1
parent 10510 9329dab04490
child 10541 7b74aa1bb58d
equal deleted inserted replaced
10458:f7a199346c3e 10515:7705784902e1
   658 case bpp of
   658 case bpp of
   659     4: for y:= 0 to Pred(h) do
   659     4: for y:= 0 to Pred(h) do
   660         begin
   660         begin
   661         for x:= 0 to Pred(w) do
   661         for x:= 0 to Pred(w) do
   662             if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then
   662             if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then
   663                 if (outOfMap and 
   663                 if (outOfMap and
   664                    ((cpY + y) < LAND_HEIGHT) and ((cpY + y) >= 0) and
   664                    ((cpY + y) < LAND_HEIGHT) and ((cpY + y) >= 0) and
   665                    ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and
   665                    ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and
   666                    ((not force) and (Land[cpY + y, cpX + x] <> 0))) or
   666                    ((not force) and (Land[cpY + y, cpX + x] <> 0))) or
   667 
   667 
   668                    (not outOfMap and
   668                    (not outOfMap and
   669                        (((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
   669                        (((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
   670                        ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or 
   670                        ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or
   671                        ((not force) and (Land[cpY + y, cpX + x] <> 0)))) then
   671                        ((not force) and (Land[cpY + y, cpX + x] <> 0)))) then
   672                    begin
   672                    begin
   673                    if SDL_MustLock(Image) then
   673                    if SDL_MustLock(Image) then
   674                        SDL_UnlockSurface(Image);
   674                        SDL_UnlockSurface(Image);
   675                    exit
   675                    exit
   905         else if (Land[y-1, x] = lfObject) then
   905         else if (Land[y-1, x] = lfObject) then
   906         Land[y, x]:= lfObject
   906         Land[y, x]:= lfObject
   907         else Land[y,x]:= lfBasic
   907         else Land[y,x]:= lfBasic
   908         end
   908         end
   909     end
   909     end
   910 else if ((cReducedQuality and rqBlurryLand) = 0) and (LandPixels[Y, X] and AMask = 255)
   910 else if ((cReducedQuality and rqBlurryLand) = 0) and ((LandPixels[Y, X] and AMask) = AMask)
   911 and (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic)
   911 and (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic)
   912 and (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then
   912 and (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then
   913     begin
   913     begin
   914     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
   914     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
   915     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
   915     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
  1093 
  1093 
  1094 function DrawDots(x, y, xx, yy: Longint; Color: Longword): Longword; inline;
  1094 function DrawDots(x, y, xx, yy: Longint; Color: Longword): Longword; inline;
  1095 begin
  1095 begin
  1096     DrawDots:= 0;
  1096     DrawDots:= 0;
  1097 
  1097 
  1098     if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) and (Land[y + yy, x + xx] <> Color) then 
  1098     if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) and (Land[y + yy, x + xx] <> Color) then
  1099         begin inc(DrawDots); Land[y + yy, x + xx]:= Color; end;
  1099         begin inc(DrawDots); Land[y + yy, x + xx]:= Color; end;
  1100     if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) and (Land[y - yy, x + xx] <> Color) then 
  1100     if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) and (Land[y - yy, x + xx] <> Color) then
  1101         begin inc(DrawDots); Land[y - yy, x + xx]:= Color; end;
  1101         begin inc(DrawDots); Land[y - yy, x + xx]:= Color; end;
  1102     if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) and (Land[y + yy, x - xx] <> Color) then 
  1102     if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) and (Land[y + yy, x - xx] <> Color) then
  1103         begin inc(DrawDots); Land[y + yy, x - xx]:= Color; end;
  1103         begin inc(DrawDots); Land[y + yy, x - xx]:= Color; end;
  1104     if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) and (Land[y - yy, x - xx] <> Color) then 
  1104     if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) and (Land[y - yy, x - xx] <> Color) then
  1105         begin inc(DrawDots); Land[y - yy, x - xx]:= Color; end;
  1105         begin inc(DrawDots); Land[y - yy, x - xx]:= Color; end;
  1106     if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) and (Land[y + xx, x + yy] <> Color) then 
  1106     if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) and (Land[y + xx, x + yy] <> Color) then
  1107         begin inc(DrawDots); Land[y + xx, x + yy]:= Color; end;
  1107         begin inc(DrawDots); Land[y + xx, x + yy]:= Color; end;
  1108     if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) and (Land[y - xx, x + yy] <> Color) then 
  1108     if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) and (Land[y - xx, x + yy] <> Color) then
  1109         begin inc(DrawDots); Land[y - xx, x + yy]:= Color; end;
  1109         begin inc(DrawDots); Land[y - xx, x + yy]:= Color; end;
  1110     if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) and (Land[y + xx, x - yy] <> Color) then 
  1110     if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) and (Land[y + xx, x - yy] <> Color) then
  1111         begin inc(DrawDots); Land[y + xx, x - yy]:= Color; end;
  1111         begin inc(DrawDots); Land[y + xx, x - yy]:= Color; end;
  1112     if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) and (Land[y - xx, x - yy] <> Color) then 
  1112     if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) and (Land[y - xx, x - yy] <> Color) then
  1113         begin inc(DrawDots); Land[y - xx, x - yy]:= Color; end;
  1113         begin inc(DrawDots); Land[y - xx, x - yy]:= Color; end;
  1114 end;
  1114 end;
  1115 
  1115 
  1116 function DrawLines(X1, Y1, X2, Y2, XX, YY: LongInt; color: Longword): Longword;
  1116 function DrawLines(X1, Y1, X2, Y2, XX, YY: LongInt; color: Longword): Longword;
  1117 var
  1117 var