From 56e04823f16f2fd96677cd56a4f5f0b87c3a5370 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 17 Jul 2017 23:28:46 +0300 Subject: [PATCH] Logging when players attach items on walls or detach them, null exception fix in Throwable (picker is set to null in Item.Drop) --- .../Source/Items/Components/Holdable/Holdable.cs | 11 ++++++++--- .../Source/Items/Components/Holdable/Throwable.cs | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs index 799641991..cbffca55c 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs @@ -191,7 +191,7 @@ namespace Barotrauma.Items.Components item.body.Enabled = true; IsActive = true; - if (!alreadySelected) Networking.GameServer.Log(character.Name + " equipped " + item.Name, Networking.ServerLog.MessageType.ItemInteraction); + if (!alreadySelected) GameServer.Log(character.Name + " equipped " + item.Name, ServerLog.MessageType.ItemInteraction); } } @@ -201,7 +201,7 @@ namespace Barotrauma.Items.Components picker.DeselectItem(item); - Networking.GameServer.Log(character.Name + " unequipped " + item.Name, Networking.ServerLog.MessageType.ItemInteraction); + GameServer.Log(character.Name + " unequipped " + item.Name, ServerLog.MessageType.ItemInteraction); item.body.Enabled = false; IsActive = false; @@ -234,6 +234,10 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null && attachable) { item.CreateServerEvent(this); + if (picker != null) + { + Networking.GameServer.Log(picker.Name + " detached " + item.Name + " from a wall", ServerLog.MessageType.ItemInteraction); + } } return true; } @@ -284,9 +288,10 @@ namespace Barotrauma.Items.Components { if (!character.IsKeyDown(InputType.Aim)) return false; if (character.CurrentHull == null) return false; - if (character != null && GameMain.Server != null) + if (GameMain.Server != null) { item.CreateServerEvent(this); + GameServer.Log(character.Name + " attached " + item.Name+" to a wall", ServerLog.MessageType.ItemInteraction); } item.Drop(); } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs index a296e2935..344477c91 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs @@ -93,11 +93,11 @@ namespace Barotrauma.Items.Components Vector2 throwVector = picker.CursorWorldPosition - picker.WorldPosition; throwVector = Vector2.Normalize(throwVector); + GameServer.Log(picker.Name + " threw " + item.Name, ServerLog.MessageType.ItemInteraction); + item.Drop(); item.body.ApplyLinearImpulse(throwVector * throwForce * item.body.Mass * 3.0f); - GameServer.Log(picker.Name + " threw " + item.Name, ServerLog.MessageType.ItemInteraction); - ac.GetLimb(LimbType.Head).body.ApplyLinearImpulse(throwVector*10.0f); ac.GetLimb(LimbType.Torso).body.ApplyLinearImpulse(throwVector * 10.0f);