hedgewars/uLand.pas
changeset 3612 b50215a8a43d
parent 3608 c509bbc779e7
child 3617 1df21e06b8ba
equal deleted inserted replaced
3611:ed00aa2b339e 3612:b50215a8a43d
    21 unit uLand;
    21 unit uLand;
    22 interface
    22 interface
    23 uses SDLh, uLandTemplates, uFloat, uConsts, GLunit;
    23 uses SDLh, uLandTemplates, uFloat, uConsts, GLunit;
    24 
    24 
    25 type
    25 type
    26 {$IFDEF DOWNSCALE}
    26     TLandArray = packed array of array of LongWord; 
    27     TLandArray = packed array[0 .. LAND_HEIGHT div 2 - 1, 0 .. LAND_WIDTH div 2 - 1] of LongWord;
    27     TCollisionArray = packed array of array of Word;
    28 {$ELSE}
       
    29     TLandArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of LongWord;
       
    30 {$ENDIF}
       
    31  
       
    32     TCollisionArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of Word;
       
    33     TPreview  = packed array[0..127, 0..31] of byte;
    28     TPreview  = packed array[0..127, 0..31] of byte;
    34     TDirtyTag = packed array[0 .. LAND_HEIGHT div 32 - 1, 0 .. LAND_WIDTH div 32 - 1] of byte;
    29     TDirtyTag = packed array of array of byte;
    35 
    30 
    36 var Land: TCollisionArray;
    31 var Land: TCollisionArray;
    37     LandPixels: TLandArray;
    32     LandPixels: TLandArray;
    38     LandDirty: TDirtyTag;
    33     LandDirty: TDirtyTag;
    39     hasBorder: boolean; 
    34     hasBorder: boolean; 
   605     end;
   600     end;
   606 end;
   601 end;
   607 
   602 
   608 function SelectTemplate: LongInt;
   603 function SelectTemplate: LongInt;
   609 begin
   604 begin
   610 case cTemplateFilter of
   605     if (cReducedQuality and rqLowRes) <> 0 then
   611      0: begin
   606         SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))]
   612      SelectTemplate:= getrandom(Succ(High(EdgeTemplates)));
   607     else
   613      end;
   608         case cTemplateFilter of
   614      1: begin
   609         0: SelectTemplate:= getrandom(Succ(High(EdgeTemplates)));
   615      SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))];
   610         1: SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))];
   616      end;
   611         2: SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))];
   617      2: begin
   612         3: SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))];
   618      SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))];
   613         4: SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))];
   619      end;
   614         5: SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))];
   620      3: begin
   615     end;
   621      SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))];
   616 
   622      end;
   617     WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
   623      4: begin
       
   624      SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))];
       
   625      end;
       
   626      5: begin
       
   627      SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))];
       
   628      end;
       
   629 end;
       
   630 WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
       
   631 end;
   618 end;
   632 
   619 
   633 procedure LandSurface2LandPixels(Surface: PSDL_Surface);
   620 procedure LandSurface2LandPixels(Surface: PSDL_Surface);
   634 var x, y: LongInt;
   621 var x, y: LongInt;
   635     p: PLongwordArray;
   622     p: PLongwordArray;
  1342 
  1329 
  1343 procedure initModule;
  1330 procedure initModule;
  1344 begin
  1331 begin
  1345     LandBackSurface:= nil;
  1332     LandBackSurface:= nil;
  1346     digest:= '';
  1333     digest:= '';
  1347     FillChar(LandPixels, sizeof(TLandArray), 0);
  1334 
       
  1335     if (cReducedQuality and rqBlurryLand) = 0 then
       
  1336         SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH)
       
  1337     else
       
  1338         SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2);
       
  1339 
       
  1340     SetLength(Land, LAND_HEIGHT, LAND_WIDTH);
       
  1341     SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32));
  1348 end;
  1342 end;
  1349 
  1343 
  1350 procedure freeModule;
  1344 procedure freeModule;
  1351 begin
  1345 begin
  1352 
  1346     Land:= nil;
       
  1347     LandPixels:= nil;
       
  1348     LandDirty:= nil;
  1353 end;
  1349 end;
  1354 
  1350 
  1355 end.
  1351 end.