--- a/hedgewars/uGears.pas Tue Apr 26 20:51:13 2016 +0200
+++ b/hedgewars/uGears.pas Tue Apr 26 22:09:50 2016 +0200
@@ -749,7 +749,7 @@
Count:= 0;
// add hedgehogs to the array in clan order
for p:= 0 to (ClansCount - 1) do
- with ClansArray[p]^ do
+ with SpawnClansArray[p]^ do
begin
// count hogs in this clan
clCount:= 0;
@@ -832,7 +832,7 @@
t:= leftX;
for p:= 0 to (ClansCount - 1) do
begin
- with ClansArray[p]^ do
+ with SpawnClansArray[p]^ do
for j:= 0 to Pred(TeamsNumber) do
with Teams[j]^ do
for i:= 0 to cMaxHHIndex do
--- a/hedgewars/uLand.pas Tue Apr 26 20:51:13 2016 +0200
+++ b/hedgewars/uLand.pas Tue Apr 26 22:09:50 2016 +0200
@@ -350,10 +350,28 @@
procedure MakeFortsMap;
var tmpsurf: PSDL_Surface;
- i: integer;
+ i, t, p: integer;
mirror: boolean;
+ pc: PClan;
const sectionWidth = 1024 + 300;
begin
+
+// mix up spawn/fort order of clans
+if ((GameFlags and gfForts) <> 0) then
+ begin
+ for i:= 0 to ClansCount - 1 do
+ begin
+ t:= GetRandom(ClansCount);
+ p:= GetRandom(ClansCount);
+ if t <> p then
+ begin
+ pc:= SpawnClansArray[t];
+ SpawnClansArray[t]:= SpawnClansArray[p];
+ SpawnClansArray[p]:= pc;
+ end;
+ end;
+ end;
+
// figure out how much space we need
playWidth:= sectionWidth * ClansCount;
@@ -382,11 +400,11 @@
if mirror then
begin
// not critical because if no R we can fallback to mirrored L
- tmpsurf:= LoadDataImage(ptForts, ClansArray[i]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
+ tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
// fallback
if tmpsurf = nil then
begin
- tmpsurf:= LoadDataImage(ptForts, ClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
+ tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true);
end
else
@@ -395,7 +413,7 @@
end
else
begin
- tmpsurf:= LoadDataImage(ptForts, ClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
+ tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
SDL_FreeSurface(tmpsurf);
end;
--- a/hedgewars/uTeams.pas Tue Apr 26 20:51:13 2016 +0200
+++ b/hedgewars/uTeams.pas Tue Apr 26 22:09:50 2016 +0200
@@ -396,6 +396,9 @@
inc(TeamsNumber)
end;
+// mirror changes into array for clans to spawn
+SpawnClansArray:= ClansArray;
+
CurrentTeam:= team;
AddTeam:= team;
end;
--- a/hedgewars/uTypes.pas Tue Apr 26 20:51:13 2016 +0200
+++ b/hedgewars/uTypes.pas Tue Apr 26 22:09:50 2016 +0200
@@ -532,6 +532,8 @@
PCakeData = ^TCakeData;
+ TClansArray = array[0..Pred(cMaxTeams)] of PClan;
+
implementation
end.
--- a/hedgewars/uVariables.pas Tue Apr 26 20:51:13 2016 +0200
+++ b/hedgewars/uVariables.pas Tue Apr 26 22:09:50 2016 +0200
@@ -2392,7 +2392,7 @@
CurrentHedgehog: PHedgehog;
TeamsArray: array[0..Pred(cMaxTeams)] of PTeam;
TeamsCount: Longword;
- ClansArray: array[0..Pred(cMaxTeams)] of PClan;
+ ClansArray, SpawnClansArray: TClansArray;
ClansCount: Longword;
LocalClan: LongInt; // last non-bot, non-extdriven clan
LocalTeam: LongInt; // last non-bot, non-extdriven clan first team
@@ -2778,6 +2778,8 @@
ClansArray[i]:= nil;
end;
+ SpawnClansArray:= ClansArray;
+
for i:= Low(TeamsArray) to High(TeamsArray) do
begin
TeamsArray[i]:= nil;