hedgewars/uGearsList.pas
changeset 14398 87562a68c41f
parent 14200 1bdce164eb72
child 14616 4638aa2ea8f2
equal deleted inserted replaced
14397:f9a3cfdec1df 14398:87562a68c41f
   769 end;
   769 end;
   770 
   770 
   771 procedure DeleteGear(Gear: PGear);
   771 procedure DeleteGear(Gear: PGear);
   772 var team: PTeam;
   772 var team: PTeam;
   773     t,i: Longword;
   773     t,i: Longword;
   774     k: boolean;
       
   775     cakeData: PCakeData;
   774     cakeData: PCakeData;
   776     iterator: PGear;
   775     iterator: PGear;
   777 begin
   776 begin
   778 
   777 
   779 ScriptCall('onGearDelete', gear^.uid);
   778 ScriptCall('onGearDelete', gear^.uid);
   855 
   854 
   856         Gear^.Hedgehog^.Gear:= nil;
   855         Gear^.Hedgehog^.Gear:= nil;
   857 
   856 
   858         if Gear^.Hedgehog^.King then
   857         if Gear^.Hedgehog^.King then
   859             begin
   858             begin
   860             // are there any other kings left? Just doing nil check.  Presumably a mortally wounded king will get reaped soon enough
   859             Gear^.Hedgehog^.Team^.hasKing:= false;
   861             k:= false;
       
   862             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   860             for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   863                 if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then
   861                 with team^.Clan^.Teams[i]^ do
   864                     k:= true;
   862                     for t:= 0 to cMaxHHIndex do
   865             if not k then
   863                         if Hedgehogs[t].Gear <> nil then
   866                 for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
   864                             Hedgehogs[t].Gear^.Health:= 0
   867                     with team^.Clan^.Teams[i]^ do
   865                         else if (Hedgehogs[t].GearHidden <> nil) then
   868                         for t:= 0 to cMaxHHIndex do
   866                             Hedgehogs[t].GearHidden^.Health:= 0  // hog is still hidden. if tardis should return though, lua, eh...
   869                             if Hedgehogs[t].Gear <> nil then
       
   870                                 Hedgehogs[t].Gear^.Health:= 0
       
   871                             else if (Hedgehogs[t].GearHidden <> nil) then
       
   872                                 Hedgehogs[t].GearHidden^.Health:= 0  // hog is still hidden. if tardis should return though, lua, eh...
       
   873             end;
   867             end;
   874 
   868 
   875         // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
   869         // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
   876         // same stand for CheckHHDamage
   870         // same stand for CheckHHDamage
   877         if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then
   871         if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then