hedgewars/uLandObjects.pas
changeset 1277 752b53481057
parent 1276 281f6aa9afba
child 1753 2ccba26f1aa4
equal deleted inserted replaced
1276:281f6aa9afba 1277:752b53481057
   345 var s: string;
   345 var s: string;
   346     f: textfile;
   346     f: textfile;
   347     i, ii: LongInt;
   347     i, ii: LongInt;
   348     vobcount: Longword;
   348     vobcount: Longword;
   349     c1, c2: TSDL_Color;
   349     c1, c2: TSDL_Color;
       
   350 
       
   351 	procedure CheckRect(Width, Height, x, y, w, h: LongWord);
       
   352 	begin
       
   353 	if (x + w > Width) then OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true);
       
   354 	if (y + h > Height) then OutError('Object''s rectangle exceeds image: y + h (' + inttostr(y) + ' + ' + inttostr(h) + ') > Height (' + inttostr(Height) + ')', true);
       
   355 	end;
       
   356 
   350 begin
   357 begin
   351 s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
   358 s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
   352 WriteLnToConsole('Reading objects info...');
   359 WriteLnToConsole('Reading objects info...');
   353 Assign(f, s);
   360 Assign(f, s);
   354 {$I-}
   361 {$I-}
   379 			Width:= Surf^.w;
   386 			Width:= Surf^.w;
   380 			Height:= Surf^.h;
   387 			Height:= Surf^.h;
   381 			with inland do
   388 			with inland do
   382 				begin
   389 				begin
   383 				Read(f, x, y, w, h);
   390 				Read(f, x, y, w, h);
   384 				TryDo((x + w <= Width) and (y + h <=Height), 'Object''s rectangle exceeds image', true)
   391 				CheckRect(Width, Height, x, y, w, h)
   385 				end;
   392 				end;
   386 			Read(f, rectcnt);
   393 			Read(f, rectcnt);
   387 			for ii:= 1 to rectcnt do
   394 			for ii:= 1 to rectcnt do
   388 				with outland[ii] do
   395 				with outland[ii] do
   389 					begin
   396 					begin
   390 					Read(f, x, y, w, h);
   397 					Read(f, x, y, w, h);
   391 					TryDo((x + w <= Width) and (y + h <=Height), 'Object''s rectangle exceeds image', true);
   398 					CheckRect(Width, Height, x, y, w, h)
   392 					end;
   399 					end;
   393 			Maxcnt:= 3;
   400 			Maxcnt:= 3;
   394 			ReadLn(f)
   401 			ReadLn(f)
   395 			end;
   402 			end;
   396 	end;
   403 	end;