hedgewars/uLandObjects.pas
changeset 3697 d5b30d6373fc
parent 3641 98319a621dc8
child 3764 eb91c02f2d84
equal deleted inserted replaced
3695:c11abf387a7d 3697:d5b30d6373fc
    92             end
    92             end
    93             else
    93             else
    94                 if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then
    94                 if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then
    95                     LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
    95                     LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
    96 
    96 
    97         if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then 
    97         if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then
    98             Land[cpY + y, cpX + x]:= lfObject
    98             Land[cpY + y, cpX + x]:= lfObject
    99         end;
    99         end;
   100     p:= @(p^[Image^.pitch shr 2])
   100     p:= @(p^[Image^.pitch shr 2])
   101     end;
   101     end;
   102 
   102 
   468     b: boolean;
   468     b: boolean;
   469 begin
   469 begin
   470     if ThemeObjects.Count = 0 then exit;
   470     if ThemeObjects.Count = 0 then exit;
   471     WriteLnToConsole('Adding theme objects...');
   471     WriteLnToConsole('Adding theme objects...');
   472 
   472 
   473     for i:=0 to ThemeObjects.Count do 
   473     for i:=0 to ThemeObjects.Count do
   474         ThemeObjects.objs[i].Maxcnt := max(1, (ThemeObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map
   474         ThemeObjects.objs[i].Maxcnt := max(1, (ThemeObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map
   475      
   475 
   476     repeat
   476     repeat
   477         t := getrandom(ThemeObjects.Count);
   477         t := getrandom(ThemeObjects.Count);
   478         b := false;
   478         b := false;
   479         for i:=0 to ThemeObjects.Count do
   479         for i:=0 to ThemeObjects.Count do
   480             begin
   480             begin
   481             ii := (i+t) mod ThemeObjects.Count;
   481             ii := (i+t) mod ThemeObjects.Count;
   482             
   482 
   483             if ThemeObjects.objs[ii].Maxcnt <> 0 then
   483             if ThemeObjects.objs[ii].Maxcnt <> 0 then
   484                 b := b or TryPut(ThemeObjects.objs[ii])
   484                 b := b or TryPut(ThemeObjects.objs[ii])
   485             end;
   485             end;
   486     until not b;
   486     until not b;
   487 end;
   487 end;
   491     b: boolean;
   491     b: boolean;
   492 begin
   492 begin
   493     if SprayObjects.Count = 0 then exit;
   493     if SprayObjects.Count = 0 then exit;
   494     WriteLnToConsole('Adding spray objects...');
   494     WriteLnToConsole('Adding spray objects...');
   495 
   495 
   496     for i:=0 to SprayObjects.Count do 
   496     for i:=0 to SprayObjects.Count do
   497         SprayObjects.objs[i].Maxcnt := max(1, (SprayObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map
   497         SprayObjects.objs[i].Maxcnt := max(1, (SprayObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map
   498      
   498 
   499     repeat
   499     repeat
   500         t := getrandom(SprayObjects.Count);
   500         t := getrandom(SprayObjects.Count);
   501         b := false;
   501         b := false;
   502         for i:=0 to SprayObjects.Count do
   502         for i:=0 to SprayObjects.Count do
   503             begin
   503             begin
   504             ii := (i+t) mod SprayObjects.Count;
   504             ii := (i+t) mod SprayObjects.Count;
   505             
   505 
   506             if SprayObjects.objs[ii].Maxcnt <> 0 then
   506             if SprayObjects.objs[ii].Maxcnt <> 0 then
   507                 b := b or TryPut(SprayObjects.objs[ii], Surface)
   507                 b := b or TryPut(SprayObjects.objs[ii], Surface)
   508             end;
   508             end;
   509     until not b;
   509     until not b;
   510 end;
   510 end;