# HG changeset patch # User alfadur # Date 1527026033 14400 # Node ID 166f8f31de3eacf0260e94469cbb8fb9f7f45123 # Parent a52b8b8cbac4510eb1089a186d40dccd17c92280 Checksum girders and masks too diff -r a52b8b8cbac4 -r 166f8f31de3e hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Fri May 18 09:57:24 2018 -0400 +++ b/hedgewars/uLandObjects.pas Tue May 22 17:53:53 2018 -0400 @@ -323,6 +323,28 @@ CountNonZeroz:= lRes; end; +procedure ChecksumLandObjectImage(Image: PSDL_Surface); +var y: LongInt; +begin + if Image = nil then exit; + + if SDL_MustLock(Image) then + SDL_LockSurface(Image); + + if checkFails(Image^.format^.BytesPerPixel = 4, 'Land object image should be 32bit', true) then + begin + if SDL_MustLock(Image) then + SDL_UnlockSurface(Image); + exit + end; + + for y := 0 to Image^.h-1 do + syncedPixelDigest:= Adler32Update(syncedPixelDigest, @PByteArray(Image^.pixels)^[y*Image^.pitch], Image^.w*4); + + if SDL_MustLock(Image) then + SDL_UnlockSurface(Image); +end; + function AddGirder(gX: LongInt; var girSurf: PSDL_Surface): boolean; var x1, x2, y, k, i, girderHeight: LongInt; rr: TSDL_Rect; @@ -331,8 +353,7 @@ if girSurf = nil then girSurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifColorKey or ifIgnoreCaps); -for y := 0 to girsurf^.h-1 do - syncedPixelDigest:= Adler32Update(syncedPixelDigest, @PByteArray(girsurf^.pixels)^[y*girsurf^.pitch], girsurf^.w*4); +ChecksumLandObjectImage(girsurf); girderHeight:= girSurf^.h; @@ -671,6 +692,7 @@ Width:= Surf^.w; Height:= Surf^.h; Delete(s, 1, i); + ChecksumLandObjectImage(Surf); end; end; @@ -879,8 +901,8 @@ Delete(s, 1, i); if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true); - for y := 0 to Surf^.h-1 do - syncedPixelDigest:= Adler32Update(syncedPixelDigest, @PByteArray(Surf^.pixels)^[y*Surf^.pitch], Surf^.w*4); + ChecksumLandObjectImage(Surf); + ChecksumLandObjectImage(Mask); inrectcnt := 0;