hedgewars/HHHandlers.inc
changeset 927 2c1675344a6f
parent 926 d231e007452a
child 928 b9064b48b001
--- a/hedgewars/HHHandlers.inc	Sun May 11 19:21:58 2008 +0000
+++ b/hedgewars/HHHandlers.inc	Sun May 11 19:30:40 2008 +0000
@@ -19,31 +19,28 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure ChangeAmmo(Gear: PGear);
 var slot: Longword;
-    caSlot, caAmmo: PLongword;
 begin
 slot:= Gear^.MsgParam;
 
 with PHedgehog(Gear^.Hedgehog)^ do
-     begin
-     if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
-        or ((Gear^.State and gstHHDriven) = 0) then exit;
+	begin
+	if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0)
+		or ((Gear^.State and gstHHDriven) = 0) then exit;
 
-     Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump or gm_Slot);
-
-     if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end
-                          else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end;
+	Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump or gm_Slot);
 
-     if caSlot^ = slot then
-        begin
-        inc(caAmmo^);
-        if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo^[slot, caAmmo^].Count = 0) then caAmmo^:= 0
-        end else
-     if Ammo^[slot, 0].Count > 0 then
-        begin
-        caSlot^:= slot;
-        caAmmo^:= 0;
-        end;
-     end;
+	if CurSlot = slot then
+		begin
+		inc(CurAmmo);
+		if (CurAmmo > cMaxSlotAmmoIndex) or (Ammo^[slot, CurAmmo].Count = 0) then CurAmmo:= 0
+		end else
+	if Ammo^[slot, 0].Count > 0 then
+		begin
+		CurSlot:= slot;
+		CurAmmo:= 0
+		end;
+	end;
+
 ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^)
 end;
 
@@ -476,15 +473,15 @@
    exit
    end;
 
+if ((Gear^.Message and gm_Attack) <> 0) or
+   ((Gear^.State and gstAttacking) <> 0) then Attack(Gear); // should be before others to avoid desync with '/put' msg and changing weapon msgs
+
 if ((Gear^.Message and gm_Slot) <> 0) then ChangeAmmo(Gear);
 
 if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear);
 
 if ((Gear^.Message and gm_Timer) <> 0) then HHSetTimer(Gear);
 
-if ((Gear^.Message and gm_Attack) <> 0) or
-   ((Gear^.State and gstAttacking) <> 0) then Attack(Gear);
-
 if (Gear^.State and gstMoving) <> 0 then
    begin
    if ((Gear^.Message and gm_HJump) <> 0) and