Fixed EndGame not working properly + Fixed exception when clients disconnected during a round

This commit is contained in:
juanjp600
2017-06-22 15:20:11 -03:00
parent c1780fa7b7
commit 72d5cb227b
5 changed files with 47 additions and 14 deletions

View File

@@ -50,7 +50,7 @@ namespace Barotrauma
public override void Select()
{
base.Select();
}
private List<Submarine> subs;

View File

@@ -692,6 +692,7 @@ namespace Barotrauma
public void ClearInputs()
{
if (keys == null) return;
foreach (Key key in keys)
{
key.Hit = false;

View File

@@ -33,10 +33,46 @@ namespace Barotrauma
public static List<ColoredText> Messages = new List<ColoredText>();
private static string[] SplitCommand(string command)
{
command = command.Trim();
List<string> commands = new List<string>();
int escape = 0;
bool inQuotes = false;
string piece = "";
for (int i=0;i<command.Length;i++)
{
if (command[i] == '\\')
{
if (escape == 0) escape = 2;
else piece += '\\';
}
else if (command[i] == '"')
{
if (escape == 0) inQuotes = !inQuotes;
else piece += '"';
}
else if (command[i] == ' ' && !inQuotes)
{
if (!string.IsNullOrWhiteSpace(piece)) commands.Add(piece);
piece = "";
}
else if (escape == 0) piece += command[i];
if (escape > 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"))
{

View File

@@ -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;

View File

@@ -1381,18 +1381,16 @@ namespace Barotrauma.Networking
public IEnumerable<object> 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();