hedgewars/uLandObjects.pas
changeset 3516 a8c673657b79
parent 3513 f589230fa21b
child 3519 56cbc035b74b
equal deleted inserted replaced
3510:23145a950eae 3516:a8c673657b79
    82 
    82 
    83 p:= Image^.pixels;
    83 p:= Image^.pixels;
    84 for y:= 0 to Pred(Image^.h) do
    84 for y:= 0 to Pred(Image^.h) do
    85     begin
    85     begin
    86     for x:= 0 to Pred(Width) do
    86     for x:= 0 to Pred(Width) do
       
    87         begin
       
    88 {$IFDEF DOWNSCALE}
       
    89         if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then
       
    90             LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
       
    91 {$ELSE}
    87         if LandPixels[cpY + y, cpX + x] = 0 then
    92         if LandPixels[cpY + y, cpX + x] = 0 then
    88             begin
       
    89             LandPixels[cpY + y, cpX + x]:= p^[x];
    93             LandPixels[cpY + y, cpX + x]:= p^[x];
    90             if (p^[x] and AMask) <> 0 then Land[cpY + y, cpX + x]:= COLOR_OBJECT;
    94 {$ENDIF}
    91             end;
    95         if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then 
    92     p:= @(p^[Image^.pitch shr 2]);
    96             Land[cpY + y, cpX + x]:= LAND_OBJECT
       
    97         end;
       
    98     p:= @(p^[Image^.pitch shr 2])
    93     end;
    99     end;
    94 
   100 
    95 if SDL_MustLock(Image) then
   101 if SDL_MustLock(Image) then
    96    SDL_UnlockSurface(Image);
   102    SDL_UnlockSurface(Image);
    97 WriteLnToConsole(msgOK)
   103 WriteLnToConsole(msgOK)
   230 function CheckCanPlace(x, y: Longword; var Obj: TThemeObject): boolean;
   236 function CheckCanPlace(x, y: Longword; var Obj: TThemeObject): boolean;
   231 var i: Longword;
   237 var i: Longword;
   232     bRes: boolean;
   238     bRes: boolean;
   233 begin
   239 begin
   234 with Obj do
   240 with Obj do
   235      if CheckLand(inland, x, y, COLOR_LAND) then
   241      if CheckLand(inland, x, y, LAND_BASIC) then
   236         begin
   242         begin
   237         bRes:= true;
   243         bRes:= true;
   238         i:= 1;
   244         i:= 1;
   239         while bRes and (i <= rectcnt) do
   245         while bRes and (i <= rectcnt) do
   240               begin
   246               begin
   310     r.w:= Width;
   316     r.w:= Width;
   311     r.h:= Height + 16;
   317     r.h:= Height + 16;
   312     repeat
   318     repeat
   313         y:= 8;
   319         y:= 8;
   314         repeat
   320         repeat
   315             if CheckLand(r, x, y - 8, COLOR_LAND)
   321             if CheckLand(r, x, y - 8, LAND_BASIC)
   316             and not CheckIntersect(x, y, Width, Height) then
   322             and not CheckIntersect(x, y, Width, Height) then
   317             begin
   323             begin
   318             ar[cnt].x:= x;
   324             ar[cnt].x:= x;
   319             ar[cnt].y:= y;
   325             ar[cnt].y:= y;
   320             inc(cnt);
   326             inc(cnt);
   528     begin
   534     begin
   529         if ThemeObjects.objs[i].Surf <> nil then
   535         if ThemeObjects.objs[i].Surf <> nil then
   530             SDL_FreeSurface(ThemeObjects.objs[i].Surf);
   536             SDL_FreeSurface(ThemeObjects.objs[i].Surf);
   531         if SprayObjects.objs[i].Surf <> nil then
   537         if SprayObjects.objs[i].Surf <> nil then
   532             SDL_FreeSurface(SprayObjects.objs[i].Surf);
   538             SDL_FreeSurface(SprayObjects.objs[i].Surf);
       
   539         ThemeObjects.objs[i].Surf:= nil;
       
   540         SprayObjects.objs[i].Surf:= nil;
   533     end;
   541     end;
   534 end;
   542 end;
   535 
   543 
   536 end.
   544 end.