Limit max droplet count to 50 (fix for 0.9.24 branch only) 0.9.24
authorWuzzy <Wuzzy2@mail.ru>
Tue, 24 Jul 2018 20:07:58 +0200
branch0.9.24
changeset 13555 d42237d16acf
parent 13554 bc6f3d5309f4
child 13556 7259891805f9
Limit max droplet count to 50 (fix for 0.9.24 branch only) This fixes the issue with insane amounts of droplets in 0.9.24. It's temporary, the real fix is in default branch, but would be desyncing.
ChangeLog.txt
hedgewars/uConsts.pas
hedgewars/uGearsUtils.pas
hedgewars/uVariables.pas
hedgewars/uVisualGearsList.pas
--- a/ChangeLog.txt	Tue Jul 24 19:34:04 2018 +0200
+++ b/ChangeLog.txt	Tue Jul 24 20:07:58 2018 +0200
@@ -3,6 +3,8 @@
 ====================== 0.9.24.2 ====================
  * Restore joystick/controller functionality
  * Fix crash when starting game with 2 controllers or more
+ * Fix insane amount of droplets appearing when shooting minigun into ocean world edge
+ * Limit number of droplets to 50 (temporary bugfix)
  + Add default controls for controllers (see README)
 
 ====================== 0.9.24.1 ====================
--- a/hedgewars/uConsts.pas	Tue Jul 24 19:34:04 2018 +0200
+++ b/hedgewars/uConsts.pas	Tue Jul 24 20:07:58 2018 +0200
@@ -349,6 +349,8 @@
     cMinPlayWidth = 200;
     cWorldEdgeDist = 200;
 
+    maxDroplets = 50;
+
 implementation
 
 end.
--- a/hedgewars/uGearsUtils.pas	Tue Jul 24 19:34:04 2018 +0200
+++ b/hedgewars/uGearsUtils.pas	Tue Jul 24 20:07:58 2018 +0200
@@ -516,12 +516,13 @@
     // adjust water impact sound based on gear speed and density
     hwTmp:= hwAbs(Gear^.Density * speed);
 
-    if hwTmp > _1 then
-        PlaySound(sndSplash)
-    else if hwTmp > _0_5 then
-        PlaySound(sndSkip)
-    else if hwTmp > _0_0002 then  // arbitrary sanity cutoff.  mostly for airmines
-        PlaySound(sndDroplet2);
+    if (numDroplets < maxDroplets) then
+        if hwTmp > _1 then
+            PlaySound(sndSplash)
+        else if hwTmp > _0_5 then
+            PlaySound(sndSkip)
+        else if hwTmp > _0_0002 then  // arbitrary sanity cutoff.  mostly for airmines
+            PlaySound(sndDroplet2);
     end;
 
 
--- a/hedgewars/uVariables.pas	Tue Jul 24 19:34:04 2018 +0200
+++ b/hedgewars/uVariables.pas	Tue Jul 24 20:07:58 2018 +0200
@@ -264,6 +264,10 @@
 
     SDLwindow: PSDL_Window;
     SDLGLcontext: PSDL_GLContext;
+
+// 0.9.24.2 TEMPORARY BUGFIXES
+
+    numDroplets: LongInt; // number of droplets in game
   
 /////////////////////////////////////
 //Buttons
@@ -2956,6 +2960,8 @@
         CountTexz[i]:= nil;
         end;
 
+    numDroplets:= 0;
+
 end;
 
 procedure freeModule;
--- a/hedgewars/uVisualGearsList.pas	Tue Jul 24 19:34:04 2018 +0200
+++ b/hedgewars/uVisualGearsList.pas	Tue Jul 24 20:07:58 2018 +0200
@@ -84,6 +84,11 @@
 
         exit;
 
+// 0.9.24.2 workaround for minigun droplet spam.
+// Limit the max. number of droplets.
+if ((Kind = vgtDroplet) or (Kind = vgtSplash)) and (numDroplets > maxDroplets) and (not Critical) then
+    exit;
+
 inc(VGCounter);
 New(gear);
 FillChar(gear^, sizeof(TVisualGear), 0);
@@ -231,6 +236,8 @@
                 end;
     vgtDroplet:
                 begin
+                // droplet counter for 0.9.24.2 bugfix
+                inc(numDroplets);
                 // old dx & dy calcs
                 // dx:= 0.001 * (random(180) - 90);
                 // dy:= -0.001 * (random(160) + 40);
@@ -459,6 +466,9 @@
     if lastVisualGearByUID = Gear then
         lastVisualGearByUID:= nil;
 
+    if (Gear^.Kind = vgtDroplet) and (numDroplets > 0) then
+        dec(numDroplets);
+
     Dispose(Gear);
 end;