(30e7a1617) Added an error check & exception handling to DebugConsole.RewriteInputToCommandLine (cherry-picked from respawn-overhaul, accidentally commited in the wrong branch)
This commit is contained in:
@@ -178,22 +178,33 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private static void RewriteInputToCommandLine(string input)
|
private static void RewriteInputToCommandLine(string input)
|
||||||
{
|
{
|
||||||
|
if (Console.WindowWidth == 0 || Console.WindowHeight == 0) { return; }
|
||||||
|
|
||||||
int consoleWidth = Math.Max(Console.WindowWidth, 5);
|
int consoleWidth = Math.Max(Console.WindowWidth, 5);
|
||||||
int inputLines = Math.Max((int)Math.Ceiling(input.Length / (float)consoleWidth), 1);
|
int inputLines = Math.Max((int)Math.Ceiling(input.Length / (float)consoleWidth), 1);
|
||||||
int cursorLine = Math.Max((int)Math.Ceiling((input.Length + 1) / (float)consoleWidth), 1);
|
int cursorLine = Math.Max((int)Math.Ceiling((input.Length + 1) / (float)consoleWidth), 1);
|
||||||
|
|
||||||
Console.WriteLine(""); Console.CursorTop -= inputLines;
|
try
|
||||||
|
{
|
||||||
string ln = input.Length > 0 ? AutoComplete(input, 0) : "";
|
Console.WriteLine(""); Console.CursorTop -= inputLines;
|
||||||
ln += new string(' ', consoleWidth - (ln.Length % consoleWidth));
|
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
string ln = input.Length > 0 ? AutoComplete(input, 0) : "";
|
||||||
Console.CursorLeft = 0;
|
ln += new string(' ', consoleWidth - (ln.Length % consoleWidth));
|
||||||
Console.Write(ln);
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.CursorLeft = 0;
|
||||||
Console.CursorLeft = 0;
|
Console.Write(ln);
|
||||||
Console.CursorTop -= cursorLine;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Console.Write(input);
|
Console.CursorLeft = 0;
|
||||||
Console.CursorLeft = input.Length % consoleWidth;
|
Console.CursorTop -= cursorLine;
|
||||||
|
Console.Write(input);
|
||||||
|
Console.CursorLeft = input.Length % consoleWidth;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
string errorMsg = "Failed to write input to command line (window width: " + Console.WindowWidth + ", window height: " + Console.WindowHeight + ", inputLines:" + inputLines + ")\n"
|
||||||
|
+ e.Message + "\n" + e.StackTrace;
|
||||||
|
GameAnalyticsManager.AddErrorEventOnce("DebugConsole.RewriteInputToCommandLine", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AssignOnClientRequestExecute(string names, Action<Client, Vector2, string[]> onClientRequestExecute)
|
private static void AssignOnClientRequestExecute(string names, Action<Client, Vector2, string[]> onClientRequestExecute)
|
||||||
|
|||||||
Reference in New Issue
Block a user