hedgewars/uLand.pas
changeset 9243 d8f6a396d98e
parent 9080 9b42757d7e71
child 9295 f8819c3dde54
equal deleted inserted replaced
9241:6f94d6434f94 9243:d8f6a396d98e
   273     rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
   273     rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1;
   274     topY:= LAND_HEIGHT - playHeight;
   274     topY:= LAND_HEIGHT - playHeight;
   275 end;
   275 end;
   276 
   276 
   277 function SelectTemplate: LongInt;
   277 function SelectTemplate: LongInt;
       
   278 var l: LongInt;
   278 begin
   279 begin
   279     if (cReducedQuality and rqLowRes) <> 0 then
   280     if (cReducedQuality and rqLowRes) <> 0 then
   280         SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))]
   281         SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))]
   281     else
   282     else
       
   283     begin
       
   284         if cTemplateFilter = 0 then
       
   285             begin
       
   286             l:= getRandom(GroupedTemplatesCount);
       
   287             repeat
       
   288                 inc(cTemplateFilter);
       
   289                 dec(l, TemplateCounts[cTemplateFilter]);
       
   290             until l < 0;
       
   291             end else getRandom(1);
       
   292         
   282         case cTemplateFilter of
   293         case cTemplateFilter of
   283         0: SelectTemplate:= getrandom(Succ(High(EdgeTemplates)));
   294         0: OutError('Ask unC0Rr about what you did wrong', true);
   284         1: SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))];
   295         1: SelectTemplate:= SmallTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   285         2: SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))];
   296         2: SelectTemplate:= MediumTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   286         3: SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))];
   297         3: SelectTemplate:= LargeTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   287         4: SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))];
   298         4: SelectTemplate:= CavernTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   288         5: SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))];
   299         5: SelectTemplate:= WackyTemplates[getrandom(TemplateCounts[cTemplateFilter])];
   289 // For lua only!
   300 // For lua only!
   290         6: begin
   301         6: begin
   291            SelectTemplate:= min(LuaTemplateNumber,High(EdgeTemplates));
   302            SelectTemplate:= min(LuaTemplateNumber,High(EdgeTemplates));
   292            GetRandom(2) // burn 1
   303            GetRandom(2) // burn 1
   293            end;
   304            end;
       
   305         end
   294     end;
   306     end;
   295 
   307 
   296     WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
   308     WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
   297 end;
   309 end;
   298 
   310 
   515     begin
   527     begin
   516     mapName:= ExtractFileName(cPathz[ptMapCurrent]);
   528     mapName:= ExtractFileName(cPathz[ptMapCurrent]);
   517     tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   529     tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   518     end;
   530     end;
   519 // (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take
   531 // (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take
   520 TryDo((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (tmpsurf^.w * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true);
   532 TryDo((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (QWord(tmpsurf^.w) * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true);
   521 
   533 
   522 ResizeLand(tmpsurf^.w, tmpsurf^.h);
   534 ResizeLand(tmpsurf^.w, tmpsurf^.h);
   523 LoadMapConfig;
   535 LoadMapConfig;
   524 
   536 
   525 playHeight:= tmpsurf^.h;
   537 playHeight:= tmpsurf^.h;