(050a72bf3) Server resets remote character inputs if no inputs have been received in the past 0.5 seconds. Previously the server would assume the inputs hadn't changed from the last known ones, which works well when there are brief networking hiccups that cause the server to run out of inputs for a few frames, but if it takes longer, we don't want to keep the character firing a welding tool or whatever else they were doing until the kill disconnect timer kicks in.

This commit is contained in:
Joonas Rikkonen
2019-03-30 21:44:37 +02:00
parent c244b33fe8
commit 84121674b1
2 changed files with 12 additions and 1 deletions
@@ -3,7 +3,6 @@ using Lidgren.Network;
using Microsoft.Xna.Framework;
using System;
using System.Linq;
using System.Collections.Generic;
namespace Barotrauma
{
@@ -15,6 +15,8 @@ namespace Barotrauma
private bool networkUpdateSent;
private double LastInputTime;
public float GetPositionUpdateInterval(Client recipient)
{
if (!Enabled) { return 1000.0f; }
@@ -61,6 +63,15 @@ namespace Barotrauma
else if (memInput.Count == 0)
{
AnimController.Frozen = true;
if (Timing.TotalTime > LastInputTime + 0.5)
{
//no inputs have been received in 0.5 seconds, reset input
//(if there's a temporary network hiccup that prevents us from receiving inputs, we assume the inputs haven't changed,
//but if it takes too long, for example due to a client crashing/disconnecting, we don't want to keep the character
//firing a welding tool or whatever else they were doing until the kill disconnect timer kicks in)
prevDequeuedInput = dequeuedInput =
dequeuedInput.HasFlag(InputNetFlags.FacingLeft) ? InputNetFlags.FacingLeft : InputNetFlags.None;
}
}
else
{
@@ -190,6 +201,7 @@ namespace Barotrauma
networkUpdateID = (ushort)(networkUpdateID - i)
};
memInput.Insert(i, newMem);
LastInputTime = Timing.TotalTime;
}
}