Server limits chatmessage length and the number of chatmessages written in one packet

This commit is contained in:
Regalis
2017-05-08 19:06:05 +03:00
parent 152a92e600
commit 7dad837733
6 changed files with 47 additions and 16 deletions

View File

@@ -6,7 +6,6 @@ using System.Text;
namespace Barotrauma.Networking
{
enum ChatMessageType
{
Default, Error, Dead, Server, Radio, Private
@@ -14,6 +13,8 @@ namespace Barotrauma.Networking
class ChatMessage
{
public const int MaxLength = 150;
public const float SpeakRange = 2000.0f;
public static Color[] MessageColor =
@@ -138,6 +139,12 @@ namespace Barotrauma.Networking
{
UInt16 ID = msg.ReadUInt16();
string txt = msg.ReadString();
if (txt.Length > MaxLength)
{
txt = txt.Substring(0, MaxLength);
}
if (NetIdUtils.IdMoreRecent(ID, c.lastSentChatMsgID))
{
//this chat message is new to the server