Fix spectator crash due to missing nil check in new dust gear, init Ammo to nil in World prior to nil check
authornemo
Wed, 24 Feb 2010 13:29:06 +0000
changeset 2857 768dfbe276a5
parent 2856 cc70797a0b75
child 2858 4c5c4bc0ae35
Fix spectator crash due to missing nil check in new dust gear, init Ammo to nil in World prior to nil check
hedgewars/GSHandlers.inc
hedgewars/uWorld.pas
--- a/hedgewars/GSHandlers.inc	Wed Feb 24 03:03:43 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Wed Feb 24 13:29:06 2010 +0000
@@ -106,7 +106,7 @@
 
 	for i:= min(12, (3 + dmg div 10)) downto 0 do begin
 		particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
-		particle^.dX := particle^.dX + (Gear^.dX / 5);
+        if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX / 5);
 		end;
 		
   ApplyDamage(Gear, dmg);
--- a/hedgewars/uWorld.pas	Wed Feb 24 03:03:43 2010 +0000
+++ b/hedgewars/uWorld.pas	Wed Feb 24 13:29:06 2010 +0000
@@ -139,6 +139,7 @@
    else
        if AMxShift < 210 then inc(AMxShift, MENUSPEED);
    end;
+Ammo:= nil;
 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
    Ammo:= CurrentHedgehog^.Ammo
 else if (LocalAmmo <> -1) then