From 33b3e5374b5516523efbd4f93fc7ac8d7d4bb923 Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 29 May 2017 17:15:16 +0300 Subject: [PATCH] Fixed a null exception if the server log UI hasn't been opened and the max number of lines is reached --- Subsurface/Source/Networking/ServerLog.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Subsurface/Source/Networking/ServerLog.cs b/Subsurface/Source/Networking/ServerLog.cs index 2bb50d026..1018b9527 100644 --- a/Subsurface/Source/Networking/ServerLog.cs +++ b/Subsurface/Source/Networking/ServerLog.cs @@ -30,7 +30,7 @@ namespace Barotrauma.Networking Error } - private Color[] messageColor = new Color[] + private readonly Color[] messageColor = { Color.LightBlue, new Color(255, 142, 0), @@ -40,7 +40,7 @@ namespace Barotrauma.Networking Color.Red }; - private string[] messageTypeName = new string[] + private readonly string[] messageTypeName = { "Chat message", "Item interaction", @@ -105,9 +105,13 @@ namespace Barotrauma.Networking while (lines.Count > LinesPerFile) { - listBox.RemoveChild(listBox.children[0]); lines.Dequeue(); - } + } + + while (listBox != null && listBox.children.Count > LinesPerFile) + { + listBox.RemoveChild(listBox.children[0]); + } } public void CreateLogFrame() @@ -164,7 +168,7 @@ namespace Barotrauma.Networking if (listBox.BarScroll == 0.0f || listBox.BarScroll == 1.0f) listBox.BarScroll = 1.0f; GUIButton closeButton = new GUIButton(new Rectangle(-100, 10, 100, 15), "Close", Alignment.BottomRight, "", innerFrame); - closeButton.OnClicked = (GUIButton button, object userData) => + closeButton.OnClicked = (button, userData) => { LogFrame = null; return true;