Try avoiding spamming the log by retaining the gears. untested.
authornemo
Fri, 20 Jul 2012 14:16:05 -0400
changeset 7406 1fe2c821f9bf
parent 7405 63f56edae4c6
child 7407 c1ade666c124
Try avoiding spamming the log by retaining the gears. untested.
hedgewars/GSHandlers.inc
hedgewars/uGears.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsUtils.pas
--- a/hedgewars/GSHandlers.inc	Fri Jul 20 18:42:45 2012 +0400
+++ b/hedgewars/GSHandlers.inc	Fri Jul 20 14:16:05 2012 -0400
@@ -2081,12 +2081,13 @@
 
 procedure doStepCase(Gear: PGear);
 var 
-    i, x, y, rx, ry: LongInt;
+    i, x, y: LongInt;
     k: TGearType;
     exBoom: boolean;
-    dX, dY, rdx, rdy: HWFloat;
+    dX, dY: HWFloat;
     hog: PHedgehog;
     sparkles: PVisualGear;
+    gi: PGear;
 begin
     k := Gear^.Kind;
     exBoom := false;
@@ -2121,16 +2122,21 @@
         end
     else
         begin 
-        if (Gear^.Pos <> posCaseHealth) and (GameTicks and $3FF = 0) then
+        if (Gear^.Pos <> posCaseHealth) and (GameTicks and $3FF = 0) then // stir it up every second or so
             begin
-            for i:= 0 to GetRandom(3) do
+            gi := GearsList;
+            while gi <> nil do
                 begin
-                rx:= GetRandom(rightX-leftX)+leftX;
-                ry:= GetRandom(LAND_HEIGHT-topY)+topY;
-                rdx:= _90-(GetRandomf*_360);
-                rdy:= _90-(GetRandomf*_360);
-                AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, GetRandom(1000)+1000)
-                end;
+                if gi^.Kind = gtGenericFaller then
+                    begin
+                    gi^.Active:= true;
+                    gi^.X:=  int2hwFloat(GetRandom(rightX-leftX)+leftX);
+                    gi^.Y:=  int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY);
+                    gi^.dX:= _90-(GetRandomf*_360);
+                    gi^.dY:= _90-(GetRandomf*_360)
+                    end;
+                gi := gi^.NextGear
+                end
             end;
 
         if Gear^.Timer = 500 then
@@ -5580,10 +5586,14 @@
 
 procedure doStepGenericFaller(Gear: PGear);
 begin
-if Gear^.Timer > 0 then 
-    begin
-    doStepFallingGear(Gear);
-    dec(Gear^.Timer)
-    end
-else DeleteGear(Gear)
+if Gear^.Timer < $FFFFFFFF then
+    if Gear^.Timer > 0 then
+        dec(Gear^.Timer)
+    else
+        begin
+        DeleteGear(Gear);
+        exit
+        end;
+    
+doStepFallingGear(Gear);
 end;
--- a/hedgewars/uGears.pas	Fri Jul 20 18:42:45 2012 +0400
+++ b/hedgewars/uGears.pas	Fri Jul 20 14:16:05 2012 -0400
@@ -587,7 +587,8 @@
 end;
 
 procedure AddMiscGears;
-var i: Longword;
+var i,rx, ry: Longword;
+    rdx, rdy: hwFloat;
     Gear: PGear;
 begin
 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
@@ -633,6 +634,14 @@
 if (GameFlags and gfArtillery) <> 0 then
     cArtillery:= true;
 
+for i:= 0 to GetRandom(10)+30 do
+    begin                                                                                                                                       rx:= GetRandom(rightX-leftX)+leftX;
+    ry:= GetRandom(LAND_HEIGHT-topY)+topY;
+    rdx:= _90-(GetRandomf*_360);
+    rdy:= _90-(GetRandomf*_360);
+    AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, $FFFFFFFF);
+    end;
+
 if not hasBorder and ((Theme = 'Snow') or (Theme = 'Christmas')) then
     for i:= 0 to Pred(vobCount*2) do
         AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(LAND_HEIGHT div 2), gtFlake, 0, _0, _0, 0);
--- a/hedgewars/uGearsHedgehog.pas	Fri Jul 20 18:42:45 2012 +0400
+++ b/hedgewars/uGearsHedgehog.pas	Fri Jul 20 14:16:05 2012 -0400
@@ -596,10 +596,9 @@
 procedure PickUp(HH, Gear: PGear);
 var s: shortstring;
     a: TAmmoType;
-    i, rx, ry: LongInt;
-    rdx, rdy: hwFloat;
+    i: LongInt;
     vga: PVisualGear;
-    ag: PGear;
+    ag, gi: PGear;
 begin
 Gear^.Message:= gmDestroy;
 if (Gear^.Pos and posCaseExplode) <> 0 then
@@ -621,14 +620,19 @@
                         begin
 // Add spawning here...
                         AddRandomness(CheckSum xor GameTicks);
-
-                        for i:= 0 to GetRandom(50)+50 do
+                        
+                        gi := GearsList;
+                        while gi <> nil do
                             begin
-                            rx:= GetRandom(rightX-leftX)+leftX;
-                            ry:= GetRandom(LAND_HEIGHT-topY)+topY;
-                            rdx:= _90-(GetRandomf*_360);
-                            rdy:= _90-(GetRandomf*_360);
-                            AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, GetRandom(500));
+                            if gi^.Kind = gtGenericFaller then
+                                begin
+                                gi^.Active:= true;
+                                gi^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX);
+                                gi^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY);
+                                gi^.dX:= _90-(GetRandomf*_360);
+                                gi^.dY:= _90-(GetRandomf*_360)
+                                end;
+                            gi := gi^.NextGear
                             end;
                         ag:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAddAmmo, gstInvisible, _0, _0, GetRandom(200)+100);
                         ag^.Pos:= Gear^.Pos;
--- a/hedgewars/uGearsUtils.pas	Fri Jul 20 18:42:45 2012 +0400
+++ b/hedgewars/uGearsUtils.pas	Fri Jul 20 14:16:05 2012 -0400
@@ -345,7 +345,14 @@
         begin
         if Gear^.State and gstInvisible <> 0 then
             begin
-            DeleteGear(Gear);
+            if Gear^.Kind = gtGenericFaller then
+                begin
+                Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX);
+                Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY);
+                Gear^.dX:= _90-(GetRandomf*_360);
+                Gear^.dY:= _90-(GetRandomf*_360)
+                end
+            else DeleteGear(Gear);
             exit
             end;
         isSubmersible:= (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack);