From 8215c4d91bad9cecca7431a084e1ddd12b2508e7 Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 4 Apr 2017 21:32:53 +0300 Subject: [PATCH] MemStates without a timestamp are removed from a character when using timestamp-based interpolation (there may still be ID-based states with a timestamp of 0.0 in the buffer when switching to timestamp-based interpolation, for example when the controlled character dies) + vice versa when switching from timestamp-based to ID-based --- Subsurface/Source/Characters/Animation/Ragdoll.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs index 92f65903f..e7307f5d3 100644 --- a/Subsurface/Source/Characters/Animation/Ragdoll.cs +++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs @@ -1252,6 +1252,10 @@ namespace Barotrauma if (character != GameMain.NetworkMember.Character || !character.AllowInput) { + //remove states without a timestamp (there may still be ID-based states + //in the list when the controlled character switches to timestamp-based interpolation) + character.MemState.RemoveAll(m => m.Timestamp == 0.0f); + //use simple interpolation for other players' characters and characters that can't move if (character.MemState.Count > 0) { @@ -1298,13 +1302,17 @@ namespace Barotrauma } else { + //remove states with a timestamp (there may still timestamp-based states + //in the list if the controlled character switches from timestamp-based interpolation to ID-based) + character.MemState.RemoveAll(m => m.Timestamp > 0.0f); + for (int i = 0; i < character.MemLocalState.Count; i++) { if (character.Submarine == null) { //transform in-sub coordinates to outside coordinates if (character.MemLocalState[i].Position.Y > ConvertUnits.ToSimUnits(Level.Loaded.Size.Y)) - character.MemLocalState[i].TransformInToOutside(); + character.MemLocalState[i].TransformInToOutside(); } else if (currentHull != null) {