Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
--- a/hedgewars/CCHandlers.inc Sun May 11 19:21:58 2008 +0000
+++ b/hedgewars/CCHandlers.inc Sun May 11 19:30:40 2008 +0000
@@ -348,11 +348,10 @@
end;
SendIPCXY('p', TargetPoint.X, TargetPoint.Y);
end;
- State:= State and not gstHHChooseTarget;
+ State:= State and not gstHHChooseTarget;
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then
Message:= Message or gm_Attack;
end else if CurrentTeam^.ExtDriven then OutError('got /put while not being in choose target mode', false)
-
end;
procedure chPut(var s: shortstring);
--- 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
--- a/hedgewars/uAmmos.pas Sun May 11 19:21:58 2008 +0000
+++ b/hedgewars/uAmmos.pas Sun May 11 19:30:40 2008 +0000
@@ -131,13 +131,10 @@
end;
procedure OnUsedAmmo(var Hedgehog: THedgehog);
-var s, a: Longword;
begin
with Hedgehog do
begin
- if CurAmmoGear = nil then begin s:= CurSlot; a:= CurAmmo end
- else begin s:= AltSlot; a:= AltAmmo end;
- with Ammo^[s, a] do
+ with Ammo^[CurSlot, CurAmmo] do
if Count <> AMMO_INFINITE then
begin
dec(Count);
--- a/hedgewars/uTeams.pas Sun May 11 19:21:58 2008 +0000
+++ b/hedgewars/uTeams.pas Sun May 11 19:30:40 2008 +0000
@@ -35,7 +35,6 @@
Ammo: PHHAmmo;
AmmoStore: Longword;
CurSlot, CurAmmo: LongWord;
- AltSlot, AltAmmo: LongWord;
Team: PTeam;
AttacksNum: Longword;
visStepPos: LongWord;