hedgewars/uLandObjects.pas
changeset 11532 bf86c6cb9341
parent 11507 bd9a2f1b0080
child 11539 c22d292e7266
equal deleted inserted replaced
11531:d1cf1ff6cabb 11532:bf86c6cb9341
   110 
   110 
   111 if SDL_MustLock(Image) then
   111 if SDL_MustLock(Image) then
   112     if SDLCheck(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true) then exit;
   112     if SDLCheck(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true) then exit;
   113 
   113 
   114 bpp:= Image^.format^.BytesPerPixel;
   114 bpp:= Image^.format^.BytesPerPixel;
   115 TryDo(bpp = 4, 'Land object should be 32bit', true);
   115 if checkFails(bpp = 4, 'Land object should be 32bit', true) then
       
   116 begin
       
   117 if SDL_MustLock(Image) then
       
   118     SDL_UnlockSurface(Image);
       
   119 end;
   116 
   120 
   117 if Width = 0 then
   121 if Width = 0 then
   118     Width:= Image^.w;
   122     Width:= Image^.w;
   119 
   123 
   120 p:= Image^.pixels;
   124 p:= Image^.pixels;
   161 
   165 
   162 if SDL_MustLock(Image) then
   166 if SDL_MustLock(Image) then
   163     if SDLCheck(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true) then exit;
   167     if SDLCheck(SDL_LockSurface(Image) >= 0, 'SDL_LockSurface', true) then exit;
   164 
   168 
   165 bpp:= Image^.format^.BytesPerPixel;
   169 bpp:= Image^.format^.BytesPerPixel;
   166 TryDo(bpp = 4, 'Land object should be 32bit', true);
   170 if checkFails(bpp = 4, 'Land object should be 32bit', true) then
       
   171 begin
       
   172 if SDL_MustLock(Image) then
       
   173     SDL_UnlockSurface(Image);
       
   174 end;
   167 
   175 
   168 p:= Image^.pixels;
   176 p:= Image^.pixels;
   169 mp:= Mask^.pixels;
   177 mp:= Mask^.pixels;
   170 for y:= 0 to Pred(Image^.h) do
   178 for y:= 0 to Pred(Image^.h) do
   171     begin
   179     begin
   201     y:= y1;
   209     y:= y1;
   202     w:= w1;
   210     w:= w1;
   203     h:= h1
   211     h:= h1
   204     end;
   212     end;
   205 inc(RectCount);
   213 inc(RectCount);
   206 TryDo(RectCount < MaxRects, 'AddRect: overflow', true)
   214 checkFails(RectCount < MaxRects, 'AddRect: overflow', true)
   207 end;
   215 end;
   208 
   216 
   209 procedure InitRects;
   217 procedure InitRects;
   210 begin
   218 begin
   211     RectCount:= 0;
   219     RectCount:= 0;
   510     end;
   518     end;
   511 
   519 
   512 s:= cPathz[ptCurrTheme] + '/' + cThemeCFGFilename;
   520 s:= cPathz[ptCurrTheme] + '/' + cThemeCFGFilename;
   513 WriteLnToConsole('Reading objects info...');
   521 WriteLnToConsole('Reading objects info...');
   514 f:= pfsOpenRead(s);
   522 f:= pfsOpenRead(s);
   515 TryDo(f <> nil, 'Bad data or cannot access file ' + s, true);
   523 if checkFails(f <> nil, 'Bad data or cannot access file ' + s, true) then exit;
   516 
   524 
   517 ThemeObjects.Count:= 0;
   525 ThemeObjects.Count:= 0;
   518 SprayObjects.Count:= 0;
   526 SprayObjects.Count:= 0;
   519 
   527 
   520 while not pfsEOF(f) do
   528 while not pfsEOF(f) do