hedgewars/uGears.pas
changeset 4780 8571151411b3
parent 4748 ce9b48de1f52
child 4783 f9564c66a086
equal deleted inserted replaced
4778:1565a553d200 4780:8571151411b3
   593 with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   593 with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   594 {$ENDIF}
   594 {$ENDIF}
   595 
   595 
   596 if CurAmmoGear = Gear then CurAmmoGear:= nil;
   596 if CurAmmoGear = Gear then CurAmmoGear:= nil;
   597 if FollowGear = Gear then FollowGear:= nil;
   597 if FollowGear = Gear then FollowGear:= nil;
       
   598 if lastGearByUID = Gear then lastGearByUID := nil;
   598 RemoveGearFromList(Gear);
   599 RemoveGearFromList(Gear);
   599 Dispose(Gear)
   600 Dispose(Gear)
   600 end;
   601 end;
   601 
   602 
   602 function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs
   603 function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs
  1776 
  1777 
  1777 function GearByUID(uid : Longword) : PGear;
  1778 function GearByUID(uid : Longword) : PGear;
  1778 var gear: PGear;
  1779 var gear: PGear;
  1779 begin
  1780 begin
  1780 GearByUID:= nil;
  1781 GearByUID:= nil;
       
  1782 if uid = 0 then exit;
       
  1783 if (lastGearByUID <> nil) and (lastGearByUID^.uid = uid) then
       
  1784     begin
       
  1785     GearByUID:= lastGearByUID;
       
  1786     exit
       
  1787     end;
  1781 gear:= GearsList;
  1788 gear:= GearsList;
  1782 while gear <> nil do
  1789 while gear <> nil do
  1783     begin
  1790     begin
  1784     if gear^.uid = uid then
  1791     if gear^.uid = uid then
  1785         begin
  1792         begin
  1786             GearByUID:= gear;
  1793         lastGearByUID:= gear;
  1787             exit
  1794         GearByUID:= gear;
       
  1795         exit
  1788         end;
  1796         end;
  1789     gear:= gear^.NextGear
  1797     gear:= gear^.NextGear
  1790     end
  1798     end
  1791 end;
  1799 end;
  1792 
  1800