Fix map preview not matching actual map
authorWuzzy <Wuzzy2@mail.ru>
Mon, 08 Apr 2019 03:15:34 +0200
changeset 14765 ba8dd081359d
parent 14764 b3fa6a19fc25
child 14766 cbdfc5b1d5b8
Fix map preview not matching actual map
hedgewars/hwengine.pas
hedgewars/uGears.pas
hedgewars/uGearsList.pas
--- a/hedgewars/hwengine.pas	Mon Apr 08 02:22:51 2019 +0200
+++ b/hedgewars/hwengine.pas	Mon Apr 08 03:15:34 2019 +0200
@@ -106,6 +106,7 @@
             PlayMusic;
             InitZoom(zoom);
             ScriptCall('onGameStart');
+            RandomizeHHAnim;
             for t:= 0 to Pred(TeamsCount) do
                 with TeamsArray[t]^ do
                     MaxTeamHealth:= TeamHealth;
--- a/hedgewars/uGears.pas	Mon Apr 08 02:22:51 2019 +0200
+++ b/hedgewars/uGears.pas	Mon Apr 08 03:15:34 2019 +0200
@@ -46,6 +46,7 @@
 procedure FreeGearsList;
 procedure AddMiscGears;
 procedure AssignHHCoords;
+procedure RandomizeHHAnim;
 procedure StartSuddenDeath;
 function  GearByUID(uid : Longword) : PGear;
 function  IsClockRunning() : boolean;
@@ -1064,6 +1065,18 @@
     SortHHsByClan();
 end;
 
+// Set random pos for all hogs so their animations have different starting points
+procedure RandomizeHHAnim;
+var i, j, p: LongInt;
+begin
+    for p:= 0 to (ClansCount - 1) do
+        with SpawnClansArray[p]^ do
+            for j:= 0 to Pred(TeamsNumber) do
+                with Teams[j]^ do
+                    for i:= 0 to cMaxHHIndex do
+                        if (Hedgehogs[i].Gear <> nil) then
+                            Hedgehogs[i].Gear^.Pos:= GetRandom(19);
+end;
 
 {procedure AmmoFlameWork(Ammo: PGear);
 var t: PGear;
--- a/hedgewars/uGearsList.pas	Mon Apr 08 02:22:51 2019 +0200
+++ b/hedgewars/uGearsList.pas	Mon Apr 08 03:15:34 2019 +0200
@@ -312,7 +312,6 @@
                 gear^.Angle:= cMaxAngle div 2;
                 gear^.Density:= _3;
                 gear^.Z:= cHHZ;
-                gear^.Pos:= GetRandom(19);
                 if (GameFlags and gfAISurvival) <> 0 then
                     if gear^.Hedgehog^.BotLevel > 0 then
                         gear^.Hedgehog^.Effects[heResurrectable] := 1;