equal
deleted
inserted
replaced
613 SDLTry(SDL_LockSurface(Image) >= 0, true); |
613 SDLTry(SDL_LockSurface(Image) >= 0, true); |
614 |
614 |
615 bpp:= Image^.format^.BytesPerPixel; |
615 bpp:= Image^.format^.BytesPerPixel; |
616 TryDo(bpp = 4, 'It should be 32 bpp sprite', true); |
616 TryDo(bpp = 4, 'It should be 32 bpp sprite', true); |
617 // Check that sprite fits free space |
617 // Check that sprite fits free space |
618 p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]); |
618 p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ])); |
619 case bpp of |
619 case bpp of |
620 4: for y:= 0 to Pred(h) do |
620 4: for y:= 0 to Pred(h) do |
621 begin |
621 begin |
622 for x:= 0 to Pred(w) do |
622 for x:= 0 to Pred(w) do |
623 if (PLongword(@(p^[x * 4]))^) <> 0 then |
623 if (PLongword(@(p^[x * 4]))^) <> 0 then |
626 begin |
626 begin |
627 if SDL_MustLock(Image) then |
627 if SDL_MustLock(Image) then |
628 SDL_UnlockSurface(Image); |
628 SDL_UnlockSurface(Image); |
629 exit; |
629 exit; |
630 end; |
630 end; |
631 p:= @(p^[Image^.pitch]); |
631 p:= PByteArray(@(p^[Image^.pitch])); |
632 end; |
632 end; |
633 end; |
633 end; |
634 |
634 |
635 TryPlaceOnLand:= true; |
635 TryPlaceOnLand:= true; |
636 if not doPlace then |
636 if not doPlace then |
639 SDL_UnlockSurface(Image); |
639 SDL_UnlockSurface(Image); |
640 exit |
640 exit |
641 end; |
641 end; |
642 |
642 |
643 // Checked, now place |
643 // Checked, now place |
644 p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]); |
644 p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ])); |
645 case bpp of |
645 case bpp of |
646 4: for y:= 0 to Pred(h) do |
646 4: for y:= 0 to Pred(h) do |
647 begin |
647 begin |
648 for x:= 0 to Pred(w) do |
648 for x:= 0 to Pred(w) do |
649 if (PLongword(@(p^[x * 4]))^) <> 0 then |
649 if (PLongword(@(p^[x * 4]))^) <> 0 then |
664 Land[cpY + y, cpX + x]:= lfBasic or LandFlags |
664 Land[cpY + y, cpX + x]:= lfBasic or LandFlags |
665 else |
665 else |
666 Land[cpY + y, cpX + x]:= lfObject or LandFlags; |
666 Land[cpY + y, cpX + x]:= lfObject or LandFlags; |
667 LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^ |
667 LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^ |
668 end; |
668 end; |
669 p:= @(p^[Image^.pitch]); |
669 p:= PByteArray(@(p^[Image^.pitch])); |
670 end; |
670 end; |
671 end; |
671 end; |
672 if SDL_MustLock(Image) then |
672 if SDL_MustLock(Image) then |
673 SDL_UnlockSurface(Image); |
673 SDL_UnlockSurface(Image); |
674 |
674 |