Skip to content

Commit

Permalink
Return original implementation with modified string length variable
Browse files Browse the repository at this point in the history
  • Loading branch information
MidnightTokyo committed Nov 13, 2024
1 parent ad9e106 commit 4b88055
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions Rocket.Unturned/Chat/UnturnedChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,35 @@ public static void Say(CSteamID CSteamID, string message, Color color)

public static List<string> wrapMessage(string text)
{
List<string> result = new List<string>();
if (text.Length == 0)
return new List<string>();

if (text.Length == 0)
string[] words = text.Split(' ');
List<string> lines = new List<string>();
string currentLine = "";
int maxLength = ChatManager.MAX_MESSAGE_LENGTH;

foreach (var currentWord in words)
{
return result;

if ((currentLine.Length > maxLength) ||
((currentLine.Length + currentWord.Length) > maxLength))
{
lines.Add(currentLine);
currentLine = "";
}

if (currentLine.Length > 0)
currentLine += " " + currentWord;
else
currentLine += currentWord;

}

for (int i = 0; i < text.Length; i += ChatManager.MAX_MESSAGE_LENGTH)
result.Add(text.Substring(i, Math.Min(ChatManager.MAX_MESSAGE_LENGTH, text.Length - i)));
if (currentLine.Length > 0)
lines.Add(currentLine);

return result;
return lines;
}
}
}

0 comments on commit 4b88055

Please sign in to comment.