From ceb6bf673d814a8986adcf21e48a1f3771f73ce5 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 31 Mar 2019 19:13:08 +0300 Subject: [PATCH] (0bab4a8d4) More reliable item wall attaching syncing. The problem was similar as the one fixed in 0835d92: the server occasionally received the unreliable attach inputs after the reliable item drop message, preventing the character from attaching the item server-side because it was not in the character's inventory anymore. --- .../Items/Components/Holdable/Holdable.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs index 8258fae90..e5171e5c8 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs @@ -426,11 +426,11 @@ namespace Barotrauma.Items.Components public override bool Use(float deltaTime, Character character = null) { - if (!attachable || item.body == null) return (character == null || character.IsKeyDown(InputType.Aim)); + if (!attachable || item.body == null) { return character == null || character.IsKeyDown(InputType.Aim); } if (character != null) { - if (!character.IsKeyDown(InputType.Aim)) return false; - if (!CanBeAttached()) return false; + if (!character.IsKeyDown(InputType.Aim)) { return false; } + if (!CanBeAttached()) { return false; } #if SERVER if (GameMain.Server != null) { @@ -438,10 +438,13 @@ namespace Barotrauma.Items.Components GameServer.Log(character.LogName + " attached " + item.Name + " to a wall", ServerLog.MessageType.ItemInteraction); } #endif - item.Drop(character); } - - AttachToWall(); + + if (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer) + { + if (character != null) { item.Drop(character); } + AttachToWall(); + } return true; } @@ -552,7 +555,7 @@ namespace Barotrauma.Items.Components public override void ServerWrite(NetBuffer msg, Client c, object[] extraData = null) { base.ServerWrite(msg, c, extraData); - if (!attachable || body == null) return; + if (!attachable || body == null) { return; } msg.Write(Attached); msg.Write(body.SimPosition.X);