From 671f59e98416618922f30909d7a2e4282ec88476 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 22 Feb 2018 15:08:38 +0200 Subject: [PATCH] Unequipped headsets can't be used and don't consume batteries. Closes #272 --- .../BarotraumaShared/Content/Items/Jobgear/misc.xml | 11 ++++------- .../BarotraumaShared/Source/Networking/GameServer.cs | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml b/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml index 50e1d602b..41c418c2c 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml @@ -16,15 +16,12 @@ - - - - - - + + - + + diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index e5c25b008..cb75b8492 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -1777,7 +1777,7 @@ namespace Barotrauma.Networking //return if senderCharacter doesn't have a working radio var radio = senderCharacter.Inventory.Items.FirstOrDefault(i => i != null && i.GetComponent() != null); - if (radio == null) return; + if (radio == null || !senderCharacter.HasEquippedItem(radio)) return; senderRadio = radio.GetComponent(); if (!senderRadio.CanTransmit()) return; @@ -1866,10 +1866,10 @@ namespace Barotrauma.Networking { var receiverItem = receiver.Inventory.Items.FirstOrDefault(i => i?.GetComponent() != null); //client doesn't have a radio -> don't send - if (receiverItem == null) return ""; + if (receiverItem == null || !receiver.HasEquippedItem(receiverItem)) return ""; var senderItem = sender.Inventory.Items.FirstOrDefault(i => i?.GetComponent() != null); - if (senderItem == null) return ""; + if (senderItem == null || !sender.HasEquippedItem(senderItem)) return ""; var receiverRadio = receiverItem.GetComponent(); var senderRadio = senderItem.GetComponent();