From 5a4201c3f22868ce4fcd7f1382d4b7976d7f4cdd Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 31 Jan 2017 20:18:11 +0200 Subject: [PATCH] Character status syncing fix, less frequent stun update messages --- Subsurface/Source/Characters/Character.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index bc3667388..fd76cbdb2 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -1842,14 +1842,17 @@ namespace Barotrauma public void StartStun(float stunTimer, bool allowStunDecrease = false) { if ((stunTimer <= AnimController.StunTimer && !allowStunDecrease) || !MathUtils.IsValid(stunTimer)) return; - + + if (GameMain.Server != null && + (Math.Sign(stunTimer) != Math.Sign(AnimController.StunTimer) || Math.Abs(stunTimer - AnimController.StunTimer) > 0.1f)) + { + GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status }); + } + if (Math.Sign(stunTimer) != Math.Sign(AnimController.StunTimer)) AnimController.ResetPullJoints(); AnimController.StunTimer = Math.Max(AnimController.StunTimer, stunTimer); selectedConstruction = null; - - if (GameMain.Server != null) - GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status }); } private void Implode(bool isNetworkMessage = false) @@ -2383,12 +2386,20 @@ namespace Barotrauma { Oxygen = msg.ReadRangedSingle(-100.0f, 100.0f, 8); } + else + { + Oxygen = 100.0f; + } bool isBleeding = msg.ReadBoolean(); if (isBleeding) { bleeding = msg.ReadRangedSingle(0.0f, 5.0f, 8); } + else + { + bleeding = 0.0f; + } bool stunned = msg.ReadBoolean(); if (stunned) @@ -2396,6 +2407,10 @@ namespace Barotrauma float newStunTimer = msg.ReadRangedSingle(0.0f, 60.0f, 8); StartStun(newStunTimer, true); } + else + { + StartStun(0.0f, true); + } } }