Fixed exceptions in CharacterNetworking.WriteStatus if a characters stun timer goes over 60.0

This commit is contained in:
Joonas Rikkonen
2017-06-07 20:20:14 +03:00
parent 4395179afa
commit 9527d53558
2 changed files with 5 additions and 2 deletions
@@ -277,6 +277,8 @@ namespace Barotrauma
set { oxygenAvailable = MathHelper.Clamp(value, 0.0f, 100.0f); } set { oxygenAvailable = MathHelper.Clamp(value, 0.0f, 100.0f); }
} }
public const float MaxStun = 60.0f;
private float stunTimer; private float stunTimer;
public float Stun public float Stun
{ {
@@ -1771,6 +1773,8 @@ namespace Barotrauma
{ {
if (GameMain.Client != null && !isNetworkMessage) return; if (GameMain.Client != null && !isNetworkMessage) return;
newStun = MathHelper.Clamp(newStun, 0.0f, MaxStun);
if ((newStun <= stunTimer && !allowStunDecrease) || !MathUtils.IsValid(newStun)) return; if ((newStun <= stunTimer && !allowStunDecrease) || !MathUtils.IsValid(newStun)) return;
if (GameMain.Server != null && if (GameMain.Server != null &&
@@ -620,8 +620,7 @@ namespace Barotrauma
msg.Write(Stun > 0.0f); msg.Write(Stun > 0.0f);
if (Stun > 0.0f) if (Stun > 0.0f)
{ {
Stun = MathHelper.Clamp(Stun, 0.0f, 60.0f); msg.WriteRangedSingle(MathHelper.Clamp(Stun, 0.0f, MaxStun), 0.0f, MaxStun, 8);
msg.WriteRangedSingle(Stun, 0.0f, 60.0f, 8);
} }
msg.Write(HuskInfectionState > 0.0f); msg.Write(HuskInfectionState > 0.0f);