diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs index 4f043091d..82418a2a4 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs @@ -141,7 +141,7 @@ namespace Barotrauma float rotation = msg.ReadFloat(); int index = 0; - if (GameMain.NetworkMember.Character == this && AllowInput) + if (GameMain.NetworkMember.Character == this) { var posInfo = new CharacterStateInfo(pos, rotation, networkUpdateID, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation); while (index < memState.Count && NetIdUtils.IdMoreRecent(posInfo.ID, memState[index].ID)) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs index 1a9442acd..a0dbe6343 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs @@ -1339,17 +1339,33 @@ namespace Barotrauma } } + Hull serverHull = Hull.FindHull(serverPos.Position, character.CurrentHull, false); + Hull clientHull = Hull.FindHull(localPos.Position, serverHull, false); + Vector2 positionError = serverPos.Position - localPos.Position; float rotationError = serverPos.Rotation - localPos.Rotation; - for (int i = localPosIndex; i < character.MemLocalState.Count; i++) + + if (serverHull!=clientHull && ((serverHull==null) || (clientHull==null) || (serverHull.Submarine != clientHull.Submarine))) { - character.MemLocalState[i].Translate(positionError,rotationError); + //hull subs don't match => just teleport the player to exactly this position to avoid mismatches, + //since this would completely break the camera + positionError = Collider.SimPosition - serverPos.Position; + character.MemLocalState.Clear(); + } + else + { + for (int i = localPosIndex; i < character.MemLocalState.Count; i++) + { + Hull pointHull = Hull.FindHull(character.MemLocalState[i].Position, clientHull, false); + if (pointHull != clientHull && ((pointHull == null) || (clientHull == null) || (pointHull.Submarine == clientHull.Submarine))) break; + character.MemLocalState[i].Translate(positionError, rotationError); + } } Collider.SetTransform(Collider.SimPosition + positionError, Collider.Rotation + rotationError); foreach (Limb limb in Limbs) { - limb.body.SetTransform(limb.body.SimPosition + positionError, limb.body.Rotation + rotationError); + limb.body.SetTransform(limb.body.SimPosition + positionError, limb.body.Rotation); } }