hedgewars/uGears.pas
changeset 11896 cb36d6df3814
parent 11895 19cb0de79287
child 11914 c9bad8a01185
equal deleted inserted replaced
11895:19cb0de79287 11896:cb36d6df3814
   813 
   813 
   814 procedure AssignHHCoords;
   814 procedure AssignHHCoords;
   815 var i, t, p, j: LongInt;
   815 var i, t, p, j: LongInt;
   816     ar: array[0..Pred(cMaxHHs)] of PHedgehog;
   816     ar: array[0..Pred(cMaxHHs)] of PHedgehog;
   817     Count: Longword;
   817     Count: Longword;
   818     divide: boolean;
   818     divide, sectionDivide: boolean;
   819 begin
   819 begin
   820 if (GameFlags and gfPlaceHog) <> 0 then
   820 if (GameFlags and gfPlaceHog) <> 0 then
   821     PlacingHogs:= true;
   821     PlacingHogs:= true;
   822 
   822 
   823 divide:= ((GameFlags and gfDivideTeams) <> 0);
   823 divide:= ((GameFlags and gfDivideTeams) <> 0);
   824 
   824 
   825 // in section-divide mode, divide the map into equal-width sections and put each clan in one of them
   825 (* sectionDivide will determine the mode of hog distribution
   826 if divide then
   826  *
       
   827  * On generated maps or maps not designed with divided mode in mind,
       
   828  * using spawning sections can be problematic, because some sections may
       
   829  * contain too little land surface for sensible spawning.
       
   830  *
       
   831  * if sectionDivide is true, the map will be sliced into equal-width sections
       
   832  * and one team spawned in each
       
   833  * if false, the hogs will be spawned normally and sorted by teams after
       
   834  *
       
   835  *)
       
   836 
       
   837 // TODO: there might be a smarter way to decide if dividing clans into equal-width map sections makes sense
       
   838 // e.g. by checking if there is enough spawn area in each section
       
   839 sectionDivide:= divide and ((cMapGen = mgForts) or (ClansCount = 2));
       
   840 
       
   841 // divide the map into equal-width sections and put each clan in one of them
       
   842 if sectionDivide then
   827     begin
   843     begin
   828     t:= leftX;
   844     t:= leftX;
   829     for p:= 0 to (ClansCount - 1) do
   845     for p:= 0 to (ClansCount - 1) do
   830         begin
   846         begin
   831         with SpawnClansArray[p]^ do
   847         with SpawnClansArray[p]^ do
   906                     AddFileLog('Placed flower for hog at coordinates (' + inttostr(hwRound(Gear^.X)) + ',' + inttostr(hwRound(Gear^.Y)) + ')')
   922                     AddFileLog('Placed flower for hog at coordinates (' + inttostr(hwRound(Gear^.X)) + ',' + inttostr(hwRound(Gear^.Y)) + ')')
   907                     end;
   923                     end;
   908 
   924 
   909 
   925 
   910 // divided teams: sort the hedgehogs from left to right by clan and shuffle clan members
   926 // divided teams: sort the hedgehogs from left to right by clan and shuffle clan members
   911 if divide then
   927 if divide and (not sectionDivide) then
   912     SortHHsByClan();
   928     SortHHsByClan();
   913 end;
   929 end;
   914 
   930 
   915 
   931 
   916 {procedure AmmoFlameWork(Ammo: PGear);
   932 {procedure AmmoFlameWork(Ammo: PGear);