# HG changeset patch # User unc0rr # Date 1210533718 0 # Node ID d231e007452ac91643f7140e5b4055499607d122 # Parent c201563285291d1c82df180a80c01dd50eae8bff Timer as hedgehog message (avoid possible desync in very rare cases) diff -r c20156328529 -r d231e007452a hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Sat May 10 16:26:53 2008 +0000 +++ b/hedgewars/CCHandlers.inc Sun May 11 19:21:58 2008 +0000 @@ -282,14 +282,12 @@ begin if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit; bShowFinger:= false; -with CurrentHedgehog^ do - if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then - begin - Ammo^[CurSlot, CurAmmo].Timer:= 1000 * (byte(s[1]) - 48); - with CurrentTeam^ do - ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); - if not CurrentTeam^.ExtDriven then SendIPC(s); - end +if not CurrentTeam^.ExtDriven then SendIPC(s); +with CurrentHedgehog^.Gear^ do + begin + Message:= Message or gm_Timer; + MsgParam:= byte(s[1]) - ord('0') + end end; procedure chSlot(var s: shortstring); diff -r c20156328529 -r d231e007452a hedgewars/HHHandlers.inc --- a/hedgewars/HHHandlers.inc Sat May 10 16:26:53 2008 +0000 +++ b/hedgewars/HHHandlers.inc Sun May 11 19:21:58 2008 +0000 @@ -59,13 +59,26 @@ Gear^.Message:= Gear^.Message and not gm_Weapon; with PHedgehog(Gear^.Hedgehog)^ do - while (Ammo^[CurSlot, CurAmmo].AmmoType <> weap) and (t >= 0) do - begin - ChangeAmmo(Gear); - dec(t) - end + while (Ammo^[CurSlot, CurAmmo].AmmoType <> weap) and (t >= 0) do + begin + ChangeAmmo(Gear); + dec(t) + end end; +procedure HHSetTimer(Gear: PGear); +begin +Gear^.Message:= Gear^.Message and not gm_Timer; +with PHedgehog(Gear^.Hedgehog)^ do + if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then + begin + Ammo^[CurSlot, CurAmmo].Timer:= 1000 * Gear^.MsgParam; + with CurrentTeam^ do + ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); + end; +end; + + procedure Attack(Gear: PGear); var xx, yy: hwFloat; begin @@ -467,6 +480,8 @@ 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); diff -r c20156328529 -r d231e007452a hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Sat May 10 16:26:53 2008 +0000 +++ b/hedgewars/uConsts.pas Sun May 11 19:21:58 2008 +0000 @@ -183,6 +183,7 @@ gm_Destroy= $00000100; gm_Slot = $00000200; // with param gm_Weapon = $00000400; // with param + gm_Timer = $00000800; // with param cMaxSlotIndex = 8; cMaxSlotAmmoIndex = 2;