From a8309b5766d20a33080403b97b793626d71fae39 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 20 Mar 2019 16:28:15 +0200 Subject: [PATCH] 69487a2...d38c50c commit d38c50cc354476d5309645bc1487a4c03fe97d57 Author: Joonas Rikkonen Date: Wed Mar 20 16:27:45 2019 +0200 Fixed inability to throw anything in the multiplayer. The clients would create a network event about dropping the item during the throw, which prevented throwing it server-side (because the item isn't in the character's inventory anymore by the time it should be launched). Closes #1318 commit 25cc1ceefcf62e346281c24c41964053d102701c Author: Joonas Rikkonen Date: Wed Mar 20 16:21:33 2019 +0200 Merge same afflictions into one icon in the preview above the health bar (instead of showing the same icon for each limb that has the affliction) --- .../Source/Characters/Health/CharacterHealth.cs | 4 ++-- .../BarotraumaShared/Source/Items/Components/Door.cs | 11 ++++++----- .../Source/Items/Components/Holdable/Throwable.cs | 4 ++-- Barotrauma/BarotraumaShared/Source/Items/Item.cs | 11 +++++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs index 914ec1ee8..04cb8c620 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs @@ -448,8 +448,8 @@ namespace Barotrauma else { forceAfflictionContainerUpdate = true; - currentDisplayedAfflictions = GetAllAfflictions() - .Where(a => a.Strength >= a.Prefab.ShowIconThreshold && a.Prefab.Icon != null).ToList(); + currentDisplayedAfflictions = GetAllAfflictions(mergeSameAfflictions: true) + .FindAll(a => a.Strength >= a.Prefab.ShowIconThreshold && a.Prefab.Icon != null); currentDisplayedAfflictions.Sort((a1, a2) => { int dmgPerSecond = Math.Sign(a2.DamagePerSecond - a1.DamagePerSecond); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs index 3eceabb0c..8fed8a9ae 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs @@ -471,11 +471,12 @@ namespace Barotrauma.Items.Components if (connection.Name == "toggle") { - switch (subElement.Name.ToString().ToLowerInvariant()) - { - case "requireditem": - if (!overrideRequiredItems) requiredItems.Clear(); - overrideRequiredItems = true; + SetState(!wasOpen, false, true); + } + else if (connection.Name == "set_state") + { + SetState(signal != "0", false, true); + } #if SERVER if (sender != null && wasOpen != isOpen) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs index b6107eada..7fb161dfa 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs @@ -99,13 +99,13 @@ namespace Barotrauma.Items.Components { Vector2 throwVector = Vector2.Normalize(picker.CursorWorldPosition - picker.WorldPosition); //throw upwards if cursor is at the position of the character - if (!MathUtils.IsValid(throwVector)) throwVector = Vector2.UnitY; + if (!MathUtils.IsValid(throwVector)) { throwVector = Vector2.UnitY; } #if SERVER GameServer.Log(picker.LogName + " threw " + item.Name, ServerLog.MessageType.ItemInteraction); #endif - item.Drop(picker); + item.Drop(picker, createNetworkEvent: GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer); item.body.ApplyLinearImpulse(throwVector * throwForce * item.body.Mass * 3.0f); ac.GetLimb(LimbType.Head).body.ApplyLinearImpulse(throwVector*10.0f); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index 4a3b39c6a..434281de1 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1562,12 +1562,15 @@ namespace Barotrauma return isCombined; } - public void Drop(Character dropper) + public void Drop(Character dropper, bool createNetworkEvent = true) { - if (parentInventory != null && !parentInventory.Owner.Removed && !Removed && - GameMain.NetworkMember != null && (GameMain.NetworkMember.IsServer || Character.Controlled == dropper)) + if (createNetworkEvent) { - parentInventory.CreateNetworkEvent(); + if (parentInventory != null && !parentInventory.Owner.Removed && !Removed && + GameMain.NetworkMember != null && (GameMain.NetworkMember.IsServer || Character.Controlled == dropper)) + { + parentInventory.CreateNetworkEvent(); + } } foreach (ItemComponent ic in components) { ic.Drop(dropper); }