hedgewars/uLandObjects.pas
changeset 11871 9e0b20330d05
parent 11870 b801ff99e52c
child 11895 19cb0de79287
equal deleted inserted replaced
11870:b801ff99e52c 11871:9e0b20330d05
    46      PRectArray = ^TRectsArray;
    46      PRectArray = ^TRectsArray;
    47      TThemeObject = record
    47      TThemeObject = record
    48                      Surf, Mask: PSDL_Surface;
    48                      Surf, Mask: PSDL_Surface;
    49                      inland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect;
    49                      inland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect;
    50                      outland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect;
    50                      outland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect;
    51                      rectcnt: Longword;
    51                      inrectcnt: Longword;
    52                      rectcnt2: Longword;
    52                      outrectcnt: Longword;
    53                      Width, Height: Longword;
    53                      Width, Height: Longword;
    54                      Maxcnt: Longword;
    54                      Maxcnt: Longword;
    55                      end;
    55                      end;
    56      TThemeObjects = record
    56      TThemeObjects = record
    57                      Count: LongInt;
    57                      Count: LongInt;
   357     bRes: boolean;
   357     bRes: boolean;
   358 begin
   358 begin
   359     with Obj do begin
   359     with Obj do begin
   360         bRes:= true;
   360         bRes:= true;
   361         i:= 1;
   361         i:= 1;
   362         while bRes and (i <= rectcnt2) do
   362         while bRes and (i <= inrectcnt) do
   363             begin
   363             begin
   364             bRes:= CheckLand(inland[i], x, y, lfBasic);
   364             bRes:= CheckLand(inland[i], x, y, lfBasic);
   365             inc(i)
   365             inc(i)
   366             end;
   366             end;
   367 
   367 
   368         i:= 1;
   368         i:= 1;
   369         while bRes and (i <= rectcnt) do
   369         while bRes and (i <= outrectcnt) do
   370             begin
   370             begin
   371             bRes:= CheckLand(outland[i], x, y, 0);
   371             bRes:= CheckLand(outland[i], x, y, 0);
   372             inc(i)
   372             inc(i)
   373             end;
   373             end;
   374 
   374 
   666             i:= Pos(',', s);
   666             i:= Pos(',', s);
   667             Maxcnt:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   667             Maxcnt:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   668             Delete(s, 1, i);
   668             Delete(s, 1, i);
   669             if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then
   669             if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then
   670                 OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true);
   670                 OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true);
   671         rectcnt2 := 0;
   671 
       
   672             inrectcnt := 0;
       
   673 
   672             for ii := 1 to Length(S) do
   674             for ii := 1 to Length(S) do
   673               if S[ii] = ',' then
   675               if S[ii] = ',' then
   674                 inc(rectcnt2);
   676                 inc(inrectcnt);
   675 
   677 
   676             if rectcnt2 mod 2 = 0 then
   678             if inrectcnt mod 2 = 0 then
   677               rectcnt2 := 1
   679               inrectcnt := 1
   678             else begin
   680             else begin
   679               i:= Pos(',', s);
   681               i:= Pos(',', s);
   680               rectcnt2:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   682               inrectcnt:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   681               Delete(s, 1, i);
   683               Delete(s, 1, i);
   682             end;
   684             end;
   683 
   685 
   684             for ii:= 1 to rectcnt2 do
   686             for ii:= 1 to inrectcnt do
   685             with inland[ii] do
   687                 with inland[ii] do
   686             begin
   688                     begin
   687             i:= Pos(',', s);
   689                     i:= Pos(',', s);
   688             x:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   690                     x:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   689             Delete(s, 1, i);
   691                     Delete(s, 1, i);
   690             i:= Pos(',', s);
   692                     i:= Pos(',', s);
   691             y:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   693                     y:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   692             Delete(s, 1, i);
   694                     Delete(s, 1, i);
   693             i:= Pos(',', s);
   695                     i:= Pos(',', s);
   694             w:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   696                     w:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   695             Delete(s, 1, i);
   697                     Delete(s, 1, i);
   696             i:= Pos(',', s);
   698                     i:= Pos(',', s);
   697             h:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   699                     h:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   698             Delete(s, 1, i);
   700                     Delete(s, 1, i);
   699             CheckRect(Width, Height, x, y, w, h)
   701                     CheckRect(Width, Height, x, y, w, h)
   700         end;
   702                     end;
   701 
   703 
   702             i:= Pos(',', s);
   704             i:= Pos(',', s);
   703             rectcnt:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   705             outrectcnt:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   704             Delete(s, 1, i);
   706             Delete(s, 1, i);
   705             for ii:= 1 to rectcnt do
   707             for ii:= 1 to outrectcnt do
   706                 with outland[ii] do
   708                 with outland[ii] do
   707                     begin
   709                     begin
   708                     i:= Pos(',', s);
   710                     i:= Pos(',', s);
   709                     x:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   711                     x:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   710                     Delete(s, 1, i);
   712                     Delete(s, 1, i);
   712                     y:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   714                     y:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   713                     Delete(s, 1, i);
   715                     Delete(s, 1, i);
   714                     i:= Pos(',', s);
   716                     i:= Pos(',', s);
   715                     w:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   717                     w:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   716                     Delete(s, 1, i);
   718                     Delete(s, 1, i);
   717                     if ii = rectcnt then
   719                     if ii = outrectcnt then
   718                         h:= StrToInt(Trim(s))
   720                         h:= StrToInt(Trim(s))
   719                     else
   721                     else
   720                         begin
   722                         begin
   721                         i:= Pos(',', s);
   723                         i:= Pos(',', s);
   722                         h:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   724                         h:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   723                         Delete(s, 1, i)
   725                         Delete(s, 1, i)
   724                         end;
   726                         end;
   725                     CheckRect(Width, Height, x, y, w, h)
   727                     CheckRect(Width, Height, x, y, w, h)
   726                     end;
   728                     end;
       
   729 
   727             end;
   730             end;
   728         end
   731         end
   729     else if key = 'spray' then
   732     else if key = 'spray' then
   730         begin
   733         begin
   731         inc(SprayObjects.Count);
   734         inc(SprayObjects.Count);