From 5d7dba0f70644b77935dac1661fd60ac3406b589 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 3 Apr 2019 16:21:06 +0300 Subject: [PATCH] (cef39af84) Fixed server creating "attempted to create a network event for an item that hasn't been fully initialized yet" console errors when spawning LightComponents mid-round. + Simplified ragdoll collider null check --- .../Source/Characters/Animation/Ragdoll.cs | 2 +- .../Items/Components/Signal/LightComponent.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs index bd9551511..f6aa7ed1c 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs @@ -110,7 +110,7 @@ namespace Barotrauma { get { - return collider == null ? null : collider[colliderIndex]; + return collider?[colliderIndex]; } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs index 9a93d357f..7845f609c 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs @@ -22,6 +22,10 @@ namespace Barotrauma.Items.Components private float blinkTimer; + private bool itemLoaded; + + private float blinkTimer; + public PhysicsBody ParentBody; [Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)] @@ -77,7 +81,7 @@ namespace Barotrauma.Items.Components IsActive = value; #if SERVER - if (GameMain.Server != null && GameMain.Server.GameStarted) { item.CreateServerEvent(this); } + if (GameMain.Server != null && itemLoaded) { item.CreateServerEvent(this); } #endif } } @@ -156,7 +160,13 @@ namespace Barotrauma.Items.Components IsActive = IsOn; item.AddTag("light"); } - + + public override void OnItemLoaded() + { + base.OnItemLoaded(); + itemLoaded = true; + } + public override void Update(float deltaTime, Camera cam) { UpdateOnActiveEffects(deltaTime);