hedgewars/uLandObjects.pas
changeset 4647 20b982afbe6e
parent 4639 6de386a42fae
child 4669 296dbccdf376
equal deleted inserted replaced
4588:5ef5415c4ee1 4647:20b982afbe6e
   224 {$WARNINGS OFF}
   224 {$WARNINGS OFF}
   225 tmpx:= rect.x;
   225 tmpx:= rect.x;
   226 tmpx2:= bx;
   226 tmpx2:= bx;
   227 while (tmpx <= bx - rect.w div 2 - 1) and bRes do
   227 while (tmpx <= bx - rect.w div 2 - 1) and bRes do
   228       begin
   228       begin
   229       bRes:= (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color) and
   229       bRes:= ((rect.y and LAND_HEIGHT_MASK) = 0) and ((by and LAND_HEIGHT_MASK) = 0) and
       
   230              ((tmpx and LAND_WIDTH_MASK) = 0) and ((tmpx2 and LAND_WIDTH_MASK) = 0) and
       
   231              (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color) and
   230              (Land[rect.y, tmpx2] = Color) and (Land[by, tmpx2] = Color);
   232              (Land[rect.y, tmpx2] = Color) and (Land[by, tmpx2] = Color);
   231       inc(tmpx);
   233       inc(tmpx);
   232       dec(tmpx2)
   234       dec(tmpx2)
   233       end;
   235       end;
   234 tmpy:= rect.y+1;
   236 tmpy:= rect.y+1;
   235 tmpy2:= by-1;
   237 tmpy2:= by-1;
   236 while (tmpy <= by - rect.h div 2 - 1) and bRes do
   238 while (tmpy <= by - rect.h div 2 - 1) and bRes do
   237       begin
   239       begin
   238       bRes:= (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color) and
   240       bRes:= ((tmpy and LAND_HEIGHT_MASK) = 0) and ((tmpy2 and LAND_HEIGHT_MASK) = 0) and
       
   241              ((rect.x and LAND_WIDTH_MASK) = 0) and ((bx and LAND_WIDTH_MASK) = 0) and
       
   242              (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color) and
   239              (Land[tmpy2, rect.x] = Color) and (Land[tmpy2, bx] = Color);
   243              (Land[tmpy2, rect.x] = Color) and (Land[tmpy2, bx] = Color);
   240       inc(tmpy);
   244       inc(tmpy);
   241       dec(tmpy2)
   245       dec(tmpy2)
   242       end;
   246       end;
   243 {$WARNINGS ON}
   247 {$WARNINGS ON}
   362 end;
   366 end;
   363 
   367 
   364 procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects);
   368 procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects);
   365 var s: shortstring;
   369 var s: shortstring;
   366     f: textfile;
   370     f: textfile;
   367     i, ii: LongInt;
   371     i, ii, numFlakes: LongInt;
   368     c1, c2: TSDL_Color;
   372     c1, c2: TSDL_Color;
   369 
   373 
   370     procedure CheckRect(Width, Height, x, y, w, h: LongWord);
   374     procedure CheckRect(Width, Height, x, y, w, h: LongWord);
   371     begin
   375     begin
   372     if (x + w > Width) then OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true);
   376     if (x + w > Width) then OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true);
   454 Readln(f, vobCount);
   458 Readln(f, vobCount);
   455 if vobCount > 0 then
   459 if vobCount > 0 then
   456     Readln(f, vobFramesCount, vobFrameTicks, vobVelocity, vobFallSpeed);
   460     Readln(f, vobFramesCount, vobFrameTicks, vobVelocity, vobFallSpeed);
   457 
   461 
   458 // adjust amount of flakes scaled by screen space
   462 // adjust amount of flakes scaled by screen space
   459 vobCount:= longint(vobCount) * cScreenSpace div LAND_WIDTH;
   463 vobCount:= longint(vobCount);
       
   464 numFlakes:= vobCount * cScreenSpace div LAND_WIDTH;
   460 
   465 
   461 if (cReducedQuality and rqKillFlakes) <> 0 then
   466 if (cReducedQuality and rqKillFlakes) <> 0 then
   462     vobCount:= 0;
   467     numFlakes:= 0;
   463 
   468 
   464 
   469 if Theme <> 'Snow' then
   465 for i:= 0 to Pred(vobCount) do
   470     for i:= 0 to Pred(numFlakes) do
   466     AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake);
   471         AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake)
       
   472 else
       
   473     for i:= 0 to Pred(numFlakes div 3) do
       
   474         AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake);
   467 
   475 
   468 Close(f);
   476 Close(f);
   469 {$I+}
   477 {$I+}
   470 TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true);
   478 TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true);
   471 AddProgress;
   479 AddProgress;