* check for valid TWave before starting/drawing them, prevents segfault
authorsheepluva
Thu, 01 Apr 2010 05:33:32 +0000
changeset 3230 6c8c1fe7c2b1
parent 3229 9e7ded374113
child 3231 a578cbf5d543
* check for valid TWave before starting/drawing them, prevents segfault
hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Thu Apr 01 05:25:10 2010 +0000
+++ b/hedgewars/uGears.pas	Thu Apr 01 05:33:32 2010 +0000
@@ -1212,13 +1212,20 @@
 
     if ((Gear^.State and gstAnimation) <> 0) then
         begin
-        DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite,
-                sx,
-                sy,
-                Gear^.Pos,
-                hwSign(Gear^.dX),
-                0.0);
-        defaultPos:= false
+        if (TWave(Gear^.Tag) < Low(TWave)) or (TWave(Gear^.Tag) > High(TWave)) then
+            begin
+            Gear^.State:= Gear^.State and not gstAnimation;
+            end
+        else
+            begin
+            DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite,
+                    sx,
+                    sy,
+                    Gear^.Pos,
+                    hwSign(Gear^.dX),
+                    0.0);
+            defaultPos:= false
+            end
         end
     else
     if ((Gear^.State and gstAttacked) = 0) then