383 |
383 |
384 procedure StoreLoad(reload: boolean); |
384 procedure StoreLoad(reload: boolean); |
385 var ii: TSprite; |
385 var ii: TSprite; |
386 ai: TAmmoType; |
386 ai: TAmmoType; |
387 tmpsurf, tmpoverlay: PSDL_Surface; |
387 tmpsurf, tmpoverlay: PSDL_Surface; |
388 i, y, x, imflags: LongInt; |
388 i, imflags: LongInt; |
389 rowData: PByteArray; |
|
390 keyConfirm, keyQuit: shortstring; |
389 keyConfirm, keyQuit: shortstring; |
391 begin |
390 begin |
392 AddFileLog('StoreLoad()'); |
391 AddFileLog('StoreLoad()'); |
393 |
392 |
394 if not cOnlyStats then |
393 if not cOnlyStats then |
429 // these sprites are optional |
428 // these sprites are optional |
430 if critical then |
429 if critical then |
431 imflags := (imflags or ifCritical); |
430 imflags := (imflags or ifCritical); |
432 |
431 |
433 // load the image |
432 // load the image |
434 tmpsurf := LoadDataImageAltPath(Path, AltPath, FileName, imflags); |
433 if checkSum then |
435 if (tmpsurf <> nil) and checkSum then |
434 tmpsurf := LoadDataImageAltPath(Path, AltPath, FileName, imflags or ifDigestAlpha) |
436 begin |
435 else |
437 rowData := GetMem(tmpsurf^.w); |
436 tmpsurf := LoadDataImageAltPath(Path, AltPath, FileName, imflags); |
438 for y := 0 to tmpsurf^.h-1 do |
|
439 begin |
|
440 for x := 0 to tmpsurf^.w - 1 do |
|
441 rowData^[x] := PByteArray(tmpsurf^.pixels)^[y * tmpsurf^.pitch + x * 4 + AByteIndex]; |
|
442 syncedPixelDigest:= Adler32Update(syncedPixelDigest, rowData, tmpsurf^.w); |
|
443 end; |
|
444 FreeMem(rowData, tmpsurf^.w); |
|
445 end; |
|
446 end; |
437 end; |
447 |
438 |
448 if tmpsurf <> nil then |
439 if tmpsurf <> nil then |
449 begin |
440 begin |
450 if getImageDimensions then |
441 if getImageDimensions then |
644 end; |
635 end; |
645 |
636 |
646 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
637 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
647 var tmpsurf: PSDL_Surface; |
638 var tmpsurf: PSDL_Surface; |
648 s: shortstring; |
639 s: shortstring; |
649 logMsg: shortstring; |
640 logMsg, digestMsg: shortstring; |
650 rwops: PSDL_RWops; |
641 rwops: PSDL_RWops; |
|
642 y, x: LongInt; |
|
643 rowData: PByteArray; |
651 begin |
644 begin |
652 LoadImage:= nil; |
645 LoadImage:= nil; |
|
646 digestMsg:= ''; |
653 logMsg:= msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + ']'; |
647 logMsg:= msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + ']'; |
654 |
648 |
655 s:= filename + '.png'; |
649 s:= filename + '.png'; |
656 |
650 |
657 rwops:= nil; |
651 rwops:= nil; |
698 tmpsurf:= doSurfaceConversion(tmpsurf); |
692 tmpsurf:= doSurfaceConversion(tmpsurf); |
699 |
693 |
700 if (imageFlags and ifColorKey) <> 0 then |
694 if (imageFlags and ifColorKey) <> 0 then |
701 if checkFails(SDL_SetColorKey(tmpsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true) then exit; |
695 if checkFails(SDL_SetColorKey(tmpsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true) then exit; |
702 |
696 |
|
697 if ((imageFlags and (ifDigestAll or ifDigestAlpha)) <> 0) |
|
698 and (tmpsurf^.format^.BytesPerPixel = 4)then |
|
699 begin |
|
700 if SDL_MustLock(tmpsurf) then |
|
701 SDL_LockSurface(tmpsurf); |
|
702 |
|
703 if (imageFlags and ifDigestAll) <> 0 then |
|
704 begin |
|
705 for y := 0 to tmpsurf^.h - 1 do |
|
706 syncedPixelDigest:= Adler32Update(syncedPixelDigest, @PByteArray(tmpsurf^.pixels)^[y*tmpsurf^.pitch], tmpsurf^.w*4); |
|
707 digestMsg := ' [CD: ' + inttostr(syncedPixelDigest) + ']' |
|
708 end |
|
709 else if (imageFlags and ifDigestAlpha) <> 0 then |
|
710 begin |
|
711 rowData := GetMem(tmpsurf^.w); |
|
712 for y := 0 to tmpsurf^.h - 1 do |
|
713 begin |
|
714 for x := 0 to tmpsurf^.w - 1 do |
|
715 rowData^[x] := PByteArray(tmpsurf^.pixels)^[y * tmpsurf^.pitch + x * 4 + AByteIndex]; |
|
716 syncedPixelDigest:= Adler32Update(syncedPixelDigest, rowData, tmpsurf^.w); |
|
717 end; |
|
718 FreeMem(rowData, tmpsurf^.w); |
|
719 digestMsg := ' [AD: ' + inttostr(syncedPixelDigest) + ']' |
|
720 end; |
|
721 |
|
722 if SDL_MustLock(tmpsurf) then |
|
723 SDL_UnlockSurface(tmpsurf); |
|
724 end; |
|
725 |
703 // log success |
726 // log success |
704 WriteLnToConsole(logMsg + ' ' + msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); |
727 WriteLnToConsole(logMsg + ' ' + msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')' + digestMsg); |
705 |
728 |
706 LoadImage:= tmpsurf //Result |
729 LoadImage:= tmpsurf //Result |
707 end; |
730 end; |
708 |
731 |
709 |
732 |