# HG changeset patch
# User unc0rr
# Date 1221854337 0
# Node ID 281f6aa9afbac63636ed46f4e554b568ec687508
# Parent  bd404839954111a0fe7e394aee327370bc52850f
Fix bug #61 http://fireforge.net/tracker/index.php?func=detail&aid=61&group_id=11&atid=125
Crashing engine in some conditions due to incorrect theme info

diff -r bd4048399541 -r 281f6aa9afba hedgewars/uLandObjects.pas
--- a/hedgewars/uLandObjects.pas	Fri Sep 19 19:56:07 2008 +0000
+++ b/hedgewars/uLandObjects.pas	Fri Sep 19 19:58:57 2008 +0000
@@ -371,21 +371,29 @@
 
 Readln(f, ThemeObjects.Count);
 for i:= 0 to Pred(ThemeObjects.Count) do
-    begin
-    Readln(f, s); // filename
-    with ThemeObjects.objs[i] do
-         begin
-         Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false, true, true);
-         Width:= Surf^.w;
-         Height:= Surf^.h;
-         with inland do Read(f, x, y, w, h);
-         Read(f, rectcnt);
-         for ii:= 1 to rectcnt do
-             with outland[ii] do Read(f, x, y, w, h);
-         Maxcnt:= 3;
-         ReadLn(f)
-         end;
-    end;
+	begin
+	Readln(f, s); // filename
+	with ThemeObjects.objs[i] do
+			begin
+			Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false, true, true);
+			Width:= Surf^.w;
+			Height:= Surf^.h;
+			with inland do
+				begin
+				Read(f, x, y, w, h);
+				TryDo((x + w <= Width) and (y + h <=Height), 'Object''s rectangle exceeds image', true)
+				end;
+			Read(f, rectcnt);
+			for ii:= 1 to rectcnt do
+				with outland[ii] do
+					begin
+					Read(f, x, y, w, h);
+					TryDo((x + w <= Width) and (y + h <=Height), 'Object''s rectangle exceeds image', true);
+					end;
+			Maxcnt:= 3;
+			ReadLn(f)
+			end;
+	end;
 
 // sprays
 Readln(f, SprayObjects.Count);