hedgewars/uVisualGearsHandlers.pas
changeset 14564 78363dbfd5dc
parent 13235 9f5023a5f9e1
child 14593 34e810295d08
--- a/hedgewars/uVisualGearsHandlers.pas	Thu Jan 10 18:45:04 2019 +0100
+++ b/hedgewars/uVisualGearsHandlers.pas	Thu Jan 10 19:09:06 2019 +0100
@@ -900,6 +900,7 @@
     currwindbar: PVisualGear = nil;
 
 procedure doStepSmoothWindBarWork(Gear: PVisualGear; Steps: Longword);
+const maxWindBarWidth = 73;
 begin
     if currwindbar = Gear then
     begin
@@ -912,6 +913,11 @@
             inc(WindBarWidth)
         else if WindBarWidth > Gear^.Tag then
             dec(WindBarWidth);
+        // Prevent wind bar from overflowing
+        if WindBarWidth > maxWindBarWidth then
+            WindBarWidth:= maxWindBarWidth;
+        if WindBarWidth < - maxWindBarWidth then
+            WindBarWidth:= - maxWindBarWidth;
         end;
     if cWindspeedf > Gear^.dAngle then
         begin
@@ -925,7 +931,7 @@
         end;
     end;
 
-    if ((WindBarWidth = Gear^.Tag) and (cWindspeedf = Gear^.dAngle)) or (currwindbar <> Gear) then
+    if (((WindBarWidth = Gear^.Tag) or (Abs(WindBarWidth) >= maxWindBarWidth)) and (cWindspeedf = Gear^.dAngle)) or (currwindbar <> Gear) then
     begin
         if currwindbar = Gear then currwindbar:= nil;
         DeleteVisualGear(Gear)