sending error messages longer than 1024 bytes for some reason breaks barotrauma, fixed my splitting the message into multiple chunks

This commit is contained in:
Evil Factory
2021-09-16 12:00:48 -03:00
parent beb9b10eb3
commit b26a6d7ccc
@@ -8,6 +8,7 @@ using Microsoft.Xna.Framework;
using System.Threading.Tasks; using System.Threading.Tasks;
using Barotrauma.Items.Components; using Barotrauma.Items.Components;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
namespace Barotrauma namespace Barotrauma
{ {
@@ -40,21 +41,29 @@ namespace Barotrauma
public void PrintMessage(object message) public void PrintMessage(object message)
{ {
if (message == null) { message = "nil"; } if (message == null) { message = "nil"; }
Console.WriteLine(message.ToString()); string str = message.ToString();
Console.WriteLine(str);
for (int i = 0; i < str.Length; i += 1024)
{
string subStr = str.Substring(i, Math.Min(1024, str.Length - i));
#if SERVER #if SERVER
if (GameMain.Server != null) if (GameMain.Server != null)
{
foreach (var c in GameMain.Server.ConnectedClients)
{ {
GameMain.Server.SendDirectChatMessage(message.ToString(), c, ChatMessageType.Console); foreach (var c in GameMain.Server.ConnectedClients)
} {
GameMain.Server.SendDirectChatMessage(subStr, c, ChatMessageType.Console);
}
GameServer.Log("[LUA] " + message.ToString(), ServerLog.MessageType.ServerMessage); GameServer.Log("[LUA] " + subStr, ServerLog.MessageType.ServerMessage);
} }
#else #else
DebugConsole.NewMessage("[LUA] " + message.ToString()); DebugConsole.NewMessage("[LUA] " + message.ToString());
#endif #endif
}
} }