hedgewars/uGears.pas
changeset 3437 858105ae769c
parent 3432 83cef0f08a86
child 3440 dee31c5149e0
equal deleted inserted replaced
3436:288fcbdb77b6 3437:858105ae769c
   190             );
   190             );
   191 
   191 
   192 procedure InsertGearToList(Gear: PGear);
   192 procedure InsertGearToList(Gear: PGear);
   193 var tmp, ptmp: PGear;
   193 var tmp, ptmp: PGear;
   194 begin
   194 begin
   195 if GearsList = nil then
   195 // this thing is broken, and the bug explains why you sometimes see grenade stuck in hog not behind hedgehog sprite
   196     GearsList:= Gear
   196 // when there's only one gear in list, the next one is inserted right after it disregarding its Z value
   197     else begin
   197 // TODO: fix the bug
   198     tmp:= GearsList;
   198     tmp:= GearsList;
   199     ptmp:= GearsList;
   199     ptmp:= GearsList;
   200     while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do
   200     while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do
   201         begin
   201         begin
   202         ptmp:= tmp;
   202         ptmp:= tmp;
   208         Gear^.NextGear:= ptmp^.NextGear;
   208         Gear^.NextGear:= ptmp^.NextGear;
   209         Gear^.PrevGear:= ptmp;
   209         Gear^.PrevGear:= ptmp;
   210         if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear;
   210         if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear;
   211         ptmp^.NextGear:= Gear
   211         ptmp^.NextGear:= Gear
   212         end
   212         end
   213     else GearsList:= Gear
   213     else 
   214     end
   214         GearsList:= Gear
   215 end;
   215 end;
   216 
   216 
   217 procedure RemoveGearFromList(Gear: PGear);
   217 procedure RemoveGearFromList(Gear: PGear);
   218 begin
   218 begin
   219 if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
   219 if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear;