hedgewars/uLandGraphics.pas
changeset 14282 6015b74eea55
parent 13567 8f9b84d6991d
child 14286 7a7c090f96f6
equal deleted inserted replaced
14281:e754b516cc35 14282:6015b74eea55
   420     iceT:= max(y - iceRadius, iceT);
   420     iceT:= max(y - iceRadius, iceT);
   421     iceB:= min(y + iceRadius, iceB);
   421     iceB:= min(y + iceRadius, iceB);
   422     if x <= leftX then
   422     if x <= leftX then
   423         iceR:= min(leftX + iceHeight, iceR)
   423         iceR:= min(leftX + iceHeight, iceR)
   424     else {if x >= rightX then}
   424     else {if x >= rightX then}
   425         iceL:= max(LongInt(rightX) - iceHeight, iceL);
   425         iceL:= max(rightX - iceHeight, iceL);
   426     end;
   426     end;
   427 
   427 
   428 // don't continue if all ice is outside land array
   428 // don't continue if all ice is outside land array
   429 if (iceL > iceR) or (iceT > iceB) then
   429 if (iceL > iceR) or (iceT > iceB) then
   430     exit();
   430     exit();
   752                    ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and
   752                    ((cpX + x) < LAND_WIDTH) and ((cpX + x) >= 0) and
   753                    ((not force) and (Land[cpY + y, cpX + x] <> 0))) or
   753                    ((not force) and (Land[cpY + y, cpX + x] <> 0))) or
   754 
   754 
   755                    (not outOfMap and
   755                    (not outOfMap and
   756                        (((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
   756                        (((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
   757                        ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or
   757                        ((cpX + x) <= leftX) or ((cpX + x) >= rightX) or
   758                        ((not force) and (Land[cpY + y, cpX + x] <> 0)))) then
   758                        ((not force) and (Land[cpY + y, cpX + x] <> 0)))) then
   759                    begin
   759                    begin
   760                    if SDL_MustLock(Image) then
   760                    if SDL_MustLock(Image) then
   761                        SDL_UnlockSurface(Image);
   761                        SDL_UnlockSurface(Image);
   762                    exit
   762                    exit
   872     for y:= 0 to Pred(h) do
   872     for y:= 0 to Pred(h) do
   873         begin
   873         begin
   874         for x:= 0 to Pred(w) do
   874         for x:= 0 to Pred(w) do
   875             if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then
   875             if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then
   876                 if ((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
   876                 if ((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
   877                    ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) then
   877                    ((cpX + x) <= leftX) or ((cpX + x) >= rightX) then
   878                    begin
   878                    begin
   879                    if SDL_MustLock(Image) then
   879                    if SDL_MustLock(Image) then
   880                        SDL_UnlockSurface(Image);
   880                        SDL_UnlockSurface(Image);
   881                    exit
   881                    exit
   882                    end;
   882                    end;
   975 for y:= 0 to Pred(h) do
   975 for y:= 0 to Pred(h) do
   976     begin
   976     begin
   977     for x:= 0 to Pred(w) do
   977     for x:= 0 to Pred(w) do
   978         if ((p^[x] and AMask) <> 0)
   978         if ((p^[x] and AMask) <> 0)
   979             and (((cpY + y) < Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
   979             and (((cpY + y) < Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
   980             ((cpX + x) < Longint(leftX)) or ((cpX + x) > Longint(rightX)) or (Land[cpY + y, cpX + x] <> 0)) then
   980             ((cpX + x) < leftX) or ((cpX + x) > rightX) or (Land[cpY + y, cpX + x] <> 0)) then
   981                 pt^[x]:= cWhiteColor
   981                 pt^[x]:= cWhiteColor
   982         else
   982         else
   983             (pt^[x]):= cWhiteColor and (not AMask);
   983             (pt^[x]):= cWhiteColor and (not AMask);
   984     p:= PLongWordArray(@(p^[Image^.pitch div 4]));
   984     p:= PLongWordArray(@(p^[Image^.pitch div 4]));
   985     pt:= PLongWordArray(@(pt^[finalSurface^.pitch div 4]));
   985     pt:= PLongWordArray(@(pt^[finalSurface^.pitch div 4]));
  1073 if (Land[Y, X] and lfDamaged) = 0 then
  1073 if (Land[Y, X] and lfDamaged) = 0 then
  1074     exit;
  1074     exit;
  1075 
  1075 
  1076 // check location
  1076 // check location
  1077 if (Y <= LongInt(topY) + 1) or (Y >= LAND_HEIGHT-2)
  1077 if (Y <= LongInt(topY) + 1) or (Y >= LAND_HEIGHT-2)
  1078 or (X <= LongInt(leftX) + 1) or (X >= LongInt(rightX) - 1) then
  1078 or (X <= leftX + 1) or (X >= rightX - 1) then
  1079     exit;
  1079     exit;
  1080 
  1080 
  1081 // counter for neighbor pixels that are not known to be undamaged
  1081 // counter for neighbor pixels that are not known to be undamaged
  1082 c:= 8;
  1082 c:= 8;
  1083 
  1083 
  1125 
  1125 
  1126 procedure Smooth_oldImpl(X, Y: LongInt);
  1126 procedure Smooth_oldImpl(X, Y: LongInt);
  1127 begin
  1127 begin
  1128 // a bit of AA for explosions
  1128 // a bit of AA for explosions
  1129 if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and
  1129 if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and
  1130     (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then
  1130     (Y < LAND_HEIGHT-2) and (X > leftX + 1) and (X < rightX - 1) then
  1131     begin
  1131     begin
  1132     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
  1132     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
  1133     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
  1133     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
  1134         begin
  1134         begin
  1135         if (cReducedQuality and rqBlurryLand) = 0 then
  1135         if (cReducedQuality and rqBlurryLand) = 0 then
  1183 }
  1183 }
  1184         end
  1184         end
  1185     end
  1185     end
  1186 else if ((cReducedQuality and rqBlurryLand) = 0) and ((LandPixels[Y, X] and AMask) = AMask)
  1186 else if ((cReducedQuality and rqBlurryLand) = 0) and ((LandPixels[Y, X] and AMask) = AMask)
  1187 and (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic)
  1187 and (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic)
  1188 and (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then
  1188 and (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > leftX + 1) and (X < rightX - 1) then
  1189     begin
  1189     begin
  1190     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
  1190     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
  1191     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
  1191     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
  1192         begin
  1192         begin
  1193         LandPixels[y,x]:=
  1193         LandPixels[y,x]:=