hedgewars/uStore.pas
changeset 10260 25155aaede77
parent 10229 5d38aaff5564
child 10262 435c82ab9058
equal deleted inserted replaced
10259:c85d241d9cc9 10260:25155aaede77
   597 end;
   597 end;
   598 
   598 
   599 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   599 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   600 var tmpsurf: PSDL_Surface;
   600 var tmpsurf: PSDL_Surface;
   601     s: shortstring;
   601     s: shortstring;
       
   602     rwops: PSDL_RWops;
   602 begin
   603 begin
   603     LoadImage:= nil;
   604     LoadImage:= nil;
   604     WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
   605     WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
   605 
   606 
   606     s:= filename + '.png';
   607     s:= filename + '.png';
   607     tmpsurf:= IMG_Load_RW(rwopsOpenRead(s), true);
   608 
   608 
   609     rwops:= nil;
       
   610     tmpsurf:= nil;
       
   611 
       
   612     if pfsExists(s) then
       
   613         begin
       
   614         // get data source
       
   615         rwops:= rwopsOpenRead(s);
       
   616 
       
   617         // load image with SDL (with freesrc param set to true)
       
   618         if rwops <> nil then
       
   619             tmpsurf:= IMG_Load_RW(rwops, true);
       
   620         end;
       
   621 
       
   622     // loading failed
   609     if tmpsurf = nil then
   623     if tmpsurf = nil then
   610         begin
   624         begin
       
   625 
       
   626         // anounce that loading failed
   611         OutError(msgFailed, false);
   627         OutError(msgFailed, false);
   612         SDLTry(false, (imageFlags and ifCritical) <> 0);
   628 
       
   629         // output sdl error if loading failed when data source was available
       
   630         if rwops <> nil then
       
   631             begin
       
   632             SDLTry(false, (imageFlags and ifCritical) <> 0);
       
   633             // rwops was already freed by IMG_Load_RW
       
   634             rwops:= nil;
       
   635             end;
   613         exit;
   636         exit;
   614         end;
   637         end;
   615 
   638 
   616     if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   639     if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   617         begin
   640         begin