hedgewars/uLand.pas
changeset 11734 f48408dcea36
parent 11707 ecbf5e6c2c37
child 11744 ac58a063d26a
equal deleted inserted replaced
11733:67049c8dedd1 11734:f48408dcea36
   348     AddProgress();
   348     AddProgress();
   349 end;
   349 end;
   350 
   350 
   351 procedure MakeFortsMap;
   351 procedure MakeFortsMap;
   352 var tmpsurf: PSDL_Surface;
   352 var tmpsurf: PSDL_Surface;
   353     i: integer;
   353     i, t, p: integer;
   354     mirror: boolean;
   354     mirror: boolean;
       
   355     pc: PClan;
   355 const sectionWidth = 1024 + 300;
   356 const sectionWidth = 1024 + 300;
   356 begin
   357 begin
       
   358 
       
   359 // mix up spawn/fort order of clans
       
   360 if ((GameFlags and gfForts) <> 0) then
       
   361     begin
       
   362     for i:= 0 to ClansCount - 1 do
       
   363         begin
       
   364         t:= GetRandom(ClansCount);
       
   365         p:= GetRandom(ClansCount);
       
   366         if t <> p then
       
   367             begin
       
   368             pc:= SpawnClansArray[t];
       
   369             SpawnClansArray[t]:= SpawnClansArray[p];
       
   370             SpawnClansArray[p]:= pc;
       
   371             end;
       
   372         end;
       
   373     end;
       
   374 
   357 // figure out how much space we need
   375 // figure out how much space we need
   358 playWidth:= sectionWidth * ClansCount;
   376 playWidth:= sectionWidth * ClansCount;
   359 
   377 
   360 // note: LAND_WIDTH might be bigger than specified below (rounded to next power of 2)
   378 // note: LAND_WIDTH might be bigger than specified below (rounded to next power of 2)
   361 ResizeLand(playWidth, 2048);
   379 ResizeLand(playWidth, 2048);
   380         mirror:= (i <> 0) and (mirror or (i = ClansCount - 1));
   398         mirror:= (i <> 0) and (mirror or (i = ClansCount - 1));
   381 
   399 
   382     if mirror then
   400     if mirror then
   383         begin
   401         begin
   384         // not critical because if no R we can fallback to mirrored L
   402         // not critical because if no R we can fallback to mirrored L
   385         tmpsurf:= LoadDataImage(ptForts, ClansArray[i]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
   403         tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
   386         // fallback
   404         // fallback
   387         if tmpsurf = nil then
   405         if tmpsurf = nil then
   388             begin
   406             begin
   389             tmpsurf:= LoadDataImage(ptForts, ClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   407             tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   390             BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true);
   408             BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true);
   391             end
   409             end
   392         else
   410         else
   393             BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   411             BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   394         SDL_FreeSurface(tmpsurf);
   412         SDL_FreeSurface(tmpsurf);
   395         end
   413         end
   396     else
   414     else
   397         begin
   415         begin
   398         tmpsurf:= LoadDataImage(ptForts, ClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   416         tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
   399         BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   417         BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
   400         SDL_FreeSurface(tmpsurf);
   418         SDL_FreeSurface(tmpsurf);
   401         end;
   419         end;
   402 
   420 
   403     end;
   421     end;