hedgewars/uLandGraphics.pas
changeset 11512 bd9a2f1b0080
parent 11342 ed5a6478e710
child 11537 bf86c6cb9341
equal deleted inserted replaced
11511:24bef86e3f3a 11512:bd9a2f1b0080
   714 if flipHoriz then flipSurface(Image, false);
   714 if flipHoriz then flipSurface(Image, false);
   715 row:= Frame mod numFramesFirstCol;
   715 row:= Frame mod numFramesFirstCol;
   716 col:= Frame div numFramesFirstCol;
   716 col:= Frame div numFramesFirstCol;
   717 
   717 
   718 if SDL_MustLock(Image) then
   718 if SDL_MustLock(Image) then
   719     SDLTry(SDL_LockSurface(Image) >= 0, 'TryPlaceOnLand', true);
   719     if SDLCheck(SDL_LockSurface(Image) >= 0, 'TryPlaceOnLand', true) then exit;
   720 
   720 
   721 bpp:= Image^.format^.BytesPerPixel;
   721 bpp:= Image^.format^.BytesPerPixel;
   722 TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
   722 TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
   723 // Check that sprite fits free space
   723 // Check that sprite fits free space
   724 p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
   724 p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
   833 if flipHoriz then flipSurface(Image, false);
   833 if flipHoriz then flipSurface(Image, false);
   834 row:= Frame mod numFramesFirstCol;
   834 row:= Frame mod numFramesFirstCol;
   835 col:= Frame div numFramesFirstCol;
   835 col:= Frame div numFramesFirstCol;
   836 
   836 
   837 if SDL_MustLock(Image) then
   837 if SDL_MustLock(Image) then
   838     SDLTry(SDL_LockSurface(Image) >= 0, 'EraseLand', true);
   838     if SDLCheck(SDL_LockSurface(Image) >= 0, 'EraseLand', true) then exit;
   839 
   839 
   840 bpp:= Image^.format^.BytesPerPixel;
   840 bpp:= Image^.format^.BytesPerPixel;
   841 TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
   841 TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
   842 // Check that sprite fits free space
   842 // Check that sprite fits free space
   843 p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
   843 p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
   916 h:= SpritesData[Obj].Height;
   916 h:= SpritesData[Obj].Height;
   917 row:= Frame mod numFramesFirstCol;
   917 row:= Frame mod numFramesFirstCol;
   918 col:= Frame div numFramesFirstCol;
   918 col:= Frame div numFramesFirstCol;
   919 
   919 
   920 if SDL_MustLock(Image) then
   920 if SDL_MustLock(Image) then
   921     SDLTry(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true);
   921     if SDLCheck(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true) then
       
   922         exit;
   922 
   923 
   923 bpp:= Image^.format^.BytesPerPixel;
   924 bpp:= Image^.format^.BytesPerPixel;
   924 TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
   925 TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
   925 
   926 
   926 
   927 
   928 finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
   929 finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
   929 
   930 
   930 TryDo(finalSurface <> nil, 'GetPlaceCollisionTex: fail to create surface', true);
   931 TryDo(finalSurface <> nil, 'GetPlaceCollisionTex: fail to create surface', true);
   931 
   932 
   932 if SDL_MustLock(finalSurface) then
   933 if SDL_MustLock(finalSurface) then
   933     SDLTry(SDL_LockSurface(finalSurface) >= 0, 'GetPlaceCollisionTex', true);
   934     if SDLCheck(SDL_LockSurface(finalSurface) >= 0, 'GetPlaceCollisionTex', true) then
       
   935         exit;
   934 
   936 
   935 p:= PLongWordArray(@(PLongWordArray(Image^.pixels)^[ (Image^.pitch div 4) * row * h + col * w ]));
   937 p:= PLongWordArray(@(PLongWordArray(Image^.pixels)^[ (Image^.pitch div 4) * row * h + col * w ]));
   936 pt:= PLongWordArray(finalSurface^.pixels);
   938 pt:= PLongWordArray(finalSurface^.pixels);
   937 
   939 
   938 for y:= 0 to Pred(h) do
   940 for y:= 0 to Pred(h) do