hedgewars/HHHandlers.inc
changeset 3943 9835060e5c01
parent 3915 c05855146440
child 3945 c3d5eace0a32
equal deleted inserted replaced
3942:7b44d8fb87e5 3943:9835060e5c01
    40     end
    40     end
    41 end;
    41 end;
    42 
    42 
    43 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
    43 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
    44 procedure ChangeAmmo(Gear: PGear);
    44 procedure ChangeAmmo(Gear: PGear);
    45 var slot, ammoidx, i: Longword;
    45 var slot, i: Longword;
       
    46     ammoidx: LongInt;
    46 begin
    47 begin
    47 slot:= Gear^.MsgParam;
    48 slot:= Gear^.MsgParam;
    48 
    49 
    49 with PHedgehog(Gear^.Hedgehog)^ do
    50 with PHedgehog(Gear^.Hedgehog)^ do
    50     begin
    51     begin
    71             ammoidx:= 0;
    72             ammoidx:= 0;
    72             inc(i);
    73             inc(i);
    73             TryDo(i < 2, 'Engine bug: no ammo in current slot', true)
    74             TryDo(i < 2, 'Engine bug: no ammo in current slot', true)
    74             end;
    75             end;
    75         until (Ammo^[slot, ammoidx].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)
    76         until (Ammo^[slot, ammoidx].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)
    76         end else
    77         end 
       
    78     else
    77         begin
    79         begin
    78         i:= 0;
    80         i:= 0;
    79         // check whether there is ammo in slot
    81         // check whether there is ammo in slot
    80         while (i <= cMaxSlotAmmoIndex)
    82         while (i <= cMaxSlotAmmoIndex)
    81           and ((Ammo^[slot, i].Count = 0)
    83           and ((Ammo^[slot, i].Count = 0)
    82                or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) do inc(i);
    84                or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) do inc(i);
    83 
    85 
    84         if i <= cMaxSlotAmmoIndex then ammoidx:= i
    86         if i <= cMaxSlotAmmoIndex then ammoidx:= i
       
    87         else ammoidx:= -1
    85         end;
    88         end;
    86         CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
    89         if ammoidx >= 0 then CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
    87     end
    90     end
    88 end;
    91 end;
    89 
    92 
    90 procedure HHSetWeapon(Gear: PGear);
    93 procedure HHSetWeapon(Gear: PGear);
    91 var t: LongInt;
    94 var t: LongInt;