diff --git a/Barotrauma/BarotraumaClient/ClientSource/Fonts/ScalableFont.cs b/Barotrauma/BarotraumaClient/ClientSource/Fonts/ScalableFont.cs index b2540f17c..ad66f2a91 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Fonts/ScalableFont.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Fonts/ScalableFont.cs @@ -13,7 +13,7 @@ namespace Barotrauma { private static List FontList = new List(); private static Library Lib = null; - private static object mutex = new object(); + private readonly object mutex = new object(); private string filename; private Face face; @@ -256,10 +256,33 @@ namespace Barotrauma } private void DynamicRenderAtlas(GraphicsDevice gd, uint character, int texDims = 1024, uint baseChar = 0x54) - => DynamicRenderAtlas(gd, character.ToEnumerable(), texDims, baseChar); + { + bool missingCharacterFound = false; + lock (mutex) + { + missingCharacterFound = !texCoords.ContainsKey(character); + } + if (!missingCharacterFound) { return; } + DynamicRenderAtlas(gd, character.ToEnumerable(), texDims, baseChar); + } private void DynamicRenderAtlas(GraphicsDevice gd, string str, int texDims = 1024, uint baseChar = 0x54) - => DynamicRenderAtlas(gd, str.Distinct().Select(c => (uint)c), texDims, baseChar); + { + bool missingCharacterFound = false; + var distinctChrs = str.Distinct().Select(c => (uint)c).ToArray(); + lock (mutex) + { + foreach (var character in distinctChrs) + { + if (texCoords.ContainsKey(character)) { continue; } + + missingCharacterFound = true; + break; + } + } + if (!missingCharacterFound) { return; } + DynamicRenderAtlas(gd, distinctChrs, texDims, baseChar); + } private void DynamicRenderAtlas(GraphicsDevice gd, IEnumerable characters, int texDims = 1024, uint baseChar = 0x54) { @@ -268,7 +291,7 @@ namespace Barotrauma CrossThread.RequestExecutionOnMainThread(() => { DynamicRenderAtlas(gd, characters, texDims, baseChar); - }); + }); return; } diff --git a/Barotrauma/BarotraumaClient/ClientSource/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/ClientSource/GameSession/CrewManager.cs index 845af7489..48f599318 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/GameSession/CrewManager.cs @@ -1299,7 +1299,7 @@ namespace Barotrauma private bool CreateOrder(Order order, Hull targetHull = null) { - var sub = Character.Controlled.Submarine; + var sub = Character.Controlled?.Submarine; if (sub == null || sub.TeamID != Character.Controlled.TeamID || sub.Info.IsWreck) { return false; } diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs index b5036813b..ecc352288 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs @@ -2984,6 +2984,8 @@ namespace Barotrauma.Networking public void SetupLoadCampaign(string saveName) { + if (clientPeer == null) { return; } + GameMain.NetLobbyScreen.CampaignSetupFrame.Visible = false; GameMain.NetLobbyScreen.CampaignFrame.Visible = false; diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs index 8d80957a6..da26a5575 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/NetLobbyScreen.cs @@ -1743,6 +1743,7 @@ namespace Barotrauma public void SetSpectate(bool spectate) { + if (GameMain.Client == null) { return; } this.spectateBox.Selected = spectate; if (spectate) { diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index c7270b244..9948738a1 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.16.6.1 + 0.16.7.0 Copyright © FakeFish 2018-2020 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj index 83cf67ffa..4d84c5305 100644 --- a/Barotrauma/BarotraumaClient/MacClient.csproj +++ b/Barotrauma/BarotraumaClient/MacClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.16.6.1 + 0.16.7.0 Copyright © FakeFish 2018-2020 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index f036e9e0c..afa31a7c3 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.16.6.1 + 0.16.7.0 Copyright © FakeFish 2018-2020 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj b/Barotrauma/BarotraumaServer/LinuxServer.csproj index ee10e77d2..c60226b92 100644 --- a/Barotrauma/BarotraumaServer/LinuxServer.csproj +++ b/Barotrauma/BarotraumaServer/LinuxServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.16.6.1 + 0.16.7.0 Copyright © FakeFish 2018-2020 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj b/Barotrauma/BarotraumaServer/MacServer.csproj index bfe3eac7a..42d0facc0 100644 --- a/Barotrauma/BarotraumaServer/MacServer.csproj +++ b/Barotrauma/BarotraumaServer/MacServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.16.6.1 + 0.16.7.0 Copyright © FakeFish 2018-2020 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj index 6f417f598..ff47e4232 100644 --- a/Barotrauma/BarotraumaServer/WindowsServer.csproj +++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.16.6.1 + 0.16.7.0 Copyright © FakeFish 2018-2020 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/EventManager.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/EventManager.cs index 0fb1480a4..039131b10 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Events/EventManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Events/EventManager.cs @@ -1030,7 +1030,7 @@ namespace Barotrauma const int maxDist = 1000; - if (level != null) + if (level != null && !level.Removed) { foreach (var ruin in level.Ruins) { diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/AndComponent.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/AndComponent.cs index 9ae8bede2..af4c47b13 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/AndComponent.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/AndComponent.cs @@ -79,17 +79,18 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { - bool sendOutput = true; + bool state = true; for (int i = 0; i < timeSinceReceived.Length; i++) { - if (timeSinceReceived[i] > timeFrame) { sendOutput = false; } + if (timeSinceReceived[i] > timeFrame) { state = false; } timeSinceReceived[i] += deltaTime; } - string signalOut = sendOutput ? output : falseOutput; + string signalOut = state ? output : falseOutput; if (string.IsNullOrEmpty(signalOut)) { - IsActive = false; + //deactivate the component if state is false and there's no false output (will be woken up by non-zero signals in ReceiveSignal) + if (!state) { IsActive = false; } return; } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/OrComponent.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/OrComponent.cs index abbd0b603..8596b8070 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/OrComponent.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/OrComponent.cs @@ -12,17 +12,18 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { - bool sendOutput = false; + bool state = false; for (int i = 0; i < timeSinceReceived.Length; i++) { - if (timeSinceReceived[i] <= timeFrame) { sendOutput = true; } + if (timeSinceReceived[i] <= timeFrame) { state = true; } timeSinceReceived[i] += deltaTime; } - string signalOut = sendOutput ? output : falseOutput; + string signalOut = state ? output : falseOutput; if (string.IsNullOrEmpty(signalOut)) { - IsActive = false; + //deactivate the component if state is false and there's no false output (will be woken up by non-zero signals in ReceiveSignal) + if (!state) { IsActive = false; } return; } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/XorComponent.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/XorComponent.cs index 61d782ffb..bf493f470 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/XorComponent.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/XorComponent.cs @@ -12,17 +12,19 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { - int sendOutput = 0; + int receivedInputs = 0; for (int i = 0; i < timeSinceReceived.Length; i++) { - if (timeSinceReceived[i] <= timeFrame) { sendOutput += 1; } + if (timeSinceReceived[i] <= timeFrame) { receivedInputs += 1; } timeSinceReceived[i] += deltaTime; } - string signalOut = sendOutput == 1 ? output : falseOutput; + bool state = receivedInputs == 1; + string signalOut = state ? output : falseOutput; if (string.IsNullOrEmpty(signalOut)) { - IsActive = false; + //deactivate the component if state is false and there's no false output (will be woken up by non-zero signals in ReceiveSignal) + if (!state) { IsActive = false; } return; } diff --git a/Barotrauma/BarotraumaShared/changelog.txt b/Barotrauma/BarotraumaShared/changelog.txt index e8d8ddb64..2002433de 100644 --- a/Barotrauma/BarotraumaShared/changelog.txt +++ b/Barotrauma/BarotraumaShared/changelog.txt @@ -1,3 +1,11 @@ +--------------------------------------------------------------------------------------------------------- +v0.16.7.0 +--------------------------------------------------------------------------------------------------------- + +- Fixed excessive loading times when playing in Chinese, Japanese or Korean. +- Fixed certain logic components (and/or/xor with an empty output and non-empty false output) stopping to work altogether when they stop sending a signal. +- Fixes to crashes when trying to interact with certain elements in the server lobby while getting disconnected. + --------------------------------------------------------------------------------------------------------- v0.16.6.1 ---------------------------------------------------------------------------------------------------------