Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
authornemo
Sun, 24 Jan 2010 07:37:00 +0000
changeset 2704 51cda17b7c3b
parent 2703 fbde0d971ba6
child 2705 2b5625c4ec16
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
hedgewars/uTeams.pas
hedgewars/uWorld.pas
--- a/hedgewars/uTeams.pas	Sun Jan 24 07:26:03 2010 +0000
+++ b/hedgewars/uTeams.pas	Sun Jan 24 07:37:00 2010 +0000
@@ -309,18 +309,7 @@
 procedure InitTeams;
 var i, t: LongInt;
     th: LongInt;
-    cp: PClan;
 begin
-if (GameFlags and gfRandomOrder) <> 0 then  // shuffle them up a bit
-   for i:= 0 to ClansCount * 8 do
-      begin
-      t:= GetRandom(Pred(ClansCount))+1;
-      cp:= ClansArray[0];
-      ClansArray[0]:= ClansArray[t];
-      ClansArray[t]:= cp;
-      ClansArray[t]^.ClanIndex:= t;
-      ClansArray[0]^.ClanIndex:= 0;
-      end;
 for t:= 0 to Pred(TeamsCount) do
    with TeamsArray[t]^ do
       begin
--- a/hedgewars/uWorld.pas	Sun Jan 24 07:26:03 2010 +0000
+++ b/hedgewars/uWorld.pas	Sun Jan 24 07:37:00 2010 +0000
@@ -20,7 +20,7 @@
 
 unit uWorld;
 interface
-uses SDLh, uGears, uConsts, uFloat;
+uses SDLh, uGears, uConsts, uFloat, uRandom;
 
 const WorldDx: LongInt = -512;
       WorldDy: LongInt = -256;
@@ -66,7 +66,26 @@
     fpsTexture: PTexture;
 
 procedure InitWorld;
+var i, t: LongInt;
+    cp: PClan;
 begin
+if (GameFlags and gfRandomOrder) <> 0 then  // shuffle them up a bit
+   begin
+   for i:= 0 to ClansCount * 4 do
+      begin
+      t:= GetRandom(ClansCount);
+      if t <> 0 then
+         begin
+         cp:= ClansArray[0];
+         ClansArray[0]:= ClansArray[t];
+         ClansArray[t]:= cp;
+         ClansArray[t]^.ClanIndex:= t;
+         ClansArray[0]^.ClanIndex:= 0;
+         end;
+      end;
+   CurrentTeam:= ClansArray[0]^.Teams[0];
+   end;
+
 cWaveWidth:= SpritesData[sprWater].Width;
 //cWaveHeight:= SpritesData[sprWater].Height;
 cWaveHeight:= 32;