--- a/hedgewars/SDLh.pas Mon Aug 19 09:11:49 2019 -0400
+++ b/hedgewars/SDLh.pas Mon Aug 19 18:06:46 2019 +0300
@@ -218,6 +218,7 @@
GShift = 8;
BShift = 16;
AShift = 24;
+ AByteIndex = 0;
{$ELSE}
RMask = $FF000000;
GMask = $00FF0000;
@@ -227,6 +228,7 @@
GShift = 16;
BShift = 8;
AShift = 0;
+ AByteIndex = 3;
{$ENDIF}
KMOD_NONE = $0000;
--- a/hedgewars/uLandObjects.pas Mon Aug 19 09:11:49 2019 -0400
+++ b/hedgewars/uLandObjects.pas Mon Aug 19 18:06:46 2019 +0300
@@ -346,11 +346,15 @@
CountNonZeroz:= lRes;
end;
-procedure ChecksumLandObjectImage(Image: PSDL_Surface);
-var y: LongInt;
+procedure ChecksumLandObjectImage(Image: PSDL_Surface; alphaOnly: boolean);
+var y, x: LongInt;
+var rowData: PByte;
begin
if Image = nil then exit;
+ if alphaOnly then
+ rowData := GetMem(Image^.w);
+
if SDL_MustLock(Image) then
SDL_LockSurface(Image);
@@ -361,11 +365,25 @@
exit
end;
- for y := 0 to Image^.h-1 do
- syncedPixelDigest:= Adler32Update(syncedPixelDigest, @PByteArray(Image^.pixels)^[y*Image^.pitch], Image^.w*4);
+ for y := 0 to Image^.h - 1 do
+ begin
+ if alphaOnly then
+ begin
+ for x := 0 to Image^.w - 1 do
+ (rowData + x)^:= (PByte(Image^.pixels) + y * Image^.pitch + x * 4 + AByteIndex)^;
+ syncedPixelDigest:= Adler32Update(syncedPixelDigest, rowData, Image^.w);
+ end
+ else
+ syncedPixelDigest:= Adler32Update(syncedPixelDigest, @PByteArray(Image^.pixels)^[y*Image^.pitch], Image^.w*4);
+
+ AddFileLog(IntToStr(syncedPixelDigest));
+ end;
if SDL_MustLock(Image) then
SDL_UnlockSurface(Image);
+
+ if alphaOnly then
+ FreeMem(rowData, Image^.w);
end;
function AddGirder(gX: LongInt; var girSurf: PSDL_Surface): boolean;
@@ -376,7 +394,7 @@
if girSurf = nil then
girSurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifColorKey or ifIgnoreCaps);
-ChecksumLandObjectImage(girsurf);
+ChecksumLandObjectImage(girsurf, true);
girderHeight:= girSurf^.h;
@@ -735,7 +753,7 @@
Width:= Surf^.w;
Height:= Surf^.h;
Delete(s, 1, i);
- ChecksumLandObjectImage(Surf);
+ ChecksumLandObjectImage(Surf, true);
end;
end;
@@ -945,8 +963,8 @@
Delete(s, 1, i);
if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then
OutError('Broken theme. Object''s max. count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true);
- ChecksumLandObjectImage(Surf);
- ChecksumLandObjectImage(Mask);
+ ChecksumLandObjectImage(Surf, true);
+ ChecksumLandObjectImage(Mask, false);
inrectcnt := 0;
--- a/hedgewars/uStore.pas Mon Aug 19 09:11:49 2019 -0400
+++ b/hedgewars/uStore.pas Mon Aug 19 18:06:46 2019 +0300
@@ -433,7 +433,10 @@
tmpsurf := LoadDataImageAltPath(Path, AltPath, FileName, imflags);
if (tmpsurf <> nil) and checkSum then
for y := 0 to tmpsurf^.h-1 do
- syncedPixelDigest:= Adler32Update(syncedPixelDigest, @PByteArray(tmpsurf^.pixels)^[y*tmpsurf^.pitch], tmpsurf^.w*4)
+ begin
+ syncedPixelDigest:= Adler32Update(syncedPixelDigest, @PByteArray(tmpsurf^.pixels)^[y*tmpsurf^.pitch], tmpsurf^.w*4);
+ AddFileLog(FileName + ': ' + IntToStr(syncedPixelDigest));
+ end;
end;
if tmpsurf <> nil then