hedgewars/uLand.pas
changeset 11537 bf86c6cb9341
parent 11512 bd9a2f1b0080
child 11544 c22d292e7266
--- a/hedgewars/uLand.pas	Sun Jan 24 00:02:57 2016 +0100
+++ b/hedgewars/uLand.pas	Sun Jan 31 16:07:14 2016 +0300
@@ -260,7 +260,7 @@
 var x, y: LongInt;
     p: PLongwordArray;
 begin
-TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true);
+if checkFails(Surface <> nil, 'Assert (LandSurface <> nil) failed', true) then exit;
 
 if SDL_MustLock(Surface) then
     if SDLCheck(SDL_LockSurface(Surface) >= 0, 'SDL_LockSurface', true) then exit;
@@ -291,7 +291,7 @@
 
     tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, AMask);
 
-    TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true);
+    if checkFails(tmpsurf <> nil, 'Error creating pre-land surface', true) then exit;
     ColorizeLand(tmpsurf);
     if gameFlags and gfShoppaBorder = 0 then DrawBorderFromImage(tmpsurf);
     AddOnLandObjects(tmpsurf);
@@ -490,9 +490,11 @@
     begin
     mapName:= ExtractFileName(cPathz[ptMapCurrent]);
     tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
+    if not allOK then exit;
     end;
 // (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take
-TryDo((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (QWord(tmpsurf^.w) * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true);
+if checkFails((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (QWord(tmpsurf^.w) * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true)
+        then exit;
 
 ResizeLand(tmpsurf^.w, tmpsurf^.h);
 LoadMapConfig;
@@ -503,16 +505,16 @@
 rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
 topY:= LAND_HEIGHT - playHeight;
 
-TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true);
+if not checkFails(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true) then
+    BlitImageAndGenerateCollisionInfo(
+        (LAND_WIDTH - tmpsurf^.w) div 2,
+        LAND_HEIGHT - tmpsurf^.h,
+        tmpsurf^.w,
+        tmpsurf);
 
-BlitImageAndGenerateCollisionInfo(
-    (LAND_WIDTH - tmpsurf^.w) div 2,
-    LAND_HEIGHT - tmpsurf^.h,
-    tmpsurf^.w,
-    tmpsurf);
 SDL_FreeSurface(tmpsurf);
 
-LoadMask;
+if allOK then LoadMask;
 end;
 
 procedure DrawBottomBorder; // broken out from other borders for doing a floor-only map, or possibly updating bottom during SD
@@ -797,7 +799,7 @@
     if digest = '' then
         digest:= s
     else
-        TryDo(s = digest, 'Different maps generated, sorry', true);
+        checkFails(s = digest, 'Different maps generated, sorry', true);
 end;
 
 procedure chSendLandDigest(var s: shortstring);
@@ -811,7 +813,7 @@
     ScriptSetString('LandDigest', s);
 
     chLandCheck(s);
-    SendIPCRaw(@s[0], Length(s) + 1)
+    if allOK then SendIPCRaw(@s[0], Length(s) + 1)
 end;
 
 procedure initModule;