hedgewars/uLand.pas
branchtransitional_engine
changeset 15934 022ec6b916b7
parent 15933 33798b649d9c
child 16055 ce4b50823a95
equal deleted inserted replaced
15933:33798b649d9c 15934:022ec6b916b7
   353     topY:= LAND_HEIGHT - playHeight;
   353     topY:= LAND_HEIGHT - playHeight;
   354 
   354 
   355     uLandPainted.Draw;
   355     uLandPainted.Draw;
   356 end;
   356 end;
   357 
   357 
   358 function SelectTemplate: LongInt;
   358 function SelectTemplate: shortstring;
   359 var l: LongInt;
   359 var l: LongInt;
   360 begin
   360 begin
   361     SelectTemplate:= 0;
   361     SelectTemplate:= '';
   362     if (cReducedQuality and rqLowRes) <> 0 then
   362     if (cReducedQuality and rqLowRes) <> 0 then
   363         SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))]
   363         SelectTemplate:= 'small'
   364     else
   364     else
   365         begin
   365         begin
   366         if cTemplateFilter = 0 then
   366         if cTemplateFilter = 0 then
   367             begin
   367             begin
   368             l:= getRandom(GroupedTemplatesCount);
   368             l:= getRandom(GroupedTemplatesCount);
   373             end
   373             end
   374             else getRandom(1);
   374             else getRandom(1);
   375 
   375 
   376             case cTemplateFilter of
   376             case cTemplateFilter of
   377             0: OutError('Error selecting TemplateFilter. Ask unC0Rr about what you did wrong', true);
   377             0: OutError('Error selecting TemplateFilter. Ask unC0Rr about what you did wrong', true);
   378             1: SelectTemplate:= SmallTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   378             1: SelectTemplate:= 'small';
   379             2: SelectTemplate:= MediumTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   379             2: SelectTemplate:= 'medium';
   380             3: SelectTemplate:= LargeTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   380             3: SelectTemplate:= 'large';
   381             4: SelectTemplate:= CavernTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   381             4: SelectTemplate:= 'cavern';
   382             5: SelectTemplate:= WackyTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   382             5: SelectTemplate:= 'wacky';
   383     // For lua only!
   383     // For lua only!
   384             6: begin
   384             6: begin
   385                SelectTemplate:= min(LuaTemplateNumber,High(EdgeTemplates));
   385                SelectTemplate:= 'small';
   386                GetRandom(2) // burn 1
   386                GetRandom(2) // burn 1
   387                end
   387                end
   388             end
   388             end
   389         end;
   389         end;
   390 
   390 
   391     WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
   391     WriteLnToConsole('Using template filter '+SelectTemplate);
   392 end;
   392 end;
   393 
   393 
   394 procedure LandSurface2LandPixels(Surface: PSDL_Surface);
   394 procedure LandSurface2LandPixels(Surface: PSDL_Surface);
   395 var x, y: LongInt;
   395 var x, y: LongInt;
   396     p: PLongwordArray;
   396     p: PLongwordArray;
   791         end
   791         end
   792     else
   792     else
   793         begin
   793         begin
   794         WriteLnToConsole('Generating land...');
   794         WriteLnToConsole('Generating land...');
   795         case cMapGen of
   795         case cMapGen of
   796             mgRandom: CreateTemplatedLand(cFeatureSize, cSeed, PathPrefix, Theme);
   796             mgRandom: GenerateTemplatedLand(cFeatureSize, cSeed, SelectTemplate, PathPrefix);
   797             mgMaze  : begin ResizeLand(4096,2048); GenMaze; end;
   797             mgMaze  : begin ResizeLand(4096,2048); GenMaze; end;
   798             mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
   798             mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
   799             mgDrawn : GenDrawnMap;
   799             mgDrawn : GenDrawnMap;
   800             mgForts : begin GameFlags:= (GameFlags or gfDivideTeams); MakeFortsMap(); end;
   800             mgForts : begin GameFlags:= (GameFlags or gfDivideTeams); MakeFortsMap(); end;
   801         else
   801         else
   802             OutError('Unknown mapgen', true);
   802             OutError('Unknown mapgen', true);
   803         end;
   803         end;
   804         if (cMapGen <> mgForts) and (cMapGen <> mgRandom) then
   804         if (cMapGen <> mgForts) then
   805             GenLandSurface
   805             GenLandSurface
   806         end;
   806         end;
   807 
   807 
   808     AddProgress;
   808     AddProgress;
   809 
   809 
   946 procedure GenPreview(out Preview: TPreview);
   946 procedure GenPreview(out Preview: TPreview);
   947 var rh, rw, ox, oy, x, y, xx, yy, t, bit, cbit, lh, lw: LongInt;
   947 var rh, rw, ox, oy, x, y, xx, yy, t, bit, cbit, lh, lw: LongInt;
   948 begin
   948 begin
   949     WriteLnToConsole('Generating preview...');
   949     WriteLnToConsole('Generating preview...');
   950     case cMapGen of
   950     case cMapGen of
   951         mgRandom: CreateTemplatedLand(cFeatureSize, cSeed, PathPrefix, Theme);
   951         mgRandom: GenerateTemplatedLand(cFeatureSize, cSeed, SelectTemplate, PathPrefix);
   952         mgMaze: begin ResizeLand(4096,2048); GenMaze; end;
   952         mgMaze: begin ResizeLand(4096,2048); GenMaze; end;
   953         mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
   953         mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
   954         mgDrawn: begin GenDrawnMap; end;
   954         mgDrawn: begin GenDrawnMap; end;
   955         mgForts: MakeFortsPreview();
   955         mgForts: MakeFortsPreview();
   956     else
   956     else
  1005 procedure GenPreviewAlpha(out Preview: TPreviewAlpha);
  1005 procedure GenPreviewAlpha(out Preview: TPreviewAlpha);
  1006 var rh, rw, ox, oy, x, y, xx, yy, t, lh, lw: LongInt;
  1006 var rh, rw, ox, oy, x, y, xx, yy, t, lh, lw: LongInt;
  1007 begin
  1007 begin
  1008     WriteLnToConsole('Generating preview...');
  1008     WriteLnToConsole('Generating preview...');
  1009     case cMapGen of
  1009     case cMapGen of
  1010         mgRandom: CreateTemplatedLand(cFeatureSize, cSeed, PathPrefix, Theme);
  1010         mgRandom: GenerateTemplatedLand(cFeatureSize, cSeed, SelectTemplate, PathPrefix);
  1011         mgMaze: begin ResizeLand(4096,2048); GenMaze; end;
  1011         mgMaze: begin ResizeLand(4096,2048); GenMaze; end;
  1012         mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
  1012         mgPerlin: begin ResizeLand(4096,2048); GenPerlin; end;
  1013         mgDrawn: begin GenDrawnMap; end;
  1013         mgDrawn: begin GenDrawnMap; end;
  1014         mgForts: MakeFortsPreview;
  1014         mgForts: MakeFortsPreview;
  1015     else
  1015     else