# HG changeset patch # User Wuzzy # Date 1531399284 -7200 # Node ID 480ea997036bc2706317eb4097f7ea856b01729d # Parent c265a3e6f6da20853c46d1410aa26c56095df8fa Send proper failure error message when image loading has failed diff -r c265a3e6f6da -r 480ea997036b hedgewars/uDebug.pas --- a/hedgewars/uDebug.pas Wed Jul 11 21:56:30 2018 +0200 +++ b/hedgewars/uDebug.pas Thu Jul 12 14:41:24 2018 +0200 @@ -69,7 +69,7 @@ if not Assert then begin s:= SDL_GetError(); - OutError(Msg + ': ' + s, false) + OutError(Msg + ': ' + s, isFatal) end; allOK:= allOK and (Assert or (not isFatal)); diff -r c265a3e6f6da -r 480ea997036b hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Wed Jul 11 21:56:30 2018 +0200 +++ b/hedgewars/uLandObjects.pas Thu Jul 12 14:41:24 2018 +0200 @@ -731,7 +731,8 @@ s:= cPathz[ptCurrTheme] + '/' + cThemeCFGFilename; WriteLnToConsole('Reading objects info...'); f:= pfsOpenRead(s); -if checkFails(f <> nil, 'Bad data or cannot access file ' + s, true) then exit; +if (f = nil) then + OutError('Error loading theme. File could not be opened: ' + s, true); ThemeObjects.Count:= 0; SprayObjects.Count:= 0; diff -r c265a3e6f6da -r 480ea997036b hedgewars/uStore.pas --- a/hedgewars/uStore.pas Wed Jul 11 21:56:30 2018 +0200 +++ b/hedgewars/uStore.pas Thu Jul 12 14:41:24 2018 +0200 @@ -624,10 +624,11 @@ function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; var tmpsurf: PSDL_Surface; s: shortstring; + logMsg: shortstring; rwops: PSDL_RWops; begin LoadImage:= nil; - WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] '); + logMsg:= msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + ']'; s:= filename + '.png'; @@ -651,20 +652,22 @@ if rwops <> nil then begin // anounce that loading failed - OutError(msgFailed, false); + OutError(logMsg + ' ' + msgFailed, false); - if SDLCheck(false, 'LoadImage', (imageFlags and ifCritical) <> 0) then exit; + if SDLCheck(false, 'LoadImage: ' + logMsg + ' ' + msgFailed, (imageFlags and ifCritical) <> 0) then + exit; // rwops was already freed by IMG_Load_RW rwops:= nil; - end else - OutError(msgFailed, (imageFlags and ifCritical) <> 0); + end + else + OutError(logMsg + ' ' + msgFailed, (imageFlags and ifCritical) <> 0); exit; end; if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then begin SDL_FreeSurface(tmpsurf); - OutError(msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0))); + OutError(logMsg + ' ' + msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0))); // dummy surface to replace non-critical textures that failed to load due to their size LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask); exit; @@ -675,7 +678,8 @@ if (imageFlags and ifColorKey) <> 0 then if checkFails(SDL_SetColorKey(tmpsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true) then exit; - WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); + // log success + WriteLnToConsole(logMsg + ' ' + msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')'); LoadImage:= tmpsurf //Result end;