hedgewars/uRenderUtils.pas
changeset 11532 bf86c6cb9341
parent 11507 bd9a2f1b0080
child 11821 d8844d4c67de
--- a/hedgewars/uRenderUtils.pas	Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uRenderUtils.pas	Sun Jan 31 16:07:14 2016 +0300
@@ -115,7 +115,8 @@
     tmpPixel: Longword;
     pixels: PLongWordArray;
 begin
-    TryDo(Surface^.format^.BytesPerPixel = 4, 'flipSurface failed, expecting 32 bit surface', true);
+    if checkFails(Surface^.format^.BytesPerPixel = 4, 'flipSurface failed, expecting 32 bit surface', true) then
+        exit;
     SDL_LockSurface(Surface);
     pixels:= Surface^.pixels;
     if Vertical then
@@ -130,7 +131,7 @@
             end
     else
     for x := 0 to (Surface^.w div 2) - 1 do
-        for y := 0 to Surface^.h -1 do
+        for y := 0 to Surface^.h - 1 do
             begin
             i:= y*Surface^.w + x;
             j:= y*Surface^.w + (Surface^.w - x - 1);
@@ -246,8 +247,9 @@
 var y, x, i, j: LongInt;
     srcPixels, destPixels: PLongWordArray;
 begin
-    TryDo(src^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
-    TryDo(dest^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
+    checkFails(src^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
+    checkFails(dest^.format^.BytesPerPixel = 4, 'rotateSurface failed, expecting 32 bit surface', true);
+    if not allOK then exit;
 
     SDL_LockSurface(src);
     SDL_LockSurface(dest);
@@ -293,11 +295,12 @@
         finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
                 32, RMask, GMask, BMask, AMask);
 
-        TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);
+        if checkFails(finalSurface <> nil, 'RenderString: fail to create surface', true) then
+            exit(nil);
 
         WriteInRoundRect(finalSurface, 0, 0, Color, font, s, maxLength);
 
-        TryDo(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+        checkFails(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, false);
 
         RenderStringTexLim:= Surface2Tex(finalSurface, false);
 
@@ -444,7 +447,8 @@
 
     finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, rect.h, 32, RMask, GMask, BMask, AMask);
 
-    TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);
+    if checkFails(finalSurface <> nil, 'RenderString: fail to create surface', true) then
+        exit(nil);
 
     //////////////////////////////// CORNERS ///////////////////////////////
     copyToXY(SpritesData[corner].Surface, finalSurface, 0, 0); /////////////////// NW