From 72d5cb227b1f815a8a849db5b81686b4ad6a374f Mon Sep 17 00:00:00 2001 From: juanjp600 Date: Thu, 22 Jun 2017 15:20:11 -0300 Subject: [PATCH] Fixed EndGame not working properly + Fixed exception when clients disconnected during a round --- .../Source/Screens/NetLobbyScreen.cs | 2 +- .../Source/Characters/Character.cs | 1 + BarotraumaShared/Source/DebugConsole.cs | 38 ++++++++++++++++++- .../Source/Map/TransitionCinematic.cs | 10 ++--- .../Source/Networking/GameServer.cs | 10 ++--- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/BarotraumaServer/Source/Screens/NetLobbyScreen.cs b/BarotraumaServer/Source/Screens/NetLobbyScreen.cs index e25da9588..675efd6ed 100644 --- a/BarotraumaServer/Source/Screens/NetLobbyScreen.cs +++ b/BarotraumaServer/Source/Screens/NetLobbyScreen.cs @@ -50,7 +50,7 @@ namespace Barotrauma public override void Select() { - + base.Select(); } private List subs; diff --git a/BarotraumaShared/Source/Characters/Character.cs b/BarotraumaShared/Source/Characters/Character.cs index 17a242749..9b631143b 100644 --- a/BarotraumaShared/Source/Characters/Character.cs +++ b/BarotraumaShared/Source/Characters/Character.cs @@ -692,6 +692,7 @@ namespace Barotrauma public void ClearInputs() { + if (keys == null) return; foreach (Key key in keys) { key.Hit = false; diff --git a/BarotraumaShared/Source/DebugConsole.cs b/BarotraumaShared/Source/DebugConsole.cs index 0d52cf7bd..1b449ceac 100644 --- a/BarotraumaShared/Source/DebugConsole.cs +++ b/BarotraumaShared/Source/DebugConsole.cs @@ -33,10 +33,46 @@ namespace Barotrauma public static List Messages = new List(); + private static string[] SplitCommand(string command) + { + command = command.Trim(); + + List commands = new List(); + int escape = 0; + bool inQuotes = false; + string piece = ""; + + for (int i=0;i 0) escape--; + } + + if (!string.IsNullOrWhiteSpace(piece)) commands.Add(piece); //add final piece + + return commands.ToArray(); + } + public static void ExecuteCommand(string command, GameMain game) { if (string.IsNullOrWhiteSpace(command)) return; - string[] commands = command.Split(' '); + string[] commands = SplitCommand(command); if (!commands[0].ToLowerInvariant().Equals("admin")) { diff --git a/BarotraumaShared/Source/Map/TransitionCinematic.cs b/BarotraumaShared/Source/Map/TransitionCinematic.cs index 05d39cf09..10064077c 100644 --- a/BarotraumaShared/Source/Map/TransitionCinematic.cs +++ b/BarotraumaShared/Source/Map/TransitionCinematic.cs @@ -80,16 +80,14 @@ namespace Barotrauma } cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.UnscaledDeltaTime * 0.1f); - + Vector2 cameraPos = subs.First().Position + Submarine.MainSub.HiddenSubPosition; - cameraPos.Y = Math.Min(cameraPos.Y, ConvertUnits.ToDisplayUnits(Level.Loaded.ShaftBody.Position.Y) - cam.WorldView.Height/2.0f); - + cameraPos.Y = Math.Min(cameraPos.Y, ConvertUnits.ToDisplayUnits(Level.Loaded.ShaftBody.Position.Y) - cam.WorldView.Height / 2.0f); + cam.Translate((cameraPos - cam.Position) * CoroutineManager.UnscaledDeltaTime * 10.0f); #if CLIENT GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, timer/duration); #endif - - cam.Translate((cameraPos - cam.Position) * CoroutineManager.UnscaledDeltaTime*10.0f); - + foreach (Submarine sub in subs) { if (sub.Position == targetPos) continue; diff --git a/BarotraumaShared/Source/Networking/GameServer.cs b/BarotraumaShared/Source/Networking/GameServer.cs index 7a8986100..3e9889059 100644 --- a/BarotraumaShared/Source/Networking/GameServer.cs +++ b/BarotraumaShared/Source/Networking/GameServer.cs @@ -1381,18 +1381,16 @@ namespace Barotrauma.Networking public IEnumerable EndCinematic() { float endPreviewLength = 10.0f; - + var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength); - - new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength); - float secondsLeft = endPreviewLength; + //float secondsLeft = endPreviewLength; do { - secondsLeft -= CoroutineManager.UnscaledDeltaTime; + //secondsLeft -= CoroutineManager.UnscaledDeltaTime; yield return CoroutineStatus.Running; - } while (secondsLeft > 0.0f); + } while (cinematic.Running);//(secondsLeft > 0.0f); Submarine.Unload(); entityEventManager.Clear();