hedgewars/uGears.pas
changeset 4780 8571151411b3
parent 4748 ce9b48de1f52
child 4783 f9564c66a086
--- a/hedgewars/uGears.pas	Wed Dec 29 17:27:33 2010 +0100
+++ b/hedgewars/uGears.pas	Wed Dec 29 16:21:30 2010 -0500
@@ -595,6 +595,7 @@
 
 if CurAmmoGear = Gear then CurAmmoGear:= nil;
 if FollowGear = Gear then FollowGear:= nil;
+if lastGearByUID = Gear then lastGearByUID := nil;
 RemoveGearFromList(Gear);
 Dispose(Gear)
 end;
@@ -1778,13 +1779,20 @@
 var gear: PGear;
 begin
 GearByUID:= nil;
+if uid = 0 then exit;
+if (lastGearByUID <> nil) and (lastGearByUID^.uid = uid) then
+    begin
+    GearByUID:= lastGearByUID;
+    exit
+    end;
 gear:= GearsList;
 while gear <> nil do
     begin
     if gear^.uid = uid then
         begin
-            GearByUID:= gear;
-            exit
+        lastGearByUID:= gear;
+        GearByUID:= gear;
+        exit
         end;
     gear:= gear^.NextGear
     end