changeset 11588 | 7c8fd2f66e9b |
parent 11532 | bf86c6cb9341 |
child 11589 | c453620cc6d6 |
11587:cf83d9cb5590 | 11588:7c8fd2f66e9b |
---|---|
691 |
691 |
692 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; Tint: LongWord; Behind, flipHoriz, flipVert: boolean): boolean; inline; |
692 function ForcePlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; LandFlags: Word; Tint: LongWord; Behind, flipHoriz, flipVert: boolean): boolean; inline; |
693 begin |
693 begin |
694 ForcePlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, true, false, true, behind, flipHoriz, flipVert, LandFlags, Tint) |
694 ForcePlaceOnLand:= TryPlaceOnLand(cpX, cpY, Obj, Frame, true, false, true, behind, flipHoriz, flipVert, LandFlags, Tint) |
695 end; |
695 end; |
696 |
|
697 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force, behind, flipHoriz, flipVert: boolean; LandFlags: Word; Tint: LongWord): boolean; |
696 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace, outOfMap, force, behind, flipHoriz, flipVert: boolean; LandFlags: Word; Tint: LongWord): boolean; |
698 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt; |
697 var X, Y, bpp, h, w, row, col, gx, gy, numFramesFirstCol: LongInt; |
699 p: PByteArray; |
698 p: PByteArray; |
700 Image: PSDL_Surface; |
699 Image: PSDL_Surface; |
701 pixel: LongWord; |
700 pixel: LongWord; |
763 case bpp of |
762 case bpp of |
764 4: for y:= 0 to Pred(h) do |
763 4: for y:= 0 to Pred(h) do |
765 begin |
764 begin |
766 for x:= 0 to Pred(w) do |
765 for x:= 0 to Pred(w) do |
767 if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then |
766 if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then |
768 begin |
767 begin |
769 if (cReducedQuality and rqBlurryLand) = 0 then |
768 if (cReducedQuality and rqBlurryLand) = 0 then |
770 begin |
769 begin |
771 gX:= cpX + x; |
770 gX:= cpX + x; |
772 gY:= cpY + y; |
771 gY:= cpY + y; |
773 end |
772 end |
774 else |
773 else |
775 begin |
774 begin |
776 gX:= (cpX + x) div 2; |
775 gX:= (cpX + x) div 2; |
777 gY:= (cpY + y) div 2; |
776 gY:= (cpY + y) div 2; |
778 end; |
777 end; |
779 if not behind or (Land[cpY + y, cpX + x] and lfLandMask = 0) then |
778 if not behind or (Land[cpY + y, cpX + x] and lfLandMask = 0) then |
780 begin |
779 begin |
781 if (LandFlags and lfBasic <> 0) or |
780 if (LandFlags and lfBasic <> 0) or |
782 (((LandPixels[gY, gX] and AMask) shr AShift = 255) and // This test assumes lfBasic and lfObject differ only graphically |
781 ((LandPixels[gY, gX] and AMask shr AShift > 128) and // This test assumes lfBasic and lfObject differ only graphically |
783 (LandFlags or lfObject = 0)) then |
782 (LandFlags and lfObject = 0)) then |
784 Land[cpY + y, cpX + x]:= lfBasic or LandFlags |
783 Land[cpY + y, cpX + x]:= lfBasic or LandFlags |
785 else Land[cpY + y, cpX + x]:= lfObject or LandFlags |
784 else Land[cpY + y, cpX + x]:= lfObject or LandFlags |
786 end; |
785 end; |
787 if not behind or (LandPixels[gY, gX] = 0) then |
786 if not behind or (LandPixels[gY, gX] = 0) then |
788 begin |
787 begin |
789 if tint = $FFFFFFFF then |
788 if tint = $FFFFFFFF then |
790 LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^ |
789 LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^ |
791 else |
790 else |
792 begin |
791 begin |
996 begin |
995 begin |
997 xx:= X div 2; |
996 xx:= X div 2; |
998 yy:= Y div 2; |
997 yy:= Y div 2; |
999 end; |
998 end; |
1000 |
999 |
1001 pixelsweep:= (Land[Y, X] <= lfAllObjMask) and ((LandPixels[yy, xx] and AMASK) <> 0); |
1000 pixelsweep:= (Land[Y, X] <= lfAllObjMask) and ((LandPixels[yy, xx] and AMask) <> 0); |
1002 if (((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0)) or pixelsweep then |
1001 if (((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0)) or pixelsweep then |
1003 begin |
1002 begin |
1004 c:= 0; |
1003 c:= 0; |
1005 for i:= -1 to 1 do |
1004 for i:= -1 to 1 do |
1006 for j:= -1 to 1 do |
1005 for j:= -1 to 1 do |