From 605be8f813dcc01cd24e3c422d545dea720f5b0c Mon Sep 17 00:00:00 2001 From: SGKoishi Date: Mon, 27 Jan 2025 08:11:36 +0900 Subject: [PATCH] Detect xterm compatibility to avoid console spam --- TShockAPI/Utils.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 23b1e224a..3b9c0286b 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1149,11 +1149,15 @@ internal void FixChestStacks() /// If the server is empty; determines if we should use Utils.GetActivePlayerCount() for player count or 0. internal void SetConsoleTitle(bool empty) { + if (ShouldSkipTitle) + return; Console.Title = GetString("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})", !string.IsNullOrWhiteSpace(TShock.Config.Settings.ServerName) ? TShock.Config.Settings.ServerName + " - " : "", empty ? 0 : GetActivePlayerCount(), TShock.Config.Settings.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum); } + // Some terminals doesn't supports XTerm escape sequences for setting the title + private static bool ShouldSkipTitle = !System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows) && !(Environment.GetEnvironmentVariable("TERM")?.Contains("xterm") ?? false); /// Determines the distance between two vectors. /// The first vector location.